/// <summary>
            /// Override to do custom comparison
            /// </summary>
            /// <param name="obj">The object to compare.</param>
            /// <returns><c>true</c> if they are equal.</returns>
            public override bool Equals(object obj)
            {
                OperationRoutingKey other = obj as OperationRoutingKey;

                Fx.Assert(other != null, "The 'obj' parameter should always be an OperationRoutingKey.");

                return(this.uriTemplate.IsEquivalentTo(other.uriTemplate) && this.method == other.method);
            }
        private static Dictionary <HttpMethod, UriTemplateTable> GenerateMethodSpecificTables(IEnumerable <HttpOperationDescription> operations, Uri baseAddress, out string catchAllOperationName)
        {
            Fx.Assert(operations != null, "The 'operations' parameter should not be null.");

            catchAllOperationName = string.Empty;
            Dictionary <HttpMethod, UriTemplateTable> methodSpecificTables = new Dictionary <HttpMethod, UriTemplateTable>();

            Dictionary <OperationRoutingKey, string> alreadyHaves = new Dictionary <OperationRoutingKey, string>();

            foreach (HttpOperationDescription operation in operations)
            {
                UriTemplate uriTemplate       = operation.GetUriTemplate();
                string      uriTemplateString = uriTemplate.ToString();
                HttpMethod  httpMethod        = operation.GetHttpMethod();

                if (uriTemplate.IsWildcardPath() && httpMethod.Method == WildcardMethod)
                {
                    if (catchAllOperationName != string.Empty)
                    {
                        throw Fx.Exception.AsError(
                                  new InvalidOperationException(
                                      Http.SR.MultipleOperationsWithSameMethodAndUriTemplate(uriTemplateString, httpMethod.Method)));
                    }

                    catchAllOperationName = operation.Name;
                }

                OperationRoutingKey operationKey = new OperationRoutingKey(uriTemplate, httpMethod);
                if (alreadyHaves.ContainsKey(operationKey))
                {
                    throw Fx.Exception.AsError(
                              new InvalidOperationException(
                                  Http.SR.MultipleOperationsWithSameMethodAndUriTemplate(uriTemplateString, httpMethod.Method)));
                }

                alreadyHaves.Add(operationKey, operation.Name);

                UriTemplateTable methodSpecificTable;
                if (!methodSpecificTables.TryGetValue(httpMethod, out methodSpecificTable))
                {
                    methodSpecificTable = new UriTemplateTable(baseAddress);
                    methodSpecificTables.Add(httpMethod, methodSpecificTable);
                }

                methodSpecificTable.KeyValuePairs.Add(new KeyValuePair <UriTemplate, object>(uriTemplate, operation.Name));
            }

            foreach (UriTemplateTable table in methodSpecificTables.Values)
            {
                table.MakeReadOnly(true);
            }

            return(methodSpecificTables);
        }