protected IFeature InsertComFeatureBase(string[] paramNames, int[] paramTypes, string[] paramValues, int[] dimTypes, double[] dimValues, object[] selection, object[] editBodies) { if (!typeof(SwMacroFeatureDefinition).IsAssignableFrom(DefinitionType)) { throw new InvalidCastException($"{DefinitionType.FullName} must inherit {typeof(SwMacroFeatureDefinition).FullName}"); } var options = CustomFeatureOptions_e.Default; var provider = ""; DefinitionType.TryGetAttribute <CustomFeatureOptionsAttribute>(a => { options = a.Flags; provider = a.Provider; }); var baseName = MacroFeatureInfo.GetBaseName(DefinitionType); var progId = MacroFeatureInfo.GetProgId(DefinitionType); if (string.IsNullOrEmpty(progId)) { throw new NullReferenceException("Prog id for macro feature cannot be extracted"); } var icons = MacroFeatureIconInfo.GetIcons(DefinitionType, CompatibilityUtils.SupportsHighResIcons(SwMacroFeatureDefinition.Application.Application, CompatibilityUtils.HighResIconsScope_e.MacroFeature)); using (var selSet = new SelectionGroup(m_FeatMgr.Document.ISelectionManager)) { if (selection != null && selection.Any()) { var selRes = selSet.AddRange(selection); Debug.Assert(selRes); } var feat = m_FeatMgr.InsertMacroFeature3(baseName, progId, null, paramNames, paramTypes, paramValues, dimTypes, dimValues, editBodies, icons, (int)options) as IFeature; return(feat); } }
private static IFeature InsertComFeatureBase(IFeatureManager featMgr, Type macroFeatType, string[] paramNames, int[] paramTypes, string[] paramValues, int[] dimTypes, double[] dimValues, object[] selection, object[] editBodies) { if (!typeof(MacroFeatureEx).IsAssignableFrom(macroFeatType)) { throw new InvalidCastException($"{macroFeatType.FullName} must inherit {typeof(MacroFeatureEx).FullName}"); } var options = swMacroFeatureOptions_e.swMacroFeatureByDefault; var provider = ""; macroFeatType.TryGetAttribute <OptionsAttribute>(a => { options = a.Flags; provider = a.Provider; }); var baseName = MacroFeatureInfo.GetBaseName(macroFeatType); var progId = MacroFeatureInfo.GetProgId(macroFeatType); if (string.IsNullOrEmpty(progId)) { throw new NullReferenceException("Prog id for macro feature cannot be extracted"); } var icons = MacroFeatureIconInfo.GetIcons(macroFeatType, m_App.SupportsHighResIcons()); using (var selSet = new SelectionGroup(featMgr.Document.ISelectionManager)) { if (selection != null && selection.Any()) { var selRes = selSet.AddRange(selection); Debug.Assert(selRes); } var feat = featMgr.InsertMacroFeature3(baseName, progId, null, paramNames, paramTypes, paramValues, dimTypes, dimValues, editBodies, icons, (int)options) as IFeature; return(feat); } }