/// <summary> /// Return the localizability of an element to the BamlLocalizer /// </summary> public override ElementLocalizability GetElementLocalizability( string assembly, string className ) { ElementLocalizability loc = new ElementLocalizability(); Type type = GetType(assembly, className); if (type != null) { // We found the type, now try to get the localizability attribute from the type loc.Attribute = GetLocalizabilityFromType(type); } // fill in the formatting tag int index = Array.IndexOf(FormattedElements, className); if (index >= 0) { loc.FormattingTag = FormattingTag[index]; } return(loc); }
private void GetLocalizabilityForElementNode( BamlStartElementNode node, out LocalizabilityAttribute localizability, out string formattingTag ) { localizability = null; formattingTag = null; // get the names we need string assemblyName = node.AssemblyName; string className = node.TypeFullName; // query the resolver ElementLocalizability result = _resolver.GetElementLocalizability( assemblyName, className ); LocalizabilityGroup comment = null; comment = _resolver.GetLocalizabilityComment(node, BamlConst.ContentSuffix); if (comment != null) { localizability = comment.Override(result.Attribute); } else { localizability = result.Attribute; } formattingTag = result.FormattingTag; }
public override string ResolveFormattingTagToClass(string formattingTag) { // go through the cache to find the mapping foreach (KeyValuePair <string, ElementLocalizability> pair in _classAttributeTable) { if (pair.Value.FormattingTag == formattingTag) { return(pair.Key); } } string className = null; if (_externalResolver != null) { // it is a formatting tag not resolved before. need to ask for client's help className = _externalResolver.ResolveFormattingTagToClass(formattingTag); if (!string.IsNullOrEmpty(className)) { // cache the result if (_classAttributeTable.ContainsKey(className)) { _classAttributeTable[className].FormattingTag = formattingTag; } else { _classAttributeTable[className] = new ElementLocalizability(formattingTag, null); } } } return(className); }
//-------------------------------------- // BamlLocalizabilityResolver interface //-------------------------------------- public override ElementLocalizability GetElementLocalizability(string assembly, string className) { if (_externalResolver == null || assembly == null || assembly.Length == 0 || className == null || className.Length == 0) { // return the default value return(new ElementLocalizability( null, DefaultAttribute )); } if (_classAttributeTable.ContainsKey(className)) { // return cached value return(_classAttributeTable[className]); } else { ElementLocalizability loc = _externalResolver.GetElementLocalizability(assembly, className); if (loc == null || loc.Attribute == null) { loc = new ElementLocalizability( null, DefaultAttribute ); } _classAttributeTable[className] = loc; return(loc); } }
// Token: 0x06006EB8 RID: 28344 RVA: 0x001FD1C4 File Offset: 0x001FB3C4 private void GetLocalizabilityForElementNode(BamlStartElementNode node, out LocalizabilityAttribute localizability, out string formattingTag) { localizability = null; formattingTag = null; string assemblyName = node.AssemblyName; string typeFullName = node.TypeFullName; ElementLocalizability elementLocalizability = this._resolver.GetElementLocalizability(assemblyName, typeFullName); LocalizabilityGroup localizabilityComment = this._resolver.GetLocalizabilityComment(node, "$Content"); if (localizabilityComment != null) { localizability = localizabilityComment.Override(elementLocalizability.Attribute); } else { localizability = elementLocalizability.Attribute; } formattingTag = elementLocalizability.FormattingTag; }
// Token: 0x06006E29 RID: 28201 RVA: 0x001FB6E8 File Offset: 0x001F98E8 public override ElementLocalizability GetElementLocalizability(string assembly, string className) { if (this._externalResolver == null || assembly == null || assembly.Length == 0 || className == null || className.Length == 0) { return(new ElementLocalizability(null, this.DefaultAttribute)); } if (this._classAttributeTable.ContainsKey(className)) { return(this._classAttributeTable[className]); } ElementLocalizability elementLocalizability = this._externalResolver.GetElementLocalizability(assembly, className); if (elementLocalizability == null || elementLocalizability.Attribute == null) { elementLocalizability = new ElementLocalizability(null, this.DefaultAttribute); } this._classAttributeTable[className] = elementLocalizability; return(elementLocalizability); }