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


C# CodeElement类代码示例

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


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


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