public EventType AddReturnExistingAnonymousType(EventType requiredType)
        {
            lock (this)
            {
                // only EventTypeSPI compliant implementations considered
                if (!(requiredType is EventTypeSPI))
                {
                    return(requiredType);
                }

                // check recent types
                foreach (EventTypeSPI existing in _recentTypes)
                {
                    if (existing.GetType() == requiredType.GetType() &&
                        Collections.AreEqual(requiredType.PropertyNames, existing.PropertyNames) &&
                        Collections.AreEqual(requiredType.PropertyDescriptors, existing.PropertyDescriptors) &&
                        existing.EqualsCompareType(requiredType))
                    {
                        return(existing);
                    }
                }

                // add, removing the oldest
                if (_recentTypes.Count == _size && !_recentTypes.IsEmpty())
                {
                    _recentTypes.RemoveFirst();
                }
                if (_recentTypes.Count < _size)
                {
                    _recentTypes.AddLast((EventTypeSPI)requiredType);
                }
                return(requiredType);
            }
        }
 public static void RemoveListener <T>(EventType eventType, CallBack <T> callBack)
 {
     if (m_EventTable.ContainsKey(eventType))
     {
         Delegate d = m_EventTable[eventType];
         if (d == null)
         {
             throw new Exception(string.Format("移除监听错误:对应事件{0}没有对应委托", eventType));
         }
         else if (d.GetType() != callBack.GetType())
         {
             throw new Exception(string.Format("移除监听错误:尝试为事件{0}移除不同类型的委,当前委托类型为{1},移除委托类型为{2}",
                                               eventType, eventType.GetType(), callBack.GetType()));
         }
     }
     else
     {
         throw new Exception(string.Format("移除监听错:尝试移除事件不存在!"));
     }
     m_EventTable[eventType] = (CallBack <T>)m_EventTable[eventType] - callBack;
     if (m_EventTable[eventType] == null)
     {
         m_EventTable.Remove(eventType);
     }
 }
    {//todo: maybe move color resolver to gui
        public int Resolve(PSCalendarDB.Event source, dto.Event destination, int destMember, ResolutionContext context)
        {
            PeriodTypeResolver resolver = new PeriodTypeResolver();
            EventType          @event   = resolver.ResolvePublic(source.Type);

            FieldInfo fi = @event.GetType().GetField(@event.ToString());

            ColorAttribute[] attributes = (ColorAttribute[])fi.GetCustomAttributes(
                typeof(ColorAttribute),
                false);

            if (attributes != null && attributes.Length > 0)
            {
                return(attributes[0].Color);
            }

            return(15);
        }
 public static EventBeanFactory GetFactoryForType(EventType type, EventAdapterService eventAdapterService)
 {
     if (type is WrapperEventType)
     {
         var wrapperType = (WrapperEventType)type;
         if (wrapperType.UnderlyingEventType is BeanEventType)
         {
             return(new EventBeanFactoryBeanWrapped(wrapperType.UnderlyingEventType, wrapperType, eventAdapterService));
         }
     }
     if (type is BeanEventType)
     {
         return(new EventBeanFactoryBean(type, eventAdapterService));
     }
     if (type is MapEventType)
     {
         return(new EventBeanFactoryMap(type, eventAdapterService));
     }
     if (type is ObjectArrayEventType)
     {
         return(new EventBeanFactoryObjectArray(type, eventAdapterService));
     }
     if (type is BaseXMLEventType)
     {
         return(new EventBeanFactoryXML(type, eventAdapterService));
     }
     throw new ArgumentException("Cannot create event bean factory for event type '" + type.Name + "': " + type.GetType().FullName + " is not a recognized event type or supported wrap event type");
 }
        public void AssertEventNotQueued <T>(EventType <T> eventType)
        {
            T temp;

            if (TryGetEvent(eventType, out temp))
            {
                Assert.True(false, string.Format("Event of type {0} was found in the queue.", eventType.GetType().FullName, temp.ToString()));
            }
        }
Esempio n. 6
0
 public static ArgumentReturnType[] InnerReturnTypes(this EventType type)
 {
     return(type.GetType().GetField(type.ToString())?.GetCustomAttribute <InnerReturnTypesAttribute>()
            ?.InnerReturnTypes);
 }