Example #1
0
        protected override void ProcessRecord()
        {
            WriteVerbose($"New-IniFileSectionData Process {ParameterSetName}");
            switch (ParameterSetName)
            {
            case "ByName":
                foreach (var item in SectionName)
                {
                    WriteObject(new IniFileSection {
                        SectionName = item
                    });
                }
                break;

            case "ByObject":
                var section = new IniFileSection {
                    SectionName = Name
                };
                foreach (var item in Values.Keys)
                {
                    section.Values.Add(item.ToString(), Values[item].ToString());
                }
                WriteObject(section);
                break;
            }
        }
Example #2
0
        protected override void ProcessRecord()
        {
            WriteVerbose($"Get-IniFileSection Process ParameterSetName={ParameterSetName}...");
            switch (ParameterSetName)
            {
            case "Object":
                foreach (var item in InputObject)
                {
                    foreach (var sect in this.Section)
                    {
                        WriteVerbose($"Retrieving section {sect}");

                        var section = item.Sections.Where(s => s.SectionName.Equals(sect, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (section != null)
                        {
                            WriteObject(section);
                        }
                    }
                }
                break;

            default:
                var iniHelper = new IniFileHelper(this.IniFile);
                foreach (var item in Section)
                {
                    WriteVerbose($"Retrieving section {item}");
                    var fileSection = iniHelper.GetINISection(item);
                    var iniSection  = new IniFileSection {
                        Path = this.IniFile, SectionName = item, Values = fileSection
                    };
                    WriteObject(iniSection);
                }
                break;
            }
        }
Example #3
0
 protected override void ProcessRecord()
 {
     WriteVerbose("Get-IniFile Process...");
     foreach (var item in Files)
     {
         if (!item.Exists)
         {
             WriteWarning($"{item.FullName} does not exist!");
         }
         else
         {
             WriteVerbose($"Examining {item.FullName}");
             var iniFile = new IniFile {
                 Path = item.FullName
             };
             var fileMap = IniFileHelper.GetFileMap(item.FullName);
             foreach (var section in fileMap.Keys)
             {
                 var sectionValues = fileMap[section];
                 var newSection    = new IniFileSection {
                     Path = item.FullName, SectionName = section, Values = sectionValues
                 };
                 iniFile.Sections.Add(newSection);
             }
             WriteVerbose($"{item.FullName} finished!");
             WriteObject(iniFile);
         }
     }
 }