C# 클래스 Castle.DynamicProxy.Generators.Emitters.CustomAttributeUtil

파일 보기 프로젝트 열기: nats/castle-1.0.3-mono

공개 메소드들

메소드 설명
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