Commits

Roger Kratz committed bd9f66f

fixes to run against envers 1.2

  • Participants
  • Parent commits 7f5be2d

Comments (0)

Files changed (5)

File NHibernate.Envers.SetForNet4/CollectionProxyMapperFactoryForNet4.cs

 using NHibernate.Envers.Configuration.Metadata;
 using NHibernate.Envers.Entities.Mapper;
 using NHibernate.Envers.Entities.Mapper.Relation;
+using NHibernate.Envers.Entities.Mapper.Relation.Lazy.Proxy;
 
 namespace NHibernate.Envers.SetForNet4
 {
-	public class CollectionProxyMapperFactoryForNet4 : DefaultCollectionProxyMapperFactory
+	public class CollectionProxyMapperFactoryForNet4 : DefaultCollectionMapperFactory
 	{
+		//change this when https://nhibernate.jira.com/browse/NHE-82 is fixed
+		private readonly IEnversProxyFactory proxyFactory = new DefaultEnversProxyFactory();
+
 		public override IPropertyMapper Set<T>(CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData)
 		{
-			return new SetForNet4CollectionMapper<T>(commonCollectionMapperData, elementComponentData);
+			return new SetForNet4CollectionMapper<T>(proxyFactory, commonCollectionMapperData, elementComponentData);
 		}
 	}
 }

File NHibernate.Envers.SetForNet4/NHibernate.Envers.SetForNet4.csproj

     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SetForNet4CollectionInitializor.cs" />
     <Compile Include="SetForNet4CollectionMapper.cs" />
-    <Compile Include="SetForNet4Proxy.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

File NHibernate.Envers.SetForNet4/SetForNet4CollectionMapper.cs

 using NHibernate.Collection;
 using NHibernate.Envers.Configuration;
 using NHibernate.Envers.Entities.Mapper.Relation;
+using NHibernate.Envers.Entities.Mapper.Relation.Lazy.Initializor;
 using NHibernate.Envers.Reader;
 
 namespace NHibernate.Envers.SetForNet4
 	{
 		private readonly MiddleComponentData _elementComponentData;
 
-		public SetForNet4CollectionMapper(CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData)
-			: base(commonCollectionMapperData, typeof(SetForNet4Proxy<T>))
+		public SetForNet4CollectionMapper(IEnversProxyFactory enversProxyFactory, CommonCollectionMapperData commonCollectionMapperData, MiddleComponentData elementComponentData)
+			: base(enversProxyFactory, commonCollectionMapperData, typeof(ISet<T>))
 		{
 			_elementComponentData = elementComponentData;
 		}
 
-		protected override object GetInitializor(AuditConfiguration verCfg,
+		protected override IInitializor GetInitializor(AuditConfiguration verCfg,
 		                                                        IAuditReaderImplementor versionsReader,
 		                                                        object primaryKey,
 		                                                        long revision)

File NHibernate.Envers.SetForNet4/SetForNet4Proxy.cs

-using System;
-using System.Collections.Generic;
-using NHibernate.Envers.Entities.Mapper.Relation.Lazy.Initializor;
-using NHibernate.Envers.Entities.Mapper.Relation.Lazy.Proxy;
-
-namespace NHibernate.Envers.SetForNet4
-{
-	[Serializable]
-	public class SetForNet4Proxy<T> : CollectionProxy<T, ISet<T>>, ISet<T> 
-	{
-		protected SetForNet4Proxy() 
-		{
-		}
-
-		public SetForNet4Proxy(IInitializor<ISet<T>> initializor)
-			:base(initializor) 
-		{
-		}
-
-		public new bool Add(T item)
-		{
-			CheckInit();
-			return CollectionDelegate.Add(item);
-		}
-
-		public void UnionWith(IEnumerable<T> other)
-		{
-			CheckInit();
-			CollectionDelegate.UnionWith(other);
-		}
-
-		public void IntersectWith(IEnumerable<T> other)
-		{
-			CheckInit();
-			CollectionDelegate.IntersectWith(other);
-		}
-
-		public void ExceptWith(IEnumerable<T> other)
-		{
-			CheckInit();
-			CollectionDelegate.ExceptWith(other);
-		}
-
-		public void SymmetricExceptWith(IEnumerable<T> other)
-		{
-			CheckInit();
-			CollectionDelegate.SymmetricExceptWith(other);
-		}
-
-		public bool IsSubsetOf(IEnumerable<T> other)
-		{
-			CheckInit();
-			return CollectionDelegate.IsSubsetOf(other);
-		}
-
-		public bool IsSupersetOf(IEnumerable<T> other)
-		{
-			CheckInit();
-			return CollectionDelegate.IsSupersetOf(other);
-		}
-
-		public bool IsProperSupersetOf(IEnumerable<T> other)
-		{
-			CheckInit();
-			return CollectionDelegate.IsProperSupersetOf(other);
-		}
-
-		public bool IsProperSubsetOf(IEnumerable<T> other)
-		{
-			CheckInit();
-			return CollectionDelegate.IsProperSubsetOf(other);
-		}
-
-		public bool Overlaps(IEnumerable<T> other)
-		{
-			CheckInit();
-			return CollectionDelegate.Overlaps(other);
-		}
-
-		public bool SetEquals(IEnumerable<T> other)
-		{
-			CheckInit();
-			return CollectionDelegate.SetEquals(other);
-		}
-	}
-}

File NHibernate.Envers.SetForNet4Test/Tests/SimpleTest.cs

 		{
 			var cfg = new Cfg.Configuration()
 					.SetProperty(Environment.CollectionTypeFactoryClass, typeof(Net4CollectionTypeFactory).AssemblyQualifiedName)
-					.SetEnversProperty(ConfigurationKey.CollectionProxyMapperFactory, typeof(CollectionProxyMapperFactoryForNet4))
+					.SetEnversProperty(ConfigurationKey.CollectionMapperFactory, typeof(CollectionProxyMapperFactoryForNet4))
 					.Configure()
 					.AddAssembly(GetType().Assembly);
 			var enversCfg = new FluentConfiguration();