private static Action <object, T> LazyReflectionInstanceSetter <T>(Func <Type> typeLoader, string fieldName) { var innerSetter = new SimpleLazy <Action <object, T> >(() => LazyReflectionInstanceSetter <T>(typeLoader(), fieldName)); Expression <Action <object, T> > setter = (obj, value) => innerSetter.Value(obj, value); return(setter.Compile()); }
private static Action <object, T> LazyReflectionInstanceSetter <T>(Type type, string fieldName) { var innerSetter = new SimpleLazy <Action <object, T> >(() => FieldOrPropertySetter <T>(type, fieldName)); Expression <Action <object, T> > setter = (obj, value) => innerSetter.Value(obj, value); return(setter.Compile()); }
public static Func <TObj, TField> LazyReflectionInstanceGetter <TObj, TField>(string fieldName) { var innerGetter = new SimpleLazy <Func <object, TField> >(() => LazyReflectionInstanceGetter <TField>(typeof(TObj), fieldName)); Expression <Func <TObj, TField> > getter = obj => innerGetter.Value(obj); return(getter.Compile()); }
private static Func <object, T> LazyReflectionInstanceGetter <T>(Func <Type> typeLoader, string fieldName) { var innerGetter = new SimpleLazy <Func <object, T> >(() => LazyReflectionInstanceGetter <T>(typeLoader(), fieldName)); Expression <Func <object, T> > getter = obj => innerGetter.Value(obj); return(getter.Compile()); }
public static Action <TObj, TField> LazyReflectionInstanceSetter <TObj, TField>(string fieldName) { var innerSetter = new SimpleLazy <Action <object, TField> >(() => LazyReflectionInstanceSetter <TField>(typeof(TObj), fieldName)); Expression <Action <TObj, TField> > setter = (obj, value) => innerSetter.Value(obj, value); return(setter.Compile()); }
private static Func <object, T> LazyReflectionInstanceGetter <T>(Type type, string fieldName) { Logger?.DebugLogDebug( $"{nameof(LazyReflectionGetter)}<{typeof(T).GetPrettyTypeName()}>({type.GetPrettyTypeName()}, {fieldName}"); var innerGetter = new SimpleLazy <Func <object, T> >(() => FieldOrPropertyGetter <T>(type, fieldName)); Expression <Func <object, T> > getter = obj => innerGetter.Value(obj); return(getter.Compile()); }
public static Func <T> LazyReflectionGetter <T>(Func <Type> typeLoader, Func <object> objLoader, string fieldName) { Logger.DebugLogDebug( $"{nameof(LazyReflectionGetter)}<{typeof(T).Name}>({typeLoader}, {objLoader}, {fieldName}"); var fieldInfo = new SimpleLazy <FieldInfo>(() => AccessTools.Field(typeLoader(), fieldName)); var instance = new SimpleLazy <object>(objLoader); return(() => (T)fieldInfo.Value?.GetValue(instance.Value)); }
public static Action <T> LazyReflectionSetter <T>(Func <Type> typeLoader, Func <object> objLoader, string fieldName) { Logger?.DebugLogDebug( $"{nameof(LazyReflectionSetter)}<{typeof(T).GetPrettyTypeName()}>({typeLoader}, {objLoader}, {fieldName})"); var innerSetter = new SimpleLazy <Action <object, T> >(() => LazyReflectionInstanceSetter <T>(typeLoader, fieldName)); var instance = new SimpleLazy <object>(objLoader); Expression <Action <T> > setter = value => innerSetter.Value(instance.Value, value); return(setter.Compile()); }
public static Action <T> LazyReflectionSetter <T>(SimpleLazy <Type> typeLoader, string fieldName) { return(LazyReflectionSetter <T>(() => typeLoader.Value, fieldName)); }
public static Action <T> LazyReflectionSetter <T>(SimpleLazy <object> instLoader, string fieldName) { return(LazyReflectionSetter <T>(() => instLoader.Value, fieldName)); }
public CoroutineHelper() { _coroutineStubHolderLoader = new SimpleLazy <GameObject>(InitHolder); _coroutineStubLoader = new SimpleLazy <CoroutineStub>(InitStub); }