Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / XSLT

Customize Applications with XML Fragments: Part 2

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
19 Jun 20073 min read 21.9K   111   9  
An advanced discussion of customizing applications with XML fragments
using System;
using System.Collections.Generic;
using System.Text;
using ConsoleApplication1.data;
using Bulasoft.Common.Serialization;
using System.Drawing;
using System.IO;
using System.Xml.Serialization;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            AdvancedSerialization();
        }

        private static void AdvancedSerialization()
        {
            Project2Space space = new Project2Space();
            LogInfo logInfo = space.LogInfo;
            logInfo.UserName = "username";
            logInfo.Password = "userpassword";

            StyleCollection styles = space.Styles;
            Style style1 = styles.Add("red icon 1");
            style1.Color = Color.Red;
            style1.Icon = "icon1";

            Style style2 = styles.Add("black icon2");
            style2.Color = Color.Black;
            style2.Icon = "icon2";

            TreeItemCollection collection = space.TreeItems;
            TreeItem root = collection.Add("root");
            root.Style = style1;

            TreeItem item1 = collection.Add("item1");
            item1.Style = style2;

            TreeItem item2 = collection.Add("item2");
            item2.Style = style2;

            TreeItem item11 = collection.Add("item11");
            item11.Parent = item11;
            item11.Style = style1;

            Writer.Write(space, "test.xml", false);
            space.AcceptChanges();
            item11.Parent = root;
            item1.Style = style1;
            Writer.Write(space, "changes.xml", true);

            Project2Space testSpace = new Project2Space();
            Reader.Read("test.xml", testSpace, null);
            Reader.Read("changes.xml", testSpace, null);
            Style redStyle = testSpace.Find(style1.ID.Value) as Style;
            TreeItem test_item1 = testSpace.TreeItems.Find(item1.Name);

            if (test_item1.Style == redStyle)
                Console.WriteLine("Perfect");

            if (testSpace.LogInfo.Password == space.LogInfo.Password)
                Console.WriteLine("Password passed");
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions