예제 #1
0
        public static ILogger GetFileLogger(string path)
        {
            var logger = StoreLogger.New(NaturalInMemoryStore.New().Polls());

            logger.Store.GetPoll().SetBackgroundAction(LogicOf <IStore> .New((store) =>
            {
                var dat = StoreSerializer.SerializeStore(store, ValueManagerChainOfResponsibility.NewDefault());
                Debug.WriteLine(dat);
                dat.MakeStringable().Fileable().Filing(path).Write();
            }), 100);
            return(logger);
        }
        public IStore Send(IStore request)
        {
            //encode the store to send over the wire
            var requestText = StoreSerializer.SerializeStore(request, this.ValueManager);

            //send it
            var respData = this.Decorated.Send(requestText);

            //decode the response store
            var responseStore = StoreSerializer.DeserializeStore(respData, this.ValueManager);

            return(responseStore);
        }
        private string HandleStoreProtocolRequest(string request)
        {
            //decode the request store
            var requestStore = StoreSerializer.DeserializeStore(request, this.ValueManager);

            Condition.Requires(requestStore).IsNotNull();

            var responseStore          = NaturalInMemoryStore.New();
            Tuple <IStore, IStore> uow = new Tuple <IStore, IStore>(requestStore, responseStore);

            this.StoreProtocolLogic.Perform(uow);

            //encode the response
            var responseText = StoreSerializer.SerializeStore(uow.Item2, this.ValueManager);

            return(responseText);
        }
예제 #4
0
        public static void RunTest(this ITestable testable)
        {
            Condition.Requires(testable).IsNotNull();

            var    tests            = testable.GetTests();
            var    testStore        = testable.GenerateTestInput();
            IStore testResultsStore = NaturalInMemoryStore.New();

            tests.HandleOperations(testStore, testResultsStore);

            var errors = tests.GetErrors(testResultsStore);

            if (errors != null && errors.Count > 0)
            {
                //output the stores
                testResultsStore.JoinStore(testStore);
                var dump = StoreSerializer.SerializeStore(testResultsStore, ValueManagerChainOfResponsibility.NewDefault());
                Debug.WriteLine(dump);
                throw new InvalidOperationException("test failure");
            }
        }
예제 #5
0
 /// <summary>
 /// use this ctor when creating a disconnected store from existing encoded/disconnected data
 /// </summary>
 /// <param name="storeData"></param>
 /// <param name="storeDecodingStrategy"></param>
 public DisconnectedStore(string storeData, Func <string, string> storeDecodingStrategy)
 {
     Condition.Requires(storeData).IsNotNullOrEmpty();
     this._data  = storeData;
     this._store = StoreSerializer.DecodeAndDeserializeStoreData(this._data, storeDecodingStrategy);
 }
예제 #6
0
 /// <summary>
 /// use this ctor when creating a disconnected store from an existing store
 /// </summary>
 /// <param name="store"></param>
 /// <param name="storeEncodingStrategy"></param>
 /// <param name="storeDecodingStrategy"></param>
 public DisconnectedStore(IStore store, Func <string, string> storeEncodingStrategy)
 {
     Condition.Requires(store).IsNotNull();
     this._data  = StoreSerializer.SerializeAndEncodeStoreData(store, storeEncodingStrategy);
     this._store = store;
 }