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

C# CsDocument类代码示例

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

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



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

示例1: GetElementByQualifiedName

		/// <summary>
		/// Gets element by name.
		/// </summary>
		private static CsElement GetElementByQualifiedName(CsDocument document, string qualifiedName)
		{
			return GetElementByName(
				document.RootElement.ChildElements,
				qualifiedName,
				true);
		}
开发者ID:jozefizso,项目名称:StyleCopPlus,代码行数:10,代码来源:CodeHelperTest.cs


示例2: GetElementByName

		/// <summary>
		/// Gets element by name.
		/// </summary>
		private static CsElement GetElementByName(CsDocument document, string name)
		{
			return GetElementByName(
				document.RootElement.ChildElements,
				name,
				false);
		}
开发者ID:jozefizso,项目名称:StyleCopPlus,代码行数:10,代码来源:CodeHelperTest.cs


示例3: AnalyzePlainText

		/// <summary>
		/// Analyzes source code as plain text.
		/// </summary>
		private void AnalyzePlainText(CsDocument document, CustomRulesSettings settings)
		{
			string source;
			using (TextReader reader = document.SourceCode.Read())
			{
				source = reader.ReadToEnd();
			}

			List<string> lines = new List<string>(
				source.Split(
					new[] { "\r\n", "\r", "\n" },
					StringSplitOptions.None));

			for (int i = 0; i < lines.Count; i++)
			{
				int currentLineNumber = i + 1;
				string currentLine = lines[i];
				string previousLine = i > 0 ? lines[i - 1] : null;

				CheckLineEnding(document, currentLine, currentLineNumber);
				CheckIndentation(document, currentLine, previousLine, currentLineNumber, settings);
				CheckLineLength(document, currentLine, currentLineNumber, settings);
			}

			CheckLastLine(document, source, lines.Count, settings);
		}
开发者ID:jozefizso,项目名称:StyleCopPlus,代码行数:29,代码来源:MoreCustomRules.cs


示例4: Method

 internal Method(CsDocument document, CsElement parent, XmlHeader header, ICollection<Microsoft.StyleCop.CSharp.Attribute> attributes, Declaration declaration, TypeToken returnType, IList<Parameter> parameters, ICollection<TypeParameterConstraintClause> typeConstraints, bool unsafeCode, bool generated)
     : base(document, parent, ElementType.Method, "method " + declaration.Name, header, attributes, declaration, unsafeCode, generated)
 {
     this.returnType = returnType;
     this.parameters = parameters;
     this.typeConstraints = typeConstraints;
     if ((this.parameters.Count > 0) && base.Declaration.ContainsModifier(new CsTokenType[] { CsTokenType.Static }))
     {
         foreach (Parameter parameter in this.parameters)
         {
             if ((parameter.Modifiers & ParameterModifiers.This) != ParameterModifiers.None)
             {
                 this.extensionMethod = true;
             }
             break;
         }
     }
     base.QualifiedName = CodeParser.AddQualifications(this.parameters, base.QualifiedName);
     if ((base.Declaration.Name.IndexOf(".", StringComparison.Ordinal) > -1) && !base.Declaration.Name.StartsWith("this.", StringComparison.Ordinal))
     {
         base.Declaration.AccessModifierType = AccessModifierType.Public;
     }
     if (typeConstraints != null)
     {
         foreach (TypeParameterConstraintClause clause in typeConstraints)
         {
             clause.ParentElement = this;
         }
     }
 }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:30,代码来源:Method.cs


示例5: Field

 internal Field(CsDocument document, CsElement parent, XmlHeader header, ICollection<Microsoft.StyleCop.CSharp.Attribute> attributes, Declaration declaration, TypeToken fieldType, bool unsafeCode, bool generated)
     : base(document, parent, ElementType.Field, "field " + declaration.Name, header, attributes, declaration, unsafeCode, generated)
 {
     this.type = fieldType;
     this.isConst = base.Declaration.ContainsModifier(new CsTokenType[] { CsTokenType.Const });
     this.isReadOnly = base.Declaration.ContainsModifier(new CsTokenType[] { CsTokenType.Readonly });
 }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:7,代码来源:Field.cs


示例6: EnumItem

        /// <summary>
        /// Initializes a new instance of the EnumItem class.
        /// </summary>
        /// <param name="document">The document that contains the element.</param>
        /// <param name="parent">The parent of the element.</param>
        /// <param name="header">The Xml header for this element.</param>
        /// <param name="attributes">The list of attributes attached to this element.</param>
        /// <param name="declaration">The declaration code for this element.</param>
        /// <param name="initialization">The initialization expression, if there is one.</param>
        /// <param name="unsafeCode">Indicates whether the element resides within a block of unsafe code.</param>
        /// <param name="generated">Indicates whether the code element was generated or written by hand.</param>
        internal EnumItem(
            CsDocument document,
            Enum parent,
            XmlHeader header,
            ICollection<Attribute> attributes,
            Declaration declaration,
            Expression initialization,
            bool unsafeCode,
            bool generated)
            : base(document,
            parent,
            ElementType.EnumItem, 
            "enum item " + declaration.Name, 
            header, 
            attributes,
            declaration,
            unsafeCode,
            generated)
        {
            Param.Ignore(document, parent, header, attributes, declaration, initialization, unsafeCode, generated);

            this.initialization = initialization;
            if (this.initialization != null)
            {
                this.AddExpression(this.initialization);
            }
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:38,代码来源:EnumItem.cs


示例7: GetElementByLine

        /// <summary>
        /// Gets first code element at specified line number.
        /// </summary>
        /// <remarks>
        /// Returns object because it is ICodeElement for 4.4 and CodeElement for 4.3.
        /// </remarks>
        public static object GetElementByLine(CsDocument document, int lineNumber)
        {
            object[] args = new object[] { lineNumber, null };
            document.WalkDocument(FindByLineElementVisitor, null, args);

            return args[1];
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:13,代码来源:CodeHelper.cs


示例8: UsingDirective

        /// <summary>
        /// Initializes a new instance of the UsingDirective class.
        /// </summary>
        /// <param name="document">The document that contains the element.</param>
        /// <param name="parent">The parent of the element.</param>
        /// <param name="declaration">The declaration code for this element.</param>
        /// <param name="generated">Indicates whether the code element was generated or written by hand.</param>
        /// <param name="namespace">The namespace being used.</param>
        /// <param name="alias">Optional alias for the namespace, if any.</param>
        internal UsingDirective(
            CsDocument document,
            CsElement parent,
            Declaration declaration,
            bool generated,
            string @namespace,
            string alias)
            : base(document,
            parent,
            ElementType.UsingDirective,
            "using " + declaration.Name,
            null,
            null,
            declaration,
            false,
            generated)
        {
            Param.Ignore(document);
            Param.Ignore(parent);
            Param.Ignore(declaration);
            Param.Ignore(generated);
            Param.AssertValidString(@namespace, "namespace");
            Param.Ignore(alias);

            this.namespaceType = @namespace;

            if (alias != null)
            {
                this.alias = alias;
            }
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:40,代码来源:UsingDirective.cs


示例9: CheckLineLength

        private void CheckLineLength(CsDocument csharpDocument)
        {
            var lengthProperty = GetSetting(csharpDocument.Settings, LineLengthProperty) as IntProperty;
            if (lengthProperty == null)
            {
                return;
            }

            using (var reader = csharpDocument.SourceCode.Read())
            {
                string line;
                var lineNumber = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    lineNumber++;
                    if (line.Length > lengthProperty.Value)
                    {
                        AddViolation(
                            csharpDocument.RootElement,
                            lineNumber,
                            RuleName,
                            lengthProperty.Value);
                    }
                }
            }
        }
开发者ID:RadhikaSaini,项目名称:Testing,代码行数:26,代码来源:LineLengthRule.cs


示例10: Property

        /// <summary>
        /// Initializes a new instance of the Property class.
        /// </summary>
        /// <param name="document">
        /// The document that contains the element.
        /// </param>
        /// <param name="parent">
        /// The parent of the element.
        /// </param>
        /// <param name="header">
        /// The Xml header for this element.
        /// </param>
        /// <param name="attributes">
        /// The list of attributes attached to this element.
        /// </param>
        /// <param name="declaration">
        /// The declaration code for this element.
        /// </param>
        /// <param name="returnType">
        /// The property return type.
        /// </param>
        /// <param name="unsafeCode">
        /// Indicates whether the element resides within a block of unsafe code.
        /// </param>
        /// <param name="generated">
        /// Indicates whether the code element was generated or written by hand.
        /// </param>
        internal Property(
            CsDocument document, 
            CsElement parent, 
            XmlHeader header, 
            ICollection<Attribute> attributes, 
            Declaration declaration, 
            TypeToken returnType, 
            bool unsafeCode, 
            bool generated)
            : base(document, parent, ElementType.Property, "property " + declaration.Name, header, attributes, declaration, unsafeCode, generated)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(parent, "parent");
            Param.Ignore(header);
            Param.Ignore(attributes);
            Param.AssertNotNull(declaration, "declaration");
            Param.AssertNotNull(returnType, "returnType");
            Param.Ignore(unsafeCode);
            Param.Ignore(generated);

            this.returnType = returnType;

            // If this is an explicit interface member implementation and our access modifier
            // is currently set to private because we don't have one, then it should be public instead.
            if (this.Declaration.Name.IndexOf(".", StringComparison.Ordinal) > -1 && !this.Declaration.Name.StartsWith("this.", StringComparison.Ordinal))
            {
                this.Declaration.AccessModifierType = AccessModifierType.Public;
            }
        }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:56,代码来源:Property.cs


示例11: Field

        /// <summary>
        /// Initializes a new instance of the Field class.
        /// </summary>
        /// <param name="document">The documenent that contains the element.</param>
        /// <param name="parent">The parent of the element.</param>
        /// <param name="header">The Xml header for this element.</param>
        /// <param name="attributes">The list of attributes attached to this element.</param>
        /// <param name="declaration">The declaration code for this element.</param>
        /// <param name="fieldType">The type of the field.</param>
        /// <param name="unsafeCode">Indicates whether the element resides within a block of unsafe code.</param>
        /// <param name="generated">Indicates whether the code element was generated or written by hand.</param>
        internal Field(
            CsDocument document,
            CsElement parent,
            XmlHeader header,
            ICollection<Attribute> attributes,
            Declaration declaration,
            TypeToken fieldType,
            bool unsafeCode,
            bool generated)
            : base(document, 
            parent, 
            ElementType.Field, 
            "field " + declaration.Name, 
            header,
            attributes,
            declaration, 
            unsafeCode,
            generated)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(parent, "parent");
            Param.Ignore(header);
            Param.Ignore(attributes);
            Param.AssertNotNull(declaration, "declaration");
            Param.AssertNotNull(fieldType, "fieldType");
            Param.Ignore(unsafeCode);
            Param.Ignore(generated);

            this.type = fieldType;

            // Determine whether the item is const or readonly.
            this.isConst = this.Declaration.ContainsModifier(CsTokenType.Const);
            this.isReadOnly = this.Declaration.ContainsModifier(CsTokenType.Readonly);
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:45,代码来源:Field.cs


示例12: ClassBase

        /// <summary>
        /// Initializes a new instance of the ClassBase class.
        /// </summary>
        /// <param name="document">
        /// The document that contains the element.
        /// </param>
        /// <param name="parent">
        /// The parent of the element.
        /// </param>
        /// <param name="type">
        /// The element type.
        /// </param>
        /// <param name="name">
        /// The name of this element.
        /// </param>
        /// <param name="header">
        /// The Xml header for this element.
        /// </param>
        /// <param name="attributes">
        /// The list of attributes attached to this element.
        /// </param>
        /// <param name="declaration">
        /// The declaration code for this element.
        /// </param>
        /// <param name="typeConstraints">
        /// The list of type constraints on the element.
        /// </param>
        /// <param name="unsafeCode">
        /// Indicates whether the element resides within a block of unsafe code.
        /// </param>
        /// <param name="generated">
        /// Indicates whether the code element was generated or written by hand.
        /// </param>
        internal ClassBase(
            CsDocument document, 
            CsElement parent, 
            ElementType type, 
            string name, 
            XmlHeader header, 
            ICollection<Attribute> attributes, 
            Declaration declaration, 
            ICollection<TypeParameterConstraintClause> typeConstraints, 
            bool unsafeCode, 
            bool generated)
            : base(document, parent, type, name, header, attributes, declaration, unsafeCode, generated)
        {
            Param.Ignore(document, parent, type, name, header, attributes, declaration, typeConstraints, unsafeCode, generated);

            this.typeConstraints = typeConstraints;

            // Set the parent of the type constraint clauses.
            if (typeConstraints != null)
            {
                Debug.Assert(typeConstraints.IsReadOnly, "The typeconstraints collection should be read-only.");

                foreach (TypeParameterConstraintClause constraint in typeConstraints)
                {
                    constraint.ParentElement = this;
                }
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:61,代码来源:ClassBase.cs


示例13: DocumentRoot

 /// <summary>
 /// Initializes a new instance of the DocumentRoot class.
 /// </summary>
 /// <param name="document">
 /// The document that this element belongs to.
 /// </param>
 /// <param name="declaration">
 /// The declaration class for this element.
 /// </param>
 /// <param name="generated">
 /// Indicates whether the element contains generated code.
 /// </param>
 internal DocumentRoot(CsDocument document, Declaration declaration, bool generated)
     : base(document, null, ElementType.Root, Strings.DocumentRoot, null, null, declaration, false, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertNotNull(declaration, "declaration");
     Param.Ignore(generated);
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:19,代码来源:DocumentRoot.cs


示例14: Destructor

        /// <summary>
        /// Initializes a new instance of the Destructor class.
        /// </summary>
        /// <param name="document">The documenent that contains the element.</param>
        /// <param name="parent">The parent of the element.</param>
        /// <param name="header">The Xml header for this element.</param>
        /// <param name="attributes">The list of attributes attached to this element.</param>
        /// <param name="declaration">The declaration code for this element.</param>
        /// <param name="unsafeCode">Indicates whether the element resides within a block of unsafe code.</param>
        /// <param name="generated">Indicates whether the code element was generated or written by hand.</param>
        internal Destructor(
            CsDocument document,
            CsElement parent,
            XmlHeader header,
            ICollection<Attribute> attributes,
            Declaration declaration,
            bool unsafeCode,
            bool generated)
            : base(document,
            parent,
            ElementType.Destructor,
            "destructor " + declaration.Name,
            header,
            attributes,
            declaration,
            unsafeCode,
            generated)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(parent, "parent");
            Param.Ignore(header);
            Param.Ignore(attributes);
            Param.AssertNotNull(declaration, "declaration");
            Param.Ignore(unsafeCode);
            Param.Ignore(generated);

            // Static destructors are always public.
            if (this.Declaration.ContainsModifier(CsTokenType.Static))
            {
                this.Declaration.AccessModifierType = AccessModifierType.Public;
            }
        }
开发者ID:katerina-marchenkova,项目名称:my,代码行数:42,代码来源:Destructor.cs


示例15: CodeUnitProxy

        /// <summary>
        /// Initializes a new instance of the CodeUnitProxy class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        public CodeUnitProxy(CsDocument document)
        {
            Param.Ignore(document);

            this.document = document;
            this.children = new CodeUnitCollection(this);
        }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:11,代码来源:CodeUnitProxy.cs


示例16: Accessor

        /// <summary>
        /// Initializes a new instance of the Accessor class.
        /// </summary>
        /// <param name="document">
        /// The document that contains the element.
        /// </param>
        /// <param name="parent">
        /// The parent of the element.
        /// </param>
        /// <param name="accessorType">
        /// The type of the accessor.
        /// </param>
        /// <param name="header">
        /// The Xml header for this element.
        /// </param>
        /// <param name="attributes">
        /// The list of attributes attached to this element.
        /// </param>
        /// <param name="declaration">
        /// The declaration code for this element.
        /// </param>
        /// <param name="unsafeCode">
        /// Indicates whether the element resides within a block of unsafe code.
        /// </param>
        /// <param name="generated">
        /// Indicates whether the code element was generated or written by hand.
        /// </param>
        internal Accessor(
            CsDocument document, 
            CsElement parent, 
            AccessorType accessorType, 
            XmlHeader header, 
            ICollection<Attribute> attributes, 
            Declaration declaration, 
            bool unsafeCode, 
            bool generated)
            : base(document, parent, ElementType.Accessor, declaration.Name + " accessor", header, attributes, declaration, unsafeCode, generated)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(parent, "parent");
            Param.Ignore(accessorType);
            Param.Ignore(header);
            Param.Ignore(attributes);
            Param.AssertNotNull(declaration, "declaration");
            Param.Ignore(unsafeCode);
            Param.Ignore(generated);

            this.accessorType = accessorType;

            // Make sure the type and name match.
            Debug.Assert(
                (accessorType == AccessorType.Get && declaration.Name == "get") || (accessorType == AccessorType.Set && declaration.Name == "set")
                || (accessorType == AccessorType.Add && declaration.Name == "add") || (accessorType == AccessorType.Remove && declaration.Name == "remove"), 
                "The accessor type does not match its name.");

            this.FillDetails(parent);
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:57,代码来源:Accessor.cs


示例17: ElementHeaderLine

 /// <summary>
 /// Initializes a new instance of the ElementHeaderLine class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal ElementHeaderLine(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, CommentType.ElementHeaderLine, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:15,代码来源:XmlHeaderLine.cs


示例18: SimpleToken

        /// <summary>
        /// Initializes a new instance of the SimpleToken class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The token string.</param>
        /// <param name="tokenType">The token type.</param>
        /// <param name="location">The location of the token within the code document.</param>
        /// <param name="generated">True if the token is inside of a block of generated code.</param>
        internal SimpleToken(CsDocument document, string text, int tokenType, CodeLocation location, bool generated)
            : base(new CodeUnitProxy(document), tokenType, location)
        {
            Param.Ignore(document, text, tokenType, location, generated);

            this.Text = text;
            this.Generated = generated;
        }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:16,代码来源:SimpleToken.cs


示例19: RegionDirective

 /// <summary>
 /// Initializes a new instance of the RegionDirective class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The line text.</param>
 /// <param name="location">The location of the preprocessor in the code.</param>
 /// <param name="generated">Indicates whether the preprocessor lies within a block of generated code.</param>
 internal RegionDirective(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, PreprocessorType.Region, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:15,代码来源:RegionDirective.cs


示例20: XorEqualsOperator

 /// <summary>
 /// Initializes a new instance of the XorEqualsOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal XorEqualsOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Assignment, OperatorType.XorEquals, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
开发者ID:jonthegiant,项目名称:StyleCop,代码行数:15,代码来源:XorEqualsOperator.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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