I can't find _cap function in rhinocommon.dll

Such as the title,I try to put a lid for a square tube but I can’t find the function _cap in rhinocommon , I tried CapPlanerHoles or create the top and bottom surface and join them,but none of thoes work

here are my code:

protected override void SolveInstance(IGH_DataAccess DA)
{
    Curve C=null ;
    Curve C_rec_start = null;
    Curve C_rec_end = null;
    Plane P = new Plane();
    double H = 0;
    double W = 0;

    if (!DA.GetData(0, ref C)) return;
    //if (!DA.GetData(1, ref P)) return;
    if (!DA.GetData(1, ref H)) return;
    if (!DA.GetData(2, ref W)) return;

    
    if(C.TryGetPlane(out Plane P2))
    {
       
        Plane P3 = new Plane(P2.Origin, P2.XAxis, P2.ZAxis);
        double angle1 = Vector3d.VectorAngle(C.TangentAtStart, P3.Normal);
        double angle2 = Vector3d.VectorAngle(C.TangentAtEnd, P3.Normal);

        if (!P3.Rotate(angle1, P2.ZAxis, P3.Origin)) return;
        if (!P3.Rotate(angle2, P2.ZAxis, P3.Origin)) return;

        P3.Origin = C.PointAtStart;
        Plane P4 = P3;
        P4.Origin = C.PointAtEnd;

        Rectangle3d rec_start = new Rectangle3d(P3, W, H);
        GH_Convert.ToCurve(rec_start, ref C_rec_start, GH_Conversion.Both);

        Rectangle3d rec_end = new Rectangle3d(P3, W, H);
        GH_Convert.ToCurve(rec_end, ref C_rec_end, GH_Conversion.Both);

        Curve[] C_sweep = new Curve[2] { C_rec_start, C_rec_end };

        Brep[] B_start = Brep.CreatePlanarBreps(C_rec_start, 0.01);
        Brep[] B_end = Brep.CreatePlanarBreps(C_rec_start, 0.01);

        Brep[] B = Brep.CreateFromSweep(C, C_sweep, true, 0.01);
        B = Brep.JoinBreps(B, 0.01);
        Brep[] B_combine = new Brep[3] { B_end[0], B_end[0], B[0] };
        B_combine = Brep.JoinBreps(B_combine, 0.01);

        DA.SetData(0, B_start[0]);
    }
}

?

I tried this,but this method can’t cap the start and end of a tube

I write my own cap method,I think this can be a solution

public static Brep RectangularPath_nP_nC(Curve C, Plane P, double H, double W)
{
Curve C_rec_start = null;
Curve C_rec_end = null;

        Plane P3_start = new Plane(P.Origin, P.XAxis, P.ZAxis);
        Plane P3_end = new Plane(P.Origin, P.XAxis, P.ZAxis);//P3是P2平面的XZ平面

        //if(!calculate.Adjust_plane(ref P3_start, C.TangentAtStart, P3_start.Origin)) return;
        //if(!calculate.Adjust_plane(ref P3_end, C.TangentAtEnd, P3_end.Origin)) return;

        double angle1 = Vector3d.VectorAngle(C.TangentAtStart, P3_start.Normal);
        double angle2 = Vector3d.VectorAngle(C.TangentAtEnd, P3_end.Normal);

        P3_start.Rotate(angle1, P.ZAxis, P3_start.Origin);
        P3_end.Rotate(angle2, P.ZAxis, P3_end.Origin);

        P3_start.Origin = C.PointAtStart;

        P3_end.Origin = C.PointAtEnd;

        Rectangle3d rec_start = new Rectangle3d(P3_start, W, H);
        GH_Convert.ToCurve(rec_start, ref C_rec_start, GH_Conversion.Both);
        Vector3d start_transform = Point3d.Subtract(C.PointAtStart, rec_start.Center);
        geometry_base.move(C_rec_start, start_transform);

        Rectangle3d rec_end = new Rectangle3d(P3_end, W, H);
        GH_Convert.ToCurve(rec_end, ref C_rec_end, GH_Conversion.Both);
        Vector3d end_transform = Point3d.Subtract(C.PointAtEnd, rec_end.Center);
        geometry_base.move(C_rec_end, end_transform);

        Curve[] C_sweep = new Curve[2] { C_rec_start, C_rec_end };

        Brep[] B_start = Brep.CreatePlanarBreps(C_rec_start, 0.01);
        Brep[] B_end = Brep.CreatePlanarBreps(C_rec_end, 0.01);

        Brep[] B = Brep.CreateFromSweep(C, C_sweep, true, 0.01);
        B = Brep.JoinBreps(B, 0.01);
        Brep[] B_combine = new Brep[3] { B_start[0], B_end[0], B[0] };
        B_combine = Brep.JoinBreps(B_combine, 0.01);

        return B_combine[0];
    }