Exemple #1
0
        public void TestMethod1()
        {
            Sections s = new Sections();

            s.Add(new Section("test1"));
            s.Add(new Section("test2"));
            s.Add(new Section("test3"));

            foreach (Section ss in s)
            {
                Console.WriteLine(ss.Name);
            }
        }
Exemple #2
0
        /// <summary>
        /// Write a string to INIFile, its not save a file default after operation
        /// </summary>
        /// <param name="section">Section name</param>
        /// <param name="variable">Variable Name</param>
        /// <param name="value">Value</param>
        public void WriteString(string section, string variable, string value)
        {
            Section sect = FindSection(section);

            if (sect != null)
            {
                Variable var = sect.Find(variable);

                if (var != null)
                {
                    var.Value = value;
                }

                else
                {
                    sect.Add(new Variable(variable, value));
                }
            }
            else
            {
                sect = new Section(section);
                sect.Add(new Variable(variable, value));

                Sections.Add(sect);
            }
        }
        public void ReadSections(XElement root)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }

            var sectionsElement = root.Element("Sections");

            if (sectionsElement == null)
            {
                return;
            }

            var sectionElements = from el in sectionsElement.Elements("Section") select el;

            // Loop through the sections
            foreach (var sectionElement in sectionElements)
            {
                CoalesceSection section;
                var             currentSection = new CoalesceSection();
                var             sectionName    = (string)sectionElement.Attribute("name");

                // Make sure the section has a name
                if (sectionName.IsNullOrEmpty())
                {
                    continue;
                }

                var propertyElements = from el in sectionElement.Elements("Property") select el;

                // Loop through the current sections properties
                foreach (var propertyElement in propertyElements)
                {
                    var currentProperty = ReadProperty(propertyElement);
                    CoalesceProperty property;

                    if (currentProperty == null)
                    {
                        continue;
                    }

                    if (!currentSection.TryGetValue(currentProperty.Name, out property))
                    {
                        property = new CoalesceProperty();
                        currentSection.Add(currentProperty.Name, property);
                    }

                    property.AddRange(currentProperty);
                }

                if (!Sections.TryGetValue(sectionName, out section))
                {
                    section = new CoalesceSection();
                    Sections.Add(sectionName, section);
                }

                section.Combine(currentSection);
            }
        }
Exemple #4
0
        /// <summary>
        /// Adds single section.
        /// </summary>
        /// <param name="sectionName">Section name.</param>
        public IniSection AddSection(string sectionName)
        {
            var section = new IniSection(sectionName);

            Sections.Add(section);
            return(section);
        }
Exemple #5
0
        internal Section AddSection(Element element, string type, int group, Format format, string content)
        {
            if (group < 1)
            {
                group = 1;
            }
            else if (group > 5)
            {
                group = 5;
            }

            Section section = new Section(element, type, CalculateOrder(), group, format, content);

            if (!Sections.Contains(section))
            {
                Sections.Add(section);
                return(section);
            }
            else
            {
                throw new ArgumentException("A section of type " + type +
                                            (element != null ? " for " + element.Name : "")
                                            + " already exists.");
            }
        }
        public IIniSection this[string section, IniGetOption option = default]
        {
            get
            {
                if (option is null)
                {
                    option = new IniGetOption();
                }

                foreach (var item in Sections)
                {
                    if (item.Name == section)
                    {
                        return(item);
                    }
                }
                if (option.Create)
                {
                    var result = New(section);
                    Sections.Add(result);
                    return(result);
                }
                else
                {
                    throw new DataNotExistsException($"Cannot Found Section : {section}");
                }
            }
        }
