WebRequest.GetSystemWebProxy() throws a NullReferenceException in case the proxy...
[mono.git] / mcs / class / System.Data.Services.Client / Client / System.Data.Services.Client.cs
1 //Copyright 2010 Microsoft Corporation\r
2 //\r
3 //Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. \r
4 //You may obtain a copy of the License at \r
5 //\r
6 //http://www.apache.org/licenses/LICENSE-2.0 \r
7 //\r
8 //Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \r
9 //"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
10 //See the License for the specific language governing permissions and limitations under the License.\r
11 \r
12 \r
13 namespace System.Data.Services.Client {\r
14     using System;\r
15     using System.Reflection;\r
16     using System.Globalization;\r
17     using System.Resources;\r
18     using System.Text;\r
19     using System.Threading;\r
20     using System.ComponentModel;\r
21     using System.Security.Permissions;\r
22 \r
23     [AttributeUsage(AttributeTargets.All)]\r
24     internal sealed class TextResDescriptionAttribute : DescriptionAttribute {\r
25 \r
26         private bool replaced;\r
27 \r
28 \r
29         public TextResDescriptionAttribute(string description) : base(description) {\r
30         }\r
31 \r
32         public override string Description {\r
33             get {\r
34                 if (!replaced) {\r
35                     replaced = true;\r
36                     DescriptionValue = TextRes.GetString(base.Description);\r
37                 }\r
38                 return base.Description;\r
39             }\r
40         }\r
41     }\r
42 \r
43     [AttributeUsage(AttributeTargets.All)]\r
44     internal sealed class TextResCategoryAttribute : CategoryAttribute {\r
45 \r
46         public TextResCategoryAttribute(string category) : base(category) {\r
47         }\r
48 \r
49         protected override string GetLocalizedString(string value) {\r
50             return TextRes.GetString(value);\r
51         }\r
52     }\r
53 \r
54     \r
55     internal sealed class TextRes {\r
56         internal const string BatchStream_MissingBoundary = "BatchStream_MissingBoundary";\r
57         internal const string BatchStream_ContentExpected = "BatchStream_ContentExpected";\r
58         internal const string BatchStream_ContentUnexpected = "BatchStream_ContentUnexpected";\r
59         internal const string BatchStream_GetMethodNotSupportedInChangeset = "BatchStream_GetMethodNotSupportedInChangeset";\r
60         internal const string BatchStream_InvalidBatchFormat = "BatchStream_InvalidBatchFormat";\r
61         internal const string BatchStream_InvalidDelimiter = "BatchStream_InvalidDelimiter";\r
62         internal const string BatchStream_MissingEndChangesetDelimiter = "BatchStream_MissingEndChangesetDelimiter";\r
63         internal const string BatchStream_InvalidHeaderValueSpecified = "BatchStream_InvalidHeaderValueSpecified";\r
64         internal const string BatchStream_InvalidContentLengthSpecified = "BatchStream_InvalidContentLengthSpecified";\r
65         internal const string BatchStream_OnlyGETOperationsCanBeSpecifiedInBatch = "BatchStream_OnlyGETOperationsCanBeSpecifiedInBatch";\r
66         internal const string BatchStream_InvalidOperationHeaderSpecified = "BatchStream_InvalidOperationHeaderSpecified";\r
67         internal const string BatchStream_InvalidHttpMethodName = "BatchStream_InvalidHttpMethodName";\r
68         internal const string BatchStream_MoreDataAfterEndOfBatch = "BatchStream_MoreDataAfterEndOfBatch";\r
69         internal const string BatchStream_InternalBufferRequestTooSmall = "BatchStream_InternalBufferRequestTooSmall";\r
70         internal const string BatchStream_InvalidMethodHeaderSpecified = "BatchStream_InvalidMethodHeaderSpecified";\r
71         internal const string BatchStream_InvalidHttpVersionSpecified = "BatchStream_InvalidHttpVersionSpecified";\r
72         internal const string BatchStream_InvalidNumberOfHeadersAtOperationStart = "BatchStream_InvalidNumberOfHeadersAtOperationStart";\r
73         internal const string BatchStream_MissingOrInvalidContentEncodingHeader = "BatchStream_MissingOrInvalidContentEncodingHeader";\r
74         internal const string BatchStream_InvalidNumberOfHeadersAtChangeSetStart = "BatchStream_InvalidNumberOfHeadersAtChangeSetStart";\r
75         internal const string BatchStream_MissingContentTypeHeader = "BatchStream_MissingContentTypeHeader";\r
76         internal const string BatchStream_InvalidContentTypeSpecified = "BatchStream_InvalidContentTypeSpecified";\r
77         internal const string Batch_ExpectedContentType = "Batch_ExpectedContentType";\r
78         internal const string Batch_ExpectedResponse = "Batch_ExpectedResponse";\r
79         internal const string Batch_IncompleteResponseCount = "Batch_IncompleteResponseCount";\r
80         internal const string Batch_UnexpectedContent = "Batch_UnexpectedContent";\r
81         internal const string Context_BaseUri = "Context_BaseUri";\r
82         internal const string Context_CannotConvertKey = "Context_CannotConvertKey";\r
83         internal const string Context_TrackingExpectsAbsoluteUri = "Context_TrackingExpectsAbsoluteUri";\r
84         internal const string Context_LinkResourceInsertFailure = "Context_LinkResourceInsertFailure";\r
85         internal const string Context_InternalError = "Context_InternalError";\r
86         internal const string Context_BatchExecuteError = "Context_BatchExecuteError";\r
87         internal const string Context_EntitySetName = "Context_EntitySetName";\r
88         internal const string Context_MissingEditLinkInResponseBody = "Context_MissingEditLinkInResponseBody";\r
89         internal const string Context_MissingSelfLinkInResponseBody = "Context_MissingSelfLinkInResponseBody";\r
90         internal const string Context_MissingEditMediaLinkInResponseBody = "Context_MissingEditMediaLinkInResponseBody";\r
91         internal const string Content_EntityWithoutKey = "Content_EntityWithoutKey";\r
92         internal const string Content_EntityIsNotEntityType = "Content_EntityIsNotEntityType";\r
93         internal const string Context_EntityNotContained = "Context_EntityNotContained";\r
94         internal const string Context_EntityAlreadyContained = "Context_EntityAlreadyContained";\r
95         internal const string Context_DifferentEntityAlreadyContained = "Context_DifferentEntityAlreadyContained";\r
96         internal const string Context_DidNotOriginateAsync = "Context_DidNotOriginateAsync";\r
97         internal const string Context_AsyncAlreadyDone = "Context_AsyncAlreadyDone";\r
98         internal const string Context_OperationCanceled = "Context_OperationCanceled";\r
99         internal const string Context_NoLoadWithInsertEnd = "Context_NoLoadWithInsertEnd";\r
100         internal const string Context_NoRelationWithInsertEnd = "Context_NoRelationWithInsertEnd";\r
101         internal const string Context_NoRelationWithDeleteEnd = "Context_NoRelationWithDeleteEnd";\r
102         internal const string Context_RelationAlreadyContained = "Context_RelationAlreadyContained";\r
103         internal const string Context_RelationNotRefOrCollection = "Context_RelationNotRefOrCollection";\r
104         internal const string Context_AddLinkCollectionOnly = "Context_AddLinkCollectionOnly";\r
105         internal const string Context_AddRelatedObjectCollectionOnly = "Context_AddRelatedObjectCollectionOnly";\r
106         internal const string Context_AddRelatedObjectSourceDeleted = "Context_AddRelatedObjectSourceDeleted";\r
107         internal const string Context_SetLinkReferenceOnly = "Context_SetLinkReferenceOnly";\r
108         internal const string Context_NoContentTypeForMediaLink = "Context_NoContentTypeForMediaLink";\r
109         internal const string Context_BatchNotSupportedForMediaLink = "Context_BatchNotSupportedForMediaLink";\r
110         internal const string Context_UnexpectedZeroRawRead = "Context_UnexpectedZeroRawRead";\r
111         internal const string Context_VersionNotSupported = "Context_VersionNotSupported";\r
112         internal const string Context_SendingRequestEventArgsNotHttp = "Context_SendingRequestEventArgsNotHttp";\r
113         internal const string Context_ChildResourceExists = "Context_ChildResourceExists";\r
114         internal const string Context_EntityNotMediaLinkEntry = "Context_EntityNotMediaLinkEntry";\r
115         internal const string Context_MLEWithoutSaveStream = "Context_MLEWithoutSaveStream";\r
116         internal const string Context_SetSaveStreamOnMediaEntryProperty = "Context_SetSaveStreamOnMediaEntryProperty";\r
117         internal const string Context_SetSaveStreamWithoutEditMediaLink = "Context_SetSaveStreamWithoutEditMediaLink";\r
118         internal const string Collection_NullCollectionReference = "Collection_NullCollectionReference";\r
119         internal const string ClientType_MissingOpenProperty = "ClientType_MissingOpenProperty";\r
120         internal const string Clienttype_MultipleOpenProperty = "Clienttype_MultipleOpenProperty";\r
121         internal const string ClientType_MissingProperty = "ClientType_MissingProperty";\r
122         internal const string ClientType_KeysMustBeSimpleTypes = "ClientType_KeysMustBeSimpleTypes";\r
123         internal const string ClientType_KeysOnDifferentDeclaredType = "ClientType_KeysOnDifferentDeclaredType";\r
124         internal const string ClientType_MissingMimeTypeProperty = "ClientType_MissingMimeTypeProperty";\r
125         internal const string ClientType_MissingMediaEntryProperty = "ClientType_MissingMediaEntryProperty";\r
126         internal const string ClientType_NoSettableFields = "ClientType_NoSettableFields";\r
127         internal const string ClientType_MultipleImplementationNotSupported = "ClientType_MultipleImplementationNotSupported";\r
128         internal const string ClientType_NullOpenProperties = "ClientType_NullOpenProperties";\r
129         internal const string ClientType_CollectionOfNonEntities = "ClientType_CollectionOfNonEntities";\r
130         internal const string ClientType_Ambiguous = "ClientType_Ambiguous";\r
131         internal const string DataServiceException_GeneralError = "DataServiceException_GeneralError";\r
132         internal const string DataServiceRequest_FailGetCount = "DataServiceRequest_FailGetCount";\r
133         internal const string Deserialize_GetEnumerator = "Deserialize_GetEnumerator";\r
134         internal const string Deserialize_Current = "Deserialize_Current";\r
135         internal const string Deserialize_MixedTextWithComment = "Deserialize_MixedTextWithComment";\r
136         internal const string Deserialize_ExpectingSimpleValue = "Deserialize_ExpectingSimpleValue";\r
137         internal const string Deserialize_NotApplicationXml = "Deserialize_NotApplicationXml";\r
138         internal const string Deserialize_MismatchAtomLinkLocalSimple = "Deserialize_MismatchAtomLinkLocalSimple";\r
139         internal const string Deserialize_MismatchAtomLinkFeedPropertyNotCollection = "Deserialize_MismatchAtomLinkFeedPropertyNotCollection";\r
140         internal const string Deserialize_MismatchAtomLinkEntryPropertyIsCollection = "Deserialize_MismatchAtomLinkEntryPropertyIsCollection";\r
141         internal const string Deserialize_UnknownMimeTypeSpecified = "Deserialize_UnknownMimeTypeSpecified";\r
142         internal const string Deserialize_ExpectedEmptyMediaLinkEntryContent = "Deserialize_ExpectedEmptyMediaLinkEntryContent";\r
143         internal const string Deserialize_ContentPlusPropertiesNotAllowed = "Deserialize_ContentPlusPropertiesNotAllowed";\r
144         internal const string Deserialize_NoLocationHeader = "Deserialize_NoLocationHeader";\r
145         internal const string Deserialize_ServerException = "Deserialize_ServerException";\r
146         internal const string Deserialize_MissingIdElement = "Deserialize_MissingIdElement";\r
147         internal const string EpmClientType_PropertyIsComplex = "EpmClientType_PropertyIsComplex";\r
148         internal const string EpmClientType_PropertyIsPrimitive = "EpmClientType_PropertyIsPrimitive";\r
149         internal const string EpmSourceTree_InvalidSourcePath = "EpmSourceTree_InvalidSourcePath";\r
150         internal const string EpmSourceTree_DuplicateEpmAttrsWithSameSourceName = "EpmSourceTree_DuplicateEpmAttrsWithSameSourceName";\r
151         internal const string EpmSourceTree_InaccessiblePropertyOnType = "EpmSourceTree_InaccessiblePropertyOnType";\r
152         internal const string EpmTargetTree_InvalidTargetPath = "EpmTargetTree_InvalidTargetPath";\r
153         internal const string EpmTargetTree_AttributeInMiddle = "EpmTargetTree_AttributeInMiddle";\r
154         internal const string EpmTargetTree_DuplicateEpmAttrsWithSameTargetName = "EpmTargetTree_DuplicateEpmAttrsWithSameTargetName";\r
155         internal const string EntityPropertyMapping_EpmAttribute = "EntityPropertyMapping_EpmAttribute";\r
156         internal const string EntityPropertyMapping_TargetNamespaceUriNotValid = "EntityPropertyMapping_TargetNamespaceUriNotValid";\r
157         internal const string HttpProcessUtility_ContentTypeMissing = "HttpProcessUtility_ContentTypeMissing";\r
158         internal const string HttpProcessUtility_MediaTypeMissingValue = "HttpProcessUtility_MediaTypeMissingValue";\r
159         internal const string HttpProcessUtility_MediaTypeRequiresSemicolonBeforeParameter = "HttpProcessUtility_MediaTypeRequiresSemicolonBeforeParameter";\r
160         internal const string HttpProcessUtility_MediaTypeRequiresSlash = "HttpProcessUtility_MediaTypeRequiresSlash";\r
161         internal const string HttpProcessUtility_MediaTypeRequiresSubType = "HttpProcessUtility_MediaTypeRequiresSubType";\r
162         internal const string HttpProcessUtility_MediaTypeUnspecified = "HttpProcessUtility_MediaTypeUnspecified";\r
163         internal const string HttpProcessUtility_EncodingNotSupported = "HttpProcessUtility_EncodingNotSupported";\r
164         internal const string HttpProcessUtility_EscapeCharWithoutQuotes = "HttpProcessUtility_EscapeCharWithoutQuotes";\r
165         internal const string HttpProcessUtility_EscapeCharAtEnd = "HttpProcessUtility_EscapeCharAtEnd";\r
166         internal const string HttpProcessUtility_ClosingQuoteNotFound = "HttpProcessUtility_ClosingQuoteNotFound";\r
167         internal const string MaterializeFromAtom_CountNotPresent = "MaterializeFromAtom_CountNotPresent";\r
168         internal const string MaterializeFromAtom_CountFormatError = "MaterializeFromAtom_CountFormatError";\r
169         internal const string MaterializeFromAtom_TopLevelLinkNotAvailable = "MaterializeFromAtom_TopLevelLinkNotAvailable";\r
170         internal const string MaterializeFromAtom_CollectionKeyNotPresentInLinkTable = "MaterializeFromAtom_CollectionKeyNotPresentInLinkTable";\r
171         internal const string MaterializeFromAtom_GetNestLinkForFlatCollection = "MaterializeFromAtom_GetNestLinkForFlatCollection";\r
172         internal const string Serializer_NullKeysAreNotSupported = "Serializer_NullKeysAreNotSupported";\r
173         internal const string Util_EmptyString = "Util_EmptyString";\r
174         internal const string Util_EmptyArray = "Util_EmptyArray";\r
175         internal const string Util_NullArrayElement = "Util_NullArrayElement";\r
176         internal const string ALinq_UnsupportedExpression = "ALinq_UnsupportedExpression";\r
177         internal const string ALinq_CouldNotConvert = "ALinq_CouldNotConvert";\r
178         internal const string ALinq_MethodNotSupported = "ALinq_MethodNotSupported";\r
179         internal const string ALinq_UnaryNotSupported = "ALinq_UnaryNotSupported";\r
180         internal const string ALinq_BinaryNotSupported = "ALinq_BinaryNotSupported";\r
181         internal const string ALinq_ConstantNotSupported = "ALinq_ConstantNotSupported";\r
182         internal const string ALinq_TypeBinaryNotSupported = "ALinq_TypeBinaryNotSupported";\r
183         internal const string ALinq_ConditionalNotSupported = "ALinq_ConditionalNotSupported";\r
184         internal const string ALinq_ParameterNotSupported = "ALinq_ParameterNotSupported";\r
185         internal const string ALinq_MemberAccessNotSupported = "ALinq_MemberAccessNotSupported";\r
186         internal const string ALinq_LambdaNotSupported = "ALinq_LambdaNotSupported";\r
187         internal const string ALinq_NewNotSupported = "ALinq_NewNotSupported";\r
188         internal const string ALinq_MemberInitNotSupported = "ALinq_MemberInitNotSupported";\r
189         internal const string ALinq_ListInitNotSupported = "ALinq_ListInitNotSupported";\r
190         internal const string ALinq_NewArrayNotSupported = "ALinq_NewArrayNotSupported";\r
191         internal const string ALinq_InvocationNotSupported = "ALinq_InvocationNotSupported";\r
192         internal const string ALinq_QueryOptionsOnlyAllowedOnLeafNodes = "ALinq_QueryOptionsOnlyAllowedOnLeafNodes";\r
193         internal const string ALinq_CantExpand = "ALinq_CantExpand";\r
194         internal const string ALinq_CantCastToUnsupportedPrimitive = "ALinq_CantCastToUnsupportedPrimitive";\r
195         internal const string ALinq_CantNavigateWithoutKeyPredicate = "ALinq_CantNavigateWithoutKeyPredicate";\r
196         internal const string ALinq_CanOnlyApplyOneKeyPredicate = "ALinq_CanOnlyApplyOneKeyPredicate";\r
197         internal const string ALinq_CantTranslateExpression = "ALinq_CantTranslateExpression";\r
198         internal const string ALinq_TranslationError = "ALinq_TranslationError";\r
199         internal const string ALinq_CantAddQueryOption = "ALinq_CantAddQueryOption";\r
200         internal const string ALinq_CantAddDuplicateQueryOption = "ALinq_CantAddDuplicateQueryOption";\r
201         internal const string ALinq_CantAddAstoriaQueryOption = "ALinq_CantAddAstoriaQueryOption";\r
202         internal const string ALinq_CantAddQueryOptionStartingWithDollarSign = "ALinq_CantAddQueryOptionStartingWithDollarSign";\r
203         internal const string ALinq_CantReferToPublicField = "ALinq_CantReferToPublicField";\r
204         internal const string ALinq_QueryOptionsOnlyAllowedOnSingletons = "ALinq_QueryOptionsOnlyAllowedOnSingletons";\r
205         internal const string ALinq_QueryOptionOutOfOrder = "ALinq_QueryOptionOutOfOrder";\r
206         internal const string ALinq_CannotAddCountOption = "ALinq_CannotAddCountOption";\r
207         internal const string ALinq_CannotAddCountOptionConflict = "ALinq_CannotAddCountOptionConflict";\r
208         internal const string ALinq_ProjectionOnlyAllowedOnLeafNodes = "ALinq_ProjectionOnlyAllowedOnLeafNodes";\r
209         internal const string ALinq_ProjectionCanOnlyHaveOneProjection = "ALinq_ProjectionCanOnlyHaveOneProjection";\r
210         internal const string ALinq_ProjectionMemberAssignmentMismatch = "ALinq_ProjectionMemberAssignmentMismatch";\r
211         internal const string ALinq_ExpressionNotSupportedInProjectionToEntity = "ALinq_ExpressionNotSupportedInProjectionToEntity";\r
212         internal const string ALinq_ExpressionNotSupportedInProjection = "ALinq_ExpressionNotSupportedInProjection";\r
213         internal const string ALinq_CannotConstructKnownEntityTypes = "ALinq_CannotConstructKnownEntityTypes";\r
214         internal const string ALinq_CannotCreateConstantEntity = "ALinq_CannotCreateConstantEntity";\r
215         internal const string ALinq_PropertyNamesMustMatchInProjections = "ALinq_PropertyNamesMustMatchInProjections";\r
216         internal const string ALinq_CanOnlyProjectTheLeaf = "ALinq_CanOnlyProjectTheLeaf";\r
217         internal const string ALinq_CannotProjectWithExplicitExpansion = "ALinq_CannotProjectWithExplicitExpansion";\r
218         internal const string DSKAttribute_MustSpecifyAtleastOnePropertyName = "DSKAttribute_MustSpecifyAtleastOnePropertyName";\r
219         internal const string DataServiceCollection_LoadRequiresTargetCollectionObserved = "DataServiceCollection_LoadRequiresTargetCollectionObserved";\r
220         internal const string DataServiceCollection_CannotStopTrackingChildCollection = "DataServiceCollection_CannotStopTrackingChildCollection";\r
221         internal const string DataServiceCollection_OperationForTrackedOnly = "DataServiceCollection_OperationForTrackedOnly";\r
222         internal const string DataServiceCollection_CannotDetermineContextFromItems = "DataServiceCollection_CannotDetermineContextFromItems";\r
223         internal const string DataServiceCollection_InsertIntoTrackedButNotLoadedCollection = "DataServiceCollection_InsertIntoTrackedButNotLoadedCollection";\r
224         internal const string DataBinding_DataServiceCollectionArgumentMustHaveEntityType = "DataBinding_DataServiceCollectionArgumentMustHaveEntityType";\r
225         internal const string DataBinding_CollectionPropertySetterValueHasObserver = "DataBinding_CollectionPropertySetterValueHasObserver";\r
226         internal const string DataBinding_CollectionChangedUnknownAction = "DataBinding_CollectionChangedUnknownAction";\r
227         internal const string DataBinding_BindingOperation_DetachedSource = "DataBinding_BindingOperation_DetachedSource";\r
228         internal const string DataBinding_BindingOperation_ArrayItemNull = "DataBinding_BindingOperation_ArrayItemNull";\r
229         internal const string DataBinding_BindingOperation_ArrayItemNotEntity = "DataBinding_BindingOperation_ArrayItemNotEntity";\r
230         internal const string DataBinding_Util_UnknownEntitySetName = "DataBinding_Util_UnknownEntitySetName";\r
231         internal const string DataBinding_EntityAlreadyInCollection = "DataBinding_EntityAlreadyInCollection";\r
232         internal const string DataBinding_NotifyPropertyChangedNotImpl = "DataBinding_NotifyPropertyChangedNotImpl";\r
233         internal const string DataBinding_ComplexObjectAssociatedWithMultipleEntities = "DataBinding_ComplexObjectAssociatedWithMultipleEntities";\r
234         internal const string AtomParser_FeedUnexpected = "AtomParser_FeedUnexpected";\r
235         internal const string AtomParser_PagingLinkOutsideOfFeed = "AtomParser_PagingLinkOutsideOfFeed";\r
236         internal const string AtomParser_ManyFeedCounts = "AtomParser_ManyFeedCounts";\r
237         internal const string AtomParser_FeedCountNotUnderFeed = "AtomParser_FeedCountNotUnderFeed";\r
238         internal const string AtomParser_UnexpectedContentUnderExpandedLink = "AtomParser_UnexpectedContentUnderExpandedLink";\r
239         internal const string AtomMaterializer_CannotAssignNull = "AtomMaterializer_CannotAssignNull";\r
240         internal const string AtomMaterializer_DuplicatedNextLink = "AtomMaterializer_DuplicatedNextLink";\r
241         internal const string AtomMaterializer_EntryIntoCollectionMismatch = "AtomMaterializer_EntryIntoCollectionMismatch";\r
242         internal const string AtomMaterializer_EntryToAccessIsNull = "AtomMaterializer_EntryToAccessIsNull";\r
243         internal const string AtomMaterializer_EntryToInitializeIsNull = "AtomMaterializer_EntryToInitializeIsNull";\r
244         internal const string AtomMaterializer_ProjectEntityTypeMismatch = "AtomMaterializer_ProjectEntityTypeMismatch";\r
245         internal const string AtomMaterializer_LinksMissingHref = "AtomMaterializer_LinksMissingHref";\r
246         internal const string AtomMaterializer_PropertyMissing = "AtomMaterializer_PropertyMissing";\r
247         internal const string AtomMaterializer_PropertyMissingFromEntry = "AtomMaterializer_PropertyMissingFromEntry";\r
248         internal const string AtomMaterializer_PropertyNotExpectedEntry = "AtomMaterializer_PropertyNotExpectedEntry";\r
249 \r
250         static TextRes loader;\r
251         ResourceManager resources;\r
252 \r
253         internal TextRes() {\r
254             resources = new System.Resources.ResourceManager("System.Data.Services.Client", this.GetType().Assembly);\r
255         }\r
256         \r
257         private static TextRes GetLoader() {\r
258             if (loader == null) {\r
259                 TextRes sr = new TextRes();\r
260                 Interlocked.CompareExchange(ref loader, sr, null);\r
261             }\r
262             return loader;\r
263         }\r
264 \r
265         private static CultureInfo Culture {\r
266             get { return null; }\r
267         }\r
268         \r
269 #if !TEXTRES_ONLYGETSTRING\r
270         public static ResourceManager Resources {\r
271             get {\r
272                 return GetLoader().resources;\r
273             }\r
274         }\r
275         \r
276 #endif\r
277         public static string GetString(string name, params object[] args) {\r
278             TextRes sys = GetLoader();\r
279             if (sys == null)\r
280                 return null;\r
281             string res = sys.resources.GetString(name, TextRes.Culture);\r
282 \r
283             if (args != null && args.Length > 0) {\r
284                 for (int i = 0; i < args.Length; i ++) {\r
285                     String value = args[i] as String;\r
286                     if (value != null && value.Length > 1024) {\r
287                         args[i] = value.Substring(0, 1024 - 3) + "...";\r
288                     }\r
289                 }\r
290                 return String.Format(CultureInfo.CurrentCulture, res, args);\r
291             }\r
292             else {\r
293                 return res;\r
294             }\r
295         }\r
296 \r
297         public static string GetString(string name) {\r
298             TextRes sys = GetLoader();\r
299             if (sys == null)\r
300                 return null;\r
301             return sys.resources.GetString(name, TextRes.Culture);\r
302         }\r
303         \r
304 #if !TEXTRES_ONLYGETSTRING\r
305         public static object GetObject(string name) {\r
306             TextRes sys = GetLoader();\r
307             if (sys == null)\r
308                 return null;\r
309             return sys.resources.GetObject(name, TextRes.Culture);\r
310         }\r
311 #endif\r
312     }\r
313 }\r