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

C# CodeElement类代码示例

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

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



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

示例1: AddCommentsTo

		private static void AddCommentsTo(CodeElement codeElement)
		{
			if (CodeElementsThatNeedDocComment.Contains(codeElement.Kind))
			{
				if (string.IsNullOrWhiteSpace(codeElement.GetDocComment()))
				{
					if (codeElement.IsInherited() || codeElement.OverridesSomething())
					{
						codeElement.SetDocComment(@"<DOC><inheritdoc/></DOC>");
					}
					else
					{
						switch (codeElement.Kind)
						{
							case vsCMElement.vsCMElementProperty: AddDocCommentToProperty(codeElement as CodeProperty); break;
							case vsCMElement.vsCMElementFunction: AddDocCommentToFunction(codeElement as CodeFunction); break;
							case vsCMElement.vsCMElementEnum: AddGhostDogCommand(codeElement); break;
							case vsCMElement.vsCMElementStruct: AddGhostDogCommand(codeElement); break;
							case vsCMElement.vsCMElementInterface: AddDocCommentToInterface(codeElement as CodeInterface); break;
							case vsCMElement.vsCMElementEvent: AddGhostDogCommand(codeElement); break;
							case vsCMElement.vsCMElementClass: AddDocCommentToClass(codeElement as CodeClass); break;
							case vsCMElement.vsCMElementVariable: AddGhostDogCommand(codeElement); break;
						}
					}
				}
			}

			if (CodeElementsWithChildren.Contains(codeElement.Kind))
			{
				foreach (CodeElement child in codeElement.Children)
				{
					AddCommentsTo(child);
				}
			}
		}
开发者ID:mmahulea,项目名称:FactonExtensionPackage,代码行数:35,代码来源:AddCommentsToCodeElements.cs


示例2: GoToCodeElementHelper

        /// <summary>
        /// Selects text in the code editor.
        /// </summary>
        /// <param name="dte">A DTE2 object exposing the Visual Studio automation object model.</param>
        /// <param name="element">The CodeElementWrapper object containing the selection.</param>
        /// <param name="useTryShow">true to use TryToShow to adjust the code editor window to show the selection, otherwise false.</param>
        public static void GoToCodeElementHelper(DTE dte, CodeElement element, bool useTryShow)
        {
            if (element != null)
            {
                try
                {
                    TextPoint start = element.StartPoint;
                    var tx = (TextDocument)dte.ActiveDocument.Object("TextDocument");
                    int line = start.Line;
                    int offset = start.LineCharOffset;

                    if (!useTryShow)
                    {
                        tx.Selection.MoveToLineAndOffset(line, offset, false);
                    }
                    else
                    {
                        start.TryToShow(vsPaneShowHow.vsPaneShowCentered, start);
                    }

                    if (!useTryShow)
                    {
                        tx.Selection.SelectLine();
                    }
                }
                catch (COMException)
                {
                    // Discard the exception that gets thrown when accessing
                    // a non-code TextDocument, for example a Windows form.
                }
            }
        }
开发者ID:jda808,项目名称:NPL,代码行数:38,代码来源:EditorSupport.cs


示例3: Process

        // ------------------------------------------------------
        public void Process(CodeElement element)
        {
            bool visitChildren = Visit(element);

            if (visitChildren)
                Process(element.Children);
        }
开发者ID:edpack1980,项目名称:uml-auto-assessment,代码行数:8,代码来源:CodeElementVisitor.cs


