示例#1
0
        /// <summary>
        /// 加载数据记录
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="node"></param>
        internal void LoadMember(SubString name, Xml.Node node)
        {//https://msdn.microsoft.com/zh-cn/library/fsbx0t7x(v=vs.80).aspx
            //对于泛型类型,类型名称后跟反勾号,再跟一个数字,指示泛型类型参数的个数。例如,
            //<member name="T:SampleClass`2"> 是定义为 public class SampleClass<T, U> 的类型的标记。
            if (name[1] == ':')
            {
                char code = name[0];
                switch (code & 7)
                {
                case 'T' & 7:    //类型:类、接口、结构、枚举、委托
                    if (code == 'T')
                    {
                        types[name.GetSub(2)] = node;
                    }
                    break;

                case 'F' & 7:    //字段
                    if (code == 'F')
                    {
                        fields[name.GetSub(2)] = node;
                    }
                    break;

                case 'P' & 7:    //属性(包括索引程序或其他索引属性)
                    if (code == 'P')
                    {
                        properties[name.GetSub(2)] = node;
                    }
                    break;

                case 'M' & 7:    //方法(包括一些特殊方法,例如构造函数、运算符等)
                    if (code == 'M')
                    {
                        methods[name.GetSub(2)] = node;
                    }
                    break;
                    //case 'E' & 7://事件
                    //    break;
                    //case 'N' & 7://命名空间
                    //case '!' & 7://错误字符串
                    //break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// 获取列表节点数据
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public                                      Node this[int index]
        {
            get
            {
                switch (Type)
                {
                case NodeType.String:
                case NodeType.NumberString:
                case NodeType.ErrorQuoteString:
                    goto CHARNODE;

                case NodeType.QuoteString:
                    checkQuoteString();
CHARNODE:
                    if ((uint)index < SubString.Length)
                    {
                        return new Node {
                                   Type = NodeType.String, SubString = SubString.GetSub(index, 1)
                        }
                    }
                    ;
                    break;

                case NodeType.Array:
                    if ((uint)index < (uint)Int64)
                    {
                        return(ListArray[index]);
                    }
                    break;

                case NodeType.Dictionary:
                    int count = (int)Int64;
                    if (count != 0)
                    {
                        string key = index.toString();
                        foreach (KeyValue <Node, Node> value in DictionaryArray)
                        {
                            if (value.Key.String == key)
                            {
                                return(value.Value);
                            }
                        }
                    }
                    break;
                }
                return(default(Node));
            }
        }