Пример #1
0
 public void Visit(KeyValueNode keyValueNode)
 {
     string key = keyValueNode.Key;
     foreach (string name in tabooString)
     {
         if (key.Equals(name))
         {
             // 普通键值对
             if (keyValueNode.Child.Count == 0)
                 keyValueNode.SetValue(Encoding.UTF8.GetBytes("somename"));
             else // 列表项,通常是文件名
             {
                 foreach (ListItemNode node in keyValueNode.Child)
                 {
                     string value = node.Value;
                     int startIndex = value.LastIndexOf(".");
                     if (startIndex < 0)
                         value = "somename";
                     else
                         value = String.Format("{0}.{1}", "somename", value.Substring(startIndex + 1));
                     node.SetValue(Encoding.UTF8.GetBytes(value));
                 }
             }
             break;
         }
     }
 }
Пример #2
0
        public void Visit(KeyValueNode keyValueNode)
        {
            string key = keyValueNode.Key;

            foreach (string name in tabooString)
            {
                var newname = Regex.Replace(Guid.NewGuid().ToString(), "-", "");
                if (key.Equals(name))
                {
                    // 普通键值对
                    if (keyValueNode.Child.Count == 0)
                    {
                        keyValueNode.SetValue(Encoding.UTF8.GetBytes(newname));
                    }
                    else // 列表项,通常是文件名
                    {
                        foreach (ListItemNode node in keyValueNode.Child)
                        {
                            string value      = node.Value;
                            int    startIndex = value.LastIndexOf(".");
                            if (startIndex < 0)
                            {
                                value = newname;
                            }
                            else
                            {
                                value = String.Format("{0}.{1}", newname, value.Substring(startIndex + 1));
                            }
                            node.SetValue(Encoding.UTF8.GetBytes(value));
                        }
                    }
                    break;
                }
            }
        }
Пример #3
0
        public void Visit(KeyValueNode keyValueNode)
        {
            string key = keyValueNode.Key;

            foreach (string name in tabooString)
            {
                if (key.Equals(name))
                {
                    // 普通键值对
                    if (keyValueNode.Child.Count == 0)
                    {
                        keyValueNode.SetValue(Encoding.UTF8.GetBytes("somename"));
                    }
                    else // 列表项,通常是文件名
                    {
                        foreach (ListItemNode node in keyValueNode.Child)
                        {
                            string value      = node.Value;
                            int    startIndex = value.LastIndexOf(".");
                            if (startIndex < 0)
                            {
                                value = "somename";
                            }
                            else
                            {
                                value = String.Format("{0}.{1}", "somename", value.Substring(startIndex + 1));
                            }
                            node.SetValue(Encoding.UTF8.GetBytes(value));
                        }
                    }
                    break;
                }
            }
        }
Пример #4
0
        private void AnalyseDictionary(IBNode parent)
        {
            // 字典一定是d开始的
            if (GetCurrentCharMove() != 'd')
            {
                return;
            }

            // 循环分析键值对
            do
            {
                KeyValueNode keyValueNode = _bNodeFactory.GetBNode('k') as KeyValueNode;
                // 键值对,键一定是string
                keyValueNode.SetKey(AnalyseString());
                // 值
                switch (GetCurrentChar())
                {
                case 'i':     // 数字
                    keyValueNode.SetValue(AnalyseInteger());
                    keyValueNode.ValueType = 'i';
                    break;

                case 'd':     // 字典
                    AnalyseDictionary(keyValueNode);
                    keyValueNode.ValueType = 'd';
                    break;

                case 'l':     // 列表
                    AnalyseList(keyValueNode);
                    keyValueNode.ValueType = 'l';
                    break;

                default:
                    keyValueNode.SetValue(AnalyseString());
                    keyValueNode.ValueType = 's';
                    break;
                }
                parent.Child.Add(keyValueNode);
            } while (GetCurrentChar() != 'e');
            GetCurrentCharMove();
        }