示例4: RenameSymbols

        /// <summary>
        /// Rename function in scope of parentElement.
        /// </summary>
        /// <param name="element">Element to rename.</param>
        /// <param name="parentElement">Containing element.</param>
        /// <param name="elementType">Type of element.</param>
        /// <param name="oldName">Old name of element.</param>
        /// <param name="newName">New name of element.</param>
        public override IRenameResult RenameSymbols(CodeElement element, LuaCodeClass parentElement, 
            vsCMElement elementType, string oldName, string newName)
        {
            renameResult = new RenameResult(oldName, newName);
            changedCodeElements = new List<CodeElement>();

            //Function without parent element could not be renamed
            if (element is LuaCodeFunction && parentElement == null)
            {
                var ex = new InvalidCodeElementException(Resources.InvalidFunctionParentMessage, parentElement);
                Trace.WriteLine(ex);
                throw ex;
            }
            //Rename function, function calls or null element by its name
            if (element is LuaCodeFunction || element is LuaCodeElement<FunctionCall> || element == null)
            {
                renameResult = Rename(element, parentElement, oldName, newName);
            }
            else
            {
                throw new InvalidCodeElementException(
                    Resources.InvalidFunctionElementMessage, parentElement);
            }

            //Set RenameReferences flag to indicates that rename is local or not
            renameResult.RenameReferences = !IsLocalDeclaration;
            renameResult.ChangedElements = changedCodeElements;

            renameResult.Success = true;

            return renameResult;
        }
开发者ID:jda808,项目名称:NPL,代码行数:40,代码来源:FunctionRenameStrategy.cs


示例5: GetCodeElementMembers

        private EnvDTE.CodeElements GetCodeElementMembers(CodeElement objCodeElement)
        {

            EnvDTE.CodeElements colCodeElements = default(EnvDTE.CodeElements);


            if (objCodeElement is EnvDTE.CodeNamespace)
            {
                colCodeElements = ((EnvDTE.CodeNamespace)objCodeElement).Members;


            }
            else if (objCodeElement is EnvDTE.CodeType)
            {
                colCodeElements = ((EnvDTE.CodeType)objCodeElement).Members;


            }
            else if (objCodeElement is EnvDTE.CodeFunction)
            {
                colCodeElements = ((EnvDTE.CodeFunction)objCodeElement).Parameters;

            }

            return colCodeElements;

        } 
开发者ID:Refresh06,项目名称:visualmutator,代码行数:27,代码来源:VisualStudioCodeSearcher.cs


示例6: ExamineCodeElement

 private static string ExamineCodeElement(CodeElement codeElement, vsCMElement type)
 {
     return codeElement.Kind == type
         ? codeElement.Name
         : (from CodeElement childElement in codeElement.Children select ExamineCodeElement(childElement, type))
             .FirstOrDefault(result => !string.IsNullOrEmpty(result));
 }
开发者ID:PDarkTemplar,项目名称:UnityRefactorHelper,代码行数:7,代码来源:ProjectService.cs


示例7: CodeFieldInfo

 /// <summary>
 /// 
 /// </summary>
 public CodeFieldInfo(BaseInfo parent, CodeElement item, TypeInfo type)
     : base(parent, item as CodeElement2)
 {
     this._item = item;
     this.Access = CMAccess.Public; // ObjectFactory.Convert(this._item.Access);
     this._type = type;
 }
开发者ID:t4generators,项目名称:t4-SolutionManager,代码行数:10,代码来源:CodeFieldInfo.cs


示例8: MoveToRegionForm

        public MoveToRegionForm(CodeElement classElement)
        {
            this.classElement = classElement;
            InitializeComponent();

            BindRegionToTreeView();
        }
开发者ID:qianlifeng,项目名称:easyvsx,代码行数:7,代码来源:MoveToRegionForm.cs


示例9: GetFieldStringFromElement

 private static string GetFieldStringFromElement(CodeElement elem)
 {
     var v = (CodeVariable) elem;
     var typeName = GenericNameMangler.MangleTypeName(GetTypeName(v.Parent));
     var oftype = GetVariableType(v);
     return oftype + " " + typeName + "::" + v.Name;
 }
开发者ID:simonlaroche,项目名称:AutoTest.Net,代码行数:7,代码来源:MethodNameReader.cs


