internal override bool Initialize() { string name = base.Request.PathInfo.Substring(1); this.serverType = (HttpServerType) base.GetFromCache(typeof(HttpServerProtocol), base.Type); if (this.serverType == null) { lock (ServerProtocol.InternalSyncObject) { this.serverType = (HttpServerType) base.GetFromCache(typeof(HttpServerProtocol), base.Type); if (this.serverType == null) { this.serverType = new HttpServerType(base.Type); base.AddToCache(typeof(HttpServerProtocol), base.Type, this.serverType); } } } this.serverMethod = this.serverType.GetMethod(name); if (this.serverMethod == null) { this.serverMethod = this.serverType.GetMethodIgnoreCase(name); if (this.serverMethod != null) { throw new ArgumentException(Res.GetString("WebInvalidMethodNameCase", new object[] { name, this.serverMethod.name }), "methodName"); } string str2 = Encoding.UTF8.GetString(Encoding.Default.GetBytes(name)); this.serverMethod = this.serverType.GetMethod(str2); if (this.serverMethod == null) { throw new InvalidOperationException(Res.GetString("WebInvalidMethodName", new object[] { name })); } } return true; }
internal override bool Initialize() { string name = base.Request.PathInfo.Substring(1); this.serverType = (HttpServerType)base.GetFromCache(typeof(HttpServerProtocol), base.Type); if (this.serverType == null) { lock (ServerProtocol.InternalSyncObject) { this.serverType = (HttpServerType)base.GetFromCache(typeof(HttpServerProtocol), base.Type); if (this.serverType == null) { this.serverType = new HttpServerType(base.Type); base.AddToCache(typeof(HttpServerProtocol), base.Type, this.serverType); } } } this.serverMethod = this.serverType.GetMethod(name); if (this.serverMethod == null) { this.serverMethod = this.serverType.GetMethodIgnoreCase(name); if (this.serverMethod != null) { throw new ArgumentException(Res.GetString("WebInvalidMethodNameCase", new object[] { name, this.serverMethod.name }), "methodName"); } string str2 = Encoding.UTF8.GetString(Encoding.Default.GetBytes(name)); this.serverMethod = this.serverType.GetMethod(str2); if (this.serverMethod == null) { throw new InvalidOperationException(Res.GetString("WebInvalidMethodName", new object[] { name })); } } return(true); }
internal HttpServerMethod GetMethodIgnoreCase(string name) { foreach (DictionaryEntry entry in this.methods) { HttpServerMethod method = (HttpServerMethod)entry.Value; if (string.Compare(method.name, name, StringComparison.OrdinalIgnoreCase) == 0) { return(method); } } return(null); }
internal HttpServerMethod GetMethodIgnoreCase(string name) { foreach (DictionaryEntry entry in methods) { HttpServerMethod method = (HttpServerMethod)entry.Value; if (String.Compare(method.name, name, true, CultureInfo.InvariantCulture) == 0) { return(method); } } return(null); }
internal override bool Initialize() { // The derived class better check the verb! string methodName = Request.PathInfo.Substring(1); // Skip leading '/' if (null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type)) && null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type, true))) { lock (InternalSyncObject) { if (null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type)) && null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type, true))) { bool excludeSchemeHostPortFromCachingKey = this.IsCacheUnderPressure(typeof(HttpServerProtocol), Type); serverType = new HttpServerType(Type); AddToCache(typeof(HttpServerProtocol), Type, serverType, excludeSchemeHostPortFromCachingKey); } } } serverMethod = serverType.GetMethod(methodName); if (serverMethod == null) { serverMethod = serverType.GetMethodIgnoreCase(methodName); if (serverMethod != null) { throw new ArgumentException(Res.GetString(Res.WebInvalidMethodNameCase, methodName, serverMethod.name), "methodName"); } else { // it's possible that the method name came in as UTF-8 but was mangled by IIS so we try it // again as UTF8... string utf8MethodName = Encoding.UTF8.GetString(Encoding.Default.GetBytes(methodName)); serverMethod = serverType.GetMethod(utf8MethodName); if (serverMethod == null) { throw new InvalidOperationException(Res.GetString(Res.WebInvalidMethodName, methodName)); } } } return(true); }
internal HttpServerType(Type type) : base(type) { this.methods = new Hashtable(); WebServicesSection current = WebServicesSection.Current; Type[] returnWriterTypes = current.ReturnWriterTypes; Type[] parameterReaderTypes = current.ParameterReaderTypes; LogicalMethodInfo[] methods = WebMethodReflector.GetMethods(type); HttpServerMethod[] methodArray = new HttpServerMethod[methods.Length]; object[] objArray = new object[returnWriterTypes.Length]; for (int i = 0; i < objArray.Length; i++) { objArray[i] = MimeFormatter.GetInitializers(returnWriterTypes[i], methods); } for (int j = 0; j < methods.Length; j++) { LogicalMethodInfo info = methods[j]; HttpServerMethod method = null; if (info.ReturnType == typeof(void)) { method = new HttpServerMethod(); } else { for (int num3 = 0; num3 < returnWriterTypes.Length; num3++) { object[] objArray2 = (object[]) objArray[num3]; if (objArray2[j] != null) { method = new HttpServerMethod { writerInitializer = objArray2[j], writerType = returnWriterTypes[num3] }; break; } } } if (method != null) { method.methodInfo = info; methodArray[j] = method; } } objArray = new object[parameterReaderTypes.Length]; for (int k = 0; k < objArray.Length; k++) { objArray[k] = MimeFormatter.GetInitializers(parameterReaderTypes[k], methods); } for (int m = 0; m < methods.Length; m++) { HttpServerMethod method2 = methodArray[m]; if (method2 != null) { LogicalMethodInfo info2 = methods[m]; if (info2.InParameters.Length > 0) { int index = 0; for (int num7 = 0; num7 < parameterReaderTypes.Length; num7++) { object[] objArray3 = (object[]) objArray[num7]; if (objArray3[m] != null) { index++; } } if (index == 0) { methodArray[m] = null; } else { method2.readerTypes = new Type[index]; method2.readerInitializers = new object[index]; index = 0; for (int num8 = 0; num8 < parameterReaderTypes.Length; num8++) { object[] objArray4 = (object[]) objArray[num8]; if (objArray4[m] != null) { method2.readerTypes[index] = parameterReaderTypes[num8]; method2.readerInitializers[index] = objArray4[m]; index++; } } } } } } for (int n = 0; n < methodArray.Length; n++) { HttpServerMethod method3 = methodArray[n]; if (method3 != null) { WebMethodAttribute methodAttribute = method3.methodInfo.MethodAttribute; method3.name = methodAttribute.MessageName; if (method3.name.Length == 0) { method3.name = method3.methodInfo.Name; } this.methods.Add(method3.name, method3); } } }
internal HttpServerType(Type type) : base(type) { WebServicesSection config = WebServicesSection.Current; Type[] returnWriterTypes = config.ReturnWriterTypes; Type[] parameterReaderTypes = config.ParameterReaderTypes; LogicalMethodInfo[] methodInfos = WebMethodReflector.GetMethods(type); HttpServerMethod[] methods = new HttpServerMethod[methodInfos.Length]; object[] initializersByType = new object[returnWriterTypes.Length]; for (int i = 0; i < initializersByType.Length; i++) { initializersByType[i] = MimeFormatter.GetInitializers(returnWriterTypes[i], methodInfos); } for (int i = 0; i < methodInfos.Length; i++) { LogicalMethodInfo methodInfo = methodInfos[i]; HttpServerMethod method = null; if (methodInfo.ReturnType == typeof(void)) { method = new HttpServerMethod(); } else { for (int j = 0; j < returnWriterTypes.Length; j++) { object[] initializers = (object[])initializersByType[j]; if (initializers[i] != null) { method = new HttpServerMethod(); method.writerInitializer = initializers[i]; method.writerType = returnWriterTypes[j]; break; } } } if (method != null) { method.methodInfo = methodInfo; methods[i] = method; } } initializersByType = new object[parameterReaderTypes.Length]; for (int i = 0; i < initializersByType.Length; i++) { initializersByType[i] = MimeFormatter.GetInitializers(parameterReaderTypes[i], methodInfos); } for (int i = 0; i < methodInfos.Length; i++) { HttpServerMethod method = methods[i]; if (method == null) continue; LogicalMethodInfo methodInfo = methodInfos[i]; if (methodInfo.InParameters.Length > 0) { int count = 0; for (int j = 0; j < parameterReaderTypes.Length; j++) { object[] initializers = (object[])initializersByType[j]; if (initializers[i] != null) { count++; } } if (count == 0) { methods[i] = null; } else { method.readerTypes = new Type[count]; method.readerInitializers = new object[count]; count = 0; for (int j = 0; j < parameterReaderTypes.Length; j++) { object[] initializers = (object[])initializersByType[j]; if (initializers[i] != null) { method.readerTypes[count] = parameterReaderTypes[j]; method.readerInitializers[count] = initializers[i]; count++; } } } } } for (int i = 0; i < methods.Length; i++) { HttpServerMethod method = methods[i]; if (method != null) { WebMethodAttribute methodAttribute = method.methodInfo.MethodAttribute; method.name = methodAttribute.MessageName; if (method.name.Length == 0) method.name = method.methodInfo.Name; this.methods.Add(method.name, method); } } }
internal override bool Initialize() { // The derived class better check the verb! string methodName = Request.PathInfo.Substring(1); // Skip leading '/' if (null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type)) && null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type, true))) { lock (InternalSyncObject) { if (null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type)) && null == (serverType = (HttpServerType)GetFromCache(typeof(HttpServerProtocol), Type, true))) { bool excludeSchemeHostPortFromCachingKey = this.IsCacheUnderPressure(typeof(HttpServerProtocol), Type); serverType = new HttpServerType(Type); AddToCache(typeof(HttpServerProtocol), Type, serverType, excludeSchemeHostPortFromCachingKey); } } } serverMethod = serverType.GetMethod(methodName); if (serverMethod == null) { serverMethod = serverType.GetMethodIgnoreCase(methodName); if (serverMethod != null) throw new ArgumentException(Res.GetString(Res.WebInvalidMethodNameCase, methodName, serverMethod.name), "methodName"); else { // it's possible that the method name came in as UTF-8 but was mangled by IIS so we try it // again as UTF8... string utf8MethodName = Encoding.UTF8.GetString(Encoding.Default.GetBytes(methodName)); serverMethod = serverType.GetMethod(utf8MethodName); if (serverMethod == null) throw new InvalidOperationException(Res.GetString(Res.WebInvalidMethodName, methodName)); } } return true; }
internal HttpServerType(Type type) : base(type) { this.methods = new Hashtable(); WebServicesSection current = WebServicesSection.Current; Type[] returnWriterTypes = current.ReturnWriterTypes; Type[] parameterReaderTypes = current.ParameterReaderTypes; LogicalMethodInfo[] methods = WebMethodReflector.GetMethods(type); HttpServerMethod[] methodArray = new HttpServerMethod[methods.Length]; object[] objArray = new object[returnWriterTypes.Length]; for (int i = 0; i < objArray.Length; i++) { objArray[i] = MimeFormatter.GetInitializers(returnWriterTypes[i], methods); } for (int j = 0; j < methods.Length; j++) { LogicalMethodInfo info = methods[j]; HttpServerMethod method = null; if (info.ReturnType == typeof(void)) { method = new HttpServerMethod(); } else { for (int num3 = 0; num3 < returnWriterTypes.Length; num3++) { object[] objArray2 = (object[])objArray[num3]; if (objArray2[j] != null) { method = new HttpServerMethod { writerInitializer = objArray2[j], writerType = returnWriterTypes[num3] }; break; } } } if (method != null) { method.methodInfo = info; methodArray[j] = method; } } objArray = new object[parameterReaderTypes.Length]; for (int k = 0; k < objArray.Length; k++) { objArray[k] = MimeFormatter.GetInitializers(parameterReaderTypes[k], methods); } for (int m = 0; m < methods.Length; m++) { HttpServerMethod method2 = methodArray[m]; if (method2 != null) { LogicalMethodInfo info2 = methods[m]; if (info2.InParameters.Length > 0) { int index = 0; for (int num7 = 0; num7 < parameterReaderTypes.Length; num7++) { object[] objArray3 = (object[])objArray[num7]; if (objArray3[m] != null) { index++; } } if (index == 0) { methodArray[m] = null; } else { method2.readerTypes = new Type[index]; method2.readerInitializers = new object[index]; index = 0; for (int num8 = 0; num8 < parameterReaderTypes.Length; num8++) { object[] objArray4 = (object[])objArray[num8]; if (objArray4[m] != null) { method2.readerTypes[index] = parameterReaderTypes[num8]; method2.readerInitializers[index] = objArray4[m]; index++; } } } } } } for (int n = 0; n < methodArray.Length; n++) { HttpServerMethod method3 = methodArray[n]; if (method3 != null) { WebMethodAttribute methodAttribute = method3.methodInfo.MethodAttribute; method3.name = methodAttribute.MessageName; if (method3.name.Length == 0) { method3.name = method3.methodInfo.Name; } this.methods.Add(method3.name, method3); } } }
internal HttpServerType(Type type) : base(type) { WebServicesSection config = WebServicesSection.Current; Type[] returnWriterTypes = config.ReturnWriterTypes; Type[] parameterReaderTypes = config.ParameterReaderTypes; LogicalMethodInfo[] methodInfos = WebMethodReflector.GetMethods(type); HttpServerMethod[] methods = new HttpServerMethod[methodInfos.Length]; object[] initializersByType = new object[returnWriterTypes.Length]; for (int i = 0; i < initializersByType.Length; i++) { initializersByType[i] = MimeFormatter.GetInitializers(returnWriterTypes[i], methodInfos); } for (int i = 0; i < methodInfos.Length; i++) { LogicalMethodInfo methodInfo = methodInfos[i]; HttpServerMethod method = null; if (methodInfo.ReturnType == typeof(void)) { method = new HttpServerMethod(); } else { for (int j = 0; j < returnWriterTypes.Length; j++) { object[] initializers = (object[])initializersByType[j]; if (initializers[i] != null) { method = new HttpServerMethod(); method.writerInitializer = initializers[i]; method.writerType = returnWriterTypes[j]; break; } } } if (method != null) { method.methodInfo = methodInfo; methods[i] = method; } } initializersByType = new object[parameterReaderTypes.Length]; for (int i = 0; i < initializersByType.Length; i++) { initializersByType[i] = MimeFormatter.GetInitializers(parameterReaderTypes[i], methodInfos); } for (int i = 0; i < methodInfos.Length; i++) { HttpServerMethod method = methods[i]; if (method == null) { continue; } LogicalMethodInfo methodInfo = methodInfos[i]; if (methodInfo.InParameters.Length > 0) { int count = 0; for (int j = 0; j < parameterReaderTypes.Length; j++) { object[] initializers = (object[])initializersByType[j]; if (initializers[i] != null) { count++; } } if (count == 0) { methods[i] = null; } else { method.readerTypes = new Type[count]; method.readerInitializers = new object[count]; count = 0; for (int j = 0; j < parameterReaderTypes.Length; j++) { object[] initializers = (object[])initializersByType[j]; if (initializers[i] != null) { method.readerTypes[count] = parameterReaderTypes[j]; method.readerInitializers[count] = initializers[i]; count++; } } } } } for (int i = 0; i < methods.Length; i++) { HttpServerMethod method = methods[i]; if (method != null) { WebMethodAttribute methodAttribute = method.methodInfo.MethodAttribute; method.name = methodAttribute.MessageName; if (method.name.Length == 0) { method.name = method.methodInfo.Name; } this.methods.Add(method.name, method); } } }