Beispiel #1
0
        /// <summary>
        /// Adds an IniProperty to the end of the properties list.
        /// </summary>
        /// <param name="property">The IniProperty to be added to the end of the properties list.</param>
        public IniSection Add(IniProperty property)
        {
            string key = property.Key;
            IniType type = property.Type;

            /* Generate a key for certain types, this fixes the problem
             * with duplicate key for non-property lines. */
            switch (type)
            {
                case IniType.Comment:
                case IniType.EmptyLine:
                case IniType.Invalid:
                    // Empty key means we have to generate a random one
                    if (string.IsNullOrEmpty(key))
                        key = GenerateKey(type);

                    break;
                case IniType.Property:
                default:
                    key = property.Key;
                    break;
            }

            // Apply new key and section
            property.Key = key;
            property.Section = this.Name;

            this.properties.Add(key, property);

            return this;
        }
Beispiel #2
0
        /// <summary>
        /// Returns a read-only collection of properties.
        /// </summary>
        public ICollection <IniProperty> GetAll()
        {
            IniProperty[] properties = new IniProperty[this.properties.Count];

            this.properties.Values.CopyTo(properties, 0);

            return(Array.AsReadOnly <IniProperty>(properties));
        }
Beispiel #3
0
        /// <summary>
        /// Returns a read-only collection of properties.
        /// </summary>
        public ICollection<IniProperty> GetAll()
        {
            IniProperty[] properties = new IniProperty[this.properties.Count];

            this.properties.Values.CopyTo(properties, 0);

            return Array.AsReadOnly<IniProperty>(properties);
        }