public IPersistentClassInformation GetClassMapping(string path) { var rc = new RootClass(); foreach (string p in probe.GetProperties(path)) { var ser = new JavaScriptSerializer(); var obj = ser.DeserializeObject(p) as IDictionary<string,object>; var prop = new Property(); prop.Value = NHValueJSonHelper.JSonDeserialize(prop.GetType().Assembly, obj["Value"] as IDictionary<string,object>) as IValue; prop.Name = obj["Name"] as string; rc.AddProperty( prop); } return ConfigurationMapper.MapClass(rc); }
private static RootClass CreateMappingClasses() { var classMapping = new RootClass(); var componentMapping = new NHibernate.Mapping.Component(classMapping); var componentPropertyMapping = new Property(componentMapping); componentPropertyMapping.Name = "ComponentPropertyInClass"; classMapping.AddProperty(componentPropertyMapping); var stringValue = new SimpleValue(); stringValue.TypeName = typeof(string).FullName; var stringPropertyInComponentMapping = new Property(stringValue); stringPropertyInComponentMapping.Name = "StringPropertyInComponent"; componentMapping.AddProperty(stringPropertyInComponentMapping); var componentType = (IAbstractComponentType)componentMapping.Type; Assume.That(CascadeStyle.None == stringPropertyInComponentMapping.CascadeStyle); Assume.That(CascadeStyle.None == componentType.GetCascadeStyle(0)); Assume.That(CascadeStyle.None == componentPropertyMapping.CascadeStyle); return classMapping; }
private static void BindVersioningProperty(Table table, XmlNode subnode, Mappings mappings, string name, RootClass entity) { string propertyName = subnode.Attributes["name"].Value; SimpleValue val = new SimpleValue(table); BindSimpleValue(subnode, val, false, propertyName, mappings); if (val.Type == null) { val.Type = (("version".Equals(name)) ? NHibernateUtil.Int32 : NHibernateUtil.Timestamp); } Mapping.Property prop = new Mapping.Property(val); BindProperty(subnode, prop, mappings); // for version properties marked as being generated, make sure they are "always" // generated; "insert" is invalid. This is dis-allowed by the schema, but just to make // sure... if (prop.Generation == PropertyGeneration.Insert) { throw new MappingException("'generated' attribute cannot be 'insert' for versioning property"); } MakeVersion(subnode, val); entity.Version = prop; entity.AddProperty(prop); }