private static IFeature ReplaceComFeatureBase <TMacroFeature>(this IFeatureManager featMgr, IFeature feat, object parameters) where TMacroFeature : MacroFeatureEx { if (feat == null) { throw new ArgumentNullException(nameof(feat)); } var model = featMgr.Document; if (featMgr.EditRollback((int)swMoveRollbackBarTo_e.swMoveRollbackBarToAfterFeature, feat.Name)) { IFeature newFeat = null; var name = feat.Name; if (parameters != null) { newFeat = InsertComFeatureWithParameters(featMgr, typeof(TMacroFeature), parameters); } else { newFeat = InsertComFeature <TMacroFeature>(featMgr); } if (newFeat != null) { if (feat.Select2(false, -1)) { int DEFAULT_DEL_OPTS = 0; if (model.Extension.DeleteSelection2(DEFAULT_DEL_OPTS)) { newFeat.Name = name; } else { Debug.Assert(false, "Failed to delete feature"); } } else { Debug.Assert(false, "Failed to select feature"); } } featMgr.EditRollback((int)swMoveRollbackBarTo_e.swMoveRollbackBarToEnd, ""); return(newFeat); } else { Debug.Assert(false, "Failed to rollback the feature"); return(null); } }