Exemple #1
0
 public ClrFieldBindingTargetInfo(FieldInfo field, object instance)
     : base(field.Name, ClrTargetType.Field)
 {
     Field = field;
       Instance = instance;
       _binding = new Binding(this);
       _binding.GetValueRef = GetPropertyValue;
       _binding.SetValueRef = SetPropertyValue;
 }
 //Executed only once, on the first call
 protected override object DoEvaluate(ScriptThread thread)
 {
     thread.CurrentNode = this;  //standard prolog
       _accessor = thread.Bind(Symbol, BindingRequestFlags.Read);
       this.Evaluate = _accessor.GetValueRef; // Optimization - directly set method ref to accessor's method. EvaluateReader;
       var result = this.Evaluate(thread);
       thread.CurrentNode = Parent; //standard epilog
       return result;
 }
 public override void DoSetValue(ScriptThread thread, object value)
 {
     thread.CurrentNode = this;  //standard prolog
       if (_accessor == null) {
     _accessor = thread.Bind(Symbol, BindingRequestFlags.Write | BindingRequestFlags.ExistingOrNew);
       }
       _accessor.SetValueRef(thread, value);
       thread.CurrentNode = Parent;  //standard epilog
 }
 public ClrMethodBindingTargetInfo(Type declaringType, string methodName, object instance = null) : base(methodName,  ClrTargetType.Method) {
   DeclaringType = declaringType;
   Instance = instance;
   _invokeFlags = BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic;
   if (Instance == null)
     _invokeFlags |= BindingFlags.Static;
   else
     _invokeFlags |= BindingFlags.Instance;
   _binding = new ConstantBinding(target: this as ICallTarget, targetInfo: this); 
     //The object works as CallTarget itself; the "as" conversion is not needed in fact, we do it just to underline the role
 }
 public ClrPropertyBindingTargetInfo(PropertyInfo property, object instance) : base(property.Name, ClrTargetType.Property) {
   Property = property;
   Instance = instance;
   _binding = new Binding(this);
   _binding.GetValueRef = GetPropertyValue;
   _binding.SetValueRef = SetPropertyValue;
 }
 public BuiltInCallableTargetInfo(BuiltInCallTarget target)  : base(target.Name, BindingTargetType.BuiltInObject) {
   BindingInstance = new ConstantBinding(target, this); 
 }