summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs
blob: 6517a56b6a19ff74ba55e135d4dff363605bcadb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*============================================================
**
** 
** 
**
**
** Purpose: Tells the ResourceManager what language your main
**          assembly's resources are written in.  The 
**          ResourceManager won't try loading a satellite
**          assembly for that culture, which helps perf.
**
**
** NOTE:
**
** This custom attribute is no longer implemented in managed code.  As part of a perf optimization,
** it is now read in Module::GetNeutralResourcesLanguage, accessed from ManifestBasedResourceGroveler 
** through an internal runtime call.
===========================================================*/

namespace System.Resources {
    using System;
    using System.Diagnostics.Contracts;
    
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple=false)]  
    [System.Runtime.InteropServices.ComVisible(true)]
    public sealed class NeutralResourcesLanguageAttribute : Attribute 
    {
        private String _culture;
        private UltimateResourceFallbackLocation _fallbackLoc;

        public NeutralResourcesLanguageAttribute(String cultureName)
        {
            if (cultureName == null)
                throw new ArgumentNullException(nameof(cultureName));
            Contract.EndContractBlock();

            _culture = cultureName;
            _fallbackLoc = UltimateResourceFallbackLocation.MainAssembly;
        }

        public NeutralResourcesLanguageAttribute(String cultureName, UltimateResourceFallbackLocation location)
        {
            if (cultureName == null)
                throw new ArgumentNullException(nameof(cultureName));
            if (!Enum.IsDefined(typeof(UltimateResourceFallbackLocation), location))
                throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", location));
            Contract.EndContractBlock();

            _culture = cultureName;
            _fallbackLoc = location;
        }

        public String CultureName {
            get { return _culture; }
        }

        public UltimateResourceFallbackLocation Location {
            get { return _fallbackLoc; }
        }
    }
}