예제 #1
0
 public Node Follow(string key)
 {
     if(Children.ContainsKey(key))
     {
         return Children[key];
     }else
     {
         Node n;
         Children.Add(key,n=new Node(this, key));
         return n;
     }
 }
예제 #2
0
 private Node process(Node root, string value)
 {
     return null;
 }
예제 #3
0
 public Node(Node parent, string key)
 {
     Parent = parent;
     Key = key;
     this.Children = new Dictionary<string, Node>();
     this.Links = new List<string>();
     this.TemplateIndex = 0;
 }
예제 #4
0
        /*
        function process( root, value )
        {
        var result;
        var i;
        var key;
        var node;

        if ( typeof value === "object" ) {
            // if it's an array,
            if (Object.prototype.toString.apply(value) === '[object Array]') {
                // process each item in the array.
                result = [];
                for( i = 0; i < value.length; i++ ) {
                    result.push( process( root, value[i] ) );
                }
            } else {
                node = root;
                result = { "":[] };
                // it's an object. For each key,
                for (key in value) {
                    if ( Object.hasOwnProperty.call( value, key ) ) {
                        // follow the node.
                        node = node.follow( key );

                        // add its value to the array.
                        result[""].push( process( root, value[key] ) );
                    }
                }

                node.links.push( result );
            }
        } else {
            result = value;
        }

        return result;
        }
        }*/
        public string Compress(string txt)
        {
            var root = new Node(null, "");
            var values = process(root, txt);
            //var templates = createTemplates(root);
            //if (templates.Count() > 0)
            {
                /*       return JSON.stringify( { "f": "cjson", "t": templates,
                "v": values }, null, null );*/
            }
            //else
            return txt;
        }