Skip to content

Commit

Permalink
Obsoleted the ClassMap based subclass methods, in favour of the Subcl…
Browse files Browse the repository at this point in the history
…assMap derived style.
  • Loading branch information
jagregory committed Aug 3, 2009
1 parent 4d314bf commit 95dcbd7
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void TableShouldntBeOverwritten()

private void Convention(Action<IClassInstance> convention)
{
model.ConventionFinder.Add(new ClassConventionBuilder().Always(convention));
model.Conventions.Add(new ClassConventionBuilder().Always(convention));
}

private void Mapping<T>(Action<ClassMap<T>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void OptimisticLockShouldntBeOverwritten()

private void Convention(Action<IComponentInstance> convention)
{
model.ConventionFinder.Add(new ComponentConventionBuilder().Always(convention));
model.Conventions.Add(new ComponentConventionBuilder().Always(convention));
}

private void Mapping(Action<ComponentPart<ComponentTarget>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void OptimisticLockShouldntBeOverwritten()

private void Convention(Action<IDynamicComponentInstance> convention)
{
model.ConventionFinder.Add(new DynamicComponentConventionBuilder().Always(convention));
model.Conventions.Add(new DynamicComponentConventionBuilder().Always(convention));
}

private void Mapping(Action<DynamicComponentPart<IDictionary>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void TableNameShouldntBeOverwritten()

private void Convention(Action<ICollectionInstance> convention)
{
model.ConventionFinder.Add(new CollectionConventionBuilder().Always(convention));
model.Conventions.Add(new CollectionConventionBuilder().Always(convention));
}

private void Mapping<TChild>(Expression<Func<ExampleInheritedClass, IEnumerable<TChild>>> property, Action<OneToManyPart<TChild>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void NotFoundShouldntBeOverwritten()

private void Convention(Action<IOneToManyCollectionInstance> convention)
{
model.ConventionFinder.Add(new OneToManyCollectionConventionBuilder().Always(convention));
model.Conventions.Add(new OneToManyCollectionConventionBuilder().Always(convention));
}

private void Mapping<TChild>(Expression<Func<ExampleInheritedClass, IEnumerable<TChild>>> property, Action<OneToManyPart<TChild>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void TableNameShouldntBeOverwritten()

private void Convention(Action<ICollectionInstance> convention)
{
model.ConventionFinder.Add(new CollectionConventionBuilder().Always(convention));
model.Conventions.Add(new CollectionConventionBuilder().Always(convention));
}

private void Mapping<TChild>(Expression<Func<ExampleInheritedClass, IEnumerable<TChild>>> property, Action<ManyToManyPart<TChild>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void TableNameShouldntBeOverwritten()

private void Convention(Action<IManyToManyCollectionInstance> convention)
{
model.ConventionFinder.Add(new ManyToManyCollectionConventionBuilder().Always(convention));
model.Conventions.Add(new ManyToManyCollectionConventionBuilder().Always(convention));
}

private void Mapping<TChild>(Expression<Func<ExampleInheritedClass, IEnumerable<TChild>>> property, Action<ManyToManyPart<TChild>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void PropertyRefShouldntBeOverwritten()

private void Convention(Action<IOneToOneInstance> convention)
{
model.ConventionFinder.Add(new HasOneConventionBuilder().Always(convention));
model.Conventions.Add(new HasOneConventionBuilder().Always(convention));
}

private void Mapping(Action<OneToOnePart<ExampleParentClass>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void LengthValueShouldntBeOverwritten()

private void Convention(Action<IIdentityInstance> convention)
{
model.ConventionFinder.Add(new IdConventionBuilder().Always(convention));
model.Conventions.Add(new IdConventionBuilder().Always(convention));
}

private void Mapping<T>(Expression<Func<T, object>> property, Action<IdentityPart> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void TableNameShouldntBeOverwritten()

private void Convention(Action<IJoinedSubclassInstance> convention)
{
model.ConventionFinder.Add(new JoinedSubclassConventionBuilder().Always(convention));
model.Conventions.Add(new JoinedSubclassConventionBuilder().Always(convention));
}

private void Mapping(Action<JoinedSubClassPart<ExampleInheritedClass>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void ForeignKeyShouldntBeOverwritten()

private void Convention(Action<IManyToOneInstance> convention)
{
model.ConventionFinder.Add(new ReferenceConventionBuilder().Always(convention));
model.Conventions.Add(new ReferenceConventionBuilder().Always(convention));
}

private void Mapping(Action<ManyToOnePart<ExampleParentClass>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void DefaultShouldntBeOverwritten()

private void Convention(Action<IPropertyInstance> convention)
{
model.ConventionFinder.Add(new PropertyConventionBuilder().Always(convention));
model.Conventions.Add(new PropertyConventionBuilder().Always(convention));
}

private void Mapping<T>(Expression<Func<T, object>> property, Action<PropertyMap> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void SelectBeforeUpdateShouldntBeOverwritten()

private void Convention(Action<ISubclassInstance> convention)
{
model.ConventionFinder.Add(new SubclassConventionBuilder().Always(convention));
model.Conventions.Add(new SubclassConventionBuilder().Always(convention));
}

private void Mapping(Action<SubClassPart<ExampleInheritedClass>> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void UnsavedValueShouldntBeOverwritten()

private void Convention(Action<IVersionInstance> convention)
{
model.ConventionFinder.Add(new VersionConventionBuilder().Always(convention));
model.Conventions.Add(new VersionConventionBuilder().Always(convention));
}

private void Mapping<T>(Expression<Func<T, object>> property, Action<VersionPart> mappingDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public virtual MappingTester<T> RootElement

public virtual MappingTester<T> Conventions(Action<IConventionFinder> conventionFinderAction)
{
conventionFinderAction(model.ConventionFinder);
conventionFinderAction(model.Conventions);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/FluentNHibernate/AutoMap/AutoPersistenceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public AutoPersistenceModel UseOverridesFromAssemblyOf<T>()
/// </summary>
public new SetupConventionFinder<AutoPersistenceModel> ConventionFinder
{
get { return new SetupConventionFinder<AutoPersistenceModel>(this, base.ConventionFinder); }
get { return new SetupConventionFinder<AutoPersistenceModel>(this, base.Conventions); }
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/FluentNHibernate/Cfg/FluentMappingsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public FluentMappingsContainer ExportTo(string path)
/// </summary>
public SetupConventionFinder<FluentMappingsContainer> ConventionDiscovery
{
get { return new SetupConventionFinder<FluentMappingsContainer>(this, model.ConventionFinder); }
get { return new SetupConventionFinder<FluentMappingsContainer>(this, model.Conventions); }
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/FluentNHibernate/Mapping/ClassMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public virtual IdentityPart Id(Expression<Func<T, object>> expression, string co
return part;
}

[Obsolete("Inline definitions of subclasses are depreciated. Please create a derived class from SubclassMap in the same way you do with ClassMap.")]
public virtual void JoinedSubClass<TSubclass>(string keyColumn, Action<JoinedSubClassPart<TSubclass>> action) where TSubclass : T
{
var subclass = new JoinedSubClassPart<TSubclass>(keyColumn);
Expand Down
2 changes: 2 additions & 0 deletions src/FluentNHibernate/Mapping/DiscriminatorPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ DiscriminatorMapping IDiscriminatorMappingProvider.GetDiscriminatorMapping()
return mapping;
}

[Obsolete("Inline definitions of subclasses are depreciated. Please create a derived class from SubclassMap in the same way you do with ClassMap.")]
public DiscriminatorPart SubClass<TSubClass>(object discriminatorValue, Action<SubClassPart<TSubClass>> action)
{
var subclass = new SubClassPart<TSubClass>(this, discriminatorValue);
Expand All @@ -39,6 +40,7 @@ public DiscriminatorPart SubClass<TSubClass>(object discriminatorValue, Action<S
return this;
}

[Obsolete("Inline definitions of subclasses are depreciated. Please create a derived class from SubclassMap in the same way you do with ClassMap.")]
public DiscriminatorPart SubClass<TSubClass>(Action<SubClassPart<TSubClass>> action)
{
return SubClass(null, action);
Expand Down
8 changes: 4 additions & 4 deletions src/FluentNHibernate/PersistenceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public class PersistenceModel
protected readonly IList<IMappingProvider> classProviders = new List<IMappingProvider>();
protected readonly IList<IIndeterminateSubclassMappingProvider> subclassProviders = new List<IIndeterminateSubclassMappingProvider>();
private readonly IList<IMappingModelVisitor> visitors = new List<IMappingModelVisitor>();
public IConventionFinder ConventionFinder { get; private set; }
public IConventionFinder Conventions { get; private set; }
public bool MergeMappings { get; set; }
private IEnumerable<HibernateMapping> compiledMappings;

public PersistenceModel(IConventionFinder conventionFinder)
{
ConventionFinder = conventionFinder;
Conventions = conventionFinder;

visitors.Add(new SeparateSubclassVisitor(subclassProviders));
visitors.Add(new ConventionVisitor(ConventionFinder));
visitors.Add(new ConventionVisitor(Conventions));

AddDefaultConventions();
}
Expand All @@ -45,7 +45,7 @@ private void AddDefaultConventions()
where type.Namespace == "FluentNHibernate.Conventions.Defaults" && !type.IsAbstract
select type)
{
ConventionFinder.Add(foundType);
Conventions.Add(foundType);
}
}

Expand Down

0 comments on commit 95dcbd7

Please sign in to comment.