コード例 #1
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="beanEventType">type of bean to copy</param>
 /// <param name="eventAdapterService">for creating events</param>
 /// <param name="copyMethod">method to copy the event</param>
 public BeanEventBeanConfiguredCopyMethod(BeanEventType beanEventType, EventAdapterService eventAdapterService, FastMethod copyMethod)
 {
     _beanEventType       = beanEventType;
     _eventAdapterService = eventAdapterService;
     _copyMethod          = copyMethod;
 }
コード例 #2
0
        /// <summary>Returns the fragment for dynamic properties. </summary>
        /// <param name="object">to inspect</param>
        /// <param name="eventAdapterService">factory for event beans and event types</param>
        /// <returns>fragment</returns>
        public static Object GetFragmentDynamic(Object @object, EventAdapterService eventAdapterService)
        {
            if (@object == null)
            {
                return(null);
            }

            BeanEventType fragmentEventType = null;
            bool          isArray           = false;

            if (@object.GetType().IsArray)
            {
                if (@object.GetType().GetElementType().IsFragmentableType())
                {
                    isArray           = true;
                    fragmentEventType = eventAdapterService.BeanEventTypeFactory.CreateBeanTypeDefaultName(@object.GetType().GetElementType());
                }
            }
            else
            {
                if (@object.GetType().IsFragmentableType())
                {
                    fragmentEventType = eventAdapterService.BeanEventTypeFactory.CreateBeanTypeDefaultName(@object.GetType());
                }
            }

            if (fragmentEventType == null)
            {
                return(null);
            }

            if (isArray)
            {
                var asArray     = (Array)@object;
                var len         = asArray.Length;
                var events      = new EventBean[len];
                int countFilled = 0;

                for (int i = 0; i < len; i++)
                {
                    Object element = asArray.GetValue(i);
                    if (element == null)
                    {
                        continue;
                    }

                    events[countFilled] = eventAdapterService.AdapterForTypedObject(element, fragmentEventType);
                    countFilled++;
                }

                if (countFilled == len)
                {
                    return(events);
                }

                if (countFilled == 0)
                {
                    return(new EventBean[0]);
                }

                var returnVal = new EventBean[countFilled];
                Array.Copy(events, 0, returnVal, 0, countFilled);
                return(returnVal);
            }
            else
            {
                return(eventAdapterService.AdapterForTypedObject(@object, fragmentEventType));
            }
        }
コード例 #3
0
 private static void TryInvalidIsProperty(BeanEventType type, String property)
 {
     Assert.AreEqual(null, type.GetPropertyType(property));
     Assert.AreEqual(false, type.IsProperty(property));
 }
コード例 #4
0
        public Object GetFragment(EventBean eventBean)
        {
            Object @object = Get(eventBean);

            if (@object == null)
            {
                return(null);
            }

            if (!_isFragmentable)
            {
                return(null);
            }

            if (_fragmentEventType == null)
            {
                if (_fragmentClassType.IsFragmentableType())
                {
                    _fragmentEventType = _eventAdapterService.BeanEventTypeFactory.CreateBeanTypeDefaultName(_fragmentClassType);
                }
                else
                {
                    _isFragmentable = false;
                    return(null);
                }
            }

            if (_isArray)
            {
                var asArray     = (Array)@object;
                var len         = asArray.Length;
                var events      = new EventBean[len];
                int countFilled = 0;

                for (int i = 0; i < len; i++)
                {
                    Object element = asArray.GetValue(i);
                    if (element == null)
                    {
                        continue;
                    }

                    events[countFilled] = _eventAdapterService.AdapterForTypedObject(element, _fragmentEventType);
                    countFilled++;
                }

                if (countFilled == len)
                {
                    return(events);
                }

                if (countFilled == 0)
                {
                    return(new EventBean[0]);
                }

                var returnVal = new EventBean[countFilled];
                Array.Copy(events, 0, returnVal, 0, countFilled);
                return(returnVal);
            }
            else if (_isIterable)
            {
                if (!(@object is IEnumerable))
                {
                    return(null);
                }
                IEnumerator enumerator = ((IEnumerable)@object).GetEnumerator();
                if (!enumerator.MoveNext())
                {
                    return(new EventBean[0]);
                }
                var events = new List <EventBean>();
                do
                {
                    Object next = enumerator.Current;
                    if (next == null)
                    {
                        continue;
                    }

                    events.Add(_eventAdapterService.AdapterForTypedObject(next, _fragmentEventType));
                } while (enumerator.MoveNext());

                return(events.ToArray());
            }
            else
            {
                return(_eventAdapterService.AdapterForTypedObject(@object, _fragmentEventType));
            }
        }
コード例 #5
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="beanEventType">event type</param>
 /// <param name="eventAdapterService">for creating the event object</param>
 public BeanEventBeanSerializableCopyMethod(BeanEventType beanEventType, EventAdapterService eventAdapterService)
 {
     _beanEventType       = beanEventType;
     _eventAdapterService = eventAdapterService;
 }