private static Assembly GetEntryAssembly() { #if FEATURE_ASSEMBLY_GETENTRYASSEMBLY return(System.Reflection.Assembly.GetEntryAssembly()); #else var getEntryAssembly = typeof(Assembly).GetMethod("GetEntryAssembly"); FrameworkErrorUtilities.VerifyThrowInternalNull(getEntryAssembly, "Assembly does not have the method GetEntryAssembly"); return((Assembly)getEntryAssembly.Invoke(null, Array.Empty <object>())); #endif }
private static CultureInfo[] GetValidCultures() { var cultureTypesType = s_cultureInfoGetCultureMethod?.GetParameters().FirstOrDefault()?.ParameterType; FrameworkErrorUtilities.VerifyThrow(cultureTypesType?.Name == "CultureTypes" && Enum.IsDefined(cultureTypesType, "AllCultures"), "GetCulture is expected to accept CultureTypes.AllCultures"); var allCulturesEnumValue = Enum.Parse(cultureTypesType, "AllCultures", true); var cultures = s_cultureInfoGetCultureMethod.Invoke(null, new[] { allCulturesEnumValue }) as CultureInfo[]; FrameworkErrorUtilities.VerifyThrowInternalNull(cultures, "CultureInfo.GetCultures should work if all reflection checks pass"); return(cultures); }