Beispiel #1
0
 private void MapSubclass(IList <string> mappedProperties, ISubclassMapping subclass, AutoMapType inheritedClass)
 {
     subclass.Name = inheritedClass.Type.AssemblyQualifiedName;
     ApplyOverrides(inheritedClass.Type, mappedProperties, (ClassMappingBase)subclass);
     MapEverythingInClass((ClassMappingBase)subclass, inheritedClass.Type, mappedProperties);
     inheritedClass.IsMapped = true;
 }
        public override void Visit(ISubclassMapping subclassMapping)
        {
            var writer      = serviceLocator.GetWriter <ISubclassMapping>();
            var subclassXml = writer.Write(subclassMapping);

            document.ImportAndAppendChild(subclassXml);
        }
Beispiel #3
0
        private void GenerateNestedSubclasses(ISubclassMapping mapping)
        {
            foreach (var subclassType in indetermineateSubclasses.Keys)
            {
                var emptySubclassMapping = (ISubclassMapping)mapping.GetType().InstantiateUsingParameterlessConstructor();
                var subclassMapping      = indetermineateSubclasses[subclassType].GetSubclassMapping(emptySubclassMapping);

                mapping.AddSubclass(subclassMapping);
            }
        }
 public virtual void Visit(ISubclassMapping subclassMapping)
 {
 }
 private void MapSubclass(IList<string> mappedProperties, ISubclassMapping subclass, AutoMapType inheritedClass)
 {
     subclass.Name = inheritedClass.Type.AssemblyQualifiedName;
     ApplyOverrides(inheritedClass.Type, mappedProperties, (ClassMappingBase)subclass);
     MapEverythingInClass((ClassMappingBase)subclass, inheritedClass.Type, mappedProperties);
     inheritedClass.IsMapped = true;
 }
Beispiel #6
0
 public virtual void Visit(ISubclassMapping subclassMapping)
 {
 }
 public void AddSubclass(ISubclassMapping subclass)
 {
     subclasses.Add(subclass);
 }
 public override void Visit(ISubclassMapping subclassMapping)
 {
     subclassMapping.AcceptVisitor(this);
 }
 public void AddSubclass(ISubclassMapping subclass)
 {
     subclasses.Add(subclass);
 }
Beispiel #10
0
 public override void Visit(ISubclassMapping subclassMapping)
 {
     subclassMapping.AcceptVisitor(this);
 }
Beispiel #11
0
        ISubclassMapping IIndeterminateSubclassMappingProvider.GetSubclassMapping(ISubclassMapping mapping)
        {
            GenerateNestedSubclasses(mapping);

            subclassAttributes.SetDefault(x => x.Type, typeof(T));
            subclassAttributes.SetDefault(x => x.Name, typeof(T).AssemblyQualifiedName);
            subclassAttributes.SetDefault(x => x.DiscriminatorValue, typeof(T).Name);

            // TODO: un-hardcode this
            var key = new KeyMapping();

            key.AddDefaultColumn(new ColumnMapping {
                Name = typeof(T).BaseType.Name + "_id"
            });

            joinedSubclassAttributes.SetDefault(x => x.Type, typeof(T));
            joinedSubclassAttributes.SetDefault(x => x.Name, typeof(T).AssemblyQualifiedName);
            joinedSubclassAttributes.SetDefault(x => x.TableName, GetDefaultTableName());
            joinedSubclassAttributes.SetDefault(x => x.Key, key);

            // TODO: this is nasty, we should find a better way
            if (mapping is JoinedSubclassMapping)
            {
                mapping.OverrideAttributes(joinedSubclassAttributes.CloneInner());
            }
            else
            {
                mapping.OverrideAttributes(subclassAttributes.CloneInner());

                foreach (var join in joins)
                {
                    ((SubclassMapping)mapping).AddJoin(join);
                }
            }

            foreach (var property in properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var oneToOne in oneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in references)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            return(mapping);
        }