예제 #1
0
        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());
        }
예제 #2
0
        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());
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }
예제 #5
0
        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());
        }
예제 #6
0
        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());
        }
예제 #7
0
        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));
        }
예제 #8
0
        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());
        }
예제 #9
0
 public static Action <T> LazyReflectionSetter <T>(SimpleLazy <Type> typeLoader, string fieldName)
 {
     return(LazyReflectionSetter <T>(() => typeLoader.Value, fieldName));
 }
예제 #10
0
 public static Action <T> LazyReflectionSetter <T>(SimpleLazy <object> instLoader, string fieldName)
 {
     return(LazyReflectionSetter <T>(() => instLoader.Value, fieldName));
 }
예제 #11
0
 public CoroutineHelper()
 {
     _coroutineStubHolderLoader = new SimpleLazy <GameObject>(InitHolder);
     _coroutineStubLoader       = new SimpleLazy <CoroutineStub>(InitStub);
 }