示例10: GetMethodStringFromElement

 public static string GetMethodStringFromElement(CodeElement elem)
 {
     try
     {
         if (elem.Kind == vsCMElement.vsCMElementFunction)
         {
             return GetMethodStringFromElement(elem as CodeFunction);
         }
         if (elem.Kind == vsCMElement.vsCMElementProperty)
         {
             var getter = ((CodeProperty) elem).Getter;
             return GetMethodStringFromElement(getter);
         }
         if (elem.Kind == vsCMElement.vsCMElementVariable)
         {
             return GetFieldStringFromElement(elem);
         }
     }
     catch(Exception ex)
     {
         Core.DebugLog.Debug.WriteDebug("Exception getting Method String : " + ex.ToString());
         return null;
     }
     return null;
 }
开发者ID:simonlaroche,项目名称:AutoTest.Net,代码行数:25,代码来源:MethodNameReader.cs


示例11: Parse

        public static VsClass Parse( CodeElement codeElement)
        {
            var vsClass = new VsClass();
            vsClass.Name = codeElement.Name;
            var codeClass = (CodeClass) codeElement;
            var startPoint = codeClass.StartPoint.CreateEditPoint();
            var endPoint = codeClass.EndPoint.CreateEditPoint();
            int i = 1;
            while( startPoint.LessThan(endPoint))
            {
                i++;
                startPoint.LineDown(1);
            }
            vsClass.Loc = i;
            foreach (CodeElement element in ((CodeClass)codeElement).Members)
            {

                if (element.Kind == vsCMElement.vsCMElementVariable)
                {
                    vsClass.Variables.Add(VsVariable.Parse(element));
                }
                else if (element.Kind == vsCMElement.vsCMElementFunction)
                {
                    CodeFunction function = element as CodeFunction;
                    if (function.FunctionKind == vsCMFunction.vsCMFunctionConstructor)
                        vsClass.Constructors.Add(VsConstructors.Parse(function));
                    else
                        vsClass.Methods.Add(VsMethod.Parse(function));
                }
            }
            return vsClass;
        }
开发者ID:sankalpsaxena81,项目名称:Addin-3,代码行数:32,代码来源:VsClass.cs


