using System.Collections; using System.Collections.Generic; using System.Linq; using WebsitePanel.EnterpriseServer; using WebsitePanel.WebDavPortal.WebConfigSections; namespace WebsitePanel.WebDav.Core.Config.Entities { public class OfficeOnlineCollection : AbstractConfigCollection, IReadOnlyCollection { private readonly IList _officeExtensions; public OfficeOnlineCollection() { NewFilePath = ConfigSection.OfficeOnline.CobaltNewFilePath; CobaltFileTtl = ConfigSection.OfficeOnline.CobaltFileTtl; _officeExtensions = ConfigSection.OfficeOnline.Cast().ToList(); } public bool IsEnabled { get { return GetWebdavSystemSettigns().GetValueOrDefault(EnterpriseServer.SystemSettings.WEBDAV_OWA_ENABLED_KEY, false); } } public string Url { get { return GetWebdavSystemSettigns().GetValueOrDefault(EnterpriseServer.SystemSettings.WEBDAV_OWA_URL, string.Empty); } } private SystemSettings GetWebdavSystemSettigns() { return WspContext.Services.Organizations.GetWebDavSystemSettings() ?? new SystemSettings(); } public string NewFilePath { get; private set; } public int CobaltFileTtl { get; private set; } public IEnumerator GetEnumerator() { return _officeExtensions.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public int Count { get { return _officeExtensions.Count; } } public bool Contains(string extension) { return _officeExtensions.Any(x=>x.Extension == extension); } } }