C# Класс Castle.DynamicProxy.Generators.Emitters.CustomAttributeUtil

Показать файл Открыть проект

Открытые методы

Метод Описание
CreateCustomAttribute ( Attribute attribute ) : CustomAttributeBuilder

Приватные методы

Метод Описание
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.

Описание методов

CreateCustomAttribute() публичный статический Метод

public static CreateCustomAttribute ( Attribute attribute ) : CustomAttributeBuilder
attribute System.Attribute
Результат System.Reflection.Emit.CustomAttributeBuilder