• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CodeClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetEntityNameForRepository

        internal static string GetEntityNameForRepository(CodeClass repo)
        {
            ////使用 Attribute 来进行获取实体类名。
            //foreach (CodeAttribute attri in repo.Attributes)
            //{
            //    //RootEntity or ChildEntity
            //    if (attri.FullName == Consts.RepositoryForAttributeClassFullName)
            //    {
            //    }
            //}

            return repo.Name.Substring(0, repo.Name.Length - Consts.RepositorySuffix.Length);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:13,代码来源:Helper.cs


示例17: GetNextAvailableCopyName

      public static string GetNextAvailableCopyName(CodeClass codeClass, ref string codeFunctionName, Project project)
      {
         codeFunctionName = "CopyOf" + codeFunctionName;

         if (!CodeSelectionHandler.CanGenerateHandleCodeFunction(
           codeClass,
           codeFunctionName))
         {
            return GetNextAvailableCopyName(codeClass, ref codeFunctionName, project);
         }

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


示例18: CanGenerateHandleCodeFunction

      internal static bool CanGenerateHandleCodeFunction(CodeClass parentCodeClass, string codeFunctionName)
      {

         foreach (CodeElement codeElement in parentCodeClass.Members)
         {
            if (codeElement is CodeFunction)
            {
               if (codeFunctionName.Equals(((CodeFunction)codeElement).Name))
                  return false;

            }
         }

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


示例19: ProcessCodeClass

        private void ProcessCodeClass(CodeClass codeClass, IdeBindingSourceProcessor bindingSourceProcessor, params CodeClass[] classParts)
        {
            var filteredAttributes = classParts
                .SelectMany(cc => cc.Attributes.Cast<CodeAttribute2>().Where(attr => CanProcessTypeAttribute(bindingSourceProcessor, attr))).ToArray();
                
            if (!bindingSourceProcessor.PreFilterType(filteredAttributes.Select(attr => attr.FullName)))
                return;

            var bindingSourceType = bindingReflectionFactory.CreateBindingSourceType(classParts, filteredAttributes); //TODO: merge info from parts

            if (!bindingSourceProcessor.ProcessType(bindingSourceType))
                return;

            ProcessCodeFunctions(codeClass, bindingSourceType, bindingSourceProcessor);

            bindingSourceProcessor.ProcessTypeDone();
        }
开发者ID:Galad,项目名称:SpecFlow,代码行数:17,代码来源:VsBindingRegistryBuilder.cs


示例20: SelectObjectClass

		protected void SelectObjectClass( CodeClass cc )
		{
			ProjectItem p = cc.ProjectItem;
			//  Open the file as a source code file
			EnvDTE.Window theWindow = p.Open(Constants.vsViewKindCode);

			//Get a handle to the new document in the open window
			TextDocument objTextDoc = (TextDocument)theWindow.Document.Object("TextDocument");
			EditPoint objEditPoint = (EditPoint)objTextDoc.StartPoint.CreateEditPoint();

			theWindow.Visible = true;

			TextSelection ts = (TextSelection) theWindow.Selection;
			ts.StartOfDocument(false);
			objEditPoint.MoveToLineAndOffset(cc.StartPoint.Line,1);
			ts.MoveToPoint( objEditPoint, false );
		}
开发者ID:Robby777,项目名称:ambientsmell,代码行数:17,代码来源:BaseVisualization.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeColorizer类代码示例发布时间:2022-05-24
下一篇:
C# CodeBlock类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap