Beispiel #1
0
        private uint WalkSettingsValues(SettingsWriter writer, IPropertySet values, bool isLastAtThisNestingLevel)
        {
            if (values.Count == 0)
            {
                return(0);
            }

            writer.StartValues();
            uint count = 0;
            var  keys  = SortKeys(values.Keys);

            foreach (var key in keys)
            {
                ++count;
                var value = values[key];
                ShowProgressAddingSettingsValue(key);
                var type = value.GetAppDataType();
                if (type == AppDataType.Type.ApplicationDataCompositeValue)
                {
                    WalkSettingsComposite(writer, key, (ApplicationDataCompositeValue)value, count == keys.Count);
                }
                else
                {
                    writer.WriteValue(key, value, count == keys.Count);
                }
            }
            writer.EndValues(isLastAtThisNestingLevel);

            if (this.displayLevel < DisplayLevel.Verbose && count > 0)
            {
                PrintLine();
            }

            return(count);
        }
Beispiel #2
0
        private uint WalkSettingsContainer(SettingsWriter writer, ApplicationDataContainer container, bool isLastAtThisNestingLevel)
        {
            if (container.Values.Count == 0 && container.Containers.Count == 0)
            {
                return(0);
            }

            writer.StartContainer(container);
            WalkSettingsValues(writer, container.Values, container.Containers.Count == 0);
            uint count      = 0;
            var  containers = container.Containers;
            var  keys       = SortKeys(containers.Keys).ToList();

            foreach (var key in keys)
            {
                ++count;
                var child = containers[key];
                WalkSettingsContainer(writer, child, count == keys.Count);
            }
            writer.EndContainer(isLastAtThisNestingLevel);

            if (this.displayLevel < DisplayLevel.Verbose && count > 0)
            {
                PrintLine();
            }

            return(count);
        }
Beispiel #3
0
 private void WriteSettings(SettingsWriter writer, Locality locality, ApplicationDataContainer root)
 {
     writer.Start();
     writer.StartContainers(LocalityToApplicationDataLocality(locality));
     WalkSettingsContainer(writer, root, true);
     writer.EndContainers();
     writer.End();
 }
Beispiel #4
0
        private uint ZipAddSettings(ZipArchive zip, Locality locality, ApplicationDataContainer root)
        {
            PrintLineFormat("Scanning {0}", locality.ToString());

            var entry = zip.CreateEntry(locality.ToString() + "." + this.settingsFormat.ToString().ToLowerInvariant(), this.compressionLevel);

            uint countValues     = 0;
            uint countContainers = 0;

            using (SettingsWriter writer = CreateSettingsWriter(entry.Open()))
            {
                WriteSettings(writer, locality, root);
            }

            return(countValues);
        }
Beispiel #5
0
        private uint FileSystemAddSettings(string path, Locality locality, ApplicationDataContainer root)
        {
            PrintLineFormat("Scanning {0}", locality.ToString());

            string filename   = Path.Combine(path, locality.ToString() + "." + this.settingsFormat.ToString().ToLowerInvariant());
            var    fileStream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Write | FileShare.Delete);

            uint countValues     = 0;
            uint countContainers = 0;

            using (SettingsWriter writer = CreateSettingsWriter(fileStream))
            {
                WriteSettings(writer, locality, root);
            }

            return(countValues);
        }
Beispiel #6
0
        private uint WalkSettingsComposite(SettingsWriter writer, string name, ApplicationDataCompositeValue composite, bool isLastAtThisNestingLevel)
        {
            if (composite.Count == 0)
            {
                return(0);
            }

            writer.StartComposite(name);
            uint count  = 0;
            var  keys   = SortKeys(composite.Keys);
            var  values = composite.Values;

            foreach (var key in composite.Keys)
            {
                ++count;
                var value = composite[key];

                writer.WriteValue(key, value, count == keys.Count);
            }
            writer.EndComposite(isLastAtThisNestingLevel);

            System.Diagnostics.Debug.Assert(composite.Count >= 0);
            return((uint)composite.Count);
        }