Exemple #7
0
        //Indexer...
        public INISection this[String index]
        {
            get
            {
                if (!String.IsNullOrEmpty(CategoryPrefix))
                {
                    index = CategoryPrefix + "." + index;
                }
                INISection returnthis =
                    Sections.FirstOrDefault((w) => w.Name.Equals(index, StringComparison.OrdinalIgnoreCase));

                if (returnthis == null)
                {
                    if (!String.IsNullOrEmpty(CategoryPrefix))
                    {
                        index = CategoryPrefix + "." + index;
                    }
                    returnthis = new INISection(index, "", new List <INIItem>(), this);
                    Sections.Add(returnthis);
                }
                return(returnthis);
            }
            set
            {
                //remove any existing value with the given name...
                INISection itemfound =
                    Sections.FirstOrDefault(w => w.Name.Equals(index, StringComparison.OrdinalIgnoreCase));
                if (itemfound != null)
                {
                    Sections.Remove(itemfound);
                }
                Sections.Add(value);
            }
        }
        internal void ParseSectionDefinitions(XElement root, Dictionary <string, SectionSchema> sectionSchemas)
        {
            foreach (var node in root.Nodes())
            {
                var element = node as XElement;
                if (element == null)
                {
                    continue;
                }

                if (element.Name.LocalName == KEYWORD_SECTIONGROUP)
                {
                    var group = SectionGroups.Add(element.Attribute(KEYWORD_SECTIONGROUP_NAME).Value);
                    group.Path = Name == string.Empty ? group.Name : string.Format("{0}/{1}", Path, @group.Name);
                    group.ParseSectionDefinitions(element, sectionSchemas);
                    continue;
                }

                if (element.Name.LocalName == KEYWORD_SECTION)
                {
                    var sectionDefinition = Sections.Add(element.Attribute(KEYWORD_SECTION_NAME).Value);
                    sectionDefinition.OverrideModeDefault = element.Attribute(KEYWORD_SECTION_OVERRIDEMODEDEFAULT).LoadString(KEYWORD_OVERRIDEMODE_ALLOW);
                    sectionDefinition.AllowLocation       = element.Attribute(KEYWORD_SECTION_ALLOWLOCATION).LoadString(KEYWORD_TRUE);
                    sectionDefinition.AllowDefinition     = element.Attribute(KEYWORD_SECTION_ALLOWDEFINITION).LoadString(KEYWORD_SECTION_ALLOWDEFINITION_EVERYWHERE);
                    sectionDefinition.Path = Name == string.Empty ? sectionDefinition.Name : $"{Path}/{sectionDefinition.Name}";
                    sectionDefinition.Type = element.Attribute(KEYWORD_SECTION_TYPE).LoadString(string.Empty);

                    SectionSchema schema;
                    sectionSchemas.TryGetValue(sectionDefinition.Path, out schema);
                    sectionDefinition.Schema = schema;
                }
            }
        }
Exemple #9
0
        // [DebuggerStepThrough]
        public void Parse(string s)
        {
            // replace disturbing chars
            string src = s.Replace("\n", "");

            src = src.Replace("\t", "");
            src = Regex.Replace(src, "~.+~", ""); // remove comments

            // transform source
            string[] cmdss = src.Split(Convert.ToChar("{"));
            src = src.Remove(0, cmdss[0].Length + 1);
            src = src.Remove(src.Length - 2, 2);
            src = src.Replace("}", "\n");

            UseStatementParser.Parse(cmdss[0], this);

            //parsing commands
            foreach (string cm in src.Split(Convert.ToChar("\n")))
            {
                var sh = BlockHeaderParser.Parse(cm.Split(Convert.ToChar("{"))[0]);

                var cmd = new Section {
                    Header = { Name = sh.Name }
                };

                VarDefParser.Parse(DataTypes, cm, cmd);
                FunctionCallParser.Parse(cm, cmd, this);
                VarSetParser.Parse(DataTypes, cm, cmd);
                ClassParser.Parse(cm, this);

                Sections.Add(cmd);
            }
        }
