Example #1
0
        public CacheController(Uri serviceUri, string scopeName, OfflineSyncProvider localProvider)
        {
            if (serviceUri == null)
            {
                throw new ArgumentNullException("serviceUri");
            }

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new ArgumentNullException("scopeName");
            }

            if (!serviceUri.Scheme.Equals("http", StringComparison.InvariantCultureIgnoreCase) &&
                !serviceUri.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new ArgumentException("Uri must be http or https schema", "serviceUri");
            }

            if (localProvider == null)
            {
                throw new ArgumentNullException("localProvider");
            }

            this._serviceUri = serviceUri;
            this._localProvider = localProvider;

            this._controllerBehavior = new CacheControllerBehavior();
            this._controllerBehavior.ScopeName = scopeName;
        }
Example #2
0
 public HttpCacheRequestHandler(Uri serviceUri, CacheControllerBehavior behaviors)
     : base(serviceUri, behaviors.ScopeName)
 {
     this._credentials = behaviors.Credentials;
     this._beforeRequestHandler = behaviors.BeforeSendingRequest;
     this._afterResponseHandler = behaviors.AfterReceivingResponse;
     this._knownTypes = new Type[behaviors.KnownTypes.Count];
     behaviors.KnownTypes.CopyTo(this._knownTypes, 0);
     this._scopeParameters = new Dictionary<string, string>(behaviors.ScopeParametersInternal);
 }
Example #3
0
        /// <summary>
        /// Creates the cache controller to sync with the context.
        /// </summary>
        private void CreateCacheController()
        {
            _cacheController = new CacheController(_scopeUri, _scopeName, this);

            CacheControllerBehavior behavior = _cacheController.ControllerBehavior;

            foreach (EntityType t in _schema.Collections)
            {
                behavior.AddType(t);
            }
        }
Example #4
0
 CacheRequestHandler CacheRequestFactory(Uri serviceUri, CacheControllerBehavior behaviors, AsyncWorkerManager manager)
 {
     if (OSVersion.Major < 7 || Settings.BackgoundLoadDisabled)
     {
         return(new HttpCacheRequestHandler(serviceUri, behaviors, manager));
     }
     else
     {
         return(new NSUrlCacheRequestHandler(serviceUri, behaviors, manager));
     }
 }
Example #5
0
        /// <summary>
        /// Creates the cache controller to sync with the c.
        /// </summary>
        private void CreateCacheController()
        {
            cacheController = new CacheController(scopeUri, scopeName, this);

            CacheControllerBehavior behavior = cacheController.ControllerBehavior;

            // Because the AddType is AddType<T>, need to create a generic method
            // for each type in the isolatedStorageSchema.  This will only be done once, so it's
            // not too expensive.
            Type       behaviorType = behavior.GetType();
            MethodInfo addType      = behaviorType.GetTypeInfo().GetDeclaredMethod("AddType");

            // Loop over each collection in the isolatedStorageSchema.
            foreach (Type t in schema.Collections)
            {
                // Create the generic method for the type.
                MethodInfo addTypeT = addType.MakeGenericMethod(t);

                // Invoke the created method.
                addTypeT.Invoke(behavior, new object[] { });
            }
        }
Example #6
0
 CacheRequestHandler CacheRequestFactory(Uri serviceUri, CacheControllerBehavior behaviors, AsyncWorkerManager manager)
 {
     return(new HttpCacheRequestHandler(serviceUri, behaviors, manager));
 }
Example #7
0
 /// <summary>
 /// Factory method for creating a cache handler. For labs only Http based implementation is provided.
 /// </summary>
 /// <param name="serviceUri">Base Uri to connect to</param>
 /// <param name="behaviors">The CacheControllerBehavior object</param>
 /// <returns>A CacheRequestHandler object</returns>
 public static CacheRequestHandler CreateRequestHandler(Uri serviceUri, CacheControllerBehavior behaviors)
 {
     // For labs its always Http
     return new HttpCacheRequestHandler(serviceUri, behaviors);
 }