Example #1
0
 public void Init()
 {
     this.nancyContext = new NancyContext();
     this.nancyContext.Request = new Request("Get", "http://test");
     this.serializationContextProvider =
         new ClientSerializationContextProvider(new ClientTypeMapper(Assembly.GetExecutingAssembly()), Client, Client);
     this.serializerFactory = new PomonaJsonSerializerFactory();
 }
Example #2
0
 public void Init()
 {
     this.nancyContext                 = new NancyContext();
     this.nancyContext.Request         = new Request("Get", "http://test");
     this.serializationContextProvider =
         new ClientSerializationContextProvider(new ClientTypeMapper(Assembly.GetExecutingAssembly()), Client, Client);
     this.serializerFactory = new PomonaJsonSerializerFactory();
 }
Example #3
0
 public ServersStorage(ILogger logger, ITextSerializerFactory serializerFactory, string filePath)
 {
     _origin =
         new CollectionStorage <T>(
             new SafeStorage <IEnumerable <T> >(
                 new LoggingStorage <IEnumerable <T> >(
                     logger,
                     new FileStorage <IEnumerable <T> >(serializerFactory, filePath))));
 }
Example #4
0
 public StreamingServicesStorage(ILogger logger, ITextSerializerFactory serializers, Common.Configuration.Config config)
 {
     _storage = new SafeStorage <StreamingServicesResponse>(
         new LoggingStorage <StreamingServicesResponse>(
             logger,
             new FileStorage <StreamingServicesResponse>(
                 serializers,
                 config.StreamingServicesFilePath)));
 }
Example #5
0
 public SettingsStorage(ILogger logger, ITextSerializerFactory serializers, Common.Configuration.Config config)
 {
     _origin =
         new SafeStorage <SettingsContract>(
             new LoggingStorage <SettingsContract>(
                 logger,
                 new FileStorage <SettingsContract>(
                     serializers,
                     config.ServiceSettingsFilePath)));
 }
Example #6
0
 public ServerCache(ILogger logger, ITextSerializerFactory serializerFactory, Config config)
 {
     _origin =
         new CollectionStorage <LogicalServerContract>(
             new SafeStorage <IEnumerable <LogicalServerContract> >(
                 new LoggingStorage <IEnumerable <LogicalServerContract> >(
                     logger,
                     new FileStorage <IEnumerable <LogicalServerContract> >(
                         serializerFactory,
                         config.ServersJsonCacheFilePath))));
 }
Example #7
0
        public FileStorage(ITextSerializerFactory serializerFactory, string fileName)
        {
            Ensure.NotNull(serializerFactory, nameof(serializerFactory));
            Ensure.NotEmpty(fileName, nameof(fileName));

            _serializer = serializerFactory.Serializer <T>();

            Ensure.IsTrue(_serializer is IThrowsExpectedExceptions,
                          $"{nameof(serializerFactory)}.{nameof(ITextSerializerFactory.Serializer)} must implement {nameof(IThrowsExpectedExceptions)} interface");

            _fileName = fileName;
        }
Example #8
0
 public RequestDispatcher(ClientTypeMapper typeMapper,
                          IWebClient webClient,
                          ITextSerializerFactory serializerFactory,
                          IEnumerable<KeyValuePair<string, IEnumerable<string>>> defaultHeaders = null)
 {
     this.defaultHeaders = defaultHeaders;
     if (typeMapper != null)
         this.typeMapper = typeMapper;
     if (webClient != null)
         WebClient = webClient;
     if (serializerFactory != null)
         this.serializerFactory = serializerFactory;
 }
Example #9
0
        public void TestInitialize()
        {
            _serializer = Substitute.For <ITextSerializer <int>, IThrowsExpectedExceptions>();
            _serializer
            .Deserialize(Arg.Any <TextReader>())
            .Returns(args => int.Parse(args.Arg <TextReader>().ReadToEnd()));
            _serializer
            .When(x => x.Serialize(Arg.Any <int>(), Arg.Any <TextWriter>()))
            .Do(args => args.Arg <TextWriter>().Write(args.Arg <int>().ToString()));

            _serializerFactory = Substitute.For <ITextSerializerFactory>();
            _serializerFactory.Serializer <int>().Returns(_serializer);
        }
Example #10
0
 public PomonaRequest(PathNode node,
     NancyContext context,
     ITextSerializerFactory serializerFactory)
 {
     if (node == null)
         throw new ArgumentNullException("node");
     if (context == null)
         throw new ArgumentNullException("context");
     if (serializerFactory == null)
         throw new ArgumentNullException("serializerFactory");
     this.node = node;
     this.context = context;
     this.serializerFactory = serializerFactory;
     this.method = (HttpMethod)Enum.Parse(typeof(HttpMethod), context.Request.Method, true);
 }
Example #11
0
 public RequestDispatcher(ClientTypeMapper typeMapper,
                          IWebClient webClient,
                          ITextSerializerFactory serializerFactory,
                          IEnumerable <KeyValuePair <string, IEnumerable <string> > > defaultHeaders = null)
 {
     this.defaultHeaders = defaultHeaders;
     if (typeMapper != null)
     {
         this.typeMapper = typeMapper;
     }
     if (webClient != null)
     {
         WebClient = webClient;
     }
     if (serializerFactory != null)
     {
         this.serializerFactory = serializerFactory;
     }
 }