static (DmdConstructorInfo ctor, IList <DmdCustomAttributeTypedArgument> constructorArguments) GetConstructor(DmdType type, SecurityAction action) { var appDomain = type.AppDomain; var securityActionType = appDomain.GetWellKnownType(DmdWellKnownType.System_Security_Permissions_SecurityAction); var ctor = type.GetConstructor(new[] { securityActionType }); if ((object)ctor != null) { var ctorArgs = new[] { new DmdCustomAttributeTypedArgument(securityActionType, (int)action) }; return(ctor, ctorArgs); } ctor = type.GetConstructor(Array.Empty <DmdType>()) ?? type.GetConstructors().FirstOrDefault(); return(ctor, null); }
public override ILValue UnboxAny(DmdType type) { if (type.IsNullable) { var method = type.GetConstructor(new[] { type.GetNullableElementType() }); if ((object)method == null) { return(null); } return(runtime.CreateInstance(method, new[] { ilValue })); } else { return(ilValue.Clone()); } }