Ejemplo n.º 1
0
        public virtual void StaticValueSet(CLS_Environment environment, string valuename, object value)
        {
            var targetp = type.GetProperty(valuename);

            if (targetp != null)
            {
                if (value != null && value.GetType() != targetp.PropertyType)
                {
                    value = environment.GetType(value.GetType()).ConvertTo(environment, value, targetp.PropertyType);
                }
                targetp.SetValue(null, value, null);
                return;
            }
            else
            {
                var targetf = type.GetField(valuename);
                if (targetf != null)
                {
                    if (value != null && value.GetType() != targetf.FieldType)
                    {
                        value = environment.GetType(value.GetType()).ConvertTo(environment, value, targetf.FieldType);
                    }
                    targetf.SetValue(null, value);
                    return;
                }
            }



            throw new NotImplementedException();
        }
Ejemplo n.º 2
0
        public CLS_Content.Value Call(CLS_Environment environment, IList <CLS_Content.Value> param)
        {
            CLS_Content.Value v    = new CLS_Content.Value();
            List <object>     objs = new List <object>();

            //var _params =   dele.Method.GetParameters();
            for (int i = 0; i < this.defvalues.Count; i++)
            {
                if (i >= param.Count)
                {
                    objs.Add(defvalues[i]);
                }
                else
                {
                    if (this.paramtype[i] == param[i].type)
                    {
                        objs.Add(param[i].value);
                    }
                    else
                    {
                        object conv = environment.GetType(param[i].type).ConvertTo(environment, param[i].value, paramtype[i]);
                        objs.Add(conv);
                    }
                }
            }
            v.type  = this.returntype;
            v.value = dele.DynamicInvoke(objs.ToArray());
            return(v);
        }
Ejemplo n.º 3
0
 public CLS_Content.Value Call(CLS_Environment environment, IList<CLS_Content.Value> param)
 {
     CLS_Content.Value v = new CLS_Content.Value();
     List<object> objs = new List<object>();
     //var _params =   dele.Method.GetParameters();
     for (int i = 0; i < this.defvalues.Count; i++)
     {
         if (i >= param.Count)
         {
             objs.Add(defvalues[i]);
         }
         else
         {
             if (this.paramtype[i] == param[i].type)
             {
                 objs.Add(param[i].value);
             }
             else
             {
                 object conv = environment.GetType(param[i].type).ConvertTo(environment, param[i].value, paramtype[i]);
                 objs.Add(conv);
             }
         }
     }
     v.type = this.returntype;
     v.value = dele.DynamicInvoke(objs.ToArray());
     return v;
 }
Ejemplo n.º 4
0
        public virtual void StaticValueSet(CLS_Environment environment, string valuename, object value)
        {
            var targetp = type.GetProperty(valuename);
            if (targetp != null)
            {
                if (value != null && value.GetType() != targetp.PropertyType)
                {
                    value = environment.GetType(value.GetType()).ConvertTo(environment, value, targetp.PropertyType);
                }
                targetp.SetValue(null, value, null);
                return;
            }
            else
            {
                var targetf = type.GetField(valuename);
                if (targetf != null)
                {
                    if (value != null && value.GetType() != targetf.FieldType)
                    {
                        value = environment.GetType(value.GetType()).ConvertTo(environment, value, targetf.FieldType);
                    }
                    targetf.SetValue(null, value);
                    return;
                }
            }

            throw new NotImplementedException();
        }