Esempio n. 1
0
 public static FlexCollection UnwrapEventBeans(
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     BeanEventType type,
     IEnumerable enumerable)
 {
     return FlexCollection.Of(
         enumerable
             .Cast<object>()
             .Select(value => eventBeanTypedEventFactory.AdapterForTypedObject(value, type))
             .ToList());
 }
Esempio n. 2
0
        public static FlexCollection EvaluateEnumMethodTakeLast(
            FlexCollection enumcoll,
            int size)
        {
            if (enumcoll.IsEventBeanCollection) {
                return FlexCollection.Of(
                    EvaluateEnumMethodTakeLast(enumcoll.EventBeanCollection, size));
            }

            return FlexCollection.Of(
                EvaluateEnumMethodTakeLast(enumcoll.ObjectCollection, size));
        }
Esempio n. 3
0
        public static FlexCollection EnumExceptForgeEvalSet(
            FlexCollection other,
            FlexCollection enumcoll)
        {
            if (other.IsEventBeanCollection) {
                if (enumcoll.IsEventBeanCollection) {
                    return FlexCollection.Of(EnumExceptForgeEvalSet(
                        other.EventBeanCollection,
                        enumcoll.EventBeanCollection));
                }
            } else if (enumcoll.IsObjectCollection) {
                return FlexCollection.Of(EnumExceptForgeEvalSet(
                    other.ObjectCollection,
                    enumcoll.ObjectCollection));
            }

            throw new ArgumentException("mismatch in FlexCollection types");
        }
        public static FlexCollection ConvertToCollection(
            string propertyName, 
            object value)
        {
            if (value == null) {
                return null;
            }

            if (value is string stringValue) {
                // Convert to a collection of characters
                return FlexCollection.Of(
                    stringValue
                        .ToCharArray()
                        .Cast<object>()
                        .ToList());
            }

            Log.Warn(
                "Expected string-type input from property '" + propertyName + "' but received " + value.GetType());
            return null;
        }
Esempio n. 5
0
        /// <summary>
        ///     NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="enumcoll">collection</param>
        /// <param name="size">size</param>
        /// <returns>collection</returns>
        public static FlexCollection EvaluateEnumTakeMethod(
            FlexCollection enumcoll,
            int size)
        {
            if (enumcoll.Count == 0) {
                return FlexCollection.Empty;
            }

            if (size <= 0) {
                return FlexCollection.Empty;
            }

            if (enumcoll.Count < size) {
                return enumcoll;
            }

            if (size == 1) {
                if (enumcoll.IsEventBeanCollection) {
                    return FlexCollection.OfEvent(
                        enumcoll.EventBeanCollection.First());
                }
                else {
                    return FlexCollection.OfObject(
                        enumcoll.ObjectCollection.First());
                }
            }

            if (enumcoll.IsEventBeanCollection) {
                return FlexCollection.Of(
                    enumcoll.EventBeanCollection
                    .Take(size)
                    .ToList());
            }

            return FlexCollection.Of(
                enumcoll.ObjectCollection
                    .Take(size)
                    .ToList());
        }
Esempio n. 6
0
 public static FlexCollection AsFlexCollection(this object value)
 {
     return(FlexCollection.Of(value));
 }