1 | // Licensed to the .NET Foundation under one or more agreements. |
---|---|
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | |
6 | #include "common.h" |
7 | #include "clrconfig.h" |
8 | #include "compatibilityswitch.h" |
9 | |
10 | FCIMPL2(StringObject*, CompatibilitySwitch::GetValue, StringObject* switchNameUNSAFE, CLR_BOOL onlyDB) { |
11 | CONTRACTL { |
12 | FCALL_CHECK; |
13 | } |
14 | CONTRACTL_END; |
15 | |
16 | if (!switchNameUNSAFE) |
17 | FCThrowRes(kArgumentNullException, W("Arg_InvalidSwitchName")); |
18 | |
19 | STRINGREF name = (STRINGREF) switchNameUNSAFE; |
20 | VALIDATEOBJECTREF(name); |
21 | |
22 | STRINGREF refName = NULL; |
23 | |
24 | HELPER_METHOD_FRAME_BEGIN_RET_1(name); |
25 | CLRConfig::ConfigStringInfo info; |
26 | info.name = name->GetBuffer(); |
27 | if(onlyDB) |
28 | { |
29 | // for public managed apis we ignore checking in registry/config/env |
30 | // only check in windows appcompat DB |
31 | info.options = CLRConfig::IgnoreEnv | |
32 | CLRConfig::IgnoreHKLM | |
33 | CLRConfig::IgnoreHKCU | |
34 | CLRConfig::IgnoreConfigFiles; |
35 | } |
36 | else |
37 | { |
38 | // for mscorlib (i.e. which use internal apis) also check in |
39 | // registry/config/env in addition to windows appcompat DB |
40 | info.options = CLRConfig::EEConfig_default; |
41 | } |
42 | LPWSTR strVal = CLRConfig::GetConfigValue(info); |
43 | refName = StringObject::NewString(strVal); |
44 | HELPER_METHOD_FRAME_END(); |
45 | |
46 | return (StringObject*)OBJECTREFToObject(refName); |
47 | } |
48 | FCIMPLEND |
49 |