OLD | NEW |
| (Empty) |
1 /// Copyright (c) Microsoft Corporation. All rights reserved. | |
2 | |
3 using System; | |
4 using System.Reflection; | |
5 using System.Globalization; | |
6 using System.Resources; | |
7 using System.Text; | |
8 using System.Threading; | |
9 using System.ComponentModel; | |
10 using System.Security.Permissions; | |
11 | |
12 namespace Microsoft.VisualStudio.Project | |
13 { | |
14 [AttributeUsage(AttributeTargets.All)] | |
15 internal sealed class SRDescriptionAttribute : DescriptionAttribute | |
16 { | |
17 private bool replaced; | |
18 | |
19 public SRDescriptionAttribute(string description) | |
20 : base(description) | |
21 { | |
22 } | |
23 | |
24 public override string Description | |
25 { | |
26 get | |
27 { | |
28 if(!replaced) | |
29 { | |
30 replaced = true; | |
31 DescriptionValue = SR.GetString(base.Des
cription, CultureInfo.CurrentUICulture); | |
32 } | |
33 return base.Description; | |
34 } | |
35 } | |
36 } | |
37 | |
38 [AttributeUsage(AttributeTargets.All)] | |
39 internal sealed class SRCategoryAttribute : CategoryAttribute | |
40 { | |
41 | |
42 public SRCategoryAttribute(string category) | |
43 : base(category) | |
44 { | |
45 } | |
46 | |
47 protected override string GetLocalizedString(string value) | |
48 { | |
49 return SR.GetString(value, CultureInfo.CurrentUICulture)
; | |
50 } | |
51 } | |
52 internal sealed class SR | |
53 { | |
54 internal const string AddReferenceDialogTitle = "AddReferenceDia
logTitle"; | |
55 internal const string AddToNullProjectError = "AddToNullProjectE
rror"; | |
56 internal const string Advanced = "Advanced"; | |
57 internal const string AssemblyReferenceAlreadyExists = "Assembly
ReferenceAlreadyExists"; | |
58 internal const string AttributeLoad = "AttributeLoad"; | |
59 internal const string BuildAction = "BuildAction"; | |
60 internal const string BuildActionDescription = "BuildActionDescr
iption"; | |
61 internal const string BuildCaption = "BuildCaption"; | |
62 internal const string BuildVerbosity = "BuildVerbosity"; | |
63 internal const string BuildVerbosityDescription = "BuildVerbosit
yDescription"; | |
64 internal const string BuildEventError = "BuildEventError"; | |
65 internal const string CancelQueryEdit = "CancelQueryEdit"; | |
66 internal const string CannotAddFileThatIsOpenInEditor = "CannotA
ddFileThatIsOpenInEditor"; | |
67 internal const string CanNotSaveFileNotOpeneInEditor = "CanNotSa
veFileNotOpeneInEditor"; | |
68 internal const string cli1 = "cli1"; | |
69 internal const string Compile = "Compile"; | |
70 internal const string ConfirmExtensionChange = "ConfirmExtension
Change"; | |
71 internal const string Content = "Content"; | |
72 internal const string CopyToLocal = "CopyToLocal"; | |
73 internal const string CopyToLocalDescription = "CopyToLocalDescr
iption"; | |
74 internal const string CustomTool = "CustomTool"; | |
75 internal const string CustomToolDescription = "CustomToolDescrip
tion"; | |
76 internal const string CustomToolNamespace = "CustomToolNamespace
"; | |
77 internal const string CustomToolNamespaceDescription = "CustomTo
olNamespaceDescription"; | |
78 internal const string DetailsImport = "DetailsImport"; | |
79 internal const string DetailsUserImport = "DetailsUserImport"; | |
80 internal const string DetailsItem = "DetailsItem"; | |
81 internal const string DetailsItemLocation = "DetailsItemLocation
"; | |
82 internal const string DetailsProperty = "DetailsProperty"; | |
83 internal const string DetailsTarget = "DetailsTarget"; | |
84 internal const string DetailsUsingTask = "DetailsUsingTask"; | |
85 internal const string Detailed = "Detailed"; | |
86 internal const string Diagnostic = "Diagnostic"; | |
87 internal const string DirectoryExistError = "DirectoryExistError
"; | |
88 internal const string EditorViewError = "EditorViewError"; | |
89 internal const string EmbeddedResource = "EmbeddedResource"; | |
90 internal const string Error = "Error"; | |
91 internal const string ErrorInvalidFileName = "ErrorInvalidFileNa
me"; | |
92 internal const string ErrorInvalidProjectName = "ErrorInvalidPro
jectName"; | |
93 internal const string ErrorReferenceCouldNotBeAdded = "ErrorRefe
renceCouldNotBeAdded"; | |
94 internal const string ErrorMsBuildRegistration = "ErrorMsBuildRe
gistration"; | |
95 internal const string ErrorSaving = "ErrorSaving"; | |
96 internal const string Exe = "Exe"; | |
97 internal const string ExpectedObjectOfType = "ExpectedObjectOfTy
pe"; | |
98 internal const string FailedToGetService = "FailedToGetService"; | |
99 internal const string FailedToRetrieveProperties = "FailedToRetr
ieveProperties"; | |
100 internal const string FileNameCannotContainALeadingPeriod = "Fil
eNameCannotContainALeadingPeriod"; | |
101 internal const string FileCannotBeRenamedToAnExistingFile = "Fil
eCannotBeRenamedToAnExistingFile"; | |
102 internal const string FileAlreadyExistsAndCannotBeRenamed = "Fil
eAlreadyExistsAndCannotBeRenamed"; | |
103 internal const string FileAlreadyExists = "FileAlreadyExists"; | |
104 internal const string FileAlreadyExistsCaption = "FileAlreadyExi
stsCaption"; | |
105 internal const string FileAlreadyInProject = "FileAlreadyInProje
ct"; | |
106 internal const string FileAlreadyInProjectCaption = "FileAlready
InProjectCaption"; | |
107 internal const string FileCopyError = "FileCopyError"; | |
108 internal const string FileName = "FileName"; | |
109 internal const string FileNameDescription = "FileNameDescription
"; | |
110 internal const string FileOrFolderAlreadyExists = "FileOrFolderA
lreadyExists"; | |
111 internal const string FileOrFolderCannotBeFound = "FileOrFolderC
annotBeFound"; | |
112 internal const string FileProperties = "FileProperties"; | |
113 internal const string FolderName = "FolderName"; | |
114 internal const string FolderNameDescription = "FolderNameDescrip
tion"; | |
115 internal const string FolderProperties = "FolderProperties"; | |
116 internal const string FullPath = "FullPath"; | |
117 internal const string FullPathDescription = "FullPathDescription
"; | |
118 internal const string ItemDoesNotExistInProjectDirectory = "Item
DoesNotExistInProjectDirectory"; | |
119 internal const string InvalidAutomationObject = "InvalidAutomati
onObject"; | |
120 internal const string InvalidLoggerType = "InvalidLoggerType"; | |
121 internal const string InvalidParameter = "InvalidParameter"; | |
122 internal const string Library = "Library"; | |
123 internal const string LinkedItemsAreNotSupported = "LinkedItemsA
reNotSupported"; | |
124 internal const string Minimal = "Minimal"; | |
125 internal const string Misc = "Misc"; | |
126 internal const string None = "None"; | |
127 internal const string Normal = "Normal"; | |
128 internal const string NestedProjectFailedToReload = "NestedProje
ctFailedToReload"; | |
129 internal const string OutputPath = "OutputPath"; | |
130 internal const string OutputPathDescription = "OutputPathDescrip
tion"; | |
131 internal const string PasteFailed = "PasteFailed"; | |
132 internal const string ParameterMustBeAValidGuid = "ParameterMust
BeAValidGuid"; | |
133 internal const string ParameterMustBeAValidItemId = "ParameterMu
stBeAValidItemId"; | |
134 internal const string ParameterCannotBeNullOrEmpty = "ParameterC
annotBeNullOrEmpty"; | |
135 internal const string PathTooLong = "PathTooLong"; | |
136 internal const string ProjectContainsCircularReferences = "Proje
ctContainsCircularReferences"; | |
137 internal const string Program = "Program"; | |
138 internal const string Project = "Project"; | |
139 internal const string ProjectFile = "ProjectFile"; | |
140 internal const string ProjectFileDescription = "ProjectFileDescr
iption"; | |
141 internal const string ProjectFolder = "ProjectFolder"; | |
142 internal const string ProjectFolderDescription = "ProjectFolderD
escription"; | |
143 internal const string ProjectLocationNotTrusted = "ProjectLocati
onNotTrusted"; | |
144 internal const string ProjectProperties = "ProjectProperties"; | |
145 internal const string Quiet = "Quiet"; | |
146 internal const string QueryReloadNestedProject = "QueryReloadNes
tedProject"; | |
147 internal const string ReferenceAlreadyExists = "ReferenceAlready
Exists"; | |
148 internal const string ReferencesNodeName = "ReferencesNodeName"; | |
149 internal const string ReferenceProperties = "ReferenceProperties
"; | |
150 internal const string RefName = "RefName"; | |
151 internal const string RefNameDescription = "RefNameDescription"; | |
152 internal const string RenameFolder = "RenameFolder"; | |
153 internal const string RTL = "RTL"; | |
154 internal const string SaveCaption = "SaveCaption"; | |
155 internal const string SaveModifiedDocuments = "SaveModifiedDocum
ents"; | |
156 internal const string SaveOfProjectFileOutsideCurrentDirectory =
"SaveOfProjectFileOutsideCurrentDirectory"; | |
157 internal const string StandardEditorViewError = "StandardEditorV
iewError"; | |
158 internal const string URL = "URL"; | |
159 internal const string UseOfDeletedItemError = "UseOfDeletedItemE
rror"; | |
160 internal const string v1 = "v1"; | |
161 internal const string v11 = "v11"; | |
162 internal const string v2 = "v2"; | |
163 internal const string Warning = "Warning"; | |
164 internal const string WinExe = "WinExe"; | |
165 | |
166 static SR loader; | |
167 ResourceManager resources; | |
168 | |
169 private static Object s_InternalSyncObject; | |
170 private static Object InternalSyncObject | |
171 { | |
172 get | |
173 { | |
174 if(s_InternalSyncObject == null) | |
175 { | |
176 Object o = new Object(); | |
177 Interlocked.CompareExchange(ref s_Intern
alSyncObject, o, null); | |
178 } | |
179 return s_InternalSyncObject; | |
180 } | |
181 } | |
182 | |
183 internal SR() | |
184 { | |
185 resources = new System.Resources.ResourceManager("Micros
oft.VisualStudio.Project.Resources", this.GetType().Assembly); | |
186 } | |
187 | |
188 private static SR GetLoader() | |
189 { | |
190 if(loader == null) | |
191 { | |
192 lock(InternalSyncObject) | |
193 { | |
194 if(loader == null) | |
195 { | |
196 loader = new SR(); | |
197 } | |
198 } | |
199 } | |
200 | |
201 return loader; | |
202 } | |
203 | |
204 private static CultureInfo Culture | |
205 { | |
206 get { return null/*use ResourceManager default, CultureI
nfo.CurrentUICulture*/; } | |
207 } | |
208 | |
209 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Perf
ormance", "CA1811:AvoidUncalledPrivateCode")] | |
210 public static ResourceManager Resources | |
211 { | |
212 get | |
213 { | |
214 return GetLoader().resources; | |
215 } | |
216 } | |
217 | |
218 public static string GetString(string name, params object[] args
) | |
219 { | |
220 SR sys = GetLoader(); | |
221 if(sys == null) | |
222 return null; | |
223 string res = sys.resources.GetString(name, SR.Culture); | |
224 | |
225 if(args != null && args.Length > 0) | |
226 { | |
227 return String.Format(CultureInfo.CurrentCulture,
res, args); | |
228 } | |
229 else | |
230 { | |
231 return res; | |
232 } | |
233 } | |
234 | |
235 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Perf
ormance", "CA1811:AvoidUncalledPrivateCode")] | |
236 public static string GetString(string name) | |
237 { | |
238 SR sys = GetLoader(); | |
239 if(sys == null) | |
240 return null; | |
241 return sys.resources.GetString(name, SR.Culture); | |
242 } | |
243 | |
244 public static string GetString(string name, CultureInfo culture) | |
245 { | |
246 SR sys = GetLoader(); | |
247 if(sys == null) | |
248 return null; | |
249 | |
250 try { | |
251 return sys.resources.GetString(name, culture); | |
252 } | |
253 catch (System.Resources.MissingManifestResourceException){ | |
254 return string.Format("'{0}' MISSING", name); | |
255 | |
256 } | |
257 } | |
258 | |
259 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Perf
ormance", "CA1811:AvoidUncalledPrivateCode")] | |
260 public static object GetObject(string name) | |
261 { | |
262 SR sys = GetLoader(); | |
263 if(sys == null) | |
264 return null; | |
265 return sys.resources.GetObject(name, SR.Culture); | |
266 } | |
267 } | |
268 } | |
OLD | NEW |