public IsapiExtensionList(string hostName) { string iisDirectoryEntryPath = string.Format("IIS://{0}/W3SVC", hostName); try { this.rootEntry = IisUtility.CreateIISDirectoryEntry(iisDirectoryEntryPath); this.restrictionList = this.rootEntry.Properties["WebSvcExtRestrictionList"]; this.extensionMap = new List <IsapiExtensionList.ExtensionMapUnit>(this.restrictionList.Count + 5); for (int i = 0; i < this.restrictionList.Count; i++) { string text = this.restrictionList[i] as string; if (text != null) { IsapiExtension isapiExtension = IsapiExtension.Parse(text); if (isapiExtension != null) { this.extensionMap.Add(new IsapiExtensionList.ExtensionMapUnit(isapiExtension, i)); } } } } catch (Exception) { this.Dispose(); throw; } }
internal static void SetStatus(string hostName, string groupID, string extensionBinary, bool allow) { using (IsapiExtensionList isapiExtensionList = new IsapiExtensionList(hostName)) { List <int> list = isapiExtensionList.FindMatchingExtensions(groupID, extensionBinary); if (list.Count == 0) { throw new ManageIsapiExtensionCouldNotFindExtensionException(groupID, extensionBinary); } if (list.Count != 1) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { stringBuilder.Append(isapiExtensionList[i].ToMetabaseString()); stringBuilder.Append("\r\n"); } throw new ManageIsapiExtensionFoundMoreThanOneExtensionException(groupID, extensionBinary, stringBuilder.ToString()); } IsapiExtension isapiExtension = isapiExtensionList[list[0]]; if (isapiExtension.Allow != allow) { isapiExtensionList[list[0]] = new IsapiExtension(isapiExtension.PhysicalPath, isapiExtension.GroupID, isapiExtension.Description, allow, isapiExtension.UIDeletable); isapiExtensionList.CommitChanges(); IisUtility.CommitMetabaseChanges(hostName); } } }
internal static IsapiExtension Parse(string extensionString) { bool flag = false; string text = null; string text2 = null; string[] array = extensionString.Split(new char[] { ',' }); switch (array.Length) { case 0: return(null); case 1: return(null); case 2: goto IL_5D; case 3: goto IL_53; case 4: break; default: text2 = array[4]; break; } text = array[3]; IL_53: flag = IsapiExtension.IntStringToBoolean(array[2]); IL_5D: string text3 = array[1]; bool flag2 = IsapiExtension.IntStringToBoolean(array[0]); return(new IsapiExtension(text3, text, text2, flag2, flag)); }
public void Add(bool allow, string physicalPath, bool uiDeletable, string groupID, string description) { bool flag = false; for (int i = 0; i < this.extensionMap.Count; i++) { IsapiExtensionList.ExtensionMapUnit extensionMapUnit = this.extensionMap[i]; if (string.Compare(extensionMapUnit.Extension.PhysicalPath, physicalPath, true, CultureInfo.InvariantCulture) == 0 && string.Compare(extensionMapUnit.Extension.GroupID, groupID, true, CultureInfo.InvariantCulture) == 0) { extensionMapUnit.Extension.Allow = allow; extensionMapUnit.Extension.UIDeletable = uiDeletable; extensionMapUnit.Extension.Description = description; flag = true; } } if (!flag) { IsapiExtension isapiExtension = new IsapiExtension(physicalPath, groupID, description, allow, uiDeletable); this.restrictionList.Add(isapiExtension.ToMetabaseString()); this.extensionMap.Add(new IsapiExtensionList.ExtensionMapUnit(isapiExtension, this.restrictionList.Count - 1)); } }
public void Add(IsapiExtension extension) { this.restrictionList.Add(extension.ToMetabaseString()); this.extensionMap.Add(new IsapiExtensionList.ExtensionMapUnit(extension, this.restrictionList.Count - 1)); }
internal ExtensionMapUnit(IsapiExtension extension, int restrictionListIndex) { this.Extension = extension; this.RestrictionListIndex = restrictionListIndex; }