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


C# IDeclaration.GetSolution方法代码示例

本文整理汇总了C#中IDeclaration.GetSolution方法的典型用法代码示例。如果您正苦于以下问题:C# IDeclaration.GetSolution方法的具体用法?C# IDeclaration.GetSolution怎么用?C# IDeclaration.GetSolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDeclaration的用法示例。


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

示例1: EnsureDocumentationTextIsUppercase

        /// <summary>
        /// Ensures the declaration passed has its comments beginning with a capital letter.
        /// </summary>
        /// <param name="declaration">
        /// The destructor <see cref="IDeclaration"/>.
        /// </param>
        public void EnsureDocumentationTextIsUppercase(IDeclaration declaration)
        {
            IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, declaration.GetSolution());
            if (!settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
            {
                return;
            }

            DeclarationHeader declarationHeader = new DeclarationHeader(declaration);

            if (declarationHeader.IsMissing || declarationHeader.IsInherited)
            {
                return;
            }

            this.SwapToUpper(declarationHeader.XmlNode);
            declarationHeader.Update();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:24,代码来源:DocumentationRules.cs

示例2: InsertMissingSummaryElement

        /// <summary>
        /// Inserts a missing summary element.
        /// </summary>
        /// <param name="declaration">
        /// The <see cref="IDeclaration"/> to get comment from.
        /// </param>
        /// <returns>
        /// True if the element was inserted.
        /// </returns>
        public bool InsertMissingSummaryElement(IDeclaration declaration)
        {
            bool returnValue = false;
            DeclarationHeader declarationHeader = new DeclarationHeader(declaration);

            if (declarationHeader.IsMissing || declarationHeader.IsInherited)
            {
                return false;
            }

            string summaryText = string.Empty;
            IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, declaration.GetSolution());
            if (settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
            {
                string text;
                if (declaration is IInterfaceDeclaration)
                {
                    text = declaration.DeclaredName.Substring(1) + " interface";
                }
                else
                {
                    text = Utils.ConvertTextToSentence(declaration.DeclaredName).ToLower();
                }

                summaryText = string.Format("The {0}.", text);
            }

            summaryText = Utils.UpdateTextWithToDoPrefixIfRequired(summaryText, settingsStore);

            XmlNode summaryXmlNode = declarationHeader.SummaryXmlNode;

            if (declarationHeader.HasSummary)
            {
                if (declarationHeader.HasEmptySummary)
                {
                    summaryXmlNode.InnerText = summaryText;
                    declarationHeader.Update();
                    returnValue = true;
                }
            }
            else
            {
                XmlNode newChild = CreateNode(declarationHeader.XmlNode, "summary");
                newChild.InnerText = summaryText;
                declarationHeader.XmlNode.InsertBefore(newChild, declarationHeader.XmlNode.FirstChild);
                declarationHeader.Update();
                returnValue = true;
            }

            return returnValue;
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:60,代码来源:DocumentationRules.cs

示例3: CreateNewHeader

        /// <summary>
        /// Creates a new DeclarationHeader for the declaration and assigns it to the declaration.
        /// </summary>
        /// <param name="declaration">
        /// The declaration to create the header for.
        /// </param>
        /// <param name="docConfig">
        /// Provides the configuration for the current ProjectFile.
        /// </param>
        /// <returns>
        /// A DeclarationHeader for the declaration passed in.
        /// </returns>
        public static DeclarationHeader CreateNewHeader(IDeclaration declaration, DocumentationRulesConfiguration docConfig)
        {
            IFile file = declaration.GetContainingFile();
            using (WriteLockCookie.Create(file.IsPhysical()))
            {
                IDeclaration declarationTreeNode = declaration;

                IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, declaration.GetSolution());
                bool useSingleLineDeclarationComments = settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.UseSingleLineDeclarationComments);
                string middleText = useSingleLineDeclarationComments ? string.Empty : Environment.NewLine;

                string emptyDocHeader = string.Format("<summary>{0}</summary>", middleText);

                if (!(declarationTreeNode is IMultipleDeclarationMember))
                {
                    emptyDocHeader = CreateDocumentationForElement((IDocCommentBlockOwnerNode)declaration, docConfig);
                    emptyDocHeader = emptyDocHeader.Substring(0, emptyDocHeader.Length - Environment.NewLine.Length);
                }

                string header = LayoutDocumentationHeader(emptyDocHeader, declaration);

                IDocCommentBlockNode newDocCommentNode = Utils.CreateDocCommentBlockNode(file, header);

                IDocCommentBlockOwnerNode docCommentBlockOwnerNode = Utils.GetDocCommentBlockOwnerNodeForDeclaration(declaration);

                if (docCommentBlockOwnerNode != null)
                {
                    docCommentBlockOwnerNode.SetDocCommentBlockNode(newDocCommentNode);
                }

                return new DeclarationHeader(declaration);
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:45,代码来源:DeclarationHeader.cs

示例4: LayoutDocumentationHeader

        /// <summary>
        /// Takes the XmlNode and creates a formatted StringBuilder of it all formatted lovely.
        /// </summary>
        /// <param name="xml">
        /// The xml to use.
        /// </param>
        /// <param name="declaration">
        /// The declaration we start with.
        /// </param>
        /// <returns>
        /// A String all formatted.
        /// </returns>
        private static string LayoutDocumentationHeader(XmlNode xml, IDeclaration declaration)
        {
            StringBuilder pattern = new StringBuilder();
            StringWriter writer = new StringWriter(pattern);

            bool writtenNewLine = true;
            IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, declaration.GetSolution());
            bool useSingleLineDeclarationComments = settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.UseSingleLineDeclarationComments);

            LayoutDocumentationXml(xml, writer, ref writtenNewLine, useSingleLineDeclarationComments);

            if (pattern.ToString().EndsWith(Environment.NewLine))
            {
                pattern.Remove(pattern.Length - Environment.NewLine.Length, Environment.NewLine.Length);
            }

            if (pattern.ToString().StartsWith(Environment.NewLine))
            {
                pattern.Remove(0, Environment.NewLine.Length);
            }

            return pattern.ToString().Trim();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:35,代码来源:DeclarationHeader.cs

示例5: GetTypeElement

 /// <summary>
 /// Gets an ITypeElement from the name passed in.
 /// </summary>
 /// <param name="declaration">
 /// The declaration to use.
 /// </param>
 /// <param name="typeName">
 /// The type to create.
 /// </param>
 /// <returns>
 /// The ITypeElement created.
 /// </returns>
 public static ITypeElement GetTypeElement(IDeclaration declaration, string typeName)
 {
     return CacheManager.GetInstance(declaration.GetSolution()).GetDeclarationsCache(DeclarationCacheLibraryScope.FULL, true).GetTypeElementByCLRName(typeName);
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:16,代码来源:Utils.cs

示例6: InsertMissingSummaryElement

        /// <summary>
        /// Inserts a missing summary element.
        /// </summary>
        /// <param name="declaration">
        /// The <see cref="IDeclaration"/> to get comment from.
        /// </param>
        public void InsertMissingSummaryElement(IDeclaration declaration)
        {
            DeclarationHeader declarationHeader = new DeclarationHeader(declaration);

            if (declarationHeader.IsMissing || declarationHeader.IsInherited)
            {
                return;
            }

            string summaryText = string.Empty;
            IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, declaration.GetSolution());
            if (settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
            {
                summaryText = string.Format("The {0}.", Utils.ConvertTextToSentence(declaration.DeclaredName).ToLower());
            }

            XmlNode summaryXmlNode = declarationHeader.SummaryXmlNode;

            if (declarationHeader.HasSummary)
            {
                if (string.IsNullOrEmpty(summaryXmlNode.InnerText.Trim()))
                {
                    summaryXmlNode.InnerText = summaryText;
                    declarationHeader.Update();
                }
                else
                {
                    return;
                }
            }
            else
            {
                XmlNode newChild = CreateNode(declarationHeader.XmlNode, "summary");
                newChild.InnerText = summaryText;
                declarationHeader.XmlNode.InsertBefore(newChild, declarationHeader.XmlNode.FirstChild);
                declarationHeader.Update();
            }
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:44,代码来源:DocumentationRules.cs

示例7: GetTypeElement

 /// <summary>
 /// Gets an ITypeElement from the name passed in.
 /// </summary>
 /// <param name="declaration">
 /// The declaration to use.
 /// </param>
 /// <param name="typeName">
 /// The type to create.
 /// </param>
 /// <returns>
 /// The ITypeElement created.
 /// </returns>
 public static ITypeElement GetTypeElement(IDeclaration declaration, string typeName)
 {
     CacheManagerEx cacheManager = declaration.GetSolution().GetPsiServices().CacheManager;
     return cacheManager.GetDeclarationsCache(DeclarationCacheLibraryScope.FULL, true).GetTypeElementByCLRName(typeName);
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:17,代码来源:Utils.cs

示例8: GetTypeElement

 /// <summary>
 /// Gets an ITypeElement from the name passed in.
 /// </summary>
 /// <param name="declaration">
 /// The declaration to use.
 /// </param>
 /// <param name="typeName">
 /// The type to create.
 /// </param>
 /// <returns>
 /// The ITypeElement created.
 /// </returns>
 public static ITypeElement GetTypeElement(IDeclaration declaration, string typeName)
 {
     PsiManager psiManager = PsiManager.GetInstance(declaration.GetSolution());
     IDeclarationsScope scope = DeclarationsScopeFactory.ModuleScope(declaration.GetPsiModule(), true);
     return psiManager.GetDeclarationsCache(scope, true).GetTypeElementByCLRName(typeName);
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:18,代码来源:Utils.cs

示例9: HasTypeDeclaration

        public static bool HasTypeDeclaration(IDeclaration element)
        {
            var uriDeclaredElement = element as IUriIdentifierDeclaredElement;
            if (uriDeclaredElement == null)
            {
                return false;
            }

            var uri = uriDeclaredElement.GetUri();
            if (string.IsNullOrEmpty(uri))
            {
                return false;
            }

            var cache = element.GetSolution().GetComponent<NTriplesCache>();
            return cache.HasTypeDeclarations(uri);
        }
开发者ID:xsburg,项目名称:ReSharper.NTriples,代码行数:17,代码来源:NTriplesIdentifierFilter.cs


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