/// <summary>
        /// Accepts a list of objects and converts them to a strongly typed list.
        /// </summary>
        /// <remarks>This should be put into a utility class as it's not directly
        /// related to data access.</remarks>
        public static IList <T> ConvertToList <T>(this System.Collections.IEnumerable objects)
        {
            if (objects == null)
            {
                return(new List <T>());
            }

            return(objects.Cast <T>().ToList());
        }
Esempio n. 2
0
        /// <summary>
        /// From a Source collection of items having a property, which is also another collection, gets the union of all the items of these collections.
        /// </summary>
        public static System.Collections.IEnumerable SelectMany(System.Collections.IEnumerable Source, string CollectionTechName)
        {
            var Collections = Source.Cast <object>()
                              .Select(item => Get(item, CollectionTechName) as System.Collections.IEnumerable);

            foreach (var Collection in Collections)
            {
                foreach (var Item in Collection)
                {
                    yield return(Item);
                }
            }
        }
Esempio n. 3
0
        public static List <float> ToFloatList(object obj)
        {
            List <float> aResult = new List <float>();

            if (obj != null)
            {
                System.Collections.IEnumerable aValues = obj as System.Collections.IEnumerable;
                if (aValues != null)
                {
                    aResult = aValues.Cast <float>().ToList();
                }
            }
            return(aResult);
        }
Esempio n. 4
0
        public static List <double> ToDoubleList(object obj)
        {
            List <float> aResult = new List <float>();

            if (obj != null)
            {
                System.Collections.IEnumerable aValues = obj as System.Collections.IEnumerable;
                if (aValues != null)
                {
                    aResult = aValues.Cast <float>().ToList();
                }
            }

            List <double> results = aResult.ConvertAll(x => (double)x).ToList();

            return(results);
        }
Esempio n. 5
0
 /// <summary>
 /// Implicit or Explicit Converts the items of the specified enumerable.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="enumerable">The enumerable.</param>
 /// <param name="explicit">if set to <c>true</c> [explicit].</param>
 /// <returns></returns>
 public static IEnumerable <T> ConvertEach <T>(this System.Collections.IEnumerable enumerable, bool @explicit = false)
 {
     return(enumerable.Cast <object>().Select(it => InvokeConvert(it, typeof(T), @explicit)).Cast <T>());
 }
Esempio n. 6
0
 protected ExpressionSyntax EmitCreateArray(Type elementType, System.Collections.IEnumerable values)
 {
     return(DefaultViewCompilerCodeEmitter.EmitCreateArray(UseType(elementType), values.Cast <object>().Select(EmitValue)));
 }
Esempio n. 7
0
 public static double Norm(this System.Collections.IEnumerable value, Func <object, Double> func)
 {
     Contract.Requires <ArgumentNullException>(value != null);
     Contract.Requires <ArgumentNullException>(func != null);
     return(value.Cast <object>().Norm(func));
 }
Esempio n. 8
0
 protected void define_enum(string name, SC.IEnumerable values)
 {
     _curProcessDef.DataTypes.AddType(new EnumDef {
         Name = name, EnumValues = new List <string>(values.Cast <string>())
     });
 }
Esempio n. 9
0
 public void AddRange(System.Collections.IEnumerable elements)
 {
     this.AddRange(elements.Cast <Element>());
 }