internal MessageImpl(ServiceImpl service, Type message) { if (!typeof(Delegate).IsAssignableFrom(message)) { throw new ArgumentException("Message type " + message + " is not a delegate type"); } Attribute attribute; foreach (Attribute attr in message.GetCustomAttributes(false)) { if (attr.GetType().FullName == typeof(PartMessageDelegate).FullName) { attribute = attr; goto foundAttribute; } } throw new ArgumentException("Message does not have the PartMessageDelegate attribute"); foundAttribute: DelegateType = message; ifMsg = ServiceImpl.AsDelegate(attribute); if (ifMsg.Parent != null) { parent = (MessageImpl)service.AsIPartMessage(ifMsg.Parent); } }
/// <summary> /// Convert delegate type into the IPartMessage interface. /// </summary> /// <param name="type">Delegate type to convert. This must be a delegate type marked with the <see cref="PartMessageDelegate"/> attribute.</param> public IPartMessage AsIPartMessage(Type type) { IPartMessage value; if (cachedPartMessages.TryGetValue(type, out value)) { return(value); } return(cachedPartMessages[type] = new MessageImpl(this, type)); }
public bool MoveNext() { if (head == null) { throw new InvalidOperationException("Iterator disposed"); } if (atEnd) { throw new InvalidOperationException("Iterator is at end"); } current = current == null ? head : current.parent; return(!(atEnd = (current == null))); }
public void Reset() { current = null; atEnd = false; }
public void Dispose() { current = head = null; atEnd = true; }