public ExtState Add(DownloadType type) { ExtState state = ExtState.Failed; if (!downloadTypes.Contains(type, new DownloadTypeEqualComparer())) { downloadTypes.Add(type); state = Save(downloadTypes); } else state = ExtState.IsExists; return state; }
private void GetDownloadTypes() { List<DownloadType> types = new List<DownloadType>(); Helper.RunElevated(SPContext.Current.Site.ID, SPContext.Current.Site.RootWeb.ID, delegate(SPWeb elevatedWeb) { string[] fileTypes = elevatedWeb.Properties[Content.SPFileTypes].ToLower().Split(';'); string[] fileSizes = elevatedWeb.Properties[Content.SPFileSizes].ToLower().Split(';'); string[] actives = elevatedWeb.Properties[Content.SPFileTypesActive].ToLower().Split(';'); if (fileSizes != null && fileTypes != null) if (fileTypes.Length == fileSizes.Length) for (int i = 0; i < fileTypes.Length - 1; i++) { DownloadType file = new DownloadType(fileTypes[i], Convert.ToInt32(fileSizes[i]), Convert.ToBoolean(actives[i])); if (!types.Contains(file, new DownloadTypeEqualComparer())) types.Add(file); } }); if (types.Count > 0) { downloadTypes.Clear(); downloadTypes.AddRange(types); } }