Click here to Skip to main content
15,892,965 members
Home / Discussions / C#
   

C#

 
GeneralRe: uploading xml to database Pin
kalyan_241617-Aug-07 1:29
kalyan_241617-Aug-07 1:29 
Questionxml serialization for multiple arraylists Pin
cyn817-Aug-07 0:13
cyn817-Aug-07 0:13 
AnswerRe: xml serialization for multiple arraylists Pin
Giorgi Dalakishvili17-Aug-07 0:39
mentorGiorgi Dalakishvili17-Aug-07 0:39 
GeneralRe: xml serialization for multiple arraylists Pin
cyn819-Aug-07 16:53
cyn819-Aug-07 16:53 
AnswerRe: xml serialization for multiple arraylists [modified] Pin
Hessam Jalali17-Aug-07 4:02
Hessam Jalali17-Aug-07 4:02 
GeneralRe: xml serialization for multiple arraylists [modified] Pin
cyn819-Aug-07 16:43
cyn819-Aug-07 16:43 
GeneralRe: xml serialization for multiple arraylists Pin
cyn819-Aug-07 19:00
cyn819-Aug-07 19:00 
GeneralRe: xml serialization for multiple arraylists Pin
Hessam Jalali19-Aug-07 22:16
Hessam Jalali19-Aug-07 22:16 
I think the best way to do this is to create a new class for holding whole of your data. about the GPD you used in the code ,as a tip holding serialized streams is not a good choice ,I think you can serialize whole of your GPDs together (because they are marked as serializable)

and in the code you put all your data in one stream ,retrieving from it is not impossible but is far more harder than use a new class to hold all of your data

here is the scheme of such a class (it has some works to be a complete one)


<code>
        [XmlRoot("MyData")]
        [Serializable]
        class MyData
        {
//it seems datas in each arraylist are the same type so if you're codinh in .NET2.0 or above use List<> instead of ArrayList

            ArrayList shapeTypeList;
            ArrayList colorList;
            ArrayList coordList;
            ArrayList sizeList;

            ArrayList graphicsPathDataList;

            [XmlArray("ShapeData")]
            [XmlArrayItem("Shape",typeof(/*you must get the type here*/))]
            public ArrayList ShapeTypeList
            {
                get { return this.shapeTypeList; }
            }

            [XmlArray("ColorData")]
            [XmlArrayItem("Color",typeof(/*you must get the type here*/))]
            public ArrayList ColorList
            {
                get { return this.colorList; }
            }

            [XmlArray("CoorinationData")]
            [XmlArrayItem("Coordination",typeof(/*you must get the type here*/))]
            public ArrayList CoordList
            {
                get { return this.coordList; }
            }

            [XmlArray("SizeData")]
            [XmlArrayItem("Size",typeof(/*you must get the type here*/))]
            public ArrayList SizeList
            {
                get { return this.sizeList; }
            }

            [XmlArray("GPDData")]
            [XmlArrayItem("GPD",typeof(/*you must get the type here*/))]
            public ArrayList GraphicsPathDataList
            {
                get { return this.graphicsPathDataList; }
            }

            public MyData(ArrayList shape, ArrayList color, ArrayList coord, ArrayList size, ArrayList gpd)
            {
                this.shapeTypeList = shape;
                this.colorList = color;
                this.coordList = coord;
                this.sizeList = size;
                this.graphicsPathDataList = gpd;
            }

            static MyData BinLoad(string path)
            {
                BinaryFormatter binSer=new BinaryFormatter();
                FileStream fo=new  FileStream(path,FileMode.Open);

                object data=binSer.Deserialize(fo);
                fo.Close();

                return data as MyData;
            }

            void BinSerialize(string path)
            {
                BinaryFormatter binSer=new BinaryFormatter();
                FileStream fo=new  FileStream(path,FileMode.OpenOrCreate);

                binSer.Serialize(fo,this);
                fo.Close();
            }

            static MyData XmlLoad(string path)
            {
                XmlSerializer xmlSer=new XmlSerializer(typeof(MyData));
                FileStream fo=new  FileStream(path,FileMode.Open);

                object data=xmlSer.Deserialize(fo);
                fo.Close();

                return data as MyData;
            }

            void XmlSerialize(string path)
            {
                XmlSerializer xmlSer=new XmlSerializer(this.GetType());
                FileStream fo=new  FileStream(path,FileMode.OpenOrCreate);

                xmlSer.Serialize(fo,this);
                fo.Close();
            }

            public enum SerializeTo{XML,Binary};

            public void Serialize(string path,SerializeTo to)
            {
                if(to==SerializeTo.Binary)
                    this.BinSerialize(path);
                else 
                    this.XmlSerialize(path);
            }

            public static MyData Load(string path,SerializeTo to)
            {
                if(to==SerializeTo.Binary)
                    return BinLoad(path);
                else 
                    return XmlLoad(path);
            }

        }
</code>


I'm not sure it works just after putting the types because I couldn't test that, but i'm sure it will give you the clue

another thing MyData Class can be serialize in both Xml and Binary

hope the post would be useful

good luck my friend
GeneralRe: xml serialization for multiple arraylists Pin
cyn820-Aug-07 0:53
cyn820-Aug-07 0:53 
QuestionInput string was not in a correct format Pin
project c16-Aug-07 23:57
project c16-Aug-07 23:57 
AnswerRe: Input string was not in a correct format Pin
Giorgi Dalakishvili17-Aug-07 0:03
mentorGiorgi Dalakishvili17-Aug-07 0:03 
AnswerRe: Input string was not in a correct format Pin
Luc Pattyn17-Aug-07 1:38
sitebuilderLuc Pattyn17-Aug-07 1:38 
Questionupdating a DB using a windows form Pin
helloise16-Aug-07 23:49
helloise16-Aug-07 23:49 
AnswerRe: updating a DB using a windows form Pin
Giorgi Dalakishvili16-Aug-07 23:55
mentorGiorgi Dalakishvili16-Aug-07 23:55 
AnswerRe: updating a DB using a windows form Pin
Rocky#17-Aug-07 1:20
Rocky#17-Aug-07 1:20 
GeneralRe: updating a DB using a windows form Pin
helloise17-Aug-07 1:40
helloise17-Aug-07 1:40 
GeneralRe: updating a DB using a windows form Pin
Rocky#17-Aug-07 1:47
Rocky#17-Aug-07 1:47 
AnswerRe: updating a DB using a windows form Pin
Talal Sultan17-Aug-07 1:33
Talal Sultan17-Aug-07 1:33 
GeneralRe: updating a DB using a windows form Pin
helloise17-Aug-07 4:45
helloise17-Aug-07 4:45 
QuestionHow to export datagridview columns to MS Word using c# Pin
Exelioindia16-Aug-07 23:22
Exelioindia16-Aug-07 23:22 
AnswerRe: How to export datagridview columns to MS Word using c# Pin
Giorgi Dalakishvili16-Aug-07 23:30
mentorGiorgi Dalakishvili16-Aug-07 23:30 
GeneralRe: How to export datagridview columns to MS Word using c# Pin
Exelioindia16-Aug-07 23:41
Exelioindia16-Aug-07 23:41 
GeneralRe: How to export datagridview columns to MS Word using c# Pin
Giorgi Dalakishvili16-Aug-07 23:51
mentorGiorgi Dalakishvili16-Aug-07 23:51 
GeneralRe: How to export datagridview columns to MS Word using c# Pin
Exelioindia17-Aug-07 0:11
Exelioindia17-Aug-07 0:11 
QuestionUsing WIndows Controls on a ASPX Page... Pin
amitkadamo16-Aug-07 23:10
amitkadamo16-Aug-07 23:10 

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.