We need you! We're working hard on the next version of Developer Fusion - Let us know what you think we should be up to!

The Labs \ Source Viewer \ SSCLI \ System.Resources \ NeutralResourcesLanguageAttribute

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  NeutralResourcesLanguageAttribute
  18. **
  19. **
  20. ** Purpose: Tells the ResourceManager what language your main
  21. **          assembly's resources are written in.  The
  22. **          ResourceManager won't try loading a satellite
  23. **          assembly for that culture, which helps perf.
  24. **
  25. **
  26. ===========================================================*/
  27. using System;
  28. namespace System.Resources
  29. {
  30.    
  31.     [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
  32.     [System.Runtime.InteropServices.ComVisible(true)]
  33.     public sealed class NeutralResourcesLanguageAttribute : Attribute
  34.     {
  35.         private string _culture;
  36.         private UltimateResourceFallbackLocation _fallbackLoc;
  37.        
  38.         public NeutralResourcesLanguageAttribute(string cultureName)
  39.         {
  40.             if (cultureName == null)
  41.                 throw new ArgumentNullException("cultureName");
  42.            
  43.             _culture = cultureName;
  44.             _fallbackLoc = UltimateResourceFallbackLocation.MainAssembly;
  45.         }
  46.        
  47.         public NeutralResourcesLanguageAttribute(string cultureName, UltimateResourceFallbackLocation location)
  48.         {
  49.             if (cultureName == null)
  50.                 throw new ArgumentNullException("cultureName");
  51.             if (!Enum.IsDefined(typeof(UltimateResourceFallbackLocation), location))
  52.                 throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", location));
  53.            
  54.             _culture = cultureName;
  55.             _fallbackLoc = location;
  56.         }
  57.        
  58.         public string CultureName {
  59.             get { return _culture; }
  60.         }
  61.        
  62.         public UltimateResourceFallbackLocation Location {
  63.             get { return _fallbackLoc; }
  64.         }
  65.     }
  66. }

Developer Fusion