Exemplo n.º 1
0
        public static XmlAndXsd GenerateXmlAndXsd(object obj)
        {
            XmlAndXsd ret  = new XmlAndXsd();
            Type      type = obj.GetType();

            ret.XsdFileName = Str.MakeSafeFileName(type.Name + ".xsd");
            ret.XsdData     = GetXmlSchemaFromType(type);

            ret.XmlFileName = Str.MakeSafeFileName(type.Name + ".xml");
            string str = Util.ObjectToXmlString(obj);

            str = str.Replace(
                "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"",
                "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\""
                + ret.XsdFileName
                + "\"");
            ret.XmlData = Str.Utf8Encoding.GetBytes(str);

            return(ret);
        }