Esempio n. 1
0
        private object[] GetParameters(MethodInfo methodInfo, IdsObjectList <IdValueObject> ParamDatas)
        {
            ParameterInfo[] paramInfos = methodInfo.GetParameters();

            object[] ret = new object[paramInfos.Length];

            for (int i = 0; i < paramInfos.Length; i++)
            {
                ParameterInfo pInfo = paramInfos[i];
                if (ParamDatas.ContainsId(pInfo.Name))
                {
                    ret[i] = ParamDatas.GetItem(pInfo.Name);
                }
            }
            return(ret);
        }
Esempio n. 2
0
 public static void SetObjProperties(object obj, IdsObjectList <IdValueObject> properties)
 {
     for (int i = 0; i < properties.Count; i++)
     {
         try
         {
             Type         t         = obj.GetType();
             object       propValue = properties[i].Value.Trim();
             string       propName  = properties[i].Id.Trim();
             PropertyInfo p         = t.GetProperty(propName);
             p.SetValue(obj, propValue, null);
         }
         catch (Exception e)
         {
             var err = new Exception("设置对象状态时,发生错误,属性名:" + properties[i].Id, e);
             throw err;
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 通过校验定义Schema, 执行校验
        /// </summary>
        /// <param name="validationSchema"></param>
        /// <param name="value"></param>
        /// <param name="errHint"></param>
        /// <returns></returns>
        public static bool InvokeValid(ValidationSchema validationSchema, string value, CheckVarHandle checkHandl, out string errHint)
        {
            List <ValidationItemSchema> items = validationSchema.Validators;



            for (int i = 0; i < items.Count; i++)
            {
                ValidationItemSchema          item    = items[i];
                IdsObjectList <IdValueObject> options = new IdsObjectList <IdValueObject>();
                for (int j = 0; j < item.Options.Count; j++)
                {
                    IdValueObject op    = item.Options[j];
                    IdValueObject newOp = new IdValueObject();
                    newOp.Id    = op.Id;
                    newOp.Value = op.Value;
                    if (checkHandl != null)
                    {
                        newOp.Value = checkHandl(newOp.Value).ToString();
                    }
                    options.Add(newOp);
                }



                Validator validator = GetValidator(item.ValidatorName);

                ActionUtils.SetObjProperties(validator, options);
                errHint = validator.ErrHint;
                if (!validator.Check(value))
                {
                    return(false);
                }
            }

            errHint = "";
            return(true);
        }
Esempio n. 4
0
        private void SetObjPropertis()
        {
            IdsObjectList <IdValueObject> Props = actionData.Options.Propertys;

            ActionUtils.SetObjProperties(obj, Props);
        }