Exemplo n.º 1
0
 /// <summary>
 /// Gets a CodeElement object from the full name string
 /// </summary>
 /// <param name="codeModel"></param>
 /// <param name="codeElementName"></param>
 /// <returns></returns>
 public static CodeElement ConvertFromString(EnvDTE.CodeModel codeModel, string codeElementName)
 {
     try
     {
         CodeType codeType = codeModel.CodeTypeFromFullName(codeElementName);
         return((CodeElement)codeType);
     }
     catch
     {
         int dotIndex = codeElementName.LastIndexOf('.');
         if (dotIndex != -1)
         {
             try
             {
                 string      className     = codeElementName.Substring(0, dotIndex);
                 string      memberName    = codeElementName.Substring(dotIndex + 1);
                 CodeElement parentElement = (CodeElement)codeModel.CodeTypeFromFullName(className);
                 return(new CodeElementEx(parentElement).Members.Item(memberName));
             }
             catch
             {
                 return(null);
             }
         }
         return(null);
     }
 }
        private static string GetSafeCategoryValue(string category, EnvDTE.CodeModel codeModel)
        {
            const string csharp = "csharp";
            const string vb     = "visualbasic";
            const string vcpp   = "visualc++";
            const string jsharp = "jsharp";
            var          map    = new Dictionary <string, string>
            {
                { "cs", csharp },
                { "vb", vb },
                { "c#", csharp },
                { "c++", vcpp },
                { "c+", vcpp },
                { "cpp", vcpp },
                { csharp, csharp },
                { vcpp, vcpp },
                { vb, vb },
                { jsharp, jsharp },
                { CodeModelLanguageConstants.vsCMLanguageCSharp, csharp },
                { CodeModelLanguageConstants.vsCMLanguageVB, vb },
                { CodeModelLanguageConstants.vsCMLanguageVC, vcpp },
                { CodeModelLanguageConstants.vsCMLanguageMC, vcpp },
                { CodeModelLanguageConstants2.vsCMLanguageJSharp, jsharp },
            };

            if (String.IsNullOrEmpty(category))
            {
                string language = String.Empty;
                if (null != codeModel && null != codeModel.Language)
                {
                    language = codeModel.Language;
                }
                category = map.ContainsKey(language) ? map[language] : csharp;
            }

            return(category);
        }
 public ProjectCodeModelNodeFactory(EnvDTE.CodeModel codeModel)
 {
     _codeModel = codeModel;
 }
Exemplo n.º 4
0
 public void SetCodeModel(CodeModel codeModel)
 {
     this.codeModel = codeModel;
 }
 public ProjectCodeModelNodeFactory(EnvDTE.CodeModel codeModel)
 {
     _codeModel = codeModel;
 }
Exemplo n.º 6
0
 public static void WalkCodeModel(EnvDTE.CodeModel codeModel, string indent)
 {
     doCodeModel(codeModel);
     WalkCodeElements(codeModel.CodeElements, indent);
 }
Exemplo n.º 7
0
 public static void doCodeModel(EnvDTE.CodeModel codeModel)
 {
     Debug.WriteLine("======== Walking Project.CodeModel for: " + codeModel.Parent.Name + "=========");
     Debug.WriteLine("==== code model language is: " + codeModel.Language + " =======");
 }