/// <summary> /// Creates a new SyncInterceptorAttribute for the specifed ScopeName and SyncOperations /// </summary> /// <param name="scopeNames">List of comma delimited sync scope names</param> /// <param name="operation">SyncOperations to which the interceptor applies.</param> public SyncInterceptorAttribute(string scopeNames, SyncOperations operation) { WebUtil.CheckArgumentNull(scopeNames, "scopeNames"); scopeNames = scopeNames.Trim(); if (scopeNames.Equals(string.Empty)) { throw new ArgumentException("scopeNames cannot be empty"); } this.ScopeName = scopeNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(e => e.Trim()).ToList().AsReadOnly(); // Ensure that the trimmer ones are not empty if (this.ScopeName.Count == 0) { throw new ArgumentException("No valid non empty scope names found. Please specify atleast one valid scopename.", scopeNames); } // Ensure there is no * scope specified. foreach (String s in this.ScopeName) { if (s.Equals("*")) { throw new ArgumentException("'*' is not a valid scopename parameter. Please specify the exact scopename.", scopeNames); } } this.Operation = operation; }
/// <summary> /// Creates a new SyncInterceptorAttribute for the specifed ScopeName and SyncOperations /// </summary> /// <param name="scopeNames">List of comma delimited sync scope names</param> /// <param name="operation">SyncOperations to which the interceptor applies.</param> public SyncInterceptorAttribute(string scopeNames, SyncOperations operation) { WebUtil.CheckArgumentNull(scopeNames, "scopeNames"); scopeNames = scopeNames.Trim(); if (scopeNames.Equals(string.Empty)) { throw new ArgumentException("scopeNames cannot be empty"); } this.ScopeName = scopeNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(e => e.Trim()).ToList().AsReadOnly(); // Ensure that the trimmer ones are not empty if (this.ScopeName.Count == 0) { throw new ArgumentException("No valid non empty scope names found. Please specify atleast one valid scopename.", scopeNames); } // Ensure there is no * scope specified. foreach (String s in this.ScopeName) { if (s.Equals("*")) { throw new ArgumentException("'*' is not a valid scopename parameter. Please specify the exact scopename.", scopeNames); } } this.Operation = operation; }
/// <summary> /// Checks to see if a typed SyncResponseInterceptor for a specific operation has been configured by the user /// </summary> /// <returns>bool</returns> internal bool HasTypedResponseInterceptor(string scopeName, SyncOperations operation, Type type) { SyncInterceptorsInfoWrapper wrapper = null; if (this.SyncInterceptors.TryGetValue(scopeName.ToLowerInvariant(), out wrapper)) { return(wrapper.HasResponseInterceptor(operation, type)); } return(false); }
/// <summary> /// Function that returns if any filtered response interceptors are configured /// </summary> /// <param name="operation">SyncOperations</param> /// <returns>bool</returns> internal bool HasTypedResponseInterceptors(SyncOperations operation) { switch (operation) { case SyncOperations.Download: return(_downloadTypedResponseInterceptors.Count > 0); case SyncOperations.Upload: return(_uploadTypedResponseInterceptors.Count > 0); } return(false); }
/// <summary> /// Utility function to check if a response interceptor for the specific type is configured /// </summary> /// <param name="operation">SyncOperations</param> /// <param name="type">Type requested</param> /// <returns>bool</returns> internal bool HasResponseInterceptor(SyncOperations operation, Type type) { switch (operation) { case SyncOperations.Download: return(this._downloadTypedResponseInterceptors.ContainsKey(type)); case SyncOperations.Upload: return(this._uploadTypedResponseInterceptors.ContainsKey(type)); } return(false); }
/// <summary> /// Utility function to check if a response interceptor is configured /// </summary> /// <param name="operation">SyncOperations</param> /// <returns>bool</returns> internal bool HasResponseInterceptor(SyncOperations operation) { switch (operation) { case SyncOperations.Download: return(this._downloadResponseInterceptor != null); case SyncOperations.Upload: return(this._uploadResponseInterceptor != null); } return(false); }
/// <summary> /// Returns the response interceptor MethodInfo for specific Type /// </summary> /// <param name="operation">SyncOperations</param> /// <param name="type">Type</param> /// <returns>MethodInfo</returns> internal MethodInfo GetResponseInterceptor(SyncOperations operation, Type type) { Debug.Assert(HasResponseInterceptor(operation, type), "No Typed response interceptors found for operation " + operation); if (!HasResponseInterceptor(operation, type)) { return(null); } switch (operation) { case SyncOperations.Download: return(this._downloadTypedResponseInterceptors[type]); case SyncOperations.Upload: return(this._uploadTypedResponseInterceptors[type]); } return(null); }
/// <summary> /// Checks to see if a typed SyncResponseInterceptor for a specific operation has been configured by the user /// </summary> /// <returns>bool</returns> internal bool HasTypedResponseInterceptor(string scopeName, SyncOperations operation, Type type) { SyncInterceptorsInfoWrapper wrapper = null; if (this.SyncInterceptors.TryGetValue(scopeName.ToLowerInvariant(), out wrapper)) { return wrapper.HasResponseInterceptor(operation, type); } return false; }
/// <summary> /// Creates a new SyncRequestInterceptorAttribute for the specifed ScopeName and SyncOperations to which the interceptor applies. /// </summary> /// <param name="scopeNames">List of comma delimited sync scope names</param> /// <param name="operation">SyncOperations to which the interceptor applies.</param> public SyncRequestInterceptorAttribute(string scopeNames, SyncOperations operation) : base(scopeNames, operation) { }
/// <summary> /// Function that returns if any filtered response interceptors are configured /// </summary> /// <param name="operation">SyncOperations</param> /// <returns>bool</returns> internal bool HasTypedResponseInterceptors(SyncOperations operation) { switch (operation) { case SyncOperations.Download: return _downloadTypedResponseInterceptors.Count > 0; case SyncOperations.Upload: return _uploadTypedResponseInterceptors.Count > 0; } return false; }
/// <summary> /// Returns the response interceptor MethodInfo for specific Type /// </summary> /// <param name="operation">SyncOperations</param> /// <param name="type">Type</param> /// <returns>MethodInfo</returns> internal MethodInfo GetResponseInterceptor(SyncOperations operation, Type type) { Debug.Assert(HasResponseInterceptor(operation, type), "No Typed response interceptors found for operation " + operation); if (!HasResponseInterceptor(operation, type)) { return null; } switch (operation) { case SyncOperations.Download: return this._downloadTypedResponseInterceptors[type]; case SyncOperations.Upload: return this._uploadTypedResponseInterceptors[type]; } return null; }
/// <summary> /// Utility function to check if a response interceptor for the specific type is configured /// </summary> /// <param name="operation">SyncOperations</param> /// <param name="type">Type requested</param> /// <returns>bool</returns> internal bool HasResponseInterceptor(SyncOperations operation, Type type) { switch (operation) { case SyncOperations.Download: return this._downloadTypedResponseInterceptors.ContainsKey(type); case SyncOperations.Upload: return this._uploadTypedResponseInterceptors.ContainsKey(type); } return false; }
/// <summary> /// Utility function to check if a response interceptor is configured /// </summary> /// <param name="operation">SyncOperations</param> /// <returns>bool</returns> internal bool HasResponseInterceptor(SyncOperations operation) { switch (operation) { case SyncOperations.Download: return this._downloadResponseInterceptor != null; case SyncOperations.Upload: return this._uploadResponseInterceptor != null; } return false; }
/// <summary> /// Creates a new SyncInterceptorAttribute for the specifed ScopeName and SyncOperations to which the interceptor applies. /// </summary> /// <param name="scopeNames">List of comma delimited sync scope names</param> /// <param name="operation">SyncOperations to which the interceptor applies.</param> public SyncResponseInterceptorAttribute(string scopeNames, SyncOperations operation) : base(scopeNames, operation) { }
/// <inheritdoc /> public IEnumerable <ISessionSyncOperation> GetSession() => SyncOperations .Where(x => x.GetType().GetInterfaces().Any(i => i == typeof(ISessionSyncOperation))) .Cast <ISessionSyncOperation>();