public ArrayBuilder(
     IEnumerable oObjects,
     ArrayElementFilter oFilter)
     : this()
 {
     AddRange(oObjects, oFilter);
 }
        internal static FieldInfo[] GetTypeFieldsForILReflector(
            Type reflectedType,
            BindingFlags bindingFlags,
            bool serializedFieldsOnly)
        {
            bool obtainAllFields = bindingFlags == BindingFlags.Default;

            ArrayBuilder oAllFields = new ArrayBuilder();

            if (obtainAllFields)
            {
                bindingFlags =
                    BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
            }

            // Get all fields that belong specified type
            // Note: private fields of base types not returned
            oAllFields.AddRange(
                reflectedType.GetFields(bindingFlags),
                new ArrayElementFilter(NonLiteralFieldsFilter));


            if (obtainAllFields)
            {
                //
                //	Now iterate the base classes and add all private fields
                //

                Type oType     = reflectedType;
                Type oBaseType = null;

                while ((oBaseType = oType.BaseType) != null)
                {
                    // Get non-public fields of type
                    FieldInfo[] Fields = oBaseType.GetFields(
                        BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy);

                    //// Add only private fields
                    oAllFields.AddRange(
                        Fields,
                        new ArrayElementFilter(PrivateFieldsFilter));

                    oType = oBaseType;
                }
            }

            ArrayElementFilter filter = null;

            if (serializedFieldsOnly)
            {
                filter = new ArrayElementFilter(SerializedFieldsFilter);
            }

            // Filter & store fields to be serialized
            return((FieldInfo[])ArrayBuilder.CreateArray(
                       oAllFields.Elements,
                       typeof(FieldInfo),
                       filter));
        }
        public static Array CreateArray(
            IEnumerable oObjects,
            Type oTargetElType,
            ArrayElementFilter oFilter)
        {
            ArrayBuilder oArrayBuiler = new ArrayBuilder(
                oObjects,
                oFilter);

            return(oArrayBuiler.GetArray(oTargetElType));
        }
 public void AddRange(
     IEnumerable oObjects,
     ArrayElementFilter oFilter)
 {
     // If no filter
     if (oFilter == null)
     {
         // Add all
         AddRange(oObjects);
     }
     else
     {
         // If filter defined
         foreach (object oObj in oObjects)
         {
             // Add only objects that pass filter
             if (oFilter(oObj))
             {
                 Add(oObj);
             }
         }
     }
 }