/// <summary> /// Register a new component. /// </summary> /// <param name="builder"> autofac container builder </param> /// <param name="type"> Type to register </param> public virtual void RegisterComponent(ContainerBuilder builder, Type type) { if (builder == null) throw new ArgumentNullException("builder"); if (type == null) throw new ArgumentNullException("type"); _builder = builder; var attribute = type.GetAttributes<ComponentAttribute>(false).Single(); var lifetime = attribute.Lifetime == Lifetime.Default ? DefaultLifetime : attribute.Lifetime; switch (lifetime) { case Lifetime.Transient: RegisterTransient(type, attribute); break; case Lifetime.Singleton: RegisterSingleton(type, attribute); break; case Lifetime.Scoped: RegisterScoped(type, attribute); break; default: throw new InvalidOperationException( string.Format( "Either the [Component] attribute on {0} or the ComponentRegistrar.DefaultLifetime must have been specified.", type.FullName)); } }
private IEnumerable<IIntroductionAspect> FindIntroductionAspects(Type type) { return (from item in type.GetAttributes<IntroductionAspectAttribute>(true) let typeFilter = new PredicateTypeFilter(t => t == type) let advice = new IntroductionAdvice(item.Types) select new IntroductionAspect(typeFilter, advice)); }
public IEnumerable<IFilterAttribute> AttributesFor(Type type) { return withCache(new Signature(type), () => { return type.GetAttributes<IFilterAttribute>(); }); }
private void AddSideEffectDeclaration(Type type) { IEnumerable<SideEffectDeclaration> sideEffects = from sideEffectAttribute in type.GetAttributes<SideEffectsAttribute>() from sideEffectType in sideEffectAttribute.SideEffectTypes select new SideEffectDeclaration(sideEffectType, type); this.sideEffectDeclarations.AddRange(sideEffects); }
private void AddConstraintDeclarations(Type type) { IEnumerable<ConstraintAttribute> annotations = type.GetAttributes<ConstraintAttribute>(); foreach (ConstraintAttribute annontation in annotations) { this.constraints.Add(new ConstraintDeclaration(annontation, type)); } }
public bool IsPersistent(Type messageType) { Preconditions.CheckNotNull(messageType, "messageType"); var deliveryModeAttribute = messageType.GetAttributes<DeliveryModeAttribute>().FirstOrDefault(); if (deliveryModeAttribute != null) return deliveryModeAttribute.IsPersistent; return connectionConfiguration.PersistentMessages; }
XmlObjectSerializer GetXmlSerializer(Type type) { if (type.GetAttributes<DataContractAttribute>(false).Length > 0) { return new DataContractSerializer(type); } return new NetDataContractSerializer(); }
public HistoryInfo CreateHistoryInfo(Type decoratedType) { return new HistoryInfo( _historyKey, ((ComponentRegistrationBase)decoratedType.GetAttributes<ComponentRegistrationBase>(true) .FirstOrDefault() .GetComponentInfo(decoratedType)).Service ); }
private static void AddConcernDeclarations(Type type, List<ConcernDeclaration> concerns) { IEnumerable<ConcernsAttribute> attributes = type.GetAttributes<ConcernsAttribute>(); IEnumerable<ConcernDeclaration> types = from attribute in attributes from concernType in attribute.ConcernTypes select new ConcernDeclaration(concernType, type); concerns.AddRange(types); }
/// <summary> /// Creates the meta-info from the specified type. /// </summary> /// <param name = "implementation">The implementation type.</param> /// <returns>The corresponding meta-info.</returns> public SynchronizeMetaInfo CreateMetaFromType(Type implementation) { var syncAttrib = implementation.GetAttributes<SynchronizeAttribute>()[0]; var metaInfo = new SynchronizeMetaInfo(syncAttrib); PopulateMetaInfoFromType(metaInfo, implementation); Register(implementation, metaInfo); return metaInfo; }
public static TypeConverter GetConverter(Type type) { TypeConverter converter; if (!Cache.TryGetValue(type, out converter)) { IEnumerable<TypeConverterAttribute> attributes = type.GetAttributes<TypeConverterAttribute>(true); if (!attributes.Any<TypeConverterAttribute>()) { return new TypeConverter(); } converter = Activator.CreateInstance(Type.GetType(attributes.First<TypeConverterAttribute>().ConverterTypeName)) as TypeConverter; Cache[type] = converter; } return converter; }
public static AttributeCollection <Attribute> Attributes(this Type type) { var inheritedAttributes = type.BaseType.GetAttributes() .Select( a => new { attribute = a, attributeUsageAtt = new AttributeCollection <Attribute>(a).Get <AttributeUsageAttribute>() }) .Where(@t => @t.attributeUsageAtt != null) .Where(@t => [email protected]) .Select(@t => @t.attribute); var result = type.GetAttributes().Except(inheritedAttributes.Reverse(), new LambdaComparer <Attribute>(ReferenceEquals)); return(new AttributeCollection <Attribute>(result)); }
/// <summary> /// Returns a type converter for the specified type. /// </summary> /// <param name="type">The System.Type of the target component.</param> /// <returns>A System.ComponentModel.TypeConverter for the specified type.</returns> public static TypeConverter GetConverter(Type type) { TypeConverter converter; if(!Cache.TryGetValue(type, out converter)) { var customAttributes = type.GetAttributes<TypeConverterAttribute>(true); if(!customAttributes.Any()) return new TypeConverter(); converter = Activator.CreateInstance(Type.GetType(customAttributes.First().ConverterTypeName)) as TypeConverter; Cache[type] = converter; } return converter; }
/// <summary> /// Creates the actual description. /// </summary> /// <param name="targetType">Type of the target.</param> /// <returns></returns> protected virtual IViewModelDescription CreateCore(Type targetType) { var customFactory = targetType .GetAttributes<IViewModelDescriptionFactory>(true) .FirstOrDefault(); if (customFactory != null) return customFactory.Create(targetType); var description = new DefaultViewModelDescription(conventionManager, targetType); var filters = new FilterManager(targetType, description.TargetType, serviceLocator); var actions = actionLocator.Locate(new ActionLocationContext(serviceLocator, targetType, filters)); description.Filters = filters; actions.Apply(description.AddAction); return description; }
private IEnumerable<IAspect> FindPointcutAspects(Type type) { var typeAspects = (from item in type.GetAttributes<PointcutAspectAttribute>(true) let typeFilter = new PredicateTypeFilter(t => t == type) let pointcut = new Pointcut(typeFilter) select new PointcutAspect(pointcut, item.Advice)); var mehodAspects = type.GetMethods().SelectMany(method => { return (from item in method.GetAttributes<PointcutAspectAttribute>(true) let typeFilter = new PredicateTypeFilter(t => t == type) let methodMatcher = new PredicateMethodMatcher((m, t) => m.Match(method)) let pointcut = new Pointcut(typeFilter, methodMatcher) select new PointcutAspect(pointcut, item.Advice)); }); return typeAspects.Concat(mehodAspects); }
/// <summary> /// This is were the actual magic happens. A type is generated for the domaintype. The domaintype should always /// be an interface. /// </summary> /// <param name="domainType">Interface decorated with MData attribute which needs a generated implementation</param> /// <param name="logicType">LogicBase class to be used (either userdefined or generic)</param> /// <returns></returns> internal Type RegisterDomainInterface(Type domainType, Type logicType) { //if one of the parameters is null, we cannot continue generating if (domainType == null || logicType == null) return null; //domaintype should always be an interface if (!domainType.IsInterface) return null; if (_domainCache.ContainsKey(domainType)) return _domainCache[domainType]; #if !DEBUG //reuse of previoulsy generated assembly is only allowed in release mode if (!_configurator.ShouldAlwaysRecreate && File.Exists(_configurator.AssemblyNameForStorage)) return GetCachedDomainInterface(domainType); #endif //get the MData attribute of the interface domaintype var mDataAttribute = domainType.GetAttributes<MDataAttribute>().FirstOrDefault(); //abort generating when no attribute found if (mDataAttribute == null) return null; //initialize local variables var generatedFields = new Dictionary<Type, FieldBuilder>(); //create the new type, passing in a name, accesibility attributes, a base class and a generic type argument var typeBuilder = _assemblyBuilder.DefineType(GetTypeFullName(domainType, mDataAttribute.GetName()), TypeAttributes.Public, _configurator.EntityType, domainType); //make sure our new class inherits interface domainType typeBuilder .TypeBuilder .AddInterfaceImplementation(domainType); //loop all interfaces the domaintype implements, including the domaintype interface itself foreach (var interfaceToImplement in GetInterfaceToImplements(domainType)) { //get the logical class associated with the current interface var logicClassType = GetLogicClass(interfaceToImplement); //create a new field (if necessary, see CreateLogicBaseField method) var logicField = CreateLogicBaseField(generatedFields, typeBuilder, interfaceToImplement, interfaceToImplement.HasAttribute<MDataMethodAttribute>(), ref logicClassType); //map the current interface with its logical field generatedFields.Add(interfaceToImplement, logicField); //implement all interface's methods MapMethods(logicField, logicClassType, interfaceToImplement, typeBuilder); //implement/generate all interface's properties MapProperties(interfaceToImplement, typeBuilder, _configurator.EntityType, logicField); } //initialize fields in the constructor CreateConstructorLogic(generatedFields.Select(x => x.Value), typeBuilder, _configurator.EntityType); //create the concrete type for domainType var registerDomainInterface = typeBuilder.Create(); _domainCache.Add(domainType, registerDomainInterface); return registerDomainInterface; }
private static void Cache(Type type) { var hs = new HashSet<string>(); var ds = new Dictionary<string, MethodInfo>(); defaultEvents.Add(type, hs); defaultHandles.Add(type, ds); foreach (var item in type.GetAttributes<RegisterEventsAttribute>(true) .SelectMany(s => s.NameEvents)) hs.Add(item); foreach (var item in type.GetAttributes<RegisterChangeEventsAttribute>(true) .SelectMany(s => s.NameEvents)) hs.Add(item); foreach (var item in type.GetPropertiesAndAttribute<RegisterPropertyChangeAttribute>(true) .SelectMany(s => s.Value.GetNamesWith(s.Key.Name))) hs.Add(item); foreach (var item in type.GetMethodsAndAttribute<RegisterOperationEventsAttribute>(true) .SelectMany(s => s.Value.NameOps)) hs.Add(item); //EventHandlerAttribute eha; //ParameterInfo[] pi; //foreach (var item in type // .GetMethodsWithAttribute<EventHandlerAttribute>(true) // .Where(s => // (pi = s.GetParameters()).Length == 3 // && pi[0].ParameterType == typeof(object) // && pi[1].ParameterType == typeof(string) // && pi[2].ParameterType == typeof(object[]) // && !s.IsStatic)) //{ // eha = item.GetAttribute<EventHandlerAttribute>(true); // if (!eha.HandlerName.IsEmpty()) // ds.Add(eha.HandlerName, item); // else // ds.Add(item.Name, item); //} }
/// <summary> /// Gets the view. /// </summary> /// <param name="modelType">Type of the model.</param> /// <param name="displayLocation">The display location.</param> /// <param name="context">The context.</param> /// <returns>The view.</returns> protected virtual object GetView(Type modelType, DependencyObject displayLocation, object context) { var customStrategy = modelType.GetAttributes<ViewStrategyAttribute>(true) .Where(x => x.Matches(context)).FirstOrDefault(); if (customStrategy != null) return customStrategy.GetView(modelType, displayLocation, context); var stringContext = context.SafeToString(); var cacheKey = DetermineCacheKey(modelType, stringContext); if (_cache.ContainsKey(cacheKey)) return GetOrCreateViewFromType(_cache[cacheKey]); var namesToCheck = GetTypeNamesToCheck(modelType, stringContext).Distinct(); foreach (var name in namesToCheck) { foreach (var assembly in new[] { modelType.Assembly }.Union(_assemblySource)) { var type = assembly.GetType(name, false); if (type == null) continue; var view = GetOrCreateViewFromType(type); if (view == null) continue; _cache[cacheKey] = type; return view; } } var message = namesToCheck.Aggregate( "A default view was not found for " + modelType.FullName + ". Views searched for include: ", (a, c) => a + Environment.NewLine + c ); var generated = new TextBlock { Text = message, TextWrapping = TextWrapping.Wrap, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch }; ToolTipService.SetToolTip(generated, message); return generated; }
public static Table GetTable(Type t) { var tableAttr = (TableAttribute)t.GetAttribute(typeof(TableAttribute)); var tableName = tableAttr != null ? tableAttr.Name : t.Name; var multiColumnPrimaryKeyAttr = (MultiColumnPrimaryKeyAttribute)t.GetAttribute(typeof(MultiColumnPrimaryKeyAttribute)); var multiColumnPrimaryKey = new SpecifiedMultiColumnPrimaryKey(); multiColumnPrimaryKey.Columns = multiColumnPrimaryKeyAttr != null ? multiColumnPrimaryKeyAttr.Columns : new List<string>(); var multiColumnForeignKeyAttrs = (MultiColumnForeignKeyAttribute[])t.GetAttributes(typeof(MultiColumnForeignKeyAttribute)); var multiColumnForeignKeys = new List<SpecifiedMultiColumnForeignKey>(); if (multiColumnForeignKeyAttrs != null) { multiColumnForeignKeyAttrs.ToList().ForEach(x => { var key = new SpecifiedMultiColumnForeignKey(); var referencedTableAttr = (TableAttribute)x.ReferencedTableType.GetAttribute(typeof(TableAttribute)); key.ForeignTable = referencedTableAttr != null ? referencedTableAttr.Name : x.ReferencedTableType.Name; key.ReferencedColumns = x.ReferencedColumns; key.Columns = x.Columns; key.OnDeleteAction = x.OnDeleteAction; key.OnUpdateAction = x.OnUpdateAction; multiColumnForeignKeys.Add(key); }); } var checkAttrs = (CheckAttribute[])t.GetAttributes(typeof(CheckAttribute)); var checks = new List<CheckConstraint>(); if (checkAttrs != null) { checkAttrs.ToList().ForEach(x => { var check = new CheckConstraint(); check.Condition = x.Condition; checks.Add(check); }); } var indexAttrs = (MultiColumnIndexAttribute[])t.GetAttributes(typeof(MultiColumnIndexAttribute)); var indexes = new List<Index>(); if (indexAttrs != null) { indexAttrs.ToList().ForEach(x => { var index = new Index(x.Name, x.Columns.ToList(), x.Unique); indexes.Add(index); }); } var properties = from property in t.GetRuntimeProperties() where (property.GetMethod != null && property.GetMethod.IsPublic) || (property.SetMethod != null && property.SetMethod.IsPublic) || (property.GetMethod != null && property.GetMethod.IsStatic) || (property.SetMethod != null && property.SetMethod.IsStatic) select property; var columns = new List<Column>(); foreach(var property in properties) { var ignore = property.GetCustomAttributes(typeof(IgnoredColumnAttribute), true).Any(); if (property.CanWrite && !ignore) { columns.Add(new Column(property)); } } return new Table(tableName, columns, multiColumnPrimaryKey, multiColumnForeignKeys, checks, indexes); }
internal static FromClause GetObjectFromClause(Type modelType) { var attribute = modelType.GetAttribute<DbTableAttribute>(false); var attributes = modelType.GetAttributes<JoinOnAttribute>(false); if ((attribute != null) && (attributes.Length != 0)) { throw new ArgumentException(string.Format("class [{0}] defined DbTable and JoinOn. Only one allowed.", modelType.Name)); } if (attribute == null) { return GetJoinedFrom(modelType, attributes); } if (attribute.TableName == null) { return new FromClause(attribute.PartOf); } return new FromClause(GetTableNameFromConfig(attribute.TableName)); }
/// <summary> /// To get the attribute of a object /// </summary> /// <typeparam name="T">the attribute type</typeparam> /// <param name="value">an type object</param> /// <returns> To get the type attribute</returns> public static T GetAttribute <T>(this Type value) where T : Attribute { return(value.GetAttributes <T>().Length == 0 ? default(T) : value.GetAttributes <T>()[0]); }
IBindingInstaller[] CreateAttributeInstallers(Type type) { return type.GetAttributes<BindAttributeBase>(true) .Select(a => CreateAttributeInstaller(a, type)) .ToArray(); }
/// <summary> /// Locates the View for the specified model type. /// </summary> /// <param name="modelType">Type of the model.</param> /// <param name="displayLocation">The display location.</param> /// <param name="context">The context.</param> /// <returns>The view.</returns> public virtual DependencyObject LocateForModelType(Type modelType, DependencyObject displayLocation, object context) { var customStrategy = modelType.GetAttributes<IViewStrategy>(true) .Where(x => x.Matches(context)).FirstOrDefault(); if (customStrategy != null) return customStrategy.Locate(modelType, displayLocation, context); var stringContext = context.SafeToString(); var cacheKey = DetermineCacheKey(modelType, stringContext); if (cache.ContainsKey(cacheKey)) return GetOrCreateViewFromType(cache[cacheKey]); var namesToCheck = GetTypeNamesToCheck(modelType, stringContext).Distinct(); foreach (var name in namesToCheck) { foreach (var assembly in new[] { modelType.Assembly }.Union(assemblySource)) { var type = assembly.GetType(name, false); if (type == null) continue; var view = GetOrCreateViewFromType(type); if (view == null) continue; cache[cacheKey] = type; Log.Info("Located view {0} for {1}.", view, modelType); return view; } } var message = namesToCheck.Aggregate( "A default view was not found for " + modelType.FullName + ". Views searched for include: ", (a, c) => a + Environment.NewLine + c ); Log.Warn(message); return new NotFoundView(message); }
/// <summary> /// Creates / gets the correct field for the generated class which represents the logicbase class for a given /// MData interface. /// </summary> /// <param name="generatedFields"></param> /// <param name="typeBuilder"></param> /// <param name="interfaceToImplement"></param> /// <param name="isMethodData"></param> /// <param name="logicClassType"></param> /// <returns></returns> private static FieldBuilder CreateLogicBaseField(Dictionary<Type, FieldBuilder> generatedFields, TypeBuilderHelper typeBuilder, Type interfaceToImplement, bool isMethodData, ref Type logicClassType) { //not all interfaces implemented by domainType necesarly have the MData attribute //they could also have the MDataMethod attribute meaning that they will be implemented //by the same logic class as the MDataMethod attribute's parameter //if the interface is a MDataMethod interface, assign it to the linked logicClass if (isMethodData) { var linkedInterfaceType = interfaceToImplement.GetAttributes<MDataMethodAttribute>().First().GetLinkedInterfaceType(); logicClassType = generatedFields[linkedInterfaceType].FieldType; return generatedFields[linkedInterfaceType]; } return typeBuilder.DefineField(GetFieldFullName(logicClassType), logicClassType,FieldAttributes.FamORAssem); }
private QueueAttribute GetQueueAttribute(Type messageType) { var attr = messageType.GetAttributes<QueueAttribute>().FirstOrDefault(); return attr ?? new QueueAttribute(string.Empty); }
public ProxyHelper(IProxyFactory factory, Type implementation) { this.factory = factory; this.implementation = implementation; behaviors = implementation.GetAttributes<IBehavior>(true).ToArray(); }
/// <summary> /// Returns a <see cref = "ComponentProxyBehaviorAttribute" /> instance if the type /// uses the attribute. Otherwise returns null. /// </summary> /// <param name = "implementation"></param> protected virtual ComponentProxyBehaviorAttribute ReadProxyBehaviorFromType(Type implementation) { return implementation.GetAttributes<ComponentProxyBehaviorAttribute>().FirstOrDefault(); }
public void BindEntity() { persistentClass.IsAbstract = annotatedClass.IsAbstract; persistentClass.ClassName = annotatedClass.Name; persistentClass.NodeName = name; //TODO:review this //persistentClass.setDynamic(false); //no longer needed with the Entity name refactoring? persistentClass.EntityName = (annotatedClass.Name); BindDiscriminatorValue(); persistentClass.IsLazy = lazy; if (proxyClass != null) { persistentClass.ProxyInterfaceName = proxyClass.Name; } persistentClass.DynamicInsert = dynamicInsert; persistentClass.DynamicUpdate = dynamicUpdate; if (persistentClass is RootClass) { RootClass rootClass = (RootClass)persistentClass; bool mutable = true; //priority on @Immutable, then @Entity.mutable() if (annotatedClass.IsAttributePresent <ImmutableAttribute>()) { mutable = false; } else { var entityAnn = annotatedClass.GetAttribute <EntityAttribute>(); if (entityAnn != null) { mutable = entityAnn.IsMutable; } } rootClass.IsMutable = mutable; rootClass.IsExplicitPolymorphism = ExplicitPolymorphismConverter.Convert(polymorphismType); if (StringHelper.IsNotEmpty(where)) { rootClass.Where = where; } if (cacheConcurrentStrategy != null) { rootClass.CacheConcurrencyStrategy = cacheConcurrentStrategy; rootClass.CacheRegionName = cacheRegion; //TODO: LazyPropertiesCacheable //rootClass.LazyPropertiesCacheable = cacheLazyProperty ; } rootClass.IsForceDiscriminator = annotatedClass.IsAttributePresent <ForceDiscriminatorAttribute>(); } else { if (explicitHibernateEntityAnnotation) { log.WarnFormat("[NHibernate.Annotations.Entity] used on a non root entity: ignored for {0}", annotatedClass.Name); } if (annotatedClass.IsAttributePresent <ImmutableAttribute>()) { log.WarnFormat("[Immutable] used on a non root entity: ignored for {0}", annotatedClass.Name); } } persistentClass.OptimisticLockMode = OptimisticLockModeConverter.Convert(optimisticLockType); persistentClass.SelectBeforeUpdate = selectBeforeUpdate; //set persister if needed //[Persister] has precedence over [Entity.persister] var persisterAnn = annotatedClass.GetAttribute <PersisterAttribute>(); System.Type persister = null; if (persisterAnn != null) { persister = persisterAnn.Implementation; } else { var entityAnn = annotatedClass.GetAttribute <EntityAttribute>(); if (entityAnn != null && !BinderHelper.IsDefault(entityAnn.Persister)) { try { persister = ReflectHelper.ClassForName(entityAnn.Persister); } catch (TypeLoadException tle) { throw new AnnotationException("Could not find persister class: " + persister, tle); } } } if (persister != null) { persistentClass.EntityPersisterClass = persister; } persistentClass.BatchSize = batchSize; //SQL overriding var sqlInsert = annotatedClass.GetAttribute <SQLInsertAttribute>(); var sqlUpdate = annotatedClass.GetAttribute <SQLUpdateAttribute>(); var sqlDelete = annotatedClass.GetAttribute <SQLDeleteAttribute>(); var sqlDeleteAll = annotatedClass.GetAttribute <SQLDeleteAllAttribute>(); var loader = annotatedClass.GetAttribute <LoaderAttribute>(); if (sqlInsert != null) { persistentClass.SetCustomSQLInsert(sqlInsert.Sql.Trim(), sqlInsert.Callable, ExecuteUpdateResultCheckStyleConverter.Convert(sqlInsert.Check)); } if (sqlUpdate != null) { persistentClass.SetCustomSQLUpdate(sqlUpdate.Sql.Trim(), sqlUpdate.Callable, ExecuteUpdateResultCheckStyleConverter.Convert(sqlUpdate.Check)); } if (sqlDelete != null) { persistentClass.SetCustomSQLDelete(sqlDelete.Sql, sqlDelete.Callable, ExecuteUpdateResultCheckStyleConverter.Convert(sqlDelete.Check)); } if (sqlDeleteAll != null) { persistentClass.SetCustomSQLDelete(sqlDeleteAll.Sql, sqlDeleteAll.Callable, ExecuteUpdateResultCheckStyleConverter.Convert(sqlDeleteAll.Check)); } if (loader != null) { persistentClass.LoaderName = loader.NamedQuery; } //tuplizers if (annotatedClass.IsAttributePresent <TuplizerAttribute>()) { foreach (TuplizerAttribute tuplizer in annotatedClass.GetAttributes <TuplizerAttribute>()) { var mode = EntityModeConverter.Convert(tuplizer.EntityMode); persistentClass.AddTuplizer(mode, tuplizer.Implementation.Name); } } if (annotatedClass.IsAttributePresent <TuplizerAttribute>()) { var tuplizer = annotatedClass.GetAttribute <TuplizerAttribute>(); var mode = EntityModeConverter.Convert(tuplizer.EntityMode); persistentClass.AddTuplizer(mode, tuplizer.Implementation.Name); } if (!inheritanceState.HasParents) { var iter = filters.GetEnumerator(); while (iter.MoveNext()) { var filter = iter.Current; String filterName = filter.Key; String cond = filter.Value; if (BinderHelper.IsDefault(cond)) { FilterDefinition definition = mappings.GetFilterDefinition(filterName); cond = definition == null ? null : definition.DefaultFilterCondition; if (StringHelper.IsEmpty(cond)) { throw new AnnotationException("no filter condition found for filter " + filterName + " in " + name); } } persistentClass.AddFilter(filterName, cond); } } else { if (filters.Count > 0) { log.WarnFormat("@Filter not allowed on subclasses (ignored): {0}", persistentClass.EntityName); } } log.DebugFormat("Import with entity name {0}", name); try { mappings.AddImport(persistentClass.EntityName, name); String entityName = persistentClass.EntityName; if (!entityName.Equals(name)) { mappings.AddImport(entityName, entityName); } } catch (MappingException me) { throw new AnnotationException("Use of the same entity name twice: " + name, me); } }