Exemple #10
0
        void LoadFeeds()
        {
            List <UserFeed> feeds = null;

            using (var repo = new Repo()) {
                feeds = repo.GetFeeds(Service);

                feeds.Sort((x, y) => x.Category.CompareTo(y.Category));
            }

            DialogSection feedSection = null;

            foreach (var f in feeds)
            {
                if (feedSection == null || feedSection.Header != f.Category)
                {
                    feedSection = new DialogSection(f.Category);
                    Sections.Add(feedSection);
                }

                var e = new FeedElement(Service, f, UITableViewCellAccessory.None);
                e.Selected += delegate {
                    if (FeedSelected != null)
                    {
                        FeedSelected(e.Feed);
                    }
                };
                feedSection.Add(e);
            }
        }
        private void SetSectionOrder()
        {
            int        posCont = 0, posRSeries = 0, posNewEps = 0;
            Visibility visCont    = System.Windows.Visibility.Visible,
                       visRSeries = System.Windows.Visibility.Visible,
                       visNewEps  = System.Windows.Visibility.Visible;

            UserSettingsVM.Instance.GetDashboardMetroSectionPosition(DashboardMetroProcessType.ContinueWatching, ref posCont, ref visCont);
            UserSettingsVM.Instance.GetDashboardMetroSectionPosition(DashboardMetroProcessType.RandomSeries, ref posRSeries, ref visRSeries);
            UserSettingsVM.Instance.GetDashboardMetroSectionPosition(DashboardMetroProcessType.NewEpisodes, ref posNewEps, ref visNewEps);

            Dash_ContinueWatching_Column = posCont;
            Dash_RandomSeries_Column     = posRSeries;
            Dash_NewEpisodes_Column      = posNewEps;

            Dash_ContinueWatching_Visibility = visCont;
            Dash_RandomSeries_Visibility     = visRSeries;
            Dash_NewEpisodes_Visibility      = visNewEps;

            Sections.Clear();
            List <MetroDashSection> sections = UserSettingsVM.Instance.GetMetroDashSections();

            foreach (MetroDashSection sect in sections)
            {
                Sections.Add(sect);
            }

            ViewSections.Refresh();
        }
        public ServiceController(UserService svc) : base(UITableViewStyle.Grouped)
        {
            try {
                Title = svc.Name;

                Service = svc;

                _queries = new DialogSection("Queries");

                _feeds = new List <DialogSection> ();
                _feeds.Add(new DialogSection("Feeds"));

                _loadingSection = new DialogSection();
                _loadingElement = new LoadingElement();
                _loadingElement.Start();
                _loadingSection.Add(_loadingElement);

                Sections.AddRange(_feeds);

                Sections.Add(_loadingSection);

                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add, HandleAddButton);
            } catch (Exception error) {
                Log.Error(error);
            }
        }
Exemple #13
0
 public override void CreateExportDocument()
 {
     Sections.Add(new OrdersSection());
     Sections.Add(new ClientInfoSection());
     Sections.Add(new HeaderSection());
     Sections.Add(new TotalsSection());
 }
 public Section this[string sectionName]
 {
     get
     {
         var existingSection = Sections.FirstOrDefault(x => x.Header == sectionName);
         if (existingSection != null)
         {
             return(existingSection);
         }
         var ns = new Section()
         {
             Header = sectionName
         };
         Sections.Add(ns);
         return(ns);
     }
     set
     {
         var sectionToReplace = Sections.FirstOrDefault(x => x.Header == sectionName);
         if (sectionToReplace != null)
         {
             Sections.Remove(sectionToReplace);
         }
         Sections.Add(value);
     }
 }
Exemple #15
0
        /// <summary>
        ///     Initialize from a blob
        /// </summary>
        /// <param name="blob"></param>
        /// <param name="platform"></param>
        public NamedSounds(Span <byte> blob, DataPlatform platform)
        {
            FullBuffer = new Memory <byte>(blob.ToArray());
            Header     = MemoryMarshal.Read <NamedSoundHeader>(blob);
            Logger.Assert(Header.Count == 1, "Header.Count == 1");
            var offset = SizeHelper.SizeOf <NamedSoundHeader>();

            Filenames = new List <string?>(Header.Count);
            for (var i = 0; i < Header.Count; ++i)
            {
                var pointer = MemoryMarshal.Read <int>(blob.Slice(offset));
                Filenames.Add(blob.Slice(pointer).ReadString());
                offset += 4;
            }

            offset = Header.PointersTablePointer;
            for (var i = 0; i < Header.Count; ++i)
            {
                var name = blob.Slice(offset).ReadStringNonNull();
                offset += name.Length + 1;
                Filenames.Add(name);
            }

            var pointers = MemoryMarshal.Cast <byte, int>(blob.Slice(Header.PointersTablePointer, 4 * Header.Count));

            foreach (var pointer in pointers)
            {
                Sections.Add(SoundResource.DecodeSection(blob.Slice(pointer), platform));
            }
        }
