本文整理汇总了C#中Roslyn.Utilities.ObjectReader类的典型用法代码示例。如果您正苦于以下问题:C# ObjectReader类的具体用法?C# ObjectReader怎么用?C# ObjectReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectReader类属于Roslyn.Utilities命名空间,在下文中一共展示了ObjectReader类的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: 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);
}
}
示例3: 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;
}
示例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: ReadFrom
internal static BKTree ReadFrom(ObjectReader reader)
{
try
{
var concatenatedLowerCaseWords = new char[reader.ReadInt32()];
for (var i = 0; i < concatenatedLowerCaseWords.Length; i++)
{
concatenatedLowerCaseWords[i] = reader.ReadChar();
}
var nodeCount = reader.ReadInt32();
var nodes = ImmutableArray.CreateBuilder<Node>(nodeCount);
for (var i = 0; i < nodeCount; i++)
{
nodes.Add(Node.ReadFrom(reader));
}
var edgeCount = reader.ReadInt32();
var edges = ImmutableArray.CreateBuilder<Edge>(edgeCount);
for (var i = 0; i < edgeCount; i++)
{
edges.Add(Edge.ReadFrom(reader));
}
return new BKTree(concatenatedLowerCaseWords, nodes.MoveToImmutable(), edges.MoveToImmutable());
}
catch
{
Logger.Log(FunctionId.BKTree_ExceptionInCacheRead);
return null;
}
}
示例6: WithTwoChildren
internal WithTwoChildren(ObjectReader reader)
: base(reader)
{
this.SlotCount = 2;
_child0 = (GreenNode)reader.ReadValue();
this.AdjustFlagsAndWidth(_child0);
_child1 = (GreenNode)reader.ReadValue();
this.AdjustFlagsAndWidth(_child1);
}
示例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: ReadMetadataReferenceFrom
public MetadataReference ReadMetadataReferenceFrom(ObjectReader reader, CancellationToken cancellationToken)
{
var type = reader.ReadString();
if (type == nameof(PortableExecutableReference))
{
return ReadPortableExecutableReferenceFrom(reader, cancellationToken);
}
throw ExceptionUtilities.UnexpectedValue(type);
}
示例9: SyntaxIdentifierWithTrailingTrivia
internal SyntaxIdentifierWithTrailingTrivia(ObjectReader reader)
: base(reader)
{
var trailing = (GreenNode)reader.ReadValue();
if (trailing != null)
{
this.AdjustFlagsAndWidth(trailing);
_trailing = trailing;
}
}
示例10: 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);
}
示例11: 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);
}
示例12: 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;
}
示例13: WithManyChildrenBase
internal WithManyChildrenBase(ObjectReader reader)
: base(reader)
{
var length = reader.ReadInt32();
this.children = new ArrayElement<GreenNode>[length];
for (var i = 0; i < length; i++)
{
this.children[i].Value = (GreenNode)reader.ReadValue();
}
this.InitializeChildren();
}
示例14: ReadOptionSetFrom
public override OptionSet ReadOptionSetFrom(ObjectReader reader, CancellationToken cancellationToken)
{
OptionSet options = new SerializedPartialOptionSet();
options = ReadOptionSetFrom(options, LanguageNames.CSharp, reader, cancellationToken);
foreach (var option in CSharpCodeStyleOptions.GetCodeStyleOptions())
{
options = ReadOptionFrom(options, option, reader, cancellationToken);
}
return options;
}
示例15: 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);
}