BamlLocalization.LocBamlConst.StringToResourceKey C# (CSharp) Метод

StringToResourceKey() статический приватный Метод

static private StringToResourceKey ( string value ) : System.Windows.Markup.Localizer.BamlLocalizableResourceKey
value string
Результат System.Windows.Markup.Localizer.BamlLocalizableResourceKey
        internal static BamlLocalizableResourceKey StringToResourceKey(string value)
        {
            int nameEnd = value.LastIndexOf(':');
            if (nameEnd < 0)
            {
                throw new ArgumentException(StringLoader.Get("ResourceKeyFormatError"));
            }

            string name  = value.Substring(0, nameEnd);
            int classEnd = value.LastIndexOf('.');

            if (classEnd < 0 || classEnd < nameEnd || classEnd == value.Length)
            {
                throw new ArgumentException(StringLoader.Get("ResourceKeyFormatError"));
            }

            string className = value.Substring(nameEnd + 1, classEnd - nameEnd - 1);
            string propertyName = value.Substring(classEnd + 1);

            return new BamlLocalizableResourceKey(
                name,
                className,
                propertyName
                );
        }

Usage Example

        internal TranslationDictionariesReader(XliffObject xliff)
        {
            // hash key is case insensitive strings
            _table = new Hashtable();

            foreach (File file in xliff.Files)
            {
                string bamlName = file.Original;

                // get the dictionary
                BamlLocalizationDictionary dictionary = this[bamlName];
                if (dictionary == null)
                {
                    // we create one if it is not there yet.
                    dictionary     = new BamlLocalizationDictionary();
                    this[bamlName] = dictionary;
                }

                Body body = file.Body;
                // There should only be one group, but go through any that exist for good measure
                foreach (Group group in body.Groups)
                {
                    foreach (TranslationUnit transUnit in group.TranslationUnits)
                    {
                        string key = transUnit.Id;
                        BamlLocalizableResourceKey resourceKey = LocBamlConst.StringToResourceKey(key);
                        BamlLocalizableResource    resource    = new BamlLocalizableResource();
                        resource.Category = (LocalizationCategory)StringCatConverter.ConvertFrom(transUnit.ResourceType);

                        /*
                         * resource.Readable = (bool)BoolTypeConverter.ConvertFrom(reader.GetColumn(3));
                         * resource.Modifiable = (bool)BoolTypeConverter.ConvertFrom(reader.GetColumn(4));
                         */
                        Note comment = transUnit.Notes.FirstOrDefault(n => n.From == "MultilingualBuild");
                        if (comment != null)
                        {
                            resource.Comments = comment.Text;
                        }
                        resource.Content = transUnit.Target.Content ?? string.Empty;

                        dictionary.Add(resourceKey, resource);
                    }
                }
            }
        }
All Usage Examples Of BamlLocalization.LocBamlConst::StringToResourceKey