Exemple #16
0
        public override void LoadSectionHeaders()
        {
            // Create the sections.
            var inames = new List <uint>();
            var links  = new List <uint>();
            var infos  = new List <uint>();
            var rdr    = imgLoader.CreateReader(Header.e_shoff);

            for (uint i = 0; i < Header.e_shnum; ++i)
            {
                var shdr = Elf32_SHdr.Load(rdr);
                if (shdr == null)
                {
                    break;
                }
                var section = new ElfSection
                {
                    Number     = i,
                    Type       = shdr.sh_type,
                    Flags      = shdr.sh_flags,
                    Address    = Address.Ptr32(shdr.sh_addr),
                    FileOffset = shdr.sh_offset,
                    Size       = shdr.sh_size,
                    Alignment  = shdr.sh_addralign,
                    EntrySize  = shdr.sh_entsize,
                };
                Sections.Add(section);
                inames.Add(shdr.sh_name);
                links.Add(shdr.sh_link);
                infos.Add(shdr.sh_info);
            }

            // Get section names and crosslink sections.

            for (int i = 0; i < Sections.Count; ++i)
            {
                var section = Sections[i];
                section.Name = ReadSectionName(inames[i]);

                ElfSection linkSection = null;
                ElfSection relSection  = null;
                switch (section.Type)
                {
                case SectionHeaderType.SHT_REL:
                case SectionHeaderType.SHT_RELA:
                    linkSection = GetSectionByIndex(links[i]);
                    relSection  = GetSectionByIndex(infos[i]);
                    break;

                case SectionHeaderType.SHT_DYNAMIC:
                case SectionHeaderType.SHT_HASH:
                case SectionHeaderType.SHT_SYMTAB:
                case SectionHeaderType.SHT_DYNSYM:
                    linkSection = GetSectionByIndex(links[i]);
                    break;
                }
                section.LinkedSection    = linkSection;
                section.RelocatedSection = relSection;
            }
        }
Exemple #17
0
 /// <summary>
 /// Сформированть коллекцию разделов (пустых)
 /// </summary>
 private void InitSections()
 {
     foreach (var item in Enum.GetValues(typeof(SectionType)))
     {
         Sections.Add(new SectionViewModel((SectionType)item));
     }
 }
Exemple #18
0
        private void OnAddCommand(object param)
        {
            AddBox box = new AddBox();

            box.ShowDialog();

            string result = box.GetResult;

            if (!string.IsNullOrWhiteSpace(result))
            {
                Section section = _database.GetSections(_currentBookId).Where(f => f.Name == result).FirstOrDefault();
                if (section == null)
                {
                    section = new Section()
                    {
                        Name        = result,
                        Description = "",
                        Book        = _currentBookId
                    };
                    _database.AddSection(section);
                    Sections.Add(section);
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Sections)));
                }
            }
        }
Exemple #19
0
        public IniSection GetOrCreateSection(string sectionName, string insertAfter = null)
        {
            var ret = Sections.Find(x => x.Name == sectionName);

            if (ret == null)
            {
                int insertIdx = (insertAfter != null) ? Sections.FindIndex(section => section.Name == insertAfter) : -1;

                ret = new IniSection(sectionName);
                if (insertIdx != -1)
                {
                    Sections.Insert(insertIdx, ret);
                    ret.Index = insertIdx;
                    // move up all section indices
                    for (int i = insertIdx + 1; i < Sections.Count; i++)
                    {
                        Sections[i].Index++;
                    }
                }
                else
                {
                    Sections.Add(ret);
                    ret.Index = Sections.Count;
                }
            }
            return(ret);
        }
