Example #1
0
        public static object CreateInstanceObject(Type typeObj)
        {
            if (typeObj == null)
            {
                return(null);
            }
            try
            {
                InstantiateObjectHandler instantiateObjectHandler = null;
                lstInitHandler.TryGetValue(typeObj.FullName, out instantiateObjectHandler);
                if (instantiateObjectHandler == null)
                {
                    instantiateObjectHandler = ABCDynamicMethodCompiler.CreateInstantiateObjectHandler(typeObj);
                    lstInitHandler.Add(typeObj.FullName, instantiateObjectHandler);
                }

                return(instantiateObjectHandler());
            }
            catch (System.Exception ex)
            {
                try
                {
                    return(typeObj.InvokeMember("", BindingFlags.CreateInstance, null, null, null));
                }
                catch (System.Exception ex2)
                {
                }
            }
            return(null);
        }
Example #2
0
        public static void SetValue(BusinessObject obj, PropertyInfo proInfo, object value)
        {
            string key = obj.AATableName + proInfo.Name;

            try
            {
                SetHandler setHandler = null;
                if (lstSetHandler.TryGetValue(key, out setHandler) == false)
                {
                    setHandler = ABCDynamicMethodCompiler.CreateSetHandler(obj.GetType(), proInfo);
                    lstSetHandler.Add(key, setHandler);
                }
                setHandler(obj, value);
            }
            catch (System.Exception ex)
            {
                proInfo.SetValue(obj, value, null);
            }
        }
Example #3
0
        public static object GetValue(BusinessObject obj, PropertyInfo proInfo)
        {
            string key = obj.AATableName + proInfo.Name;

            try
            {
                GetHandler getHandler = null;
                if (lstGetHandler.TryGetValue(key, out getHandler) == false)
                {
                    getHandler = ABCDynamicMethodCompiler.CreateGetHandler(obj.GetType(), proInfo);
                    lstGetHandler.Add(key, getHandler);
                }
                return(getHandler(obj));
            }
            catch (System.Exception ex)
            {
                return(proInfo.GetValue(obj, null));
            }
        }
Example #4
0
        public static void SetValue(BusinessObject obj, String strColName, object value)
        {
            string key = obj.AATableName + strColName;

            try
            {
                SetHandler setHandler = null;
                if (lstSetHandler.TryGetValue(key, out setHandler) == false)
                {
                    Type type = obj.GetType();

                    PropertyInfo proInfo = BusinessObjectHelper.GetProperty(obj.AATableName, strColName);
                    if (proInfo == null)
                    {
                        proInfo = type.GetProperty(strColName);
                    }

                    setHandler = ABCDynamicMethodCompiler.CreateSetHandler(type, proInfo);
                    lstSetHandler.Add(key, setHandler);
                }

                if (value is String && value.ToString().Replace("'", "").ToUpper() == "TRUE")
                {
                    value = true;
                }
                else if (value is String && value.ToString().Replace("'", "").ToUpper() == "FALSE")
                {
                    value = false;
                }
                setHandler(obj, value);
            }
            catch (System.Exception ex)
            {
                PropertyInfo proInfo = obj.GetType().GetProperty(strColName);
                if (proInfo == null)
                {
                    //    Utilities.ABCLogging.LogNewMessage( "ABCDataLib" , "" , "SetValue" , obj.GetType().Name+" not contain "+strColName , "FAILE" );
                    return;
                }
                proInfo.SetValue(obj, value, null);
            }
        }
Example #5
0
        public static object GetValue(BusinessObject obj, String strColName)
        {
            if (obj == null)
            {
                return(null);
            }

            string key = obj.AATableName + strColName;

            try
            {
                GetHandler getHandler = null;
                if (lstGetHandler.TryGetValue(key, out getHandler) == false)
                {
                    Type type = obj.GetType();

                    PropertyInfo proInfo = BusinessObjectHelper.GetProperty(obj.AATableName, strColName);
                    if (proInfo == null)
                    {
                        proInfo = type.GetProperty(strColName);
                    }

                    getHandler = ABCDynamicMethodCompiler.CreateGetHandler(type, proInfo);
                    lstGetHandler.Add(key, getHandler);
                }

                return(getHandler(obj));
            }
            catch (System.Exception ex)
            {
                PropertyInfo proInfo = obj.GetType().GetProperty(strColName);
                if (proInfo == null)
                {
                    //    Utilities.ABCLogging.LogNewMessage( "ABCDataLib" , "" , "GetValue" , obj.GetType().Name+" not contain "+strColName , "FAILE" );
                    return(null);
                }

                return(proInfo.GetValue(obj, null));
            }
        }