Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="string_0"></param>
        /// <param name="byte_0"></param>
        public void SetNestedAttribute(string path, string string_0, byte[] byte_0)
        {
            var chrArray = new[] { '.' };

            string[] strArrays     = path.Split(chrArray, StringSplitOptions.RemoveEmptyEntries);
            var      keyValuePairs = new Stack <KeyValuePair <string, DataMap> >(strArrays.Length);
            DataMap  valueMap      = this;

            foreach (string t in strArrays)
            {
                valueMap = valueMap.GetValueMap(t) ?? new DataMap();
                keyValuePairs.Push(new KeyValuePair <string, DataMap>(t, valueMap));
            }
            KeyValuePair <string, DataMap> keyValuePair = keyValuePairs.Peek();

            keyValuePair.Value.SetValueRaw(string_0, byte_0);
            while (keyValuePairs.Count > 1)
            {
                KeyValuePair <string, DataMap> keyValuePair1 = keyValuePairs.Pop();
                KeyValuePair <string, DataMap> keyValuePair2 = keyValuePairs.Peek();
                keyValuePair2.Value.SetValueRaw(keyValuePair1.Key, keyValuePair1.Value.Serialize());
            }
            KeyValuePair <string, DataMap> keyValuePair3 = keyValuePairs.Peek();
            KeyValuePair <string, DataMap> keyValuePair4 = keyValuePairs.Peek();

            SetValueRaw(keyValuePair3.Key, keyValuePair4.Value.Serialize());
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="string_0"></param>
        /// <returns></returns>
        public string GetNestedAttrib(string path, string string_0)
        {
            if (string_0 != null)
            {
                path = string.Concat(path, ".", string_0);
            }
            var chrArray = new[] { '.' };

            string[] strArrays = path.Split(chrArray, StringSplitOptions.RemoveEmptyEntries);
            DataMap  valueMap  = this;
            int      num       = 0;

            while (num < strArrays.Length)
            {
                if (num != strArrays.Length - 1)
                {
                    valueMap = valueMap.GetValueMap(strArrays[num]);
                    if (valueMap == null)
                    {
                        return(null);
                    }
                    num++;
                }
                else
                {
                    return(valueMap.GetValue(strArrays[num]));
                }
            }
            return(null);
        }