예제 #1
0
        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);
            }
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
            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)));
            }
예제 #4
0
 public void Reset()
 {
     current = null;
     atEnd   = false;
 }
예제 #5
0
 public void Dispose()
 {
     current = head = null;
     atEnd   = true;
 }