Exemplo n.º 1
0
Arquivo: Utils.cs Projeto: vebin/IQMap
        /// <summary>
        // return an instance of an object or value type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static object GetInstanceOf(Type type)
        {
            object obj;

            if (IsMappableType(type))
            {
                obj = Utils.DefaultValue(type);
            }
            else
            {
                obj = Activator.CreateInstance(type);
                // We have special handling for Expando-like objects -- don't create metadata for them
                if (!(obj is IDictionary <string, object>))
                {
                    IQ.CreateDBData(obj);
                }
            }

            return(obj);
        }
Exemplo n.º 2
0
Arquivo: Utils.cs Projeto: vebin/IQMap
        /// <summary>
        // return an instance of an object or value type
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T GetInstanceOf <T>()
        {
            T obj;

            if (IsMappableType <T>())
            {
                obj = default(T);
            }
            else
            {
                obj = Activator.CreateInstance <T>();
                // We have special handling for Expando-like objects -- don't create metadata for them
                if (!(obj is IDictionary <string, object>))
                {
                    IQ.CreateDBData(obj);
                }
            }

            return(obj);
        }