/// <summary> /// This method processes a single SyncInterceptorAttribute defined on a method. Processing involves the following /// 1. Ensure that the MethodInfo signature is the right one for the interceptor. /// 2. Retrieve the ScopeNames defined in the attribute and ensure they are valid scopes configures via the /// ISyncScopeConfiguration.SetEnableScope() API. /// 3. Create a SyncInterceptorInfoWrapper object for the scope if none is present. /// 4. Add the interceptor to the wrapper object. /// </summary> /// <param name="attr">The SyncInterceptorAttribute to process.</param> /// <param name="syncServiceType">Actual SyncService type</param> /// <param name="methodInfo">User Method on which the attribute is applied</param> private void ProcessSyncInterceptor(SyncInterceptorAttribute attr, Type syncServiceType, MethodInfo methodInfo) { // Validate the method signature attribute WebUtil.ValidateInterceptorSignature(attr, methodInfo, syncServiceType.Name); // Read the list of scopeNames from the attribute string[] scopeNames = attr.ScopeName.Select(e => e.ToLowerInvariant()).ToArray(); foreach (string scopeName in scopeNames) { // Check to ensure the scopeName is valid configured scope. if (!this.ScopeNames.Contains(scopeName)) { // ScopeName is not part of configured scopes. Throw. throw new InvalidOperationException( string.Format(CultureInfo.InvariantCulture, "ScopeName '{0}' defined in '{1}' on method '{2}' is not in the list of configured sync scopes.", scopeName, attr.GetType().Name, methodInfo.Name)); } SyncInterceptorsInfoWrapper wrapper = null; // Check and create the wrapper object for the current scope if none exists. if (!this.SyncInterceptors.TryGetValue(scopeName, out wrapper)) { wrapper = new SyncInterceptorsInfoWrapper(scopeName); this.SyncInterceptors.Add(scopeName, wrapper); } // Add interceptor to the wrapper. wrapper.AddInterceptor(attr, methodInfo, syncServiceType.Name); } }