예제 #1
0
 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);
 }
예제 #2
0
		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;
		}
예제 #3
0
		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);
		}