private IEnumerable<string> FindInterceptorRefNames(InterceptMethodElement interceptMethodElement)
 {
     if (interceptMethodElement == null)
         return null;
     if (interceptMethodElement.InterceptorRefs == null)
         return null;
     List<string> ret = new List<string>();
     foreach (InterceptorRefElement interceptorRefElement in interceptMethodElement.InterceptorRefs)
     {
         ret.Add(interceptorRefElement.Name);
     }
     return ret;
 }
 /// <summary>
 /// Adds an interception reference to the specified contract and the method.
 /// </summary>
 /// <param name="contractType">The type of the contract.</param>
 /// <param name="method">The method.</param>
 /// <param name="name">The name of the interception reference.</param>
 public void AddInterceptorRef(Type contractType, MethodInfo method, string name)
 {
     if (this.config.Interception != null)
     {
         if (this.config.Interception.Contracts != null)
         {
             foreach (InterceptContractElement interceptContract in this.config.Interception.Contracts)
             {
                 if (interceptContract.Type.Equals(contractType.AssemblyQualifiedName))
                 {
                     if (interceptContract.Methods != null)
                     {
                         foreach (InterceptMethodElement interceptMethod in interceptContract.Methods)
                         {
                             if (interceptMethod.Signature.Equals(method.GetSignature()))
                             {
                                 if (interceptMethod.InterceptorRefs != null)
                                 {
                                     foreach (InterceptorRefElement interceptorRef in interceptMethod.InterceptorRefs)
                                     {
                                         if (interceptorRef.Name.Equals(name))
                                             return;
                                     }
                                     interceptMethod.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
                                 }
                                 else
                                 {
                                     interceptMethod.InterceptorRefs = new InterceptorRefElementCollection();
                                     interceptMethod.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
                                 }
                                 return;
                             }
                         }
                         InterceptMethodElement interceptMethodAdd = new InterceptMethodElement();
                         interceptMethodAdd.Signature = method.GetSignature();
                         interceptMethodAdd.InterceptorRefs = new InterceptorRefElementCollection();
                         interceptMethodAdd.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
                         interceptContract.Methods.Add(interceptMethodAdd);
                     }
                     else
                     {
                         interceptContract.Methods = new InterceptMethodElementCollection();
                         InterceptMethodElement interceptMethodAdd = new InterceptMethodElement();
                         interceptMethodAdd.Signature = method.GetSignature();
                         interceptMethodAdd.InterceptorRefs = new InterceptorRefElementCollection();
                         interceptMethodAdd.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
                         interceptContract.Methods.Add(interceptMethodAdd);
                     }
                     return;
                 }
             }
             InterceptContractElement interceptContractAdd = new InterceptContractElement();
             interceptContractAdd.Type = contractType.AssemblyQualifiedName;
             interceptContractAdd.Methods = new InterceptMethodElementCollection();
             InterceptMethodElement interceptMethodAddToContract = new InterceptMethodElement();
             interceptMethodAddToContract.Signature = method.GetSignature();
             interceptMethodAddToContract.InterceptorRefs = new InterceptorRefElementCollection();
             interceptMethodAddToContract.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
             interceptContractAdd.Methods.Add(interceptMethodAddToContract);
             this.config.Interception.Contracts.Add(interceptContractAdd);
         }
         else
         {
             this.config.Interception.Contracts = new InterceptContractElementCollection();
             InterceptContractElement interceptContractAdd = new InterceptContractElement();
             interceptContractAdd.Type = contractType.AssemblyQualifiedName;
             interceptContractAdd.Methods = new InterceptMethodElementCollection();
             InterceptMethodElement interceptMethodAddToContract = new InterceptMethodElement();
             interceptMethodAddToContract.Signature = method.GetSignature();
             interceptMethodAddToContract.InterceptorRefs = new InterceptorRefElementCollection();
             interceptMethodAddToContract.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
             interceptContractAdd.Methods.Add(interceptMethodAddToContract);
             this.config.Interception.Contracts.Add(interceptContractAdd);
         }
     }
     else
     {
         this.config.Interception = new InterceptionElement();
         this.config.Interception.Contracts = new InterceptContractElementCollection();
         InterceptContractElement interceptContractAdd = new InterceptContractElement();
         interceptContractAdd.Type = contractType.AssemblyQualifiedName;
         interceptContractAdd.Methods = new InterceptMethodElementCollection();
         InterceptMethodElement interceptMethodAddToContract = new InterceptMethodElement();
         interceptMethodAddToContract.Signature = method.GetSignature();
         interceptMethodAddToContract.InterceptorRefs = new InterceptorRefElementCollection();
         interceptMethodAddToContract.InterceptorRefs.Add(new InterceptorRefElement { Name = name });
         interceptContractAdd.Methods.Add(interceptMethodAddToContract);
         this.config.Interception.Contracts.Add(interceptContractAdd);
     }
 }