NDB.Node.getVersion C# (CSharp) Method

getVersion() public method

public getVersion ( string version ) : Node
version string
return Node
        public Node getVersion(string version)
        {
            Node node = null;

            try
            {
                node = revision[version];
            }
            catch (Exception ee)
            {
            }

            return node;
        }

Usage Example

コード例 #1
0
ファイル: Node.cs プロジェクト: Kirosoft/NouchDB
        // Merge this revision tree with the one passed in as rootNode
        // This implementation overwrites local nodes with the supplied version
        public List <Node> merge(Node rootNode)
        {
            List <Node> conflicts      = new List <Node>();
            bool        finished       = false;
            int         currentVersion = 1;

            Console.WriteLine("Starting merge: ");

            do
            {
                Console.WriteLine("Merge version: " + Convert.ToString(currentVersion));

                Node node = rootNode.getVersion(Convert.ToString(currentVersion));

                if (node == null)
                {
                    Console.WriteLine("Merge complete..");
                    finished = true;
                }
                else
                {
                    if (revision.ContainsKey(Convert.ToString(currentVersion)))
                    {
                        Console.WriteLine("Target contains same version as source ...");
                        Console.WriteLine("Source contains: " + revision[Convert.ToString(currentVersion)].rev_id);
                        Console.WriteLine("Target contains: " + node.rev_id);

                        if (revision[Convert.ToString(currentVersion)].rev_id != node.rev_id)
                        {
                            // Conflict - two version of the same value exist
                            Console.WriteLine("Conflict detected: " + node.rev_id);

                            // work out which has the longer tail - this will take priority
                            conflicts.Add(node);
                        }
                    }
                    else
                    {
                        // Version does not exist - add the whole subtree (potentially)
                        Console.WriteLine("New version being added: " + node.rev_id);
                        this.addVersion(Convert.ToString(currentVersion - 1), node);
                    }
                }

                currentVersion++;
            } while (!finished);


            return(conflicts);
        }
All Usage Examples Of NDB.Node::getVersion