本文整理汇总了C#中StringDictionary.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# StringDictionary.ReadString方法的具体用法?C# StringDictionary.ReadString怎么用?C# StringDictionary.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringDictionary
的用法示例。
在下文中一共展示了StringDictionary.ReadString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
public Datamodel Decode(int encoding_version, string format, int format_version, Stream stream, DeferredMode defer_mode)
{
stream.Seek(0, SeekOrigin.Begin);
while (true)
{
var b = stream.ReadByte();
if (b == 0) break;
}
var dm = new Datamodel(format, format_version);
EncodingVersion = encoding_version;
Reader = new BinaryReader(stream, Datamodel.TextEncoding);
if (EncodingVersion >= 9)
{
// Read prefix elements
foreach (int prefix_elem in Enumerable.Range(0, Reader.ReadInt32()))
{
foreach (int attr_index in Enumerable.Range(0, Reader.ReadInt32()))
{
var name = ReadString_Raw();
var value = DecodeAttribute(dm);
if (prefix_elem == 0) // skip subsequent elements...are they considered "old versions"?
dm.PrefixAttributes[name] = value;
}
}
}
StringDict = new StringDictionary(this, Reader);
var num_elements = Reader.ReadInt32();
// read index
foreach (var i in Enumerable.Range(0, num_elements))
{
var type = StringDict.ReadString();
var name = EncodingVersion >= 4 ? StringDict.ReadString() : ReadString_Raw();
var id_bits = Reader.ReadBytes(16);
var id = new Guid(BitConverter.IsLittleEndian ? id_bits : id_bits.Reverse().ToArray());
var elem = new Element(dm, name, id, type);
}
// read attributes (or not, if we're deferred)
foreach (var elem in dm.AllElements.ToArray())
{
System.Diagnostics.Debug.Assert(!elem.Stub);
var num_attrs = Reader.ReadInt32();
foreach (var i in Enumerable.Range(0, num_attrs))
{
var name = StringDict.ReadString();
if (defer_mode == DeferredMode.Automatic)
{
CodecUtilities.AddDeferredAttribute(elem, name, Reader.BaseStream.Position);
SkipAttribte();
}
else
{
elem.Add(name, DecodeAttribute(dm));
}
}
}
return dm;
}