Exemple #20
0
 public BackTestingStockReport(TradingResult tradingResult)
     : base(tradingResult.Stock.Isin, "BackTestingDetails", "BackTesting details")
 {
     Sections.Add(CreateOverviewSection(tradingResult));
     Sections.Add(CreateChartSection(tradingResult));
     Sections.Add(CreateTableSection(tradingResult));
 }
        /// <summary>
        /// The actual implementation of data extraction.
        /// </summary>
        /// <param name="obj">A command parameter</param>
        /// <returns></returns>
        private async Task ExtractData(object obj)
        {
            try
            {
                LoadingData = true;
                //Checking the obvious
                if (!ConnectivityHelpers.CheckNetworkConnection())
                {
                    var dialog = new MessageDialog("No internet connection. Please enable your mobile or WiFi network.");
                    await dialog.ShowAsync();

                    return;
                }
                Sections.Clear();
                using (var repository = new DataRepository())
                {
                    var sections = await repository.GetSections(DataExtractionUrl);

                    foreach (var section in sections)
                    {
                        Sections.Add(section);
                    }
                }
                LoadingData = false;
            }
            catch (Exception)
            {
                //Just in case
                LoadingData = false;
                throw;
            }
        }
Exemple #22
0
        public void InitializeItems(ITreeGridStore <ITreeGridItem> store)
        {
            ClearCache();
            if (sections != null)
            {
                sections.Clear();
            }
            Store = store;

            if (Store != null)
            {
                for (int row = 0; row < Store.Count; row++)
                {
                    var item = Store[row];
                    if (item.Expanded)
                    {
                        var children = (ITreeGridStore <ITreeGridItem>)item;
                        var section  = new TreeController {
                            StartRow = row, Handler = Handler, parent = this
                        };
                        section.InitializeItems(children);
                        Sections.Add(section);
                    }
                }
            }
            ResetCollection();
        }
