本文整理汇总了C#中Input.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Input.Read方法的具体用法?C# Input.Read怎么用?C# Input.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input.Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseElement
private int ParseElement (Input stream)
{
int data_remaining = (int) stream.Remaining;
//Console.WriteLine ("stream.Remaining = {0}", data_remaining);
// Weird!! Well, Its a M$ format ;-)
// Fixes: 323312
byte [] data = stream.Read (data_remaining > 7 ? 8 : data_remaining);
if (data == null || data_remaining < 8)
return 0;
RecordType.TypeCode opcode = (RecordType.TypeCode) GetInt16(data, 2);
int length = (int)GetInt32(data, 4);
// Protect against garbage length
length = (length > 0 ? length : 0);
RecordType type = RecordType.Find (opcode);
// Process the container tree
if (type.is_container) {
int length_remaining = length;
if (opcode == RecordType.TypeCode.MainMaster) {
// Ignore MainMaster container as it contains
// just a master-slide view and no user data.
stream.Seek (length_remaining, SeekOrigin.Current);
} else {
while (length_remaining > 0) {
int elem_length = ParseElement(stream);
if (elem_length == 0)
return 0;
length_remaining -= elem_length;
//Console.WriteLine ("ParseElement: length = {0}, rem = {1}",
// elem_length, length_remaining);
}
}
} else {
if (length != 0) {
System.Text.Encoding encoding = null;
if (opcode == RecordType.TypeCode.TextBytesAtom) {
//encoding = System.Text.Encoding.GetEncoding (28591);
encoding = System.Text.Encoding.UTF8;
} else if (opcode == RecordType.TypeCode.TextCharsAtom) {
encoding = System.Text.Encoding.Unicode;
}
if (encoding != null && textType != TextType.NotUsed) {
StringBuilder strData = new StringBuilder () ;
data = stream.Read(length);
if (data == null)
return 0;
// Replace all ^M with "whitespace",
// because of which the contents were not properly
// been appended to the text pool.
strData.Append (encoding.GetString (data).Replace ('\r', ' '));
// Replace all ^K with "whitespace",
// because of which the contents were not properly
// been appended to the text pool.
strData.Replace ((char)0x0B, (char)0x20);
if (textType == TextType.Title ||
textType == TextType.CenterBody ||
textType == TextType.CenterTitle)
HotUp ();
AppendText (strData.ToString());
if (IsHot)
HotDown ();
AppendStructuralBreak ();
//Console.WriteLine ("Text : {0}", strData);
} else if (opcode == RecordType.TypeCode.TextHeaderAtom) {
data = stream.Read (4);
textType = (TextType) GetInt32 (data, 0);
} else {
stream.Seek(length, SeekOrigin.Current);
}
}
}
// length = RecordHeader.recLen
// 8 = sizeof (RecordHeader)
// Every Atom/container is preceded by a RecordHeader
return length + 8;
}