Esempio n. 1
0
        /// <summary>
        ///   Builds an instance of an array
        /// </summary>
        private object BuildArrayInstance(ArrayObjectInfo aoi)
        {
            // first check if array element type is native (int,short, for example)
            var type = OdbType.GetFromName(aoi.GetRealArrayComponentClassName());

            var    arrayClazz = type.GetNativeClass();
            object array      = Array.CreateInstance(arrayClazz, aoi.GetArray().Length);

            for (var i = 0; i < aoi.GetArrayLength(); i++)
            {
                var abstractObjectInfo = (AbstractObjectInfo)aoi.GetArray()[i];
                if (abstractObjectInfo == null || abstractObjectInfo.IsDeletedObject() || abstractObjectInfo.IsNull())
                {
                    continue;
                }

                var instance = BuildOneInstance(abstractObjectInfo);
                ((Array)array).SetValue(instance, i);
            }
            return(array);
        }
Esempio n. 2
0
        /// <summary>Builds an instance of an array</summary>
        public virtual object BuildArrayInstance(ArrayObjectInfo aoi)
        {
            // first check if array element type is native (int,short, for example)
            ODBType type = ODBType.GetFromName(aoi.GetRealArrayComponentClassName());

            System.Type arrayClazz = type.GetNativeClass();
            object      array      = System.Array.CreateInstance(arrayClazz, aoi.GetArray().Length);

            object             o    = null;
            AbstractObjectInfo aboi = null;

            for (int i = 0; i < aoi.GetArrayLength(); i++)
            {
                aboi = (AbstractObjectInfo)aoi.GetArray()[i];
                if (aboi != null && !aboi.IsDeletedObject() && !aboi.IsNull())
                {
                    o = BuildOneInstance(aboi);
                    ((Array)array).SetValue(o, i);
                }
            }
            return(array);
        }