private void lvStinck_SelectedIndexChanged(object sender, EventArgs e) { if (lvStinck.SelectedItems.Count == 0) { return; } ControllerStinck stinck = (ControllerStinck)lvStinck.SelectedItems[0].Tag; lbDSVM.Items.Clear(); lbDSVM.Items.AddRange(stinck.BadPublicMethods.Select(x => x.Name).ToArray()); lbNested.Items.Clear(); lbNested.Items.AddRange(stinck.NestedClasses.Select(x => x.Name).ToArray()); lbVmOther.Items.Clear(); lbVmOther.Items.AddRange(stinck.ViewModelMethods.Select(x => x.Name).ToArray()); lbSvcOther.Items.Clear(); lbSvcOther.Items.AddRange(stinck.ServiceMethods.Select(x => x.Name).ToArray()); lbPrivate.Items.Clear(); lbPrivate.Items.AddRange(stinck.NonPublicMethods.Select(x => x.Name).ToArray()); lbProperties.Items.Clear(); lbProperties.Items.AddRange(stinck.NonServiceProps.Select(x => x.Name).ToArray()); var editor = _codeEditors["Controller"]; editor.Text = string.Join(Environment.NewLine, ProjectItemHelper.GetFileLines(stinck.ProjectItem)); tabCode.SelectTab("tabController"); }
public override bool IsEnabledFor(object target) { if (string.IsNullOrEmpty(constructorParameterType)) { return(false); } ProjectItem untypedProvider = target as ProjectItem; if (untypedProvider != null && untypedProvider.FileCodeModel != null) { CodeClass untypedProviderClass = ProjectItemHelper.GetClass(untypedProvider); if (untypedProviderClass == null || untypedProviderClass.Children == null) { return(false); } foreach (CodeElement codeElement in untypedProviderClass.Children) { CodeFunction codeFunction = codeElement as CodeFunction; if (codeFunction != null) { if (vsCMFunction.vsCMFunctionConstructor.Equals(codeFunction.FunctionKind) && (codeFunction.Parameters.Count == 1)) { CodeParameter codeParameter = (CodeParameter)codeFunction.Parameters.Item(1); if (!string.IsNullOrEmpty(codeParameter.Type.AsFullName) && codeParameter.Type.AsFullName.EndsWith(constructorParameterType)) { return(true); } } } } } return(false); }
public override bool OnBeforeActions(object currentValue, out object newValue) { IDictionaryService dictionaryService = (IDictionaryService)GetService <IDictionaryService>(); ProjectItem projectItem = dictionaryService.GetValue(projectItemArgumentName) as ProjectItem; newValue = ProjectItemHelper.GetClass(projectItem).Name; return(true); }
private void FormatSelectedFilesEventHandler() { ThreadHelper.ThrowIfNotOnUIThread(); this.uiShell.SetWaitCursor(); IEnumerable <ProjectItem> projectItems = ProjectItemHelper.GetSelectedProjectItemsRecursively(this) .Where(_ => _.IsXaml() && _.IsFormatable()); this.FormatDocuments(projectItems); }
private void FormatSolutionEventHandler() { ThreadHelper.ThrowIfNotOnUIThread(); this.uiShell.SetWaitCursor(); IEnumerable <ProjectItem> projectItems = ProjectItemHelper.GetAllProjectItems(this.IDE2.Solution) .Where(_ => _.IsXaml() && _.IsFormatable()); this.FormatDocuments(projectItems); }
private static CodeClassWrapper CreateClassHierarchy(CodeClass codeClass) { CodeClass baseCodeClass = ProjectItemHelper.GetBaseClass(codeClass); if (baseCodeClass == null) { return(BuildCodeClassWrapper(codeClass, null)); } return(BuildCodeClassWrapper(codeClass, CreateClassHierarchy(baseCodeClass))); }
public override void Execute() { if (CustomProvider != null) { DTE dte = (DTE)GetService(typeof(DTE)); IUIService uiService = (IUIService)GetService(typeof(IUIService)); CodeClass customProviderClass = ProjectItemHelper.GetClass(CustomProvider); SetOutputValues(customProviderClass); AddDefaultConstructor(customProviderClass); } }
/// <summary> /// Builds the wrapper. /// </summary> /// <param name="projectItem"></param> /// <returns></returns> public static Type BuildWrapper(ProjectItem projectItem) { CodeClass codeClass = ProjectItemHelper.GetClass(projectItem); if (codeClass != null) { CodeClassWrapper type = CreateClassHierarchy(codeClass); /// This is useful for VB support. The class definition could not have a namespace definition so the codeClass.Namespace will be null. if (string.IsNullOrEmpty(type.Namespace)) { type.SetNamespace(NamespaceHelper.GetNamespace(projectItem)); } return(type); } else { return(null); } }
private CodeFunction GetMethod() { CodeClass clazz = ProjectItemHelper.GetClass(ProjectItem); if (clazz != null) { foreach (CodeElement codeElement in clazz.Children) { CodeFunction codeFunction = codeElement as CodeFunction; if (codeFunction != null) { if (codeFunction.Parameters.Count == 0 && codeFunction.Type.TypeKind.Equals(vsCMTypeRef.vsCMTypeRefVoid) && MethodName.Equals(codeFunction.Name)) { return(codeFunction); } } } } return(null); }
protected void SetOutputValues(CodeClass codeClass) { CodeNamespace codeNamespace = ProjectItemHelper.GetNamespace(codeClass.ProjectItem); this.ProviderName = codeClass.Name; RuntimeClassName = codeClass.Name; this.ConfigurationClassname = string.Format("{0}{1}", codeClass.Name, ConfigurationClassnameSuffix); if (codeNamespace != null) { if (!codeNamespace.Name.Equals(codeNamespace.FullName)) { this.ExtendedNamespace = codeNamespace.Name; } else { this.ExtendedNamespace = string.Empty; } this.Namespace = codeNamespace.FullName.Replace(string.Concat(NamespaceHelper.NamespaceSeparator, codeNamespace.Name), string.Empty); } this.RuntimeProviderBaseType = codeClass.Name; this.RuntimeProviderRootType = codeClass.Name; this.RuntimeConfigurationBaseType = Resources.ErrConfigurationBaseClassNotfound; }
private string GetSelectedRelativePath() { return(Context.ActiveProjectItem == null ? string.Empty : ProjectItemHelper.GetProjectRelativePath(Context.ActiveProjectItem)); }