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


C# ObjectReader.ReadArray方法代码示例

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


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

示例1: ReadAssets

            private IList<ValueTuple<Checksum, object>> ReadAssets(
                Stream stream, int sessionId, ISet<Checksum> checksums, CancellationToken cancellationToken)
            {
                var results = new List<ValueTuple<Checksum, object>>();

                using (var reader = new ObjectReader(stream))
                {
                    var responseSessionId = reader.ReadInt32();
                    Contract.ThrowIfFalse(sessionId == responseSessionId);

                    var count = reader.ReadInt32();
                    Contract.ThrowIfFalse(count == checksums.Count);

                    for (var i = 0; i < count; i++)
                    {
                        var responseChecksum = new Checksum(reader.ReadArray<byte>());
                        Contract.ThrowIfFalse(checksums.Contains(responseChecksum));

                        var kind = reader.ReadString();

                        // in service hub, cancellation means simply closed stream
                        var @object = _owner.RoslynServices.AssetService.Deserialize<object>(kind, reader, cancellationToken);

                        results.Add(ValueTuple.Create(responseChecksum, @object));
                    }

                    return results;
                }
            }
开发者ID:genlu,项目名称:roslyn,代码行数:29,代码来源:SnapshotService.JsonRpcAssetSource.cs

示例2: ReadParseOptionsFrom

        public override ParseOptions ReadParseOptionsFrom(ObjectReader reader, CancellationToken cancellationToken)
        {
            ReadParseOptionsFrom(reader, out var kind, out var documentationMode, out var features, cancellationToken);

            var languageVersion = (LanguageVersion)reader.ReadInt32();
            var preprocessorSymbolNames = reader.ReadArray<string>();

            var options = new CSharpParseOptions(languageVersion, documentationMode, kind, preprocessorSymbolNames);
            return options.WithFeatures(features);
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:10,代码来源:CSharpOptionsSerializationService.cs

示例3: ReadParseOptionsFrom

        public override ParseOptions ReadParseOptionsFrom(ObjectReader reader, CancellationToken cancellationToken)
        {
            SourceCodeKind kind;
            DocumentationMode documentationMode;
            IEnumerable<KeyValuePair<string, string>> features;
            ReadParseOptionsFrom(reader, out kind, out documentationMode, out features, cancellationToken);

            var languageVersion = (LanguageVersion)reader.ReadInt32();
            var preprocessorSymbolNames = reader.ReadArray<string>();

            var options = new CSharpParseOptions(languageVersion, documentationMode, kind, preprocessorSymbolNames);
            return options.WithFeatures(features);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:13,代码来源:CSharpOptionsSerializationService.cs

示例4: ReadParseOptionsFrom

        public override ParseOptions ReadParseOptionsFrom(ObjectReader reader, CancellationToken cancellationToken)
        {
            ReadParseOptionsFrom(reader, out var kind, out var documentationMode, out var features, cancellationToken);

            var languageVersion = (LanguageVersion)reader.ReadInt32();
            var preprocessorSymbolNames = reader.ReadArray<string>();

            var options = new CSharpParseOptions(languageVersion, documentationMode, kind);

            // use WithPreprocessorSymbols instead of constructor to bypass preprocessor validation.
            // https://github.com/dotnet/roslyn/issues/15797
            return options.WithPreprocessorSymbols(preprocessorSymbolNames)
                          .WithFeatures(features);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:14,代码来源:CSharpOptionsSerializationService.cs

示例5: ReadCompilationOptionsFrom

        public override CompilationOptions ReadCompilationOptionsFrom(ObjectReader reader, CancellationToken cancellationToken)
        {
            ReadCompilationOptionsFrom(
                reader,
                out var outputKind, out var reportSuppressedDiagnostics, out var moduleName, out var mainTypeName, out var scriptClassName,
                out var optimizationLevel, out var checkOverflow, out var cryptoKeyContainer, out var cryptoKeyFile, out var cryptoPublicKey,
                out var delaySign, out var platform, out var generalDiagnosticOption, out var warningLevel, out var specificDiagnosticOptions,
                out var concurrentBuild, out var deterministic, out var publicSign, out var xmlReferenceResolver, out var sourceReferenceResolver,
                out var metadataReferenceResolver, out var assemblyIdentityComparer, out var strongNameProvider, cancellationToken);

            var usings = reader.ReadArray<string>();
            var allowUnsafe = reader.ReadBoolean();

            return new CSharpCompilationOptions(
                outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName, usings, optimizationLevel, checkOverflow, allowUnsafe,
                cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, concurrentBuild,
                deterministic, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer, strongNameProvider, publicSign);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:18,代码来源:CSharpOptionsSerializationService.cs

示例6: ReadAssetAsync

            private static Task<object> ReadAssetAsync(
                Stream stream, TraceSource logger, int serviceId, Checksum checksum, CancellationToken cancellationToken)
            {
                using (var reader = new ObjectReader(stream))
                {
                    var responseServiceId = reader.ReadInt32();
                    Contract.ThrowIfFalse(serviceId == responseServiceId);

                    var responseChecksum = new Checksum(reader.ReadArray<byte>());
                    Contract.ThrowIfFalse(checksum == responseChecksum);

                    var kind = reader.ReadString();

                    // in service hub, cancellation means simply closed stream
                    var @object = RoslynServices.AssetService.Deserialize<object>(kind, reader, cancellationToken);

                    return Task.FromResult(@object);
                }
            }
开发者ID:tvsonar,项目名称:roslyn,代码行数:19,代码来源:SnapshotService.JsonRpcAssetSource.cs

示例7: ReadCompilationOptionsFrom

        public override CompilationOptions ReadCompilationOptionsFrom(ObjectReader reader, CancellationToken cancellationToken)
        {
            OutputKind outputKind;
            bool reportSuppressedDiagnostics;
            string moduleName;
            string mainTypeName;
            string scriptClassName;
            OptimizationLevel optimizationLevel;
            bool checkOverflow;
            string cryptoKeyContainer;
            string cryptoKeyFile;
            ImmutableArray<byte> cryptoPublicKey;
            bool? delaySign;
            Platform platform;
            ReportDiagnostic generalDiagnosticOption;
            int warningLevel;
            IEnumerable<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptions;
            bool concurrentBuild;
            bool deterministic;
            bool publicSign;
            XmlReferenceResolver xmlReferenceResolver;
            SourceReferenceResolver sourceReferenceResolver;
            MetadataReferenceResolver metadataReferenceResolver;
            AssemblyIdentityComparer assemblyIdentityComparer;
            StrongNameProvider strongNameProvider;

            ReadCompilationOptionsFrom(
                reader,
                out outputKind, out reportSuppressedDiagnostics, out moduleName, out mainTypeName, out scriptClassName,
                out optimizationLevel, out checkOverflow, out cryptoKeyContainer, out cryptoKeyFile, out cryptoPublicKey,
                out delaySign, out platform, out generalDiagnosticOption, out warningLevel, out specificDiagnosticOptions,
                out concurrentBuild, out deterministic, out publicSign, out xmlReferenceResolver, out sourceReferenceResolver,
                out metadataReferenceResolver, out assemblyIdentityComparer, out strongNameProvider, cancellationToken);

            var usings = reader.ReadArray<string>();
            var allowUnsafe = reader.ReadBoolean();

            return new CSharpCompilationOptions(
                outputKind, reportSuppressedDiagnostics, moduleName, mainTypeName, scriptClassName, usings, optimizationLevel, checkOverflow, allowUnsafe,
                cryptoKeyContainer, cryptoKeyFile, cryptoPublicKey, delaySign, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, concurrentBuild,
                deterministic, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, assemblyIdentityComparer, strongNameProvider, publicSign);
        }
开发者ID:orthoxerox,项目名称:roslyn,代码行数:42,代码来源:CSharpOptionsSerializationService.cs

示例8: CopyByteArrayToStream

        private void CopyByteArrayToStream(ObjectReader reader, Stream stream, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            // TODO: make reader be able to read byte[] chunk
            var content = reader.ReadArray<byte>();
            stream.Write(content, 0, content.Length);
        }
开发者ID:natidea,项目名称:roslyn,代码行数:8,代码来源:AbstractReferenceSerializationService.cs

示例9: ReadMetadataReferencePropertiesFrom

        private MetadataReferenceProperties ReadMetadataReferencePropertiesFrom(ObjectReader reader, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var kind = (MetadataImageKind)reader.ReadInt32();
            var aliases = reader.ReadArray<string>().ToImmutableArrayOrEmpty();
            var embedInteropTypes = reader.ReadBoolean();

            return new MetadataReferenceProperties(kind, aliases, embedInteropTypes);
        }
开发者ID:natidea,项目名称:roslyn,代码行数:10,代码来源:AbstractReferenceSerializationService.cs

示例10: DeserializeProjectReference

        private ProjectReference DeserializeProjectReference(ObjectReader reader, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var projectId = ProjectId.ReadFrom(reader);
            var aliases = reader.ReadArray<string>();
            var embedInteropTypes = reader.ReadBoolean();

            return new ProjectReference(projectId, aliases.ToImmutableArrayOrEmpty(), embedInteropTypes);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:10,代码来源:Serializer_Asset.cs

示例11: DeserializeDocumentSnapshotInfo

        private DocumentChecksumObjectInfo DeserializeDocumentSnapshotInfo(ObjectReader reader, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var documentId = DeserializeDocumentId(reader, cancellationToken);

            var name = reader.ReadString();
            var folders = reader.ReadArray<string>();
            var sourceCodeKind = reader.ReadInt32();
            var filePath = reader.ReadString();
            var isGenerated = reader.ReadBoolean();

            return new DocumentChecksumObjectInfo(documentId, name, folders, (SourceCodeKind)sourceCodeKind, filePath, isGenerated);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:Serializer_Asset.cs

示例12: DeserializeDocumentId

        public static DocumentId DeserializeDocumentId(ObjectReader reader, CancellationToken cancellationToken)
        {
            var projectId = DeserializeProjectId(reader, cancellationToken);

            var guid = new Guid(reader.ReadArray<byte>());
            var debugName = reader.ReadString();

            return DocumentId.CreateFromSerialized(projectId, guid, debugName);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:Serializer_Asset.cs

示例13: DeserializeSolutionId

        private SolutionId DeserializeSolutionId(ObjectReader reader, CancellationToken cancellationToken)
        {
            var guid = new Guid(reader.ReadArray<byte>());
            var debugName = reader.ReadString();

            return SolutionId.CreateFromSerialized(guid, debugName);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:Serializer_Asset.cs

示例14: ReadCompilationOptionsFrom

        protected void ReadCompilationOptionsFrom(
            ObjectReader reader,
            out OutputKind outputKind,
            out bool reportSuppressedDiagnostics,
            out string moduleName,
            out string mainTypeName,
            out string scriptClassName,
            out OptimizationLevel optimizationLevel,
            out bool checkOverflow,
            out string cryptoKeyContainer,
            out string cryptoKeyFile,
            out ImmutableArray<byte> cryptoPublicKey,
            out bool? delaySign,
            out Platform platform,
            out ReportDiagnostic generalDiagnosticOption,
            out int warningLevel,
            out IEnumerable<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptions,
            out bool concurrentBuild,
            out bool deterministic,
            out bool publicSign,
            out XmlReferenceResolver xmlReferenceResolver,
            out SourceReferenceResolver sourceReferenceResolver,
            out MetadataReferenceResolver metadataReferenceResolver,
            out AssemblyIdentityComparer assemblyIdentityComparer,
            out StrongNameProvider strongNameProvider,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            outputKind = (OutputKind)reader.ReadInt32();
            reportSuppressedDiagnostics = reader.ReadBoolean();
            moduleName = reader.ReadString();
            mainTypeName = reader.ReadString();

            scriptClassName = reader.ReadString();
            optimizationLevel = (OptimizationLevel)reader.ReadInt32();
            checkOverflow = reader.ReadBoolean();

            // REVIEW: is it okay this being not part of snapshot?
            cryptoKeyContainer = reader.ReadString();
            cryptoKeyFile = reader.ReadString();

            cryptoPublicKey = reader.ReadArray<byte>().ToImmutableArrayOrEmpty();

            delaySign = reader.ReadBoolean() ? (bool?)reader.ReadBoolean() : null;

            platform = (Platform)reader.ReadInt32();
            generalDiagnosticOption = (ReportDiagnostic)reader.ReadInt32();

            warningLevel = reader.ReadInt32();

            // REVIEW: I don't think there is a guarantee on ordering of elements in the immutable dictionary.
            //         unfortunately, we need to sort them to make it deterministic
            //         not sure why CompilationOptions uses SequencialEqual to check options equality
            //         when ordering can change result of it even if contents are same.
            var count = reader.ReadInt32();
            List<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptionsList = null;

            if (count > 0)
            {
                specificDiagnosticOptionsList = new List<KeyValuePair<string, ReportDiagnostic>>(count);

                for (var i = 0; i < count; i++)
                {
                    var key = reader.ReadString();
                    var value = (ReportDiagnostic)reader.ReadInt32();

                    specificDiagnosticOptionsList.Add(KeyValuePair.Create(key, value));
                }
            }

            specificDiagnosticOptions = specificDiagnosticOptionsList ?? SpecializedCollections.EmptyEnumerable<KeyValuePair<string, ReportDiagnostic>>();

            concurrentBuild = reader.ReadBoolean();
            deterministic = reader.ReadBoolean();
            publicSign = reader.ReadBoolean();

            // REVIEW: What should I do with these. are these service required when compilation is built ourselves, not through
            //         compiler.
            xmlReferenceResolver = XmlFileResolver.Default;
            sourceReferenceResolver = SourceFileResolver.Default;
            metadataReferenceResolver = null;
            assemblyIdentityComparer = DesktopAssemblyIdentityComparer.Default;
            strongNameProvider = new DesktopStrongNameProvider();
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:85,代码来源:AbstractOptionsSerializationService.cs


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