本文整理汇总了C#中EventReader类的典型用法代码示例。如果您正苦于以下问题:C# EventReader类的具体用法?C# EventReader怎么用?C# EventReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventReader类属于命名空间,在下文中一共展示了EventReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YamlDocument
/// <summary>
/// Initializes a new instance of the <see cref="YamlDocument"/> class.
/// </summary>
/// <param name="events">The events.</param>
internal YamlDocument(EventReader events)
{
DocumentLoadingState state = new DocumentLoadingState();
events.Expect<DocumentStart>();
while (!events.Accept<DocumentEnd>())
{
Debug.Assert(RootNode == null);
RootNode = YamlNode.ParseNode(events, state);
if (RootNode is YamlAliasNode)
{
throw new YamlException();
}
}
state.ResolveAliases();
#if DEBUG
foreach (var node in AllNodes)
{
if (node is YamlAliasNode)
{
throw new InvalidOperationException("Error in alias resolution.");
}
}
#endif
events.Expect<DocumentEnd>();
}
示例2: PopulateHeal
protected void PopulateHeal( EventReader reader )
{
amount = reader.ReadInt32();
overkill = reader.ReadInt32();
absorbed = reader.ReadInt32();
critical = reader.ReadString() != null;
}
示例3: DeserializeScript
protected virtual Script DeserializeScript(ReloadedScriptEntry reloadedScript)
{
var eventReader = new EventReader(new MemoryParser(reloadedScript.YamlEvents));
var scriptCollection = (ScriptCollection)YamlSerializer.Deserialize(eventReader, null, typeof(ScriptCollection), log != null ? new SerializerContextSettings { Logger = new YamlForwardLogger(log) } : null);
var script = scriptCollection.Count == 1 ? scriptCollection[0] : null;
return script;
}
示例4: InternalPopulate
protected override void InternalPopulate( EventReader reader )
{
base.InternalPopulate(reader);
enchant = reader.ReadString();
itemId = reader.ReadInt32();
itemName = reader.ReadString();
}
示例5: DeserializeValue
public object DeserializeValue(EventReader reader, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
{
var nodeEvent = reader.Peek<NodeEvent>();
var nodeType = GetTypeFromEvent(nodeEvent, expectedType);
try
{
foreach (var deserializer in deserializers)
{
object value;
if (deserializer.Deserialize(reader, nodeType, (r, t) => nestedObjectDeserializer.DeserializeValue(r, t, state, nestedObjectDeserializer), out value))
{
return value;
}
}
}
catch (YamlException)
{
throw;
}
catch (Exception ex)
{
throw new YamlException(nodeEvent.Start, nodeEvent.End, "Exception during deserialization", ex);
}
throw new YamlException(
nodeEvent.Start,
nodeEvent.End,
string.Format(
"No node deserializer was able to deserialize the node into type {0}",
expectedType.AssemblyQualifiedName
)
);
}
示例6: nestedObjectDeserializer
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func<EventReader, Type, object> nestedObjectDeserializer, out object value)
{
if (!typeof(IList).IsAssignableFrom(expectedType))
{
value = false;
return false;
}
reader.Expect<SequenceStart>();
var list = (IList)_objectFactory.Create(expectedType);
while (!reader.Accept<SequenceEnd>())
{
var item = nestedObjectDeserializer(reader, typeof(object));
var promise = item as IValuePromise;
if (promise == null)
{
list.Add(item);
}
else
{
var index = list.Count;
list.Add(null);
promise.ValueAvailable += v => list[index] = v;
}
}
value = list;
reader.Expect<SequenceEnd>();
return true;
}
示例7: YamlScalarNode
/// <summary>
/// Initializes a new instance of the <see cref="YamlScalarNode"/> class.
/// </summary>
/// <param name="events">The events.</param>
/// <param name="state">The state.</param>
internal YamlScalarNode(EventReader events, DocumentLoadingState state)
{
Scalar scalar = events.Expect<Scalar>();
Load(scalar, state);
Value = scalar.Value;
Style = scalar.Style;
}
示例8: Start
// Use this for initialization
void Start () {
var input = new StringReader(Document);
var deserializer = new Deserializer();
var reader = new EventReader(new Parser(input));
// Consume the stream start event "manually"
reader.Expect<StreamStart>();
var output = new StringBuilder();
while(reader.Accept<DocumentStart>())
{
// Deserialize the document
var doc = deserializer.Deserialize<List<string>>(reader);
output.AppendLine("## Document");
foreach(var item in doc)
{
output.AppendLine(item);
}
}
Debug.Log(output);
}
示例9: ParseNode
/// <summary>
/// Parses the node represented by the next event in <paramref name="events" />.
/// </summary>
/// <param name="events">The events.</param>
/// <param name="state">The state.</param>
/// <returns>Returns the node that has been parsed.</returns>
static internal YamlNode ParseNode(EventReader events, DocumentLoadingState state)
{
if (events.Accept<Scalar>())
{
return new YamlScalarNode(events, state);
}
if (events.Accept<SequenceStart>())
{
return new YamlSequenceNode(events, state);
}
if (events.Accept<MappingStart>())
{
return new YamlMappingNode(events, state);
}
if (events.Accept<AnchorAlias>())
{
AnchorAlias alias = events.Expect<AnchorAlias>();
return state.GetNode(alias.Value, false, alias.Start, alias.End) ?? new YamlAliasNode(alias.Value);
}
throw new ArgumentException("The current event is of an unsupported type.", "events");
}
示例10: PopulateAuraEvent
protected void PopulateAuraEvent( EventReader reader )
{
auraKind = reader.ReadEnum<CombatLogAuraKind>();
if( reader.HasNextValue ) {
// Note: seems to be used for absorb effects.
amount = reader.ReadInt32();
}
}
示例11: InternalPopulate
protected override void InternalPopulate( EventReader reader )
{
base.InternalPopulate(reader);
spell = reader.ReadSpell();
PopulateAuraEvent(reader);
if( reader.HasNextValue ) {
unknown1 = reader.ReadString();
unknown2 = reader.ReadString();
}
}
示例12:
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func<EventReader, Type, object> nestedObjectDeserializer, out object value)
{
var converter = converters.FirstOrDefault(c => c.Accepts(expectedType));
if (converter == null)
{
value = null;
return false;
}
value = converter.ReadYaml(reader.Parser, expectedType);
return true;
}
示例13: PopulateDamageEvent
protected void PopulateDamageEvent( EventReader reader )
{
amount = reader.ReadInt32();
overkill = reader.ReadInt32();
damageSchool = (CombatLogSpellSchool)reader.ReadUInt32();
resisted = reader.ReadInt32();
blocked = reader.ReadInt32();
absorbed = reader.ReadInt32();
critical = reader.ReadString() != null;
glancing = reader.ReadString() != null;
crushing = reader.ReadString() != null;
}
示例14: NodeIsNull
bool INodeDeserializer.Deserialize(EventReader reader, Type expectedType, Func<EventReader, Type, object> nestedObjectDeserializer, out object value)
{
value = null;
var evt = reader.Peek<NodeEvent>();
var isNull = evt != null
&& NodeIsNull(evt);
if (isNull)
{
reader.SkipThisAndNestedEvents();
}
return isNull;
}
示例15: Deserialize
public bool Deserialize(EventReader reader, Type expectedType,
Func<EventReader, Type, object> nestedObjectDeserializer,
out object value)
{
if (_nodeDeserializer.Deserialize(reader, expectedType,
nestedObjectDeserializer, out value))
{
if (((Data)value).Name == null)
{
Debug.Log("ValidatingNodeDeserializer found that 'Name' was missing or null");
}
return true;
}
return false;
}