コード例 #1
0
        private static object CreateObject(Type objType, IDataReader dr)
        {
            object objectValue = RuntimeHelpers.GetObjectValue(Activator.CreateInstance(objType));

            if (objectValue is IHydratable)
            {
                IHydratable hydratable = objectValue as IHydratable;
                if (hydratable != null)
                {
                    hydratable.Fill(dr);
                }
            }
            else
            {
                CBO.HydrateObject(RuntimeHelpers.GetObjectValue(objectValue), dr);
            }
            return(objectValue);
        }
コード例 #2
0
        private static T CreateObject <T>(IDataReader dr)
        {
            T instance = Activator.CreateInstance <T>();

            if ((object)instance is IHydratable)
            {
                IHydratable hydratable = (object)instance as IHydratable;
                if (hydratable != null)
                {
                    hydratable.Fill(dr);
                }
            }
            else
            {
                CBO.HydrateObject((object)instance, dr);
            }
            return(instance);
        }