internal CILParameterImpl( CILReflectionContextImpl ctx, Int32 anID, System.Reflection.ParameterInfo parameter ) : base(ctx, anID, CILElementKind.Parameter, () => new CustomAttributeDataEventArgs(ctx, parameter)) { var member = parameter.Member; var isCtor = member is System.Reflection.ConstructorInfo; InitFields( ref this.paramAttributes, ref this.position, ref this.name, ref this.method, ref this.parameterType, ref this.defaultValue, ref this.customModifiers, ref this.marshalInfo, new SettableValueForEnums <ParameterAttributes>((ParameterAttributes)parameter.Attributes), parameter.Position, new SettableValueForClasses <String>(parameter.Name), () => isCtor ? (CILMethodBase)ctx.Cache.GetOrAdd((System.Reflection.ConstructorInfo)member) : ctx.Cache.GetOrAdd((System.Reflection.MethodInfo)member), () => ctx.Cache.GetOrAdd(parameter.ParameterType), new SettableLazy <Object>(() => ctx.LaunchConstantValueLoadEvent(new ConstantValueLoadArgs(parameter))), ctx.LaunchEventAndCreateCustomModifiers(new CustomModifierEventLoadArgs(parameter)), new SettableLazy <MarshalingInfo>(() => MarshalingInfo.FromAttribute(parameter.GetCustomAttributes(true).OfType <System.Runtime.InteropServices.MarshalAsAttribute>().FirstOrDefault(), ctx)), true ); }
internal CILFieldImpl( CILReflectionContextImpl ctx, Int32 anID, System.Reflection.FieldInfo field ) : base(ctx, anID, CILElementKind.Field, () => new CustomAttributeDataEventArgs(ctx, field)) { ArgumentValidator.ValidateNotNull("Field", field); if (field.DeclaringType #if WINDOWS_PHONE_APP .GetTypeInfo() #endif .IsGenericType&& !field.DeclaringType #if WINDOWS_PHONE_APP .GetTypeInfo() #endif .IsGenericTypeDefinition) { throw new ArgumentException("This constructor may be used only on fields declared in genericless types or generic type definitions."); } Byte[] rvaValue = null; if (((FieldAttributes)field.Attributes).HasRVA()) { rvaValue = BitUtils.ObjectToByteArray(field.GetValue(null)); } InitFields( ref this.fieldAttributes, ref this.name, ref this.declaringType, ref this.fieldType, ref this.constValue, ref this.initialValue, ref this.customModifiers, ref this.fieldOffset, ref this.marshalInfo, new SettableValueForEnums <FieldAttributes>((FieldAttributes)field.Attributes), new SettableValueForClasses <String>(field.Name), () => (CILType)ctx.Cache.GetOrAdd(field.DeclaringType), () => ctx.Cache.GetOrAdd(field.FieldType), new SettableLazy <Object>(() => ctx.LaunchConstantValueLoadEvent(new ConstantValueLoadArgs(field))), new SettableValueForClasses <Byte[]>(rvaValue), ctx.LaunchEventAndCreateCustomModifiers(new CustomModifierEventLoadArgs(field)), new SettableLazy <Int32>(() => { var offset = field.GetCustomAttributes(true).OfType <System.Runtime.InteropServices.FieldOffsetAttribute>().FirstOrDefault(); return(offset == null ? -1 : offset.Value); }), new SettableLazy <MarshalingInfo>(() => MarshalingInfo.FromAttribute(field.GetCustomAttributes(true).OfType <System.Runtime.InteropServices.MarshalAsAttribute>().FirstOrDefault(), ctx)), true ); }