示例#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;
 }