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

C# HostLanguageServices类代码示例

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

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



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

示例1: ProjectState

        internal ProjectState(ProjectInfo projectInfo, HostLanguageServices languageServices, SolutionServices solutionServices)
        {
            Contract.ThrowIfNull(projectInfo);
            Contract.ThrowIfNull(languageServices);
            Contract.ThrowIfNull(solutionServices);

            _languageServices = languageServices;
            _solutionServices = solutionServices;

            _projectInfo = FixProjectInfo(projectInfo);

            _documentIds = _projectInfo.Documents.Select(d => d.Id).ToImmutableArray();
            _additionalDocumentIds = this.ProjectInfo.AdditionalDocuments.Select(d => d.Id).ToImmutableArray();

            var docStates = ImmutableDictionary.CreateRange<DocumentId, DocumentState>(
                _projectInfo.Documents.Select(d =>
                    new KeyValuePair<DocumentId, DocumentState>(d.Id,
                        CreateDocument(this.ProjectInfo, d, languageServices, solutionServices))));

            _documentStates = docStates;

            var additionalDocStates = ImmutableDictionary.CreateRange<DocumentId, TextDocumentState>(
                    _projectInfo.AdditionalDocuments.Select(d =>
                        new KeyValuePair<DocumentId, TextDocumentState>(d.Id, TextDocumentState.Create(d, solutionServices))));

            _additionalDocumentStates = additionalDocStates;

            _lazyLatestDocumentVersion = new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentVersionAsync(docStates, additionalDocStates, c), cacheResult: true);
            _lazyLatestDocumentTopLevelChangeVersion = new AsyncLazy<VersionStamp>(c => ComputeLatestDocumentTopLevelChangeVersionAsync(docStates, additionalDocStates, c), cacheResult: true);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:30,代码来源:ProjectState.cs


示例2: ProjectState

        private ProjectState(
            ProjectInfo projectInfo,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            IEnumerable<DocumentId> documentIds,
            IEnumerable<DocumentId> additionalDocumentIds,
            ImmutableDictionary<DocumentId, DocumentState> documentStates,
            ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
            AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
            AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion,
            ValueSource<ProjectStateChecksums> lazyChecksums)
        {
            _projectInfo = projectInfo;
            _solutionServices = solutionServices;
            _languageServices = languageServices;
            _documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
            _additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
            _documentStates = documentStates;
            _additionalDocumentStates = additionalDocumentStates;
            _lazyLatestDocumentVersion = lazyLatestDocumentVersion;
            _lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;

            // for now, let it re-calculate if anything changed.
            // TODO: optimize this so that we only re-calcuate checksums that are actually changed
            _lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:26,代码来源:ProjectState.cs


示例3: Create

        public static DocumentState Create(
            DocumentInfo info,
            ParseOptions options,
            HostLanguageServices language,
            SolutionServices services)
        {
            var textSource = info.TextLoader != null
                ? CreateRecoverableText(info.TextLoader, info.Id, services)
                : CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, info.FilePath));

            var treeSource = CreateLazyFullyParsedTree(
                textSource,
                GetSyntaxTreeFilePath(info),
                options,
                languageServices: language);

            // remove any initial loader so we don't keep source alive
            info = info.WithTextLoader(null);

            return new DocumentState(
                languageServices: language,
                solutionServices: services,
                info: info,
                options: options,
                textSource: textSource,
                treeSource: treeSource);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:27,代码来源:DocumentState.cs


示例4: TestHostSolution

 public TestHostSolution(
     HostLanguageServices languageServiceProvider,
     CompilationOptions compilationOptions,
     ParseOptions parseOptions,
     params MetadataReference[] references)
     : this(new TestHostProject(languageServiceProvider, compilationOptions, parseOptions, references))
 {
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:TestHostSolution.cs


示例5: CSharpCodeModelService

 internal CSharpCodeModelService(
     HostLanguageServices languageServiceProvider,
     IEditorOptionsFactoryService editorOptionsFactoryService,
     IEnumerable<IRefactorNotifyService> refactorNotifyServices)
     : base(languageServiceProvider,
            editorOptionsFactoryService,
            refactorNotifyServices,
            new BlankLineInGeneratedMethodFormattingRule(),
            new EndRegionFormattingRule())
 {
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:CSharpCodeModelService.cs


示例6: CreateLazyFullyParsedTree

 private static ValueSource<TreeAndVersion> CreateLazyFullyParsedTree(
     ValueSource<TextAndVersion> newTextSource,
     string filePath,
     ParseOptions options,
     HostLanguageServices languageServices,
     PreservationMode mode = PreservationMode.PreserveValue)
 {
     return new AsyncLazy<TreeAndVersion>(
         c => FullyParseTreeAsync(newTextSource, filePath, options, languageServices, mode, c),
         cacheResult: true);
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:11,代码来源:DocumentState.cs


示例7: DocumentState

 private DocumentState(
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     DocumentInfo info,
     ParseOptions options,
     ValueSource<TextAndVersion> textSource,
     ValueSource<TreeAndVersion> treeSource)
     : base(solutionServices, info, textSource)
 {
     _languageServices = languageServices;
     _options = options;
     _treeSource = treeSource;
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:13,代码来源:DocumentState.cs


示例8: CodeModelState

        public CodeModelState(
            IServiceProvider serviceProvider,
            HostLanguageServices languageServices,
            VisualStudioWorkspace workspace)
        {
            Debug.Assert(serviceProvider != null);
            Debug.Assert(languageServices != null);
            Debug.Assert(workspace != null);

            this.ServiceProvider = serviceProvider;
            this.CodeModelService = languageServices.GetService<ICodeModelService>();
            this.SyntaxFactsService = languageServices.GetService<ISyntaxFactsService>();
            this.CodeGenerator = languageServices.GetService<ICodeGenerationService>();
            this.Workspace = workspace;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:15,代码来源:CodeModelState.cs


示例9: DocumentState

 private DocumentState(
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     DocumentInfo info,
     ParseOptions options,
     ValueSource<TextAndVersion> textSource,
     ValueSource<TreeAndVersion> treeSource)
 {
     this.languageServices = languageServices;
     this.solutionServices = solutionServices;
     this.info = info;
     this.options = options;
     this.textSource = textSource;
     this.treeSource = treeSource;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:15,代码来源:DocumentState.cs


示例10: ProjectState

 private ProjectState(
     ProjectInfo projectInfo,
     HostLanguageServices languageServices,
     SolutionServices solutionServices,
     IEnumerable<DocumentId> documentIds,
     ImmutableDictionary<DocumentId, DocumentState> documentStates,
     AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
     AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
 {
     this.projectInfo = projectInfo;
     this.solutionServices = solutionServices;
     this.languageServices = languageServices;
     this.documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
     this.documentStates = documentStates;
     this.lazyLatestDocumentVersion = lazyLatestDocumentVersion;
     this.lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;
 }
开发者ID:pheede,项目名称:roslyn,代码行数:17,代码来源:ProjectState.cs


示例11: DocumentState

        private DocumentState(
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            DocumentInfo info,
            ParseOptions options,
            ValueSource<TextAndVersion> textSource,
            ValueSource<TreeAndVersion> treeSource)
            : base(solutionServices, info, textSource)
        {
            _languageServices = languageServices;
            _options = options;

            // If this is document that doesn't support syntax, then don't even bother holding
            // onto any tree source.  It will never be used to get a tree, and can only hurt us
            // by possibly holding onto data that might cause a slow memory leak.
            _treeSource = this.SupportsSyntaxTree
                ? treeSource
                : ValueSource<TreeAndVersion>.Empty;
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:19,代码来源:DocumentState.cs


示例12: ProjectState

        private ProjectState(
            ProjectInfo projectInfo,
            HostLanguageServices languageServices,
            SolutionServices solutionServices,
            IEnumerable<DocumentId> documentIds,
            IEnumerable<DocumentId> additionalDocumentIds,
            ImmutableDictionary<DocumentId, DocumentState> documentStates,
            ImmutableDictionary<DocumentId, TextDocumentState> additionalDocumentStates,
            AsyncLazy<VersionStamp> lazyLatestDocumentVersion,
            AsyncLazy<VersionStamp> lazyLatestDocumentTopLevelChangeVersion)
        {
            _projectInfo = projectInfo;
            _solutionServices = solutionServices;
            _languageServices = languageServices;
            _documentIds = documentIds.ToImmutableReadOnlyListOrEmpty();
            _additionalDocumentIds = additionalDocumentIds.ToImmutableReadOnlyListOrEmpty();
            _documentStates = documentStates;
            _additionalDocumentStates = additionalDocumentStates;
            _lazyLatestDocumentVersion = lazyLatestDocumentVersion;
            _lazyLatestDocumentTopLevelChangeVersion = lazyLatestDocumentTopLevelChangeVersion;

            _lazyChecksums = new AsyncLazy<ProjectStateChecksums>(ComputeChecksumsAsync, cacheResult: true);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:23,代码来源:ProjectState.cs


示例13: CreateDocument

        private static TestHostDocument CreateDocument(
            TestWorkspace workspace,
            XElement workspaceElement,
            XElement documentElement,
            string language,
            ExportProvider exportProvider,
            HostLanguageServices languageServiceProvider,
            Dictionary<string, ITextBuffer> filePathToTextBufferMap,
            ref int documentId)
        {
            string markupCode;
            string filePath;

            var isLinkFileAttribute = documentElement.Attribute(IsLinkFileAttributeName);
            bool isLinkFile = isLinkFileAttribute != null && ((bool?)isLinkFileAttribute).HasValue && ((bool?)isLinkFileAttribute).Value;
            if (isLinkFile)
            {
                // This is a linked file. Use the filePath and markup from the referenced document.

                var originalProjectName = documentElement.Attribute(LinkAssemblyNameAttributeName);
                var originalDocumentPath = documentElement.Attribute(LinkFilePathAttributeName);

                if (originalProjectName == null || originalDocumentPath == null)
                {
                    throw new ArgumentException("Linked file specified without LinkAssemblyName or LinkFilePath.");
                }

                var originalProjectNameStr = originalProjectName.Value;
                var originalDocumentPathStr = originalDocumentPath.Value;

                var originalProject = workspaceElement.Elements(ProjectElementName).First(p =>
                {
                    var assemblyName = p.Attribute(AssemblyNameAttributeName);
                    return assemblyName != null && assemblyName.Value == originalProjectNameStr;
                });

                if (originalProject == null)
                {
                    throw new ArgumentException("Linked file's LinkAssemblyName '{0}' project not found.", originalProjectNameStr);
                }

                var originalDocument = originalProject.Elements(DocumentElementName).First(d =>
                {
                    var documentPath = d.Attribute(FilePathAttributeName);
                    return documentPath != null && documentPath.Value == originalDocumentPathStr;
                });

                if (originalDocument == null)
                {
                    throw new ArgumentException("Linked file's LinkFilePath '{0}' file not found.", originalDocumentPathStr);
                }

                markupCode = originalDocument.NormalizedValue();
                filePath = GetFilePath(workspace, originalDocument, ref documentId);
            }
            else
            {
                markupCode = documentElement.NormalizedValue();
                filePath = GetFilePath(workspace, documentElement, ref documentId);
            }

            var folders = GetFolders(documentElement);
            var optionsElement = documentElement.Element(ParseOptionsElementName);

            // TODO: Allow these to be specified.
            var codeKind = SourceCodeKind.Regular;
            if (optionsElement != null)
            {
                var attr = optionsElement.Attribute(KindAttributeName);
                codeKind = attr == null
                    ? SourceCodeKind.Regular
                    : (SourceCodeKind)Enum.Parse(typeof(SourceCodeKind), attr.Value);
            }

            var contentTypeLanguageService = languageServiceProvider.GetService<IContentTypeLanguageService>();
            var contentType = contentTypeLanguageService.GetDefaultContentType();

            string code;
            int? cursorPosition;
            IDictionary<string, IList<TextSpan>> spans;
            MarkupTestFile.GetPositionAndSpans(markupCode, out code, out cursorPosition, out spans);

            // For linked files, use the same ITextBuffer for all linked documents
            ITextBuffer textBuffer;
            if (!filePathToTextBufferMap.TryGetValue(filePath, out textBuffer))
            {
                textBuffer = EditorFactory.CreateBuffer(contentType.TypeName, exportProvider, code);
                filePathToTextBufferMap.Add(filePath, textBuffer);
            }

            return new TestHostDocument(exportProvider, languageServiceProvider, textBuffer, filePath, cursorPosition, spans, codeKind, folders, isLinkFile);
        }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:92,代码来源:TestWorkspaceFactory_XmlConsumption.cs


示例14: GetParseOptionsWorker

        private static ParseOptions GetParseOptionsWorker(XElement projectElement, string language, HostLanguageServices languageServices)
        {
            ParseOptions parseOptions;
            var preprocessorSymbolsAttribute = projectElement.Attribute(PreprocessorSymbolsAttributeName);
            if (preprocessorSymbolsAttribute != null)
            {
                parseOptions = GetPreProcessorParseOptions(language, preprocessorSymbolsAttribute);
            }
            else
            {
                parseOptions = languageServices.GetService<ISyntaxTreeFactoryService>().GetDefaultParseOptions();
            }

            var languageVersionAttribute = projectElement.Attribute(LanguageVersionAttributeName);
            if (languageVersionAttribute != null)
            {
                parseOptions = GetParseOptionsWithLanguageVersion(language, parseOptions, languageVersionAttribute);
            }

            var documentationMode = GetDocumentationMode(projectElement);
            if (documentationMode != null)
            {
                parseOptions = parseOptions.WithDocumentationMode(documentationMode.Value);
            }

            return parseOptions;
        }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:27,代码来源:TestWorkspaceFactory_XmlConsumption.cs


示例15: GetParseOptions

 private static ParseOptions GetParseOptions(XElement projectElement, string language, HostLanguageServices languageServices)
 {
     return language == LanguageNames.CSharp || language == LanguageNames.VisualBasic
         ? GetParseOptionsWorker(projectElement, language, languageServices)
         : null;
 }
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:6,代码来源:TestWorkspaceFactory_XmlConsumption.cs


示例16: CSharpSymbolDisplayService

 public CSharpSymbolDisplayService(HostLanguageServices provider)
     : base(provider.GetService<IAnonymousTypeDisplayService>())
 {
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:CSharpSymbolDisplayService.cs


示例17: CreateDocument

        private static DocumentState CreateDocument(ProjectInfo projectInfo, DocumentInfo documentInfo, HostLanguageServices languageServices, SolutionServices solutionServices)
        {
            var doc = DocumentState.Create(documentInfo, projectInfo.ParseOptions, languageServices, solutionServices);

            if (doc.SourceCodeKind != documentInfo.SourceCodeKind)
            {
                doc = doc.UpdateSourceCodeKind(documentInfo.SourceCodeKind);
            }

            return doc;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:11,代码来源:ProjectState.cs


示例18: CodeModelProjectCache

 internal CodeModelProjectCache(AbstractProject project, IServiceProvider serviceProvider, HostLanguageServices languageServices, VisualStudioWorkspace workspace)
 {
     _project = project;
     _state = new CodeModelState(serviceProvider, languageServices, workspace);
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:5,代码来源:CodeModelProjectCache.cs


示例19: AbstractSyntaxTreeFactoryService

 public AbstractSyntaxTreeFactoryService(HostLanguageServices languageServices)
 {
     this.languageServices = languageServices;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:4,代码来源:AbstractSyntaxTreeFactoryService.cs


示例20: CreateLanguageService

 public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
 {
     return new InteractiveCommandCompletionService(languageServices.WorkspaceServices.Workspace);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:4,代码来源:InteractiveCommandCompletionService.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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