示例12: Visit

        protected override void Visit(CodeElement element)
        {
            //结果已经找到,退出访问。
            if (_result != null) return;

            base.Visit(element);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:7,代码来源:TypeFileFinder.cs


示例13: RenameSymbols

 /// <summary>
 /// Rename element in scope of parentElement.
 /// </summary>
 /// <param name="element">Element to rename.</param>
 /// <param name="parentElement">Containing element.</param>
 /// <param name="elementType">Type of element.</param>
 /// <param name="oldName">Old name of element.</param>
 /// <param name="newName">New name of element.</param>
 public IRenameResult RenameSymbols(CodeElement element, LuaCodeClass parentElement, vsCMElement elementType, string oldName, string newName)
 {
     if (CodeElementRename == null)
     {
         throw new InvalidStrategyException(CodeElementRename);
     }
     return CodeElementRename.RenameSymbols(element, parentElement, elementType, oldName, newName);
 }
开发者ID:jda808,项目名称:NPL,代码行数:16,代码来源:CodeElementRenameContext.cs


示例14: getCodeElements

        public CodeElements getCodeElements(CodeElement ce)
        {
            if (ce is CodeNamespace) return ((CodeNamespace) ce).Members;
            if (ce is CodeClass) return ((CodeClass) ce).Members;
            if (ce is CodeType ) return ((CodeType )ce).Members;
            if (ce is CodeFunction ) return ((CodeFunction )ce).Parameters ;

            return null;
        }
开发者ID:stickleprojects,项目名称:VSDropAssist,代码行数:9,代码来源:CodeElementHelper.cs


示例15: CreateNodeFactoryFromCodeElement

        internal static CodeElementNodeFactory CreateNodeFactoryFromCodeElement(CodeElement element)
        {
            if (element is CodeNamespace)
            {
                return new CodeNamespaceNodeFactory(element as CodeNamespace);
            }
            if (element is CodeClass2)
            {
                return new CodeClassNodeFactory(element as CodeClass2);
            }
            if (element is CodeInterface2)
            {
                return new CodeInterfaceNodeFactory(element as CodeInterface2);
            }
            if (element is CodeProperty)
            {
                return new CodePropertyNodeFactory(element as CodeProperty);
            }
            if (element is CodeFunction2)
            {
                return new CodeMethodNodeFactory(element as CodeFunction2);
            }
            if (element is CodeEvent)
            {
                return new CodeEventNodeFactory(element as CodeEvent);
            }
            if (element is CodeVariable2)
            {
                return new CodeVariableNodeFactory(element as CodeVariable2);
            }
            if (element is CodeEnum)
            {
                return new CodeEnumNodeFactory(element as CodeEnum);
            }
            if (element is CodeAttribute2)
            {
                return new CodeAttributeNodeFactory(element as CodeAttribute2);
            }
            if (element is CodeDelegate2)
            {
                return new CodeDelegateNodeFactory(element as CodeDelegate2);
            }
            if (element is CodeParameter2)
            {
                return new CodeParameterNodeFactory(element as CodeParameter2);
            }
            if (element is CodeAttributeArgument)
            {
                return new CodeAttributeArgumentNodeFactory(element);
            }
            if (element is CodeStruct2)
            {
                return new CodeStructNodeFactory(element as CodeStruct2);
            }

            return new CodeElementNodeFactory(element);
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:57,代码来源:FileCodeModelNodeFactory.cs


示例16: CodeDomCodeAttribute

        public CodeDomCodeAttribute(DTE dte, CodeElement parent, string name)
            : base(dte, name)
        {
            this.parent = parent;
            CodeAttributeDeclaration cad = new CodeAttributeDeclaration();
            // !!! name, value

            CodeObject = cad;
        }
开发者ID:kageyamaginn,项目名称:VSSDK-Extensibility-Samples,代码行数:9,代码来源:CodeDomCodeAttribute.cs


示例17: IsNamespaceImportPresent

 private static bool IsNamespaceImportPresent(CodeElement codeElement, string productNamespace)
 {
     if (codeElement.Kind.Equals(vsCMElement.vsCMElementImportStmt))
     {
         CodeImport codeImport = (CodeImport)codeElement;
         return String.Equals(codeImport.Namespace, productNamespace, StringComparison.OrdinalIgnoreCase);
     }
     return false;
 }
开发者ID:TomDu,项目名称:lab,代码行数:9,代码来源:CodeTypeFilter.cs


示例18: LuaCodeVariableTable

 /// <summary>
 /// Initializes a new instance of the <see cref="LuaCodeVariableTable"/> class.
 /// </summary>
 /// <param name="dte"></param>
 /// <param name="parentElement"></param>
 /// <param name="name"></param>
 /// <param name="access"></param>
 /// <param name="variable"></param>
 public LuaCodeVariableTable(DTE dte, CodeElement parentElement, string name, vsCMAccess access,
     TableConstructor variable)
     : base(dte, parentElement, name, new LuaCodeTypeRef(
                                          dte, LuaDeclaredType.Table), access,
            new Variable(variable.Location) {Identifier = new Identifier(variable.Location)})
 {
     childObjects = new LuaCodeElements(dte, this);
     astNode = variable;
     parent = parentElement;
 }
开发者ID:jda808,项目名称:NPL,代码行数:18,代码来源:LuaCodeVariableTable.cs


示例19: IsImportPresentUnderNamespace

 private static bool IsImportPresentUnderNamespace(CodeElement codeElement, string productNamespace)
 {
     foreach (CodeElement codeElementChildren in codeElement.Children)
     {
         if (IsNamespaceImportPresent(codeElementChildren, productNamespace))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:TomDu,项目名称:lab,代码行数:11,代码来源:CodeTypeFilter.cs


示例20: Violation

 internal Violation(Microsoft.StyleCop.Rule rule, CodeElement element, int line, string message)
 {
     this.rule = rule;
     this.element = element;
     this.line = line;
     this.message = message;
     if ((this.element != null) && (this.element.Document != null))
     {
         this.sourceCode = this.element.Document.SourceCode;
     }
 }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:11,代码来源:Violation.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CodeElementsParser类代码示例发布时间:2022-05-24
下一篇:
C# CodeDomProvider类代码示例发布时间: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