OverLoad for Save() in Drawing.cs

Jul 8, 2010 at 6:38 AM

hi!

I needed a sort of User Defined objects witch user can select the output object and before saving doing something on selected object!

So i wrote some Overloads for these methods:

Drawing.cs

        public void Save(string path, IEnumerable<DynamicGeometry.IFigure> lst)
        {
            DrawingSerializer.Save(this, path, lst);
        }

DrawingSerializer.cs


        public static void Save(Drawing drawing, string fileName, IEnumerable<DynamicGeometry.IFigure> lst)
        {
            string serialized = SaveDrawing(drawing, lst);
            File.WriteAllText(fileName, serialized);
        }

        public static string SaveDrawing(Drawing drawing, IEnumerable<DynamicGeometry.IFigure> lst)
        {
            return WriteUsingXmlWriter(w => SaveDrawing(drawing, w, lst));
        }

        public static void SaveDrawing(Drawing drawing, XmlWriter writer, IEnumerable<DynamicGeometry.IFigure> lst)
        {
            DrawingSerializer serializer = new DrawingSerializer();
            serializer.Write(drawing, writer, lst);
        }

        void Write(Drawing drawing, XmlWriter writer, IEnumerable<DynamicGeometry.IFigure> lst)
        {
            writer.WriteStartDocument();
            writer.WriteStartElement("Drawing");
            WriteCoordinateSystem(drawing, writer);
            WriteStyles(drawing, writer);
            WriteFigureList(lst, writer);
            writer.WriteEndElement();
            writer.WriteEndDocument();
        }

 

I hope it would be helpful!