本文整理汇总了C#中Roslyn.Utilities.ObjectReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectReader.ReadString方法的具体用法?C# ObjectReader.ReadString怎么用?C# ObjectReader.ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roslyn.Utilities.ObjectReader
的用法示例。
在下文中一共展示了ObjectReader.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeSourceText
private SourceText DeserializeSourceText(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
// REVIEW: why IDE services doesnt care about checksumAlgorithm?
var checksumAlgorithm = (SourceHashAlgorithm)reader.ReadInt32();
var webName = reader.ReadString();
var encoding = webName == null ? null : Encoding.GetEncoding(webName);
var kind = (SerializationKinds)reader.ReadInt32();
if (kind == SerializationKinds.MemoryMapFile)
{
var name = reader.ReadString();
var size = reader.ReadInt64();
var tempService = _workspaceServices.GetService<ITemporaryStorageService>() as ITemporaryStorageService2;
var storage = tempService.AttachTemporaryTextStorage(name, size, encoding, cancellationToken);
return storage.ReadText(cancellationToken);
}
// TODO: should include version info here as well?
var textService = _workspaceServices.GetService<ITextFactoryService>();
using (var textReader = new StringReader(reader.ReadString()))
{
return textService.CreateText(textReader, encoding, cancellationToken);
}
}
示例2: Deserialize
public static DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult> Deserialize(
ObjectReader reader, IDictionary<string, DiagnosticAnalyzer> analyzerMap, Project project, VersionStamp version, CancellationToken cancellationToken)
{
var diagnosticDataSerializer = new DiagnosticDataSerializer(VersionStamp.Default, VersionStamp.Default);
var analysisMap = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, DiagnosticAnalysisResult>();
var analysisCount = reader.ReadInt32();
for (var i = 0; i < analysisCount; i++)
{
var analyzer = analyzerMap[reader.ReadString()];
var syntaxLocalMap = Deserialize(reader, diagnosticDataSerializer, project, cancellationToken);
var semanticLocalMap = Deserialize(reader, diagnosticDataSerializer, project, cancellationToken);
var nonLocalMap = Deserialize(reader, diagnosticDataSerializer, project, cancellationToken);
var others = diagnosticDataSerializer.ReadFrom(reader, project, cancellationToken);
var analysisResult = new DiagnosticAnalysisResult(
project.Id, version,
syntaxLocalMap, semanticLocalMap, nonLocalMap, others,
documentIds: null, fromBuild: false);
analysisMap.Add(analyzer, analysisResult);
}
var telemetryMap = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, AnalyzerTelemetryInfo>();
var telemetryCount = reader.ReadInt32();
for (var i = 0; i < telemetryCount; i++)
{
var analyzer = analyzerMap[reader.ReadString()];
var telemetryInfo = Deserialize(reader, cancellationToken);
telemetryMap.Add(analyzer, telemetryInfo);
}
var exceptionMap = ImmutableDictionary.CreateBuilder<DiagnosticAnalyzer, ImmutableArray<DiagnosticData>>();
var exceptionCount = reader.ReadInt32();
for (var i = 0; i < exceptionCount; i++)
{
var analyzer = analyzerMap[reader.ReadString()];
var exceptions = diagnosticDataSerializer.ReadFrom(reader, project, cancellationToken);
exceptionMap.Add(analyzer, exceptions);
}
return DiagnosticAnalysisResultMap.Create(analysisMap.ToImmutable(), telemetryMap.ToImmutable(), exceptionMap.ToImmutable());
}
示例3: DeserializeProjectSnapshotInfo
private ProjectChecksumObjectInfo DeserializeProjectSnapshotInfo(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var projectId = DeserializeProjectId(reader, cancellationToken);
// var version = VersionStamp.ReadFrom(reader);
var name = reader.ReadString();
var assemblyName = reader.ReadString();
var language = reader.ReadString();
var filePath = reader.ReadString();
var outputFilePath = reader.ReadString();
return new ProjectChecksumObjectInfo(projectId, VersionStamp.Create(), name, assemblyName, language, filePath, outputFilePath);
}
示例4: 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;
}
}
示例5: DeserializeChecksumWithChildren
private ChecksumWithChildren DeserializeChecksumWithChildren(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var kind = reader.ReadString();
var checksum = Checksum.ReadFrom(reader);
var childrenCount = reader.ReadInt32();
var children = new object[childrenCount];
for (var i = 0; i < childrenCount; i++)
{
var childKind = reader.ReadByte();
if (childKind == ChecksumKind)
{
children[i] = Checksum.ReadFrom(reader);
continue;
}
if (childKind == ChecksumWithChildrenKind)
{
children[i] = DeserializeChecksumWithChildren(reader, cancellationToken);
continue;
}
throw ExceptionUtilities.UnexpectedValue(childKind);
}
var checksums = s_creatorMap[kind](children);
Contract.ThrowIfFalse(checksums.Checksum == checksum);
return checksums;
}
示例6: ReadFrom
internal static DeclaredSymbolInfo ReadFrom(ObjectReader reader)
{
try
{
var name = reader.ReadString();
var immediateContainer = reader.ReadString();
var entireContainer = reader.ReadString();
var kind = (DeclaredSymbolInfoKind)reader.ReadByte();
var spanStart = reader.ReadInt32();
var spanLength = reader.ReadInt32();
var parameterCount = reader.ReadUInt16();
var typeParameterCount = reader.ReadUInt16();
var inheritanceNamesLength = reader.ReadInt32();
var builder = ImmutableArray.CreateBuilder<string>(inheritanceNamesLength);
for (var i = 0; i < inheritanceNamesLength; i++)
{
builder.Add(reader.ReadString());
}
return new DeclaredSymbolInfo(
name, immediateContainer, entireContainer, kind, new TextSpan(spanStart, spanLength),
builder.MoveToImmutable(),
parameterCount, typeParameterCount);
}
catch
{
return default(DeclaredSymbolInfo);
}
}
示例7: DeserializeOptionSet
private OptionSet DeserializeOptionSet(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var language = reader.ReadString();
var serializationService = GetOptionsSerializationService(language);
return serializationService.ReadOptionSetFrom(reader, cancellationToken);
}
示例8: DeserializeSolutionSnapshotInfo
private SolutionChecksumObjectInfo DeserializeSolutionSnapshotInfo(ObjectReader reader, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var solutionId = DeserializeSolutionId(reader, cancellationToken);
// var version = VersionStamp.ReadFrom(reader);
var filePath = reader.ReadString();
return new SolutionChecksumObjectInfo(solutionId, VersionStamp.Create(), filePath);
}
示例9: ReadMetadataReferenceFrom
public MetadataReference ReadMetadataReferenceFrom(ObjectReader reader, CancellationToken cancellationToken)
{
var type = reader.ReadString();
if (type == nameof(PortableExecutableReference))
{
return ReadPortableExecutableReferenceFrom(reader, cancellationToken);
}
throw ExceptionUtilities.UnexpectedValue(type);
}
示例10: TryReadVersion
private static bool TryReadVersion(ObjectReader reader, string formatVersion, out VersionStamp version)
{
version = VersionStamp.Default;
if (reader.ReadString() != formatVersion)
{
return false;
}
version = VersionStamp.ReadFrom(reader);
return true;
}
示例11: ReadFrom
internal static DeclaredSymbolInfo ReadFrom(ObjectReader reader)
{
try
{
var name = reader.ReadString();
var immediateContainer = reader.ReadString();
var entireContainer = reader.ReadString();
var kind = (DeclaredSymbolInfoKind)reader.ReadByte();
var spanStart = reader.ReadInt32();
var spanLength = reader.ReadInt32();
var parameterCount = reader.ReadUInt16();
var typeParameterCount = reader.ReadUInt16();
return new DeclaredSymbolInfo(name, immediateContainer, entireContainer, kind, new TextSpan(spanStart, spanLength), parameterCount, typeParameterCount);
}
catch
{
return default(DeclaredSymbolInfo);
}
}
示例12: ReadFrom
public static BloomFilter ReadFrom(ObjectReader reader)
{
var version = reader.ReadString();
if (!string.Equals(version, SerializationFormat, StringComparison.Ordinal))
{
return null;
}
var isCaseSensitive = reader.ReadBoolean();
int hashFunctionCount = reader.ReadInt32();
var bitArray = ReadBitArray(reader);
return new BloomFilter(bitArray, hashFunctionCount, isCaseSensitive);
}
示例13: LocalizableResourceString
private LocalizableResourceString(ObjectReader reader)
{
_resourceSource = (Type)reader.ReadValue();
_nameOfLocalizableResource = reader.ReadString();
_resourceManager = new ResourceManager(_resourceSource);
var length = (int)reader.ReadCompressedUInt();
if (length == 0)
{
_formatArguments = SpecializedCollections.EmptyArray<string>();
}
else
{
var argumentsBuilder = ArrayBuilder<string>.GetInstance(length);
for (int i = 0; i < length; i++)
{
argumentsBuilder.Add(reader.ReadString());
}
_formatArguments = argumentsBuilder.ToArrayAndFree();
}
}
示例14: 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);
}
}
示例15: ReadFrom
internal static SpellChecker ReadFrom(ObjectReader reader)
{
try
{
var formatVersion = reader.ReadString();
if (string.Equals(formatVersion, SerializationFormat, StringComparison.Ordinal))
{
var version = VersionStamp.ReadFrom(reader);
var bkTree = BKTree.ReadFrom(reader);
if (bkTree != null)
{
return new SpellChecker(version, bkTree);
}
}
}
catch
{
Logger.Log(FunctionId.SpellChecker_ExceptionInCacheRead);
}
return null;
}