예제 #1
0
        /// <summary>
        /// get the entry specified by the key
        /// </summary>
        /// <param name="key">key name of entry</param>
        /// <returns>entry specified by key</returns>
        public object Get(string key)
        {
            // use PURL for easier extraction of parts
            PURL url = new PURL(key);

            // test if url is complex
            if (url.IsComplex())
            {
                // test first part of url
                string first = url.GetFirstPart();
                if (!properties.Contains(first))
                {
                    return(null);
                }
                // if ok advance to rest of url
                PropertySet child = (PropertySet)properties[first];
                return(child.Get(url.GetWithoutFirstPart()));
            }
            if (objects.Contains(key))
            {
                return(objects[key]);
            }
            if (properties.Contains(key))
            {
                return(properties[key]);
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// set the entry specififed by the key
        /// </summary>
        /// <param name="key">key name of entry</param>
        /// <param name="obj">entry to set</param>
        public void Set(string key, object obj)
        {
            // use PURL for easier extraction of parts
            PURL url = new PURL(key);

            // test if url is complex
            if (url.IsComplex())
            {
                // test first part of url
                string first = url.GetFirstPart();
                if (!properties.Contains(first))
                {
                    properties.Add(first, new PropertySet(first));
                }
                // if ok advance to rest of url
                PropertySet child = (PropertySet)properties[first];
                child.Set(url.GetWithoutFirstPart(), obj);
                return;
            }
            if (obj is PropertySet)
            {
                properties[key] = obj;
            }
            else
            {
                objects[key] = obj;
            }
        }
예제 #3
0
        /// <summary>
        /// remove a certain entry
        /// </summary>
        /// <param name="key">key name of entry</param>
        public void Remove(string key)
        {
            // use PURL for easier extraction of parts
            PURL url = new PURL(key);

            // test if url is complex
            if (url.IsComplex())
            {
                // test first part of url
                string first = url.GetFirstPart();
                if (!properties.Contains(first))
                {
                    return;
                }
                // if ok advance to rest of url
                PropertySet child = (PropertySet)properties[first];
                child.Remove(url.GetWithoutFirstPart());
                // if branch is empty => delete
                if (child.IsEmpty())
                {
                    properties.Remove(first);
                }
                return;
            }
            // remove
            if (objects.Contains(key))
            {
                objects.Remove(key);
            }
            if (properties.Contains(key))
            {
                properties.Remove(key);
            }
        }
예제 #4
0
        /// <summary>
        /// test if PropertySet contains a certain entry (object or PropertySet)
        /// </summary>
        /// <param name="key">key name of entry</param>
        /// <returns>true if entry is contained</returns>
        public bool Contains(string key)
        {
            // use PURL for easier extraction of parts
            PURL url = new PURL(key);

            // test if url is complex
            if (url.IsComplex())
            {
                // test first part
                string first = url.GetFirstPart();
                if (!properties.Contains(first))
                {
                    return(false);
                }
                // if ok test rest of url
                PropertySet child = (PropertySet)properties[first];
                return(child.Contains(url.GetWithoutFirstPart()));
            }
            // test if key is contained in properties or objects
            return(properties.Contains(key) || objects.Contains(key));
        }