当前位置: 首页>>代码示例>>C#>>正文


C# CodeClass类代码示例

本文整理汇总了C#中CodeClass的典型用法代码示例。如果您正苦于以下问题:C# CodeClass类的具体用法?C# CodeClass怎么用?C# CodeClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CodeClass类属于命名空间,在下文中一共展示了CodeClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddProperty

        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="codeClass">The code class.</param>
        /// <param name="var">The var.</param>
        /// <returns></returns>
        public static CodeProperty AddProperty(CodeClass codeClass, CodeVariable var)
        {
            CodeProperty prop = null;

            try
            {
                prop = codeClass.AddProperty(
                    FormatPropertyName(var.Name),
                    FormatPropertyName(var.Name),
                    var.Type.AsFullName, -1,
                    vsCMAccess.vsCMAccessPublic, null);

                EditPoint editPoint = prop.Getter.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint();

                //Delete return default(int); added by codeClass.AddProperty
                editPoint.Delete(editPoint.LineLength);

                editPoint.Indent(null, 4);
                editPoint.Insert(string.Format(CultureInfo.InvariantCulture, "return {0};", var.Name));

                editPoint = prop.Setter.GetStartPoint(vsCMPart.vsCMPartBody).CreateEditPoint();

                editPoint.Indent(null, 1);
                editPoint.Insert(string.Format(CultureInfo.InvariantCulture, "{0} = value;", var.Name));
                editPoint.SmartFormat(editPoint);

                return prop;
            }
            catch
            {
                //Property already exists
                return null;
            }
        }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:40,代码来源:FileCodeModelHelper.cs

示例2: VisitClass

 protected override void VisitClass(CodeClass codeClass)
 {
     if (codeClass.FullName == _classFullName)
     {
         _result = codeClass.ProjectItem;
     }
 }
开发者ID:569550384,项目名称:Rafy,代码行数:7,代码来源:TypeFileFinder.cs

示例3: HaveAClass

 // Methods
 public static bool HaveAClass(object target, out CodeClass codeClass)
 {
     ProjectItem projectItem = null;
     if (target is SelectedItems)
     {
         SelectedItems items = (SelectedItems)target;
         if ((items.Count > 1) && (items.Item(1).ProjectItem != null))
         {
             projectItem = items.Item(1).ProjectItem;
         }
     }
     else if (target is ProjectItem)
     {
         projectItem = (ProjectItem)target;
     }
     if ((projectItem != null) && (projectItem.FileCodeModel != null))
     {
         foreach (CodeElement element in projectItem.FileCodeModel.CodeElements)
         {
             if (element is CodeNamespace)
             {
                 CodeNamespace namespace2 = (CodeNamespace)element;
                 if ((namespace2.Members.Count > 0) && (namespace2.Members.Item(1) is CodeClass))
                 {
                     codeClass = (CodeClass)namespace2.Members.Item(1);
                     return true;
                 }
             }
         }
     }
     codeClass = null;
     return false;
 }
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:34,代码来源:ReferenceUtil.cs

示例4: GetClassDeclaration

        /// <summary>
        /// Gets the declaration of the specified code class as a string.
        /// </summary>
        /// <param name="codeClass">The code class.</param>
        /// <returns>The string declaration.</returns>
        internal static string GetClassDeclaration(CodeClass codeClass)
        {
            // Get the start point after the attributes.
            var startPoint = codeClass.GetStartPoint(vsCMPart.vsCMPartHeader);

            return TextDocumentHelper.GetTextToFirstMatch(startPoint, @"\{");
        }
开发者ID:reima,项目名称:codemaid,代码行数:12,代码来源:CodeElementHelper.cs

示例5: AddAttribute

 /// <summary>
 /// Adds the attribute.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="attributeName">Name of the attribute.</param>
 /// <param name="attributeValue">The attribute value.</param>
 public static void AddAttribute(CodeClass element, string attributeName, string attributeValue)
 {
     if(!HasAttribute(element, attributeName))
     {
         element.AddAttribute(attributeName, attributeValue, 0);
     }
 }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:13,代码来源:FileCodeModelHelper.cs

示例6: CanGenerateHandleCodeProperty

      internal static bool CanGenerateHandleCodeProperty(string testClassFixturePostFix, CodeClass parentCodeClass, CodeProperty codeProperty, Project unitTestProject)
      {
         foreach (ProjectItem projectItem in unitTestProject.ProjectItems)
         {
            List<CodeClass> lstProjectCodeClasses = UTGManagerAndExaminor.ProjectItemExaminor.GetCodeClasses(projectItem.FileCodeModel);

            foreach (CodeClass codeClass in lstProjectCodeClasses)
            {
               if ((parentCodeClass.Name + testClassFixturePostFix).Equals(codeClass.Name))
               {
                  foreach (CodeElement codeElement in codeClass.Members)
                  {
                     if (codeElement is CodeProperty)
                     {
                        if (codeProperty.Name.Equals(((CodeProperty)codeElement).Name))
                           return false;

                     }
                  }
               }
            }
         }

         return true;
      }
开发者ID:codemonkies,项目名称:UTGV1.0,代码行数:25,代码来源:CodeSelectionHandler.cs

示例7: ParseDomainNamespace

        /// <summary>
        /// 解析出实体的命令空间。
        /// </summary>
        /// <param name="repo"></param>
        /// <returns></returns>
        private static bool ParseDomainNamespace(CodeClass repo, string entityName, IList<CodeClass> entities, out string domainNamespace)
        {
            domainNamespace = null;

            //如果实体和仓库都是在这同一个项目中时,直接在实体列表中找到对应实体的命令空间。
            if (entities.Count > 0)
            {
                var entity = entities.FirstOrDefault(c => c.Name == entityName);
                if (entity != null)
                {
                    domainNamespace = entity.Namespace.FullName;
                    return true;
                }
            }

            //实体不在同一个项目中,则通过约定查找实体的命名空间:
            //Repository.g.cs 文件中的最后一个命名空间,即是实体的命名空间。
            var item = repo.ProjectItem;
            var fileName = item.get_FileNames(1);
            var gFileName = Path.GetFileNameWithoutExtension(fileName) + ".g.cs";
            var gFile = Path.Combine(Path.GetDirectoryName(fileName), gFileName);

            //Repository 的层基类是没有 .g.cs 文件的,这时不需要为它生成。
            if (File.Exists(gFile))
            {
                var code = File.ReadAllText(gFile);
                var match = Regex.Match(code, @"using (?<domainNamespace>\S+?);\s+namespace");
                domainNamespace = match.Groups["domainNamespace"].Value;
                return !string.IsNullOrWhiteSpace(domainNamespace);
            }
            return false;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:37,代码来源:RefreshAutoCodeCommand.cs

示例8: ProcessCodeFunctions

 private void ProcessCodeFunctions(CodeClass codeClass, BindingSourceType bindingSourceType, IdeBindingSourceProcessor bindingSourceProcessor)
 {
     foreach (var codeFunction in codeClass.Children.OfType<CodeFunction>())
     {
         var bindingSourceMethod = CreateBindingSourceMethod(codeFunction, bindingSourceType, bindingSourceProcessor);
         if (bindingSourceMethod != null)
             bindingSourceProcessor.ProcessMethod(bindingSourceMethod);
     }
 }
开发者ID:Galad,项目名称:SpecFlow,代码行数:9,代码来源:VsBindingRegistryBuilder.cs

示例9: VisitClass

        protected override void VisitClass(CodeClass codeClass)
        {
            this.ShowName(codeClass, "Class");

            _level++;

            base.VisitClass(codeClass);

            _level--;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:10,代码来源:TextVisitor.cs

示例10: IsBindingClass

 static public bool IsBindingClass(CodeClass codeClass)
 {
     try
     {
         return codeClass.Attributes.Cast<CodeAttribute>().Any(attr => typeof(BindingAttribute).FullName.Equals(attr.FullName));
     }
     catch(Exception)
     {
         return false;
     }
 }
开发者ID:roffster,项目名称:SpecFlow,代码行数:11,代码来源:VsStepSuggestionBindingCollector.cs

示例11: IsBindingClass

 static public bool IsBindingClass(CodeClass codeClass)
 {
     try
     {
         return codeClass.Attributes.Cast<CodeAttribute>().Any(attr => "TechTalk.SpecFlow.BindingAttribute".Equals(attr.FullName));
     }
     catch(Exception)
     {
         return false;
     }
 }
开发者ID:hedaayat,项目名称:SpecFlow,代码行数:11,代码来源:VsStepSuggestionBindingCollector.cs

示例12: ClassTraverser

        public ClassTraverser(CodeClass codeClass, Action<CodeProperty> withProperty)
        {
            if (codeClass == null) throw new ArgumentNullException("codeClass");
            if (withProperty == null) throw new ArgumentNullException("withProperty");

            CodeClass = codeClass;
            WithProperty = withProperty;

            if (codeClass.Members != null)
                Traverse(codeClass.Members);
        }
开发者ID:dolly22,项目名称:t4ts,代码行数:11,代码来源:ClassTraverser.cs

示例13: IsPotentialBindingClass

 static internal bool IsPotentialBindingClass(CodeClass codeClass)
 {
     try
     {
         var filteredAttributes = codeClass.Attributes.OfType<CodeAttribute2>();
         return BindingSourceProcessor.IsPotentialBindingClass(filteredAttributes.Select(attr => attr.FullName));
     }
     catch(Exception)
     {
         return false;
     }
 }
开发者ID:grassynoel,项目名称:SpecFlow,代码行数:12,代码来源:VsBindingRegistryBuilder.cs

示例14: VisitClass

 protected override void VisitClass(CodeClass codeClass)
 {
     if (Helper.IsEntity(codeClass))
     {
         _fileFinised = true;
     }
     else if (Helper.IsRepository(codeClass))
     {
         _result.Add(codeClass);
         _fileFinised = true;
     }
 }
开发者ID:569550384,项目名称:Rafy,代码行数:12,代码来源:RepoFileFinder.cs

示例15: DerivedFromBaseTest

        private static bool DerivedFromBaseTest(CodeClass classElement)
        {
            if (classElement.Name == "BaseTest")
            {
                return true;
            }

            return classElement.Bases
                       .Cast<CodeElement>()
                       .Where(e => e.Kind == vsCMElement.vsCMElementClass)
                       .Count(c => DerivedFromBaseTest((CodeClass)c)) > 0;
        }
开发者ID:MonsterCoder,项目名称:MavenThought.VSExtension,代码行数:12,代码来源:ClassItemFactory.VSExtensionPackage.cs


注:本文中的CodeClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。