Пример #1
0
 public static bool CallProperty(mdr.DObject input, string propName, out mdr.DValue output)
 {
     if (input != null)
     {
         var propDesc = input.GetPropertyDescriptor(propName);
         var prop     = new mdr.DValue();
         propDesc.Get(input, ref prop);
         mdr.DFunction func = null;
         if (prop.ValueType == mdr.ValueTypes.Function)
         {
             func = prop.AsDFunction();
             //if (toString != null)
             //{
             mdr.CallFrame callFrame = new mdr.CallFrame();
             callFrame.This     = (input);
             callFrame.Function = func;
             func.Call(ref callFrame);
             if (ValueTypesHelper.IsPrimitive(callFrame.Return.ValueType))
             {
                 output = callFrame.Return;
                 return(true);
             }
         }
     }
     output = new mdr.DValue();
     output.SetUndefined();
     return(false);
 }
Пример #2
0
 public static bool CallProperty(mdr.DObject input, string propName, out mdr.DValue output)
 {
   if (input != null)
   {
     var propDesc = input.GetPropertyDescriptor(propName);
     var prop = new mdr.DValue();
     propDesc.Get(input, ref prop);
     mdr.DFunction func = null;
     if (prop.ValueType == mdr.ValueTypes.Function)
     {
       func = prop.AsDFunction();
       //if (toString != null)
       //{
       mdr.CallFrame callFrame = new mdr.CallFrame();
       callFrame.This = (input);
       callFrame.Function = func;
       func.Call(ref callFrame);
       if (ValueTypesHelper.IsPrimitive(callFrame.Return.ValueType))
       {
         output = callFrame.Return;
         return true;
       }
     }
   }
   output = new mdr.DValue();
   output.SetUndefined();
   return false;
 }