Пример #1
0
        public static string CreateTaggedText(
            TaggedType textType,
            string nativeText,
            string context,
            int processId,
            CultureInfo culture,
            string proxyName)
        {
            Validate.ArgumentNotNull(parameter: culture, parameterName: nameof(culture));
            var    flag = true;
            string str;

            switch (textType)
            {
            case TaggedType.Unknown:
                str  = nativeText;
                flag = false;
                break;

            case TaggedType.LocalizableText:
                str = "°<ªLoc>";
                break;

            case TaggedType.ResourceKey:
                str = "°<ªKey>";
                break;

            case TaggedType.FixedText:
                str = "°<ªFix>";
                break;

            default:
                throw new ArgumentException(message: StringResource.Get(id: "InvalidTaggedType", (object)textType));
            }

            if (flag)
            {
                var stringWriter = new StringWriter(formatProvider: CultureInfo.InvariantCulture);
                var xmlWriter    = XmlWriter.Create(output: stringWriter);
                try {
                    xmlWriter.WriteStartElement(localName: "info");
                    xmlWriter.WriteStartAttribute(localName: nameof(context), ns: string.Empty);
                    xmlWriter.WriteString(text: context);
                    xmlWriter.WriteEndAttribute();
                    xmlWriter.WriteStartAttribute(localName: "native", ns: string.Empty);
                    xmlWriter.WriteString(text: nativeText);
                    xmlWriter.WriteEndAttribute();
                    xmlWriter.WriteStartAttribute(localName: "proc_id", ns: string.Empty);
                    xmlWriter.WriteString(text: processId.ToString(provider: CultureInfo.InvariantCulture));
                    xmlWriter.WriteEndAttribute();
                    xmlWriter.WriteStartAttribute(localName: "cultureName", ns: string.Empty);
                    xmlWriter.WriteString(text: culture.DisplayName);
                    xmlWriter.WriteEndAttribute();
                    xmlWriter.WriteStartAttribute(localName: "proxy", ns: string.Empty);
                    xmlWriter.WriteString(text: proxyName);
                    xmlWriter.WriteEndAttribute();
                    xmlWriter.WriteEndElement();
                } finally {
                    xmlWriter.Flush();
                    xmlWriter.Dispose();
                    str += stringWriter.ToString();
                }
            }

            return(str);
        }
Пример #2
0
        public static LocalizationProviderProxy GetInstance(string proxyName)
        {
            LocalizationProviderProxy localizationProviderProxy = null;

            lock (providersLock) {
                if (_registeredProviders.ContainsKey(key: proxyName))
                {
                    _registeredProviders.TryGetValue(key: proxyName, value: out localizationProviderProxy);
                }
                else
                {
                    localizationProviderProxy = proxyName == string.Empty ? new LocalizationProviderProxy(provider: new NonLocalizingProvider(), proxyName: string.Empty) : throw new LocalizationManagerException(message: StringResource.Get(id: "ProviderNotRegistered"));
                }
            }

            return(localizationProviderProxy);
        }