Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceMigrator"/> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 public ResourceMigrator(IServerConnection source, IServerConnection target)
 {
     Check.ArgumentNotNull(source, nameof(source));
     Check.ArgumentNotNull(target, nameof(target));
     _source    = source;
     _target    = target;
     _converter = new ResourceObjectConverter();
 }
        private void AddResourceConverter <T>(IResourceConverter <T> resourceConverter)
        {
            if (_resourceConverters.Keys.Contains(typeof(T)))
            {
                throw new Exception(string.Format("ResourceConverter with type {0} was added", typeof(T)));
            }
            var objectConverter = resourceConverter as IResourceConverter <object>;

            if (objectConverter == null)
            {
                throw new Exception("ResourceConverter doesn't implement IResourceConverter<object> interface");
            }
            _resourceConverters.Add(typeof(T), objectConverter);
        }
        internal DefaultDataStore(IClient client, IRequestExecutor requestExecutor, string baseUrl, IJsonSerializer serializer, ILogger logger, IUserAgentBuilder userAgentBuilder, ICacheProvider cacheProvider, TimeSpan identityMapExpiration)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (requestExecutor == null)
            {
                throw new ArgumentNullException(nameof(requestExecutor));
            }

            if (string.IsNullOrEmpty(baseUrl))
            {
                throw new ArgumentNullException(nameof(baseUrl));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (cacheProvider == null)
            {
                throw new ArgumentNullException(nameof(cacheProvider), "Use NullCacheProvider if you wish to turn off caching.");
            }

            this.baseUrl          = baseUrl;
            this.logger           = logger;
            this.requestExecutor  = requestExecutor;
            this.cacheProvider    = cacheProvider;
            this.cacheResolver    = new DefaultCacheResolver(cacheProvider, this.logger);
            this.userAgentBuilder = userAgentBuilder;

            this.client            = client;
            this.serializer        = new JsonSerializationProvider(serializer);
            this.identityMap       = new MemoryCacheIdentityMap <ResourceData>(identityMapExpiration, this.logger);
            this.resourceFactory   = new DefaultResourceFactory(this, this.identityMap);
            this.resourceConverter = new DefaultResourceConverter();

            this.uriQualifier = new UriQualifier(baseUrl);

            this.defaultAsyncFilters = this.BuildDefaultAsyncFilterChain();
            this.defaultSyncFilters  = this.BuildDefaultSyncFilterChain();
        }
 public CollectionReturningHttpClient(string baseUrl, IEnumerable <T> items)
     : base(baseUrl)
 {
     this.resourceConverter = new DefaultResourceConverter();
     this.items             = items.ToList();
 }
 public override void Initialize(string name, NameValueCollection config)
 {
     Converter = new ResourceConverter();
     base.Initialize(name, config);
 }
 public DlgResourceBuilder(IGenericStructConverter genericStructConverter, IResourceConverter resourceConverter)
 {
     _genericStructConverter = genericStructConverter;
     _resourceConverter = resourceConverter;
 }
 public KeyResourceBuilder(IGenericStructConverter genericStructConverter, IResourceConverter resourceConverter, IStructGenerator structGenerator)
 {
     _genericStructConverter = genericStructConverter;
     _resourceConverter = resourceConverter;
     _structGenerator = structGenerator;
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceMigrator"/> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="target">The target.</param>
 public ResourceMigrator(IServerConnection source, IServerConnection target)
 {
     Check.NotNull(source, "source"); //NOXLATE
     Check.NotNull(target, "target"); //NOXLATE
     _source = source;
     _target = target;
     _converter = new ResourceObjectConverter();
 }
Example #9
0
 //------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------
 public void RemoveConverter(IResourceConverter converter)
 {
     this._converters.Remove(converter.TypeHandled);
 }
Example #10
0
 //------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------
 public void AddConverter(IResourceConverter converter)
 {
     this._converters[converter.TypeHandled] = converter;
 }