Example #1
0
 internal DynamicInstance(IObjectVisitor <T> visitor)
 {
     _visitor = visitor ?? throw new ArgumentNullException(nameof(visitor));
     _gettingMemberHandler = Try.CreateFuture <string, object>(name => _visitor.GetValue(name));
     _settingMemberHandler = Try.Future <string, object>((name, val) => _visitor.SetValue(name, val));
     _lazyObjectGetter     = new Lazy <IObjectGetter <T> >(() => ObjectGetter.Type <T>(_visitor.AlgorithmKind).Instance(_visitor.Instance));
     _lazyObjectSetter     = new Lazy <IObjectSetter <T> >(() => ObjectSetter.Type <T>(_visitor.AlgorithmKind).Instance(_visitor.Instance));
 }
Example #2
0
 public object GetValue(string propertyName, BindingFlags bindingAttr)
 {
     return(ObjectGetter.Type(_type).Instance(null).GetValue(propertyName));
 }
Example #3
0
 public object GetValue(string propertyName)
 {
     return(ObjectGetter.Type(_type).Instance(null).GetValue(propertyName));
 }
 /// <summary>
 /// Invoke <br />
 /// 调用
 /// </summary>
 /// <param name="type"></param>
 /// <param name="that"></param>
 /// <param name="propertyName"></param>
 /// <param name="bindingAttr"></param>
 /// <returns></returns>
 public object Invoke(Type type, object that, string propertyName, BindingFlags bindingAttr)
 {
     return(ObjectGetter.Type(type).Instance(that).GetValue(propertyName));
 }