public static void Start()
        {
            InitializeOutputFolder();

            var dataRoot = GetRoot();

            Debug.WriteLine("*** Original ***");
            Display(dataRoot);

            var json = JsonConvert.SerializeObject(dataRoot);

            Debug.WriteLine("*** Serialized ***\n");
            Debug.WriteLine(json + "\n\n");
            File.WriteAllText(Path.Combine(OutputFolderName, FileName), json);

            dataRoot = JsonConvert.DeserializeObject <CategoryDataNode>(json);
            Debug.WriteLine("*** De-serialized ***");
            Display(dataRoot);

            var root = new SimpleMutableCategoryNode(new CategoryItem(dataRoot.CategoryId, dataRoot.Name));

            root.Build(dataRoot, d => new CategoryItem(d.CategoryId, d.Name), n => !n.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase));
            Debug.WriteLine("*** Proper Tree (with some ignored) ***");
            Display(root);

            dataRoot = new CategoryDataNode(root.Id, root.Name);
            root.CopyTo(dataRoot, (n, d) =>
            {
                d.CategoryId = n.Item.CategoryId;
                d.Name       = n.Item.Name;
            });

            Debug.WriteLine("*** Converted back to Serializable ***");
            Display(dataRoot);
        }
Esempio n. 2
0
        private static void DemoCopy(SimpleMutableCategoryNode root)
        {
            var newRoot = new SimpleMutableCategoryNode(root.Item);

            root.CopyTo(newRoot);

            WriteLine("\n\n*** COPIED ***");
            Display(newRoot);
        }