Пример #1
0
		public CompositeCustomType(System.Type userTypeClass, IDictionary<string, string> parameters)
		{
			name = userTypeClass.FullName;

			try
			{
				userType = (ICompositeUserType) Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(userTypeClass);
			}
			catch (MethodAccessException mae)
			{
				throw new MappingException("MethodAccessException trying to instantiate custom type: " + name, mae);
			}
			catch (TargetInvocationException tie)
			{
				throw new MappingException("TargetInvocationException trying to instantiate custom type: " + name, tie);
			}
			catch (ArgumentException ae)
			{
				throw new MappingException("ArgumentException trying to instantiate custom type: " + name, ae);
			}
			catch (InvalidCastException ice)
			{
				throw new MappingException(name + " must implement NHibernate.UserTypes.ICompositeUserType", ice);
			}
			TypeFactory.InjectParameters(userType, parameters);
			if (!userType.ReturnedClass.IsSerializable)
			{
				LogManager.GetLogger(typeof(CustomType)).Warn("custom type is not Serializable: " + userTypeClass);
			}
		}
Пример #2
0
        public CompositeCustomType(System.Type userTypeClass, IDictionary <string, string> parameters)
        {
            name = userTypeClass.FullName;

            try
            {
                userType = (ICompositeUserType)Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(userTypeClass);
            }
            catch (MethodAccessException mae)
            {
                throw new MappingException("MethodAccessException trying to instantiate custom type: " + name, mae);
            }
            catch (TargetInvocationException tie)
            {
                throw new MappingException("TargetInvocationException trying to instantiate custom type: " + name, tie);
            }
            catch (ArgumentException ae)
            {
                throw new MappingException("ArgumentException trying to instantiate custom type: " + name, ae);
            }
            catch (InvalidCastException ice)
            {
                throw new MappingException(name + " must implement NHibernate.UserTypes.ICompositeUserType", ice);
            }
            TypeFactory.InjectParameters(userType, parameters);
            if (!userType.ReturnedClass.IsSerializable)
            {
                LogManager.GetLogger(typeof(CustomType)).Warn("custom type is not Serializable: " + userTypeClass);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userTypeClass"></param>
        public CompositeCustomType(System.Type userTypeClass)
        {
            name = userTypeClass.Name;

            try
            {
                userType = ( ICompositeUserType )Activator.CreateInstance(userTypeClass);
            }
            catch (MethodAccessException mae)
            {
                throw new MappingException("MethodAccessException trying to instantiate custom type: " + name, mae);
            }
            catch (TargetInvocationException tie)
            {
                throw new MappingException("TargetInvocationException trying to instantiate custom type: " + name, tie);
            }
            catch (ArgumentException ae)
            {
                throw new MappingException("ArgumentException trying to instantiate custom type: " + name, ae);
            }
            catch (InvalidCastException ice)
            {
                throw new MappingException(name + " must implement NHibernate.ICompositeUserType", ice);
            }
            if (!userType.ReturnedClass.IsSerializable)
            {
                LogManager.GetLogger(typeof(CustomType)).Warn("custom type is not Serializable: " + userTypeClass);
            }
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="userTypeClass"></param>
		public CompositeCustomType( System.Type userTypeClass )
		{
			name = userTypeClass.Name;

			try
			{
				userType = ( ICompositeUserType ) Activator.CreateInstance( userTypeClass );
			}
			catch( MethodAccessException mae )
			{
				throw new MappingException( "MethodAccessException trying to instantiate custom type: " + name, mae );
			}
			catch( TargetInvocationException tie )
			{
				throw new MappingException( "TargetInvocationException trying to instantiate custom type: " + name, tie );
			}
			catch( ArgumentException ae )
			{
				throw new MappingException( "ArgumentException trying to instantiate custom type: " + name, ae );
			}
			catch( InvalidCastException ice )
			{
				throw new MappingException( name + " must implement NHibernate.ICompositeUserType", ice );
			}
			if( !userType.ReturnedClass.IsSerializable )
			{
				LogManager.GetLogger( typeof( CustomType ) ).Warn( "custom type is not Serializable: " + userTypeClass );
			}
		}
Пример #5
0
        public CompositeCustomType(System.Type userTypeClass, IDictionary <string, string> parameters)
        {
            name = userTypeClass.FullName;

            try
            {
                userType = (ICompositeUserType)Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(userTypeClass);
            }
            catch (MethodAccessException mae)
            {
                throw new MappingException("MethodAccessException trying to instantiate custom type: " + name, mae);
            }
            catch (TargetInvocationException tie)
            {
                throw new MappingException("TargetInvocationException trying to instantiate custom type: " + name, tie);
            }
            catch (ArgumentException ae)
            {
                throw new MappingException("ArgumentException trying to instantiate custom type: " + name, ae);
            }
            catch (InvalidCastException ice)
            {
                throw new MappingException(name + " must implement NHibernate.UserTypes.ICompositeUserType", ice);
            }
            TypeFactory.InjectParameters(userType, parameters);
            if (!userType.ReturnedClass.IsSerializable)
            {
                LoggerProvider.LoggerFor(typeof(CustomType)).WarnFormat("the custom composite class '{0}' handled by '{1}' is not Serializable: ", userType.ReturnedClass, userTypeClass);
            }

            // This is to be nice to an application developer.
            if (userType.PropertyTypes == null)
            {
                throw new InvalidOperationException(String.Format("ICompositeUserType {0} returned a null value for 'PropertyTypes'.", userType.GetType()));
            }
            if (userType.PropertyNames == null)
            {
                throw new InvalidOperationException(String.Format("ICompositeUserType {0} returned a null value for 'PropertyNames'.", userType.GetType()));
            }
        }
		public CompositeCustomType(System.Type userTypeClass, IDictionary<string, string> parameters)
		{
			name = userTypeClass.FullName;

			try
			{
				userType = (ICompositeUserType) Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(userTypeClass);
			}
			catch (MethodAccessException mae)
			{
				throw new MappingException("MethodAccessException trying to instantiate custom type: " + name, mae);
			}
			catch (TargetInvocationException tie)
			{
				throw new MappingException("TargetInvocationException trying to instantiate custom type: " + name, tie);
			}
			catch (ArgumentException ae)
			{
				throw new MappingException("ArgumentException trying to instantiate custom type: " + name, ae);
			}
			catch (InvalidCastException ice)
			{
				throw new MappingException(name + " must implement NHibernate.UserTypes.ICompositeUserType", ice);
			}
			TypeFactory.InjectParameters(userType, parameters);
			if (!userType.ReturnedClass.IsSerializable)
			{
				LoggerProvider.LoggerFor(typeof(CustomType)).WarnFormat("the custom composite class '{0}' handled by '{1}' is not Serializable: ", userType.ReturnedClass, userTypeClass);
			}

			// This is to be nice to an application developer.
			if (userType.PropertyTypes == null)
				throw new InvalidOperationException(String.Format("ICompositeUserType {0} returned a null value for 'PropertyTypes'.", userType.GetType()));
			if (userType.PropertyNames == null)
				throw new InvalidOperationException(String.Format("ICompositeUserType {0} returned a null value for 'PropertyNames'.", userType.GetType()));
		}