private void LoadSalesSettings(XElement root) { //Доступы к платежным системам RobokassaSecurityParams = new RobokassaSecurityParams(XmlParseHelper.Get <string>(root, "Payment", "Robokassa", "Login"), XmlParseHelper.Get <string>(root, "Payment", "Robokassa", "Password1"), XmlParseHelper.Get <string>(root, "Payment", "Robokassa", "Password2")); //секции на которых есть продажа материалов _salesSections = new HashSet <SectionId>(XmlParseHelper.GetList <SectionId>(root, "Payment", "SectionId")); _salesSettings = new Dictionary <SectionId, ISalesSettings>(); foreach (SectionId salesSection in _salesSections) { AddSalesSettings(root, salesSection); } }
private void LoadKeyboardKeys(XElement root) { var firstForeignChar = XmlParseHelper.Get <char>(root, "Keyboard", "FirstForeignChar"); var lastForeignChar = XmlParseHelper.Get <char>(root, "Keyboard", "LastForeignChar"); var alsoChars = new HashSet <char>(XmlParseHelper.GetList <char>(root, "Keyboard", "AlsoChar")); Dictionary <char, char> toRussian = XmlParseHelper.GetDictionary <char, char>(root, "Keyboard", "ToRussian"); ForeignToRussianKeys = toRussian; RussianToForeignKeys = new Dictionary <char, char>(); foreach (var chars in toRussian) { char source = chars.Key; char translation = chars.Value; if ((source >= firstForeignChar && source <= lastForeignChar && translation >= 'а' && translation <= 'я') || alsoChars.Contains(source) || alsoChars.Contains(translation)) { //нормальная иностранная буква и русская буква RussianToForeignKeys.Add(translation, source); } } }
public void Configure() { string fullConfigName = Path.Combine(BasePathToWriteData, "WebSettings.xml"); if (_repositoryFactory != null) { try { _repositoryFactory.Reload(); } catch (Exception e) { LoggerWrapper.LogTo(LoggerName.Errors).ErrorFormat( "WebSettingsConfig.Configure при попытке перегрузить репозитории возникло исключение {0}", e); } } else { _repositoryFactory = new RepositoryFactory(new RepositoryCache(BasePathToWriteData)); } if (SalesPicturesCache != null) { SalesPicturesCache.ClearMemory(); } else { string salesPicturesPath = Path.Combine(BasePathToWriteData, "Caches", "Sales"); SalesPicturesCache = new DiskCache(salesPicturesPath); } if (CommonDiskCache != null) { CommonDiskCache.ClearMemory(); } else { string commonDiskPath = Path.Combine(BasePathToWriteData, "Caches", "Common"); CommonDiskCache = new DiskCache(commonDiskPath, false); } DefaultUserLanguages = null; var stream = new StreamReader(fullConfigName, Encoding.UTF8); XDocument document = XDocument.Load(stream); XElement root = document.Root; if (root == null) { //TODO: ругаться return; } Domain = XmlParseHelper.Get <string>(root, "Domain"); Logo = XmlParseHelper.Get <string>(root, "Logo"); CookieWideDomain = XmlParseHelper.Get <string>(root, "CookieWideDomain"); CanPronounce = XmlParseHelper.Get <bool>(root, "CanPronounce"); XElement defaultLanguages = root.Element("DefaultLanguages"); DefaultLanguageFrom = GetLanguage(defaultLanguages, "From"); DefaultLanguageTo = GetLanguage(defaultLanguages, "To"); AvailableSections = new HashSet <SectionId>(XmlParseHelper.GetList <SectionId>(root, "AvailableSections", "SectionId")); //TODO: проверить корректность конфига, если что-то не так, то ругаться LoadKeyboardKeys(root); YandexMetrikaId = XmlParseHelper.Get <string>(root, "YandexMetrikaId"); Counters = XmlParseHelper.Get <string>(root, "Counters"); //подгружаем другие домены, а также удаляем текущий домен LoadAnotherDomains(root); LoadSalesSettings(root); PathToTopBanner = XmlParseHelper.Get <string>(root, "Banners", "TopPath"); _templates.Load(root.Element("Patterns")); SetDeferredSettings(_deferredActions); MaxIDUserForTopMessage = XmlParseHelper.Get <long>(root, "MaxIDUserForTopMessage"); WebPath = HttpContext.Current != null?HttpContext.Current.Server.MapPath("~/") : null; _fullRightUserIds = new HashSet <long>(XmlParseHelper.GetList <long>(root, "FullRightUserId")); }