Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
General[Message Deleted] Pin
Prajeesh25-Feb-09 0:23
Prajeesh25-Feb-09 0:23 
GeneralRe: Delete in Richtextbox? Pin
Eddy Vluggen25-Feb-09 1:06
professionalEddy Vluggen25-Feb-09 1:06 
Answer[Message Deleted] Pin
Prajeesh26-Feb-09 16:39
Prajeesh26-Feb-09 16:39 
GeneralRe: Delete in Richtextbox? Pin
Eddy Vluggen26-Feb-09 21:06
professionalEddy Vluggen26-Feb-09 21:06 
QuestionStront typing error Pin
kanchoette24-Feb-09 22:17
kanchoette24-Feb-09 22:17 
AnswerRe: Stront typing error Pin
kanchoette24-Feb-09 23:41
kanchoette24-Feb-09 23:41 
QuestionQ: How to serialize layer structure Pin
pandd24-Feb-09 21:13
pandd24-Feb-09 21:13 
AnswerRe: Q: How to serialize layer structure Pin
J4amieC24-Feb-09 22:39
J4amieC24-Feb-09 22:39 
It think, basically, its a case of implementing IXmlSerializable in your classes if you want to finely control how the classes are serialized to Xml. There are also a number of attributes in the System.Xml.Serialization namespace that you can adorn your classes with.

I wrote this small console application sample to demonstrate to you the IXmlSerializable route, which I think will suit you better.

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace ConsoleApplication
{
    class Program
    {      

        static void Main(string[] args)
        {
            Layer layer = new Layer();
            layer.DrawableObjects.Add(new Graphic());
            layer.DrawableObjects.Add(new Layer());

            XmlSerializer s = new XmlSerializer(typeof(Layer));
            s.Serialize(Console.Out, layer);
            Console.ReadLine();


        }

        
    }

     public abstract class DrawableObject : IXmlSerializable
     {
         #region IXmlSerializable Members

         public virtual XmlSchema GetSchema()
         {
             throw new NotImplementedException();
         }

         public abstract void ReadXml(XmlReader reader);

         public abstract void WriteXml(XmlWriter writer);

         #endregion
     }

    [Serializable]
    [XmlRoot("Root")]
    public class Layer : DrawableObject
    {
        private List<Drawableobject> drawableObjects = new List<Drawableobject>();

        public List<Drawableobject> DrawableObjects
        {
            get
            {
                return this.drawableObjects;
            }            
        }

        public override void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("Layer");
            foreach (DrawableObject obj in this.drawableObjects)
                obj.WriteXml(writer);
            writer.WriteEndElement();
        }

        public override void ReadXml(XmlReader reader)
        {
            throw new NotImplementedException();
            
        }
    }

    [Serializable]
    [XmlRoot("Graphic")]
    public class Graphic : DrawableObject
    {
        public override void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("Graphic");
            writer.WriteEndElement();
        }

        public override void ReadXml(XmlReader reader)
        {
            throw new NotImplementedException();
        }
    }

}

GeneralRe: Q: How to serialize layer structure Pin
pandd24-Feb-09 23:52
pandd24-Feb-09 23:52 
QuestionHow to retrieve images from webbrowser control without reload? Pin
WebFormSubmitter24-Feb-09 21:08
WebFormSubmitter24-Feb-09 21:08 
AnswerRe: How to retrieve images from webbrowser control without reload? Pin
Curtis Schlak.25-Feb-09 10:08
Curtis Schlak.25-Feb-09 10:08 
GeneralThanks! But how to extraxt already loaded image from the webbrower? Pin
WebFormSubmitter26-Feb-09 8:57
WebFormSubmitter26-Feb-09 8:57 
GeneralRe: Thanks! But how to extraxt already loaded image from the webbrower? Pin
Curtis Schlak.26-Feb-09 10:34
Curtis Schlak.26-Feb-09 10:34 
Questiona serialization problem Pin
abhiram_nayan24-Feb-09 20:53
abhiram_nayan24-Feb-09 20:53 
AnswerRe: a serialization problem Pin
Expert Coming24-Feb-09 22:36
Expert Coming24-Feb-09 22:36 
GeneralRe: a serialization problem Pin
abhiram_nayan25-Feb-09 0:50
abhiram_nayan25-Feb-09 0:50 
QuestionThread Pin
Ammu S24-Feb-09 20:33
Ammu S24-Feb-09 20:33 
AnswerRe: Thread Pin
Rob Philpott24-Feb-09 21:19
Rob Philpott24-Feb-09 21:19 
AnswerRe: Thread Pin
Krishnraj24-Feb-09 23:11
Krishnraj24-Feb-09 23:11 
GeneralRe: Thread Pin
Megidolaon25-Feb-09 22:13
Megidolaon25-Feb-09 22:13 
QuestionSimple Threading (VS 2005) Example Pin
WinSolution24-Feb-09 20:33
WinSolution24-Feb-09 20:33 
AnswerRe: Simple Threading (VS 2005) Example Pin
J a a n s24-Feb-09 20:41
professionalJ a a n s24-Feb-09 20:41 
GeneralRe: Simple Threading (VS 2005) Example Pin
WinSolution24-Feb-09 20:48
WinSolution24-Feb-09 20:48 
AnswerRe: Simple Threading (VS 2005) Example Pin
prasadbuddhika24-Feb-09 20:45
prasadbuddhika24-Feb-09 20:45 
GeneralRe: Simple Threading (VS 2005) Example Pin
WinSolution24-Feb-09 21:04
WinSolution24-Feb-09 21:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.