Ejemplo n.º 1
0
 protected override void AddPersistenceExceptionTranslation(ProxyFactory pf, IPersistenceExceptionTranslator pet)
 {
     if (AttributeUtils.FindAttribute(pf.TargetType, typeof(RepositoryAttribute)) != null)
     {
         DefaultListableObjectFactory of = new DefaultListableObjectFactory();
         of.RegisterObjectDefinition("peti", new RootObjectDefinition(typeof(PersistenceExceptionTranslationInterceptor)));
         of.RegisterSingleton("pet", pet);
         pf.AddAdvice((PersistenceExceptionTranslationInterceptor)of.GetObject("peti"));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks if <paramref name="objectType"/> is annotated with the specified <paramref name="attributeType"/>.
 /// </summary>
 /// <param name="objectType">the object's type</param>
 /// <param name="attributeType">the <see cref="Attribute"/> type to match agains.</param>
 /// <param name="checkInherited">whether to check base classes and intefaces for the specified attribute.</param>
 /// <returns><see langword="true"/> if the attributes is found</returns>
 protected virtual bool IsAnnotatedWithAttribute(Type objectType, Type attributeType, bool checkInherited)
 {
     if (checkInherited)
     {
         return(AttributeUtils.FindAttribute(objectType, attributeType) != null);
     }
     else
     {
         object[] atts = objectType.GetCustomAttributes(attributeType, false);
         return(ArrayUtils.HasLength(atts));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Should the pointcut apply to the supplied <see cref="System.Type"/>?
 /// </summary>
 /// <param name="type">The candidate <see cref="System.Type"/>.</param>
 /// <returns>
 ///     <see langword="true"/> if the advice should apply to the supplied
 /// <paramref name="type"/>
 /// </returns>
 public bool Matches(Type type)
 {
     if (checkInherited)
     {
         return(AttributeUtils.FindAttribute(type, attributeType) != null);
     }
     else
     {
         object[] atts = type.GetCustomAttributes(attributeType, false);
         return(ArrayUtils.HasLength(atts));
     }
 }
 public static string ToMIMEStr(MediaType mediaType)
 {
     return(AttributeUtils <MIMETypeAttribute> .FindAttribute(mediaType).MIMEType);
 }