public void Load(XElement patternsElement) { _sectionsTemplates.Clear(); foreach (XElement sectionElement in patternsElement.Elements("Section")) { var sectionId = XmlParseHelper.ParseAttribute <SectionId>(sectionElement, "Id"); var pageId = XmlParseHelper.ParseAttribute <PageId>(sectionElement, "PageId"); TemplateSection templateSection = GetOrAddSection(sectionId); Dictionary <TemplateId, string> templates = XmlParseHelper.GetDictionary <TemplateId, string>(sectionElement, "Template"); foreach (var template in templates) { templateSection.Set(pageId, template.Key, template.Value); } } }
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); } } }
private void AddSalesSettings(XElement root, SectionId sectionId) { string nodeName = sectionId.ToString(); var defaultPrice = XmlParseHelper.Get <decimal>(root, "Payment", "Settings", nodeName, "DefaultPrice"); Dictionary <string, decimal> pricesByNames = XmlParseHelper.GetDictionary <string, decimal>(root, "Payment", "Settings", nodeName, "PriceByName"); Dictionary <long, decimal> pricesByIds = XmlParseHelper.GetDictionary <long, decimal>(root, "Payment", "Settings", nodeName, "PriceById"); var discount = XmlParseHelper.Get <decimal>(root, "Payment", "Settings", nodeName, "Discount"); var summDiscountPrice = XmlParseHelper.Get <decimal>(root, "Payment", "Settings", nodeName, "SummDiscountPrice"); var salesSettings = new SalesSettings(defaultPrice, pricesByNames, pricesByIds) { Discount = discount, SummDiscountPrice = summDiscountPrice }; if (salesSettings.IsInvalid) { return; } _salesSettings.Add(sectionId, salesSettings); }