C# Class Castle.DynamicProxy.Generators.Emitters.CustomAttributeUtil

Afficher le fichier Open project: nats/castle-1.0.3-mono

Méthodes publiques

Méthode Description
CreateCustomAttribute ( Attribute attribute ) : CustomAttributeBuilder

Private Methods

Méthode Description
ConvertValue ( object obj, Type paramType ) : object

Attributes can only accept simple types, so we return null for null, if the value is passed as string we call to string (should help with converting), otherwise, we use the value as is (enums, integer, etc).

GetArgValue ( Type attType, Attribute attribute, ParameterInfo parameterInfo ) : object
GetConstructorAndArgs ( Type attType, Attribute attribute, ConstructorInfo &ci ) : object[]
GetDefaultValueFor ( Type type ) : object
GetFieldValues ( Type attType, FieldInfo &fields, Attribute attribute ) : object[]
GetPropertyValues ( Type attType, PropertyInfo &properties, Attribute attribute ) : object[]
InitializeConstructorArgs ( Type attType, Attribute attribute, object args, ParameterInfo parameterInfos ) : void

Here we try to match a constructor argument to its value. Since we can't get the values from the assembly, we use some heuristics to get it. a/ we first try to match all the properties on the attributes by name (case insensitive) to the argument b/ if we fail we try to match them by property type, with some smarts about convertions (i,e: can use Guid for string).

ReplaceIfBetterMatch ( ParameterInfo parameterInfo, PropertyInfo propertyInfo, PropertyInfo bestMatch ) : PropertyInfo

We have the following rules here. Try to find a matching type, failing that, if the parameter is string, get the first property (under the assumption that we can convert it.

Method Details

CreateCustomAttribute() public static méthode

public static CreateCustomAttribute ( Attribute attribute ) : CustomAttributeBuilder
attribute System.Attribute
Résultat System.Reflection.Emit.CustomAttributeBuilder