public void Deny_Unrestricted() { Assert.IsNotNull(coll.AllKeys, "AllKeys"); coll.CopyTo(new object[0], 0); Assert.IsNull(coll.Get("mono"), "Get(string)"); Assert.IsNull(coll["mono"], "this[string]"); try { Assert.IsNull(coll[0], "this[int]"); } catch (ArgumentOutOfRangeException) { // normal (can't avoid it) } try { Assert.IsNull(coll.GetKey(0), "GetKey(int)"); } catch (ArgumentOutOfRangeException) { // normal (can't avoid it) } try { Assert.IsNull(coll.Get(0), "Get(int)"); } catch (ArgumentOutOfRangeException) { // normal (can't avoid it) } }
public static IEnumerable <KeyValuePair <string, IHttpModule> > AsEnumerable(this HttpModuleCollection modules) { if (modules == null) { throw new ArgumentNullException(nameof(modules)); } return(from m in Enumerable.Range(0, modules.Count) select KeyValuePair.Create(modules.GetKey(m), modules[m])); }
public static void Init(HttpApplication context) { if ((Interlocked.Exchange(ref _hasBeenInitialized, 1) != 1) && ((DynamicEntries.Count != 0) && (_reflectionUtil != null))) { IntPtr integratedModeContext = _reflectionUtil.GetIntegratedModeContext(); if (integratedModeContext != IntPtr.Zero) { _reflectionUtil.SetModuleConfigInfo(null); HttpModuleCollection integratedModuleCollection = _reflectionUtil.GetIntegratedModuleCollection(context, integratedModeContext); IList moduleConfigInfo = _reflectionUtil.GetModuleConfigInfo(); string name = "__ASP_IntegratedDynamicModule_Shim"; string assemblyQualifiedName = typeof(IntegratedDynamicModule).AssemblyQualifiedName; string condition = "managedHandler"; moduleConfigInfo.Insert(0, _reflectionUtil.NewModuleConfigurationInfo(name, assemblyQualifiedName, condition)); foreach (DynamicModuleRegistryEntry entry in DynamicEntries) { moduleConfigInfo.Add(_reflectionUtil.NewModuleConfigurationInfo(entry.Name, entry.Type, "managedHandler")); } HttpModuleCollection registeredModuleCollection = _reflectionUtil.GetRegisteredModuleCollection(context); for (int i = 0; i < integratedModuleCollection.Count; i++) { _reflectionUtil.AddModuleToCollection(registeredModuleCollection, integratedModuleCollection.GetKey(i), integratedModuleCollection.Get(i)); } IList moduleList = _reflectionUtil.NewListOfModuleConfigurationInfo(); for (int j = moduleConfigInfo.Count - DynamicEntries.Count; j < moduleConfigInfo.Count; j++) { moduleList.Add(moduleConfigInfo[j]); } HttpModuleCollection modules3 = _reflectionUtil.BuildIntegratedModuleCollection(context, moduleList); for (int k = 0; k < modules3.Count; k++) { _reflectionUtil.AddModuleToCollection(registeredModuleCollection, modules3.GetKey(k), modules3.Get(k)); } } } }