Пример #1
0
        public virtual object BuildCollectionInstance(CollectionObjectInfo coi)
        {
            Type t = classPool.GetClass(coi.GetRealCollectionClassName());

            if (t.IsGenericType)
            {
                return(BuildGenericCollectionInstance(coi, t));
            }
            else
            {
                return(BuildNonGenericCollectionInstance(coi, t));
            }
        }
Пример #2
0
        public virtual object BuildGenericCollectionInstance(CollectionObjectInfo coi, Type t)
        {
            Type   genericType   = t.GetGenericTypeDefinition();
            object newCollection = null;

            try
            {
                newCollection = System.Activator.CreateInstance(t);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e);
                throw new ODBRuntimeException(NeoDatisError.CollectionInstanciationError.AddParameter(coi.GetRealCollectionClassName()));
            }
            System.Collections.IEnumerator iterator = coi.GetCollection().GetEnumerator();
            AbstractObjectInfo             aoi      = null;
            MethodInfo method = t.GetMethod("Add");

            while (iterator.MoveNext())
            {
                aoi = (AbstractObjectInfo)iterator.Current;
                if (!aoi.IsDeletedObject())
                {
                    method.Invoke(newCollection, new object[] { BuildOneInstance(aoi) });
                }
            }
            return(newCollection);
        }
Пример #3
0
        public virtual object BuildNonGenericCollectionInstance(CollectionObjectInfo coi, Type t)
        {
            System.Collections.IList       newCollection = (System.Collections.IList)System.Activator.CreateInstance(classPool.GetClass(coi.GetRealCollectionClassName()));
            System.Collections.IEnumerator iterator      = coi.GetCollection().GetEnumerator();
            AbstractObjectInfo             aoi           = null;

            while (iterator.MoveNext())
            {
                aoi = (AbstractObjectInfo)iterator.Current;
                if (!aoi.IsDeletedObject())
                {
                    newCollection.Add(BuildOneInstance(aoi));
                }
            }
            return(newCollection);
        }