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


C# ICSharpFile.GetSourceFile方法代码示例

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


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

示例1: InsertFileName

        /// <summary>
        /// Inserts the file name into the file.
        /// </summary>
        /// <param name="file">
        /// The file to insert into.
        /// </param>
        public void InsertFileName(ICSharpFile file)
        {
            string fileName = file.GetSourceFile().ToProjectFile().Location.Name;

            FileHeader fileHeader = new FileHeader(file) { FileName = fileName };
            fileHeader.Update();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:13,代码来源:DocumentationRules.cs

示例2: GetDocumentationRulesConfig

 /// <summary>
 /// Returns a config object exposing the current config settings for this file.
 /// </summary>
 /// <param name="file">
 /// The file to get the config for.
 /// </param>
 /// <returns>
 /// The configuration for the given file.
 /// </returns>
 public DocumentationRulesConfiguration GetDocumentationRulesConfig(ICSharpFile file)
 {
     return new DocumentationRulesConfiguration(file.GetSourceFile());
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:13,代码来源:DocumentationRules.cs

示例3: InsertFileHeader

        /// <summary>
        /// Updates the existing header or inserts one if missing.
        /// </summary>
        /// <param name="file">
        /// THe file to check the header on.
        /// </param>
        public void InsertFileHeader(ICSharpFile file)
        {
            FileHeader fileHeader = new FileHeader(file);
            DocumentationRulesConfiguration docConfig = this.GetDocumentationRulesConfig(file);

            fileHeader.FileName = file.GetSourceFile().ToProjectFile().Location.Name;
            fileHeader.CompanyName = docConfig.CompanyName;
            fileHeader.CopyrightText = docConfig.Copyright;
            fileHeader.Summary = Utils.GetSummaryText(file);

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

示例4: GetDocumentationRulesConfig

        /// <summary>
        /// Returns a config object exposing the current config settings for this file.
        /// </summary>
        /// <param name="file">
        /// The file to get the config for.
        /// </param>
        /// <returns>
        /// The configuration for the given file.
        /// </returns>
        public DocumentationRulesConfiguration GetDocumentationRulesConfig(ICSharpFile file)
        {
            int hashCode = file.GetSourceFile().GetHashCode();

            if (!this.docConfigFiles.ContainsKey(hashCode))
            {
                DocumentationRulesConfiguration a = new DocumentationRulesConfiguration(file.GetSourceFile());
                this.docConfigFiles.Add(hashCode, a);
            }

            return (DocumentationRulesConfiguration)this.docConfigFiles[hashCode];
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-FIRST-stylecop,代码行数:21,代码来源:DocumentationRules.cs

示例5: UpdateFileHeader

        /// <summary>
        /// Inserts any missing items from the file header.
        /// Also formats the existing header ensuring that the top and bottom line start with 2 slashes and a space and that a newline follows the header.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="file">
        /// The file to update.
        /// </param>
        private void UpdateFileHeader(DocumentationOptions options, ICSharpFile file)
        {
            // The idea here is to load the existing header into our FileHeader object
            // The FileHeader object will ensure that the format of the header is correct even if we're not changing its contents
            // Thus we'll swap it out if its changed at the end.
            string fileName = file.GetSourceFile().ToProjectFile().Location.Name;
            UpdateFileHeaderStyle updateFileHeaderOption = options.SA1633SA1641UpdateFileHeader;

            if (updateFileHeaderOption == UpdateFileHeaderStyle.Ignore)
            {
                return;
            }

            DocumentationRulesConfiguration docConfig = this.GetDocumentationRulesConfig(file);
            string summaryText = Utils.GetSummaryText(file);
            FileHeader fileHeader = new FileHeader(file) { InsertSummary = options.SA1639FileHeaderMustHaveSummary };

            switch (updateFileHeaderOption)
            {
                case UpdateFileHeaderStyle.ReplaceCopyrightElement:
                    fileHeader.FileName = fileName;
                    fileHeader.CompanyName = docConfig.CompanyName;
                    fileHeader.CopyrightText = docConfig.Copyright;
                    fileHeader.Summary = string.IsNullOrEmpty(fileHeader.Summary) ? summaryText : fileHeader.Summary;
                    break;

                case UpdateFileHeaderStyle.ReplaceAll:
                    fileHeader.FileName = fileName;
                    fileHeader.CompanyName = docConfig.CompanyName;
                    fileHeader.CopyrightText = docConfig.Copyright;
                    fileHeader.Summary = summaryText;
                    break;

                case UpdateFileHeaderStyle.InsertMissing:
                    fileHeader.FileName = string.IsNullOrEmpty(fileHeader.FileName) ? fileName : fileHeader.FileName;
                    fileHeader.CompanyName = string.IsNullOrEmpty(fileHeader.CompanyName) ? docConfig.CompanyName : fileHeader.CompanyName;
                    fileHeader.CopyrightText = string.IsNullOrEmpty(fileHeader.CopyrightText) ? docConfig.Copyright : fileHeader.CopyrightText;
                    fileHeader.Summary = string.IsNullOrEmpty(fileHeader.Summary) ? summaryText : fileHeader.Summary;
                    break;
            }

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

示例6: GetSummaryText

        /// <summary>
        /// Returns appropriate text for the file header summary element. It either uses text that it found from the summary of the first type in the file or if 
        /// that is not there it will use the name of the first type in the file.
        /// </summary>
        /// <param name="file">
        /// The file to produce the summary for.
        /// </param>
        /// <returns>
        /// A string of summary text. Empty if we're not inserting text from our settings.
        /// </returns>
        public static string GetSummaryText(ICSharpFile file)
        {
            if (!StyleCopOptions.Instance.InsertTextIntoDocumentation)
            {
                return string.Empty;
            }

            string fileName = file.GetSourceFile().ToProjectFile().Location.Name;

            string firstTypeName = Utils.GetFirstTypeName(file);

            string firstTypeSummaryText = Utils.GetSummaryForDeclaration(Utils.GetFirstType(file));

            string summaryText;

            if (string.IsNullOrEmpty(firstTypeSummaryText))
            {
                summaryText = string.IsNullOrEmpty(firstTypeName) ? fileName : string.Format("Defines the {0} type.", firstTypeName);
            }
            else
            {
                summaryText = firstTypeSummaryText;
            }

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

示例7: GetSummaryText

        /// <summary>
        /// Returns appropriate text for the file header summary element. It either uses text that it found from the summary of the first type in the file or if 
        /// that is not there it will use the name of the first type in the file.
        /// </summary>
        /// <param name="file">
        /// The file to produce the summary for.
        /// </param>
        /// <returns>
        /// A string of summary text. Empty if we're not inserting text from our settings.
        /// </returns>
        public static string GetSummaryText(ICSharpFile file)
        {
            if (file == null)
            {
                return string.Empty;
            }

            IContextBoundSettingsStore settingsStore = file.GetSourceFile().GetSettingsStore();
            if (!settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
            {
                return string.Empty;
            }

            string fileName = file.GetSourceFile().ToProjectFile().Location.Name;

            string firstTypeName = GetFirstTypeName(file);

            string firstTypeSummaryText = GetSummaryForDeclaration(GetFirstType(file));

            string summaryText;

            if (string.IsNullOrEmpty(firstTypeSummaryText))
            {
                summaryText = string.IsNullOrEmpty(firstTypeName) ? fileName : string.Format("Defines the {0} type.", firstTypeName);
            }
            else
            {
                summaryText = firstTypeSummaryText;
            }

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

示例8: GetDocumentationRulesConfig

 /// <summary>
 /// Returns a config object exposing the current config settings for this file.
 /// </summary>
 /// <param name="lifetime">
 /// The lifetime of the settings for the configuration.
 /// </param>
 /// <param name="file">
 /// The file to get the config for.
 /// </param>
 /// <returns>
 /// The configuration for the given file.
 /// </returns>
 private static DocumentationRulesConfiguration GetDocumentationRulesConfig(Lifetime lifetime, ICSharpFile file)
 {
     // TODO: We shouldn't have to resort to service locator!
     var api = file.GetSolution().GetComponent<StyleCopApiPool>().GetInstance(lifetime);
     return new DocumentationRulesConfiguration(api.Settings, file.GetSourceFile());
 }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:18,代码来源:DocumentationRules.cs

示例9: UpdateFileHeader

        /// <summary>
        /// Inserts any missing items from the file header.
        /// Also formats the existing header ensuring that the top and bottom line start with 2 slashes and a space and that a newline follows the header.
        /// </summary>
        /// <param name="file">
        /// The file to update.
        /// </param>
        /// <param name="analyzerSettings">
        /// The analyzer Settings.
        /// </param>
        private static void UpdateFileHeader(ICSharpFile file, AnalyzerSettings analyzerSettings)
        {
            // The idea here is to load the existing header into our FileHeader object
            // The FileHeader object will ensure that the format of the header is correct even if we're not changing its contents
            // Thus we'll swap it out if its changed at the end.
            string fileName = file.GetSourceFile().ToProjectFile().Location.Name;

            // TODO: How do we handle updating the file header?
            // From the main options page?
            // Actually, looks like ReplaceCopyrightElement is the best option. It fixes the filename,
            // the company name and the copyright, and it'll update the summary, if it isn't already set.
            UpdateFileHeaderStyle updateFileHeaderOption = UpdateFileHeaderStyle.ReplaceCopyrightElement;

            if (updateFileHeaderOption == UpdateFileHeaderStyle.Ignore)
            {
                return;
            }

            Lifetimes.Using(
                lifetime =>
                    {
                        DocumentationRulesConfiguration docConfig = GetDocumentationRulesConfig(lifetime, file);
                        string summaryText = Utils.GetSummaryText(file);
                        FileHeader fileHeader = new FileHeader(file) { InsertSummary = analyzerSettings.IsRuleEnabled("FileHeaderMustHaveSummary") };

                        switch (updateFileHeaderOption)
                        {
                            case UpdateFileHeaderStyle.ReplaceCopyrightElement:
                                fileHeader.FileName = fileName;
                                fileHeader.CompanyName = docConfig.CompanyName;
                                fileHeader.CopyrightText = docConfig.Copyright;
                                fileHeader.Summary = string.IsNullOrEmpty(fileHeader.Summary) ? summaryText : fileHeader.Summary;
                                break;

                            case UpdateFileHeaderStyle.ReplaceAll:
                                fileHeader.FileName = fileName;
                                fileHeader.CompanyName = docConfig.CompanyName;
                                fileHeader.CopyrightText = docConfig.Copyright;
                                fileHeader.Summary = summaryText;
                                break;

                            case UpdateFileHeaderStyle.InsertMissing:
                                fileHeader.FileName = string.IsNullOrEmpty(fileHeader.FileName) ? fileName : fileHeader.FileName;
                                fileHeader.CompanyName = string.IsNullOrEmpty(fileHeader.CompanyName) ? docConfig.CompanyName : fileHeader.CompanyName;
                                fileHeader.CopyrightText = string.IsNullOrEmpty(fileHeader.CopyrightText) ? docConfig.Copyright : fileHeader.CopyrightText;
                                fileHeader.Summary = string.IsNullOrEmpty(fileHeader.Summary) ? summaryText : fileHeader.Summary;
                                break;
                        }

                        fileHeader.Update();
                    });
        }
开发者ID:RainsSoft,项目名称:StyleCop,代码行数:62,代码来源:DocumentationRules.cs

示例10: GetDocumentationRulesConfig

 /// <summary>
 /// Returns a config object exposing the current config settings for this file.
 /// </summary>
 /// <param name="file">
 /// The file to get the config for.
 /// </param>
 /// <returns>
 /// The configuration for the given file.
 /// </returns>
 public DocumentationRulesConfiguration GetDocumentationRulesConfig(ICSharpFile file)
 {
     // TODO: We shouldn't have to resort to service locator!
     var bootstrapper = Shell.Instance.GetComponent<StyleCopBootstrapper>();
     return new DocumentationRulesConfiguration(bootstrapper.Settings, file.GetSourceFile());
 }
开发者ID:icnocop,项目名称:StyleCop,代码行数:15,代码来源:DocumentationRules.cs


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