Exemple #23
0
        internal Sections GetSections(string reference, string response_id = null)
        {
            try
            {
                QuestionProvider provider = new QuestionProvider(DbInfo);
                Sections         sections = new Sections();
                string           query    = $"select * from dsto_sections where (yref_questionaire='{reference}' or yref_field_inspection='{reference}' or yref_certification='{reference}' or yref_template='{reference}') and deleted=0 order by oid asc";

                var table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Section section = new Section(null);
                        section.Key         = row["guid"].ToString();
                        section.OID         = int.Parse(row["OID"].ToString());
                        section.Name        = row["Name"].ToString();
                        section.Description = row["Description"].ToString();
                        section.Deleted     = bool.Parse(row["deleted"].ToString());
                        section.CreatedBy   = row["created_by"].ToString();
                        section.Questions   = provider.GetQuestions(section, response_id);
                        section.SubSections = new SubSectionProvider(DbInfo).GetSubSections(section, response_id);
                        sections.Add(section);
                    }
                    return(sections);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #24
0
        public void GetDemoLocalData()
        {
            int[] arr;
            arr = new int[] { 4, 0 };
            Children.Add(new Child(1, "Иванов", "Саша", "Сергеевич", 1, arr));
            arr = new int[] { 0, 0 };
            Children.Add(new Child(2, "Сергеева", "Маша", "Александровна", 1, arr));
            Sections.Add(new Section(1, "Ритмика"));
            Sections.Add(new Section(2, "Музыка"));

            DateTime date;

            arr  = new int[] { 1, 2 };
            date = new DateTime(2019, 8, 25);
            GardenEvents.Add(new GardenEvent(1, 1, date, arr));
            arr  = new int[] { 1 };
            date = new DateTime(2019, 9, 1);
            GardenEvents.Add(new GardenEvent(2, 1, date, arr));
            arr  = new int[] { };
            date = new DateTime(2019, 9, 10);
            GardenEvents.Add(new GardenEvent(3, 1, date, arr));
            arr  = new int[] { 2 };
            date = new DateTime(2019, 9, 13);
            GardenEvents.Add(new GardenEvent(4, 1, date, arr));
        }
Exemple #25
0
        public PatronForm(IEnumerable <Tuple <int, string> > monthlyPrices)
        {
            var bundleId = Foundation.NSBundle.MainBundle.BundleIdentifier;

            prices = monthlyPrices.Select(x => new PatronSubscriptionPrice(bundleId + ".patron.cons." + x.Item1 + "month", x.Item1, x.Item2)).ToArray();

            var appdel  = DocumentAppDelegate.Shared;
            var appName = appdel.App.Name;

            Title = "Support " + appName;

            aboutSection = new PatronAboutSection(appName);
            buySection   = new PatronBuySection(prices);

            Sections.Add(aboutSection);
            Sections.Add(buySection);
                        #if DEBUG
            Sections.Add(new PatronRestoreSection());
            Sections.Add(new PatronDeleteSection());
                        #endif
            forceSection = new PatronForceSubscriptionSection(prices);

            isPatron = appdel.Settings.IsPatron;
            endDate  = appdel.Settings.PatronEndDate;
            aboutSection.SetPatronage();
            buySection.SetPatronage();

            RefreshPatronDataAsync().ContinueWith(t => {
                if (t.IsFaulted)
                {
                    Log.Error(t.Exception);
                }
            });
        }
Exemple #26
0
        public void SetSections(ThingTypeSectionType section)
        {
            Sections.Clear();

            if ((section & ThingTypeSectionType.Core) != 0)
            {
                Sections.Add(ThingTypeSections.Core);
            }
            if ((section & ThingTypeSectionType.Xsd) != 0)
            {
                Sections.Add(ThingTypeSections.Xsd);
            }
            if ((section & ThingTypeSectionType.Columns) != 0)
            {
                Sections.Add(ThingTypeSections.Columns);
            }
            if ((section & ThingTypeSectionType.Transforms) != 0)
            {
                Sections.Add(ThingTypeSections.Transforms);
            }
            if ((section & ThingTypeSectionType.TransformSource) != 0)
            {
                Sections.Add(ThingTypeSections.TransformSource);
            }
            if ((section & ThingTypeSectionType.Versions) != 0)
            {
                Sections.Add(ThingTypeSections.Versions);
            }
        }
Exemple #27
0
        void ReadSections(string[] lines)
        {
            int     i              = 0;
            int     last           = lines.Length - 1;
            Section currentSection = null;

            while (i <= last)
            {
                string currentLine       = lines[i];
                int    currentLineLength = currentLine.Length;
                if (currentLine[0] == '[')
                {
                    if (currentLineLength < 3)
                    {
                        throw new Exception("Incomplete ini section header: {0}"
                                            + currentLine);
                    }
                    currentSection = new Section(currentLine.Substring(1, currentLineLength - 2));
                    Sections.Add(currentSection);
                }
                else
                {
                    int equals = currentLine.IndexOf('=');
                    if (equals < 1 || equals > currentLineLength - 1)
                    {
                        throw new Exception("Incorrect 'name=value' syntax: {0}" + currentLine);
                    }
                    string name  = currentLine.Substring(0, equals);
                    string value = currentLine.Substring(equals + 1, currentLineLength - equals - 1);
                    currentSection.Entries.Add(name, value);
                }
                i++;
            }
        }
Exemple #28
0
        public Script(Resource res, bool translated)
        {
            Resource    = res;
            _translated = translated;

            SourceData = res.GetContent(translated);

            ushort i = 0;

            while (i < SourceData.Length)
            {
                SectionType type = (SectionType)Helpers.GetUShortBE(SourceData, i);
                if (type == SectionType.None)
                {
                    break;
                }

                ushort size = (ushort)(Helpers.GetUShortBE(SourceData, i + 2) - 4);
                i += 4;

                Section sec = Section.Create(this, type, SourceData, i, size);
                Sections.Add(sec);
                i += size;

                if (sec is StringSection)
                {
                    _strings = (StringSection)sec;
                }
            }

            foreach (var sec in Sections)
            {
                sec.SetupByOffset();
            }
        }
Exemple #29
0
        internal void _Load()
        {
            var filtered = _node.ChildNodes.Cast <XmlNode>()
                           .Where((node) => node is XmlElement);

            foreach (XmlNode node in filtered)
            {
                if (node.Attributes.Count == 0)
                {
                    // Section
                    Section section = new Section(node);
                    if (Sections.ContainsKey(section.Name))
                    {
                        throw new Exception("DUPLICATE SECTION!");
                    }
                    Sections.Add(section.Name, section);
                }
                else
                {
                    // (List)Item
                    Item item = ItemFactory.Create(node);
                    if (item == null)
                    {
                        throw new Exception("UNABLE TO CREATE ITEM!");
                    }
                    if (Items.ContainsKey(item.Name))
                    {
                        throw new Exception("DUPLICATE ITEM!");
                    }
                    Items.Add(item.Name, item);
                }
            }
        }
Exemple #30
0
        public AddController(Action doneAction) : base(UITableViewStyle.Grouped)
        {
            try {
                Title = "Add Service";

                _doneAction = doneAction;

                _nameElement = new TextFieldElement("Name", "Display Name", 70);
                _nameElement.TextField.AutocapitalizationType = UITextAutocapitalizationType.Words;

                _urlElement = new TextFieldElement("URL", "http://", 70);
                _urlElement.TextField.AutocapitalizationType = UITextAutocapitalizationType.None;
                _urlElement.TextField.KeyboardType           = UIKeyboardType.Url;
                _urlElement.TextField.AutocorrectionType     = UITextAutocorrectionType.No;

                var sec = new DialogSection();
                sec.Add(_nameElement);
                sec.Add(_urlElement);

                Sections.Add(sec);

                NavigationItem.LeftBarButtonItem  = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, HandleCancelButton);
                NavigationItem.RightBarButtonItem = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, HandleDoneButton);
            } catch (Exception error) {
                Log.Error(error);
            }
        }
        private void ParseSection(string name, List <string> lines)
        {
            //if (String.IsNullOrEmpty (name) || lines.IsNullOrEmpty ())
            if (lines.IsNullOrEmpty())
            {
                return;
            }

            ConfigFileSection sec = new ConfigFileSection(name);

            for (int k = 0; k < lines.Count; k++)
            {
                string entry = lines [k];
                int    m     = entry.IndexOf('=');
                if (m > 0)
                {
                    string key   = entry.StrLeft(m).Trim();
                    string value = entry.StrMid(m + 2).Trim();

                    if (!String.IsNullOrEmpty(key))
                    {
                        sec.Entries.Add(new ConfigFileEntry(key, value));
                    }
                }
            }
            Sections.Add(sec);
        }
        public void ICanSerializeAndDeserializeProcDetailData()
        {
            Sections procData = new Sections();
            string[] args = new string[] { "a", "b", "c" };
            IDictionary<string, string> vars = new Dictionary<string, string>() { { "a", "1" }, { "b", "2" }, { "c", "3" } };
            ProcDetails procDetails = new ProcDetails(args);
            procData.Add(ProcDetails.CommandLineArguments, Entries.MakeEntries(args));
            procData.Add(ProcDetails.EnvironmentVariables, new Entries(vars));
            procData.Add(ProcDetails.CoreSiteSettings, new Entries(vars));
            procData.Add(ProcDetails.HiveSiteSettings, new Entries(vars));
            procData.Add(ProcDetails.MapRedSiteSettings, new Entries(vars));

            SectionsSerializer ser = new SectionsSerializer();
            var content = ser.Serialize(procData);
            Sections deserialized = ser.Deserialize(content);
            Help.DoNothing(deserialized);
            Help.DoNothing(procDetails);
        }
 private Sections ConvertStringToSections(string encoded)
 {
     Sections retval = new Sections();
     string[] sections = encoded.Split(new string[] { SectionDelimiter.ToString() }, StringSplitOptions.None);
     foreach (var section in sections)
     {
         string[] pairs = section.Split(new string[] { SectionPairDelimiter.ToString() }, StringSplitOptions.None);
         retval.Add(pairs[0], this.ConvertStringToEntries(pairs[1]));
     }
     return retval;
 }
 private void Run()
 {
     Sections sections = new Sections();
     sections.Add(CommandLineArguments, Entries.MakeEntries(this.args));
     sections.Add(InputLines, this.InputGetter());
     sections.Add(SystemValues, this.GetSystemValues());
     sections.Add(EnvironmentVariables, this.EnvironmentVariablesGetter());
     sections.Add(CoreSiteSettings, this.CoreSiteGetter());
     sections.Add(HiveSiteSettings, this.HiveSiteGetter());
     sections.Add(MapRedSiteSettings, this.MapRedSiteGetter());
     sections.Add(Errors, this.errors);
     var ser = new SectionsSerializer();
     Console.Write(ser.Serialize(sections));
 }