Пример #1
0
        public IDisposable SetTestHook(T testHook)
        {
            IDisposable result = new Hookable <T> .ResetTestHook(this, this.Value);

            this.Value = ((this.setTestHookNullRestoresDefaultValue && testHook == null) ? this.defaultValue : testHook);
            return(result);
        }
Пример #2
0
 internal IDisposable SetTestHook(ITraceTestHook testHook)
 {
     if (this.testHook == null)
     {
         this.testHook = Hookable <ITraceTestHook> .Create(false, null);
     }
     return(this.testHook.SetTestHook(testHook));
 }
Пример #3
0
        public static Hookable <T> Create(bool setTestHookNullRestoresDefaultValue, string fieldName, Type type)
        {
            FieldInfo field = ReflectionHelper.TraverseTypeHierarchy <FieldInfo, string>(type, fieldName, new MatchType <FieldInfo, string>(ReflectionHelper.MatchStaticField));

            return(Hookable <T> .Create(setTestHookNullRestoresDefaultValue, field, null));
        }
Пример #4
0
        public static Hookable <T> Create <TInstance>(bool setTestHookNullRestoresDefaultValue, string fieldName, TInstance instance)
        {
            FieldInfo field = ReflectionHelper.TraverseTypeHierarchy <FieldInfo, string>(typeof(TInstance), fieldName, new MatchType <FieldInfo, string>(ReflectionHelper.MatchInstanceField));

            return(Hookable <T> .Create(setTestHookNullRestoresDefaultValue, field, instance));
        }
Пример #5
0
 public ResetTestHook(Hookable <T> parent, T oldValue)
 {
     this.disposed = false;
     this.oldValue = oldValue;
     this.parent   = parent;
 }