public static bool Extend(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat) { IFeatureClass class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID); IFeatureClass class3 = null; try { if (pTopoErrorFeat.DestinationClassID != 0) { class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID); } } catch { } IFeature feature = null; if (pTopoErrorFeat.TopologyRuleType == esriTopologyRuleType.esriTRTLineNoDangles) { feature = class2.GetFeature(pTopoErrorFeat.OriginOID); IPoint shape = (pTopoErrorFeat as IFeature).Shape as IPoint; IPolyline polyline = feature.Shape as IPolyline; double num = CommonHelper.distance(polyline.FromPoint, shape); double num2 = CommonHelper.distance(polyline.ToPoint, shape); ISegmentCollection segments = polyline as ISegmentCollection; ILine inLine = null; IConstructLine line2 = new LineClass(); if (num < num2) { inLine = segments.get_Segment(0) as ILine; line2.ConstructExtended(inLine, esriSegmentExtension.esriExtendAtFrom); } else { inLine = segments.get_Segment(segments.SegmentCount - 1) as ILine; line2.ConstructExtended(inLine, esriSegmentExtension.esriExtendAtTo); } IPolyline polyline2 = new PolylineClass(); object before = Missing.Value; (polyline2 as ISegmentCollection).AddSegment(line2 as ISegment, ref before, ref before); ISpatialFilter filter = new SpatialFilterClass { Geometry = polyline2, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }; IFeatureCursor o = class2.Search(filter, false); ITopologicalOperator operator2 = polyline2 as ITopologicalOperator; IFeature feature3 = o.NextFeature(); bool flag = true; double num3 = 0.0; ICurve toCurve = null; IPoint splitPoint = null; IFeature feature4 = null; while (feature3 != null) { if (feature3.OID != feature.OID) { double num4; IGeometry geometry2 = operator2.Intersect(feature3.Shape, esriGeometryDimension.esriGeometry0Dimension); if (geometry2 is IPoint) { num4 = CommonHelper.distance(geometry2 as IPoint, shape); if (flag) { flag = false; num3 = num4; splitPoint = geometry2 as IPoint; toCurve = feature3.Shape as ICurve; feature4 = feature3; } else if (num3 > num4) { num3 = num4; splitPoint = geometry2 as IPoint; toCurve = feature3.Shape as ICurve; feature4 = feature3; } } if (geometry2 is IPointCollection) { IPointCollection points = geometry2 as IPointCollection; for (int i = 0; i < points.PointCount; i++) { IPoint point3 = points.get_Point(i); num4 = CommonHelper.distance(point3, shape); if (flag) { flag = false; num3 = num4; splitPoint = point3; toCurve = feature3.Shape as ICurve; feature4 = feature3; } else if (num3 > num4) { num3 = num4; splitPoint = point3; toCurve = feature3.Shape as ICurve; feature4 = feature3; } } } } feature3 = o.NextFeature(); } ComReleaser.ReleaseCOMObject(o); if (toCurve != null) { bool flag3; int num6; int num7; IConstructCurve curve2 = new PolylineClass(); ICurve fromCurve = feature.Shape as ICurve; bool extensionsPerformed = true; if (num < num2) { curve2.ConstructExtended(fromCurve, toCurve, 16, ref extensionsPerformed); } else { curve2.ConstructExtended(fromCurve, toCurve, 8, ref extensionsPerformed); } if (!(curve2 as IGeometry).IsEmpty) { feature.Shape = curve2 as IGeometry; feature.Store(); } (toCurve as IPolycurve).SplitAtPoint(splitPoint, true, false, out flag3, out num6, out num7); feature4.Shape = toCurve; feature4.Store(); return(true); } } return(false); }