/// <summary> /// Tries to get the named event template. /// </summary> /// <param name="evName">the event's name</param> /// <param name="template">reference to a variable that will contain the template upon success</param> /// <returns><em>true</em> if the named event is retreived; otherwise <em>false</em></returns> public bool TryGetEventTemplate(string evName, out EventTemplate template) { if (!_initialized) throw new InvalidOperationException(Resources.Error_NotYetInitialized); if (evName == null) throw new ArgumentNullException("evName"); if (evName.Length == 0) throw new ArgumentException(Resources.Error_EmptyStringNotAllowed, "evName"); return _templates.TryGetValue(evName, out template); }
private void AssertHasAttribute(EventTemplate evt, TypeToken tt, string name) { AttributeTemplate attr = evt[name]; Assert.IsNotNull(attr); Assert.AreEqual(tt, attr.TypeToken); }
/// <summary> /// Parses a character array for an event tempate. /// </summary> /// <param name="input">character input</param> /// <param name="cursor">reference to a position within the input; upon success /// this variable is advanced by the number of characters taken while parsing</param> /// <returns>the event template</returns> public static EventTemplate ExpectEvent(char[] input, ref Cursor cursor) { Cursor c = new Cursor(cursor); EsfParser.SkipWhitespaceAndComments(input, ref c); // parse the event name string eventName = EsfParser.ExpectWord(input, ref c); EventTemplate evt = new EventTemplate(false, eventName); EsfParser.SkipWhitespaceAndComments(input, ref c); EsfParser.ExpectChar(input, ref c, EsfParser.LeftCurlyBracket); // read the attribute list List<AttributeTemplate> attributes = new List<AttributeTemplate>(); while (c < input.Length && input[c] != EsfParser.RightCurlyBracket) { EsfParser.SkipWhitespaceAndComments(input, ref c); if (c < input.Length && input[c] != EsfParser.RightCurlyBracket) { attributes.Add(AttributeTemplate.ExpectAttribute(input, ref c)); } } evt.Attributes = attributes; EsfParser.SkipWhitespaceAndComments(input, ref c); EsfParser.ExpectChar(input, ref c, EsfParser.RightCurlyBracket); // Advance the cursor upon success. cursor = c; return evt; }
internal EventTemplate PrependAttributes(params AttributeTemplate[] prepend) { EventTemplate ev = new EventTemplate(false, Name); int ord = 0; ev.Attributes = from a in Enumerable.Concat(prepend, _attributes) select new AttributeTemplate(a.TypeToken, a.Name, ord++); return ev; }
static Constants() { MetaEventInfo = new EventTemplate(true, "MetaInfoEvent") .AppendAttributes(MetaEventInfoAttributes.Encoding) .AppendAttributes(MetaEventInfoAttributes.SenderIP) .AppendAttributes(MetaEventInfoAttributes.SenderPort) .AppendAttributes(MetaEventInfoAttributes.ReceiptTime) .AppendAttributes(MetaEventInfoAttributes.SiteID); }