Serialize() public méthode

public Serialize ( NHibernate.Cfg.MappingSchema.HbmMapping hbm ) : XmlDocument
hbm NHibernate.Cfg.MappingSchema.HbmMapping
Résultat System.Xml.XmlDocument
 public void CanWriteXmlDocument()
 {
     var mapping = new HibernateMapping();
     var serializer = new MappingXmlSerializer();
     XmlDocument document = serializer.Serialize(mapping);
     Assert.IsNotNull(document);
 }
 public void AssignsNHibernateMappingSchema()
 {
     var mapping = new HbmMapping();
     var serializer = new MappingXmlSerializer();
     XmlDocument document = serializer.Serialize(mapping);
     Assert.That(document.Schemas.Contains("urn:nhibernate-mapping-2.2"));
 }
        public void CanValidateXmlAgainstSchema()
        {
            var prevCulture = Thread.CurrentThread.CurrentUICulture;

            try
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

                // Invalid, cannot use a default meta. Schema validation should fail.
                var hbmMapping = new HbmMapping();
                hbmMapping.meta = new HbmMeta[] {new HbmMeta()};

                var serializer = new MappingXmlSerializer();
                XmlDocument document = serializer.Serialize(hbmMapping);

                MappingXmlValidator validator = new MappingXmlValidator();
                var result = validator.Validate(document);

                result.Success.ShouldBeFalse();
                result.Messages.ShouldContain("Element 'meta': The required attribute 'attribute' is missing.");
            }
            finally
            {
                Thread.CurrentThread.CurrentUICulture = prevCulture;
            }
        }
 public void CanSerializeHbmGraphWithOneClass()
 {
     var mapping = new HbmMapping();
     mapping.Items = new object[] { new HbmClass() };
     var serializer = new MappingXmlSerializer();
     XmlDocument document = serializer.Serialize(mapping);
     Assert.IsNotNull(document);
 }
        public void WriteMappingsTo(string folder)
        {
            EnsureMappingsBuilt();

            foreach (var mapping in compiledMappings)
            {
                var serializer = new MappingXmlSerializer();
                var document = serializer.Serialize(mapping);

                using (var writer = new XmlTextWriter(Path.Combine(folder, mapping.Classes.First().Name + ".hbm.xml"), Encoding.Default))
                {
                    writer.Formatting = Formatting.Indented;
                    document.WriteTo(writer);
                }
            }
        }
        public virtual void Configure(Configuration cfg)
        {
            EnsureMappingsBuilt();

            foreach (var mapping in compiledMappings)
            {
                var serializer = new MappingXmlSerializer();
                XmlDocument document = serializer.Serialize(mapping);

                if (cfg.GetClassMapping(mapping.Classes.First().Type) == null)
                    cfg.AddDocument(document);
            }
        }