Exemplo n.º 1
0
 public SpreadSheet(string _Name) : this()
 {
     if (_Name == null)
     {
         this.Name = "";
         forAll    = this;
     }
     else
     {
         this.Name = _Name;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the spreadsheets config.
        /// </summary>
        /// <param name="xml">The XML.</param>
        private void ParseSpreadsheetsConfig(XDocument xml)
        {
            var spreadsheetsElements = xml.Root.Elements("Spreadsheet");

            //var spreadsheetsElements = xml.Root.Elements("Spreadsheet").Where(el => el.GetAtributeValueOrNull("name") != null);

            this.SpreadSheets = new Dictionary <string, SpreadSheet>(spreadsheetsElements.Count());

            foreach (XElement spreadSheetEl in spreadsheetsElements)
            {
                SpreadSheet spreadSheetConfig = new SpreadSheet(spreadSheetEl.GetAtributeValueOrNull("name"));
                //spreadSheetConfig.Name = spreadSheetEl.GetAtributeValueOrNull("name");

                foreach (XElement columnElements in spreadSheetEl.Elements("Column"))
                {
                    spreadSheetConfig.Columns.Add(new Config.Column(columnElements.GetAtributeValueOrNull("name")));
                }

                foreach (XElement staticFieldElements in spreadSheetEl.Elements("StaticField"))
                {
                    Config.StaticField sf = new Config.StaticField();
                    foreach (XElement fieldElements in staticFieldElements.Elements("Field"))
                    {
                        sf.addField(fieldElements.GetAtributeValueOrNull("name"));
                    }
                    spreadSheetConfig.StaticFields.Add(sf);
                }

                foreach (XElement renameElements in spreadSheetEl.Elements("RenameField"))
                {
                    spreadSheetConfig.RenameFields.Add(new RenameField(renameElements.GetAtributeValueOrNull("name"), renameElements.GetAtributeValueOrNull("changeTo")));
                }

                foreach (XElement ignore in spreadSheetEl.Elements("ReturnOnly"))
                {
                    spreadSheetConfig.ReturnOnly.Add(ignore.GetAtributeValueOrNull("name"));
                }

                this.SpreadSheets.Add(spreadSheetConfig.Name, spreadSheetConfig);
            }
        }