Exemple #1
0
        public static object ParamReplace(object inParam, object outParam, bool toUpperFlag = true, string[] trimArray = null)
        {
            string       expression   = null;
            MethodInfo   getMethod    = null;
            Hashtable    hashtable    = null;
            object       objectValue  = null;
            PropertyInfo info2        = null;
            Hashtable    propertyInfo = null;

            System.Type  propertyType = null;
            Hashtable    hashtable3   = null;
            string       str2         = null;
            PropertyInfo info3        = null;
            Hashtable    hashtable4   = null;

            System.Type type2      = null;
            object[]    parameters = null;
            object      obj3;
            MethodInfo  setMethod = null;

            try
            {
                IEnumerator enumerator = null;
                propertyInfo = GetPropertyInfo(RuntimeHelpers.GetObjectValue(inParam));
                hashtable4   = GetPropertyInfo(RuntimeHelpers.GetObjectValue(outParam));
                hashtable    = GetPropertyAliasName(RuntimeHelpers.GetObjectValue(inParam), toUpperFlag, trimArray);
                hashtable3   = GetPropertyAliasName(RuntimeHelpers.GetObjectValue(outParam), toUpperFlag, trimArray);
                try
                {
                    enumerator = hashtable4.Keys.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        str2 = enumerator.Current.ToString();
                        if (str2 != null)
                        {
                            expression = str2;
                        }
                        else
                        {
                            expression = "";
                        }
                        if (toUpperFlag)
                        {
                            expression = expression.ToUpper();
                        }
                        if ((trimArray != null) && (trimArray.Length > 0))
                        {
                            int num2 = trimArray.Length - 1;
                            for (int i = 0; i <= num2; i++)
                            {
                                if (trimArray[i] != null)
                                {
                                    //expression = Strings.Replace(expression, trimArray[i], "", 1, -1, CompareMethod.Binary);
                                    expression = expression.Replace(trimArray[i], "");
                                }
                            }
                        }
                        info2 = (PropertyInfo)propertyInfo[CharacterUtil.ReplaceNothing(hashtable[expression].ToString(), "")];
                        info3 = (PropertyInfo)hashtable4[CharacterUtil.ReplaceNothing(hashtable3[expression].ToString(), "")];
                        if (info3.CanWrite && !((info2 == null) | (info3 == null)))
                        {
                            propertyType = info2.PropertyType;
                            type2        = info3.PropertyType;
                            if (propertyType.FullName == type2.FullName)
                            {
                                getMethod = info2.GetGetMethod();
                                setMethod = info3.GetSetMethod();
                                if (!((getMethod == null) | (setMethod == null)))
                                {
                                    objectValue = RuntimeHelpers.GetObjectValue(getMethod.Invoke(RuntimeHelpers.GetObjectValue(inParam), null));
                                    parameters  = new object[] { RuntimeHelpers.GetObjectValue(objectValue) };
                                    setMethod.Invoke(RuntimeHelpers.GetObjectValue(outParam), parameters);
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                obj3 = outParam;
            }
            catch (Exception)
            {
                obj3 = null;
            }
            return(obj3);
        }