// Token: 0x06006E2E RID: 28206 RVA: 0x001FB950 File Offset: 0x001F9B50 private InternalBamlLocalizabilityResolver.ElementComments LookupCommentForElement(BamlStartElementNode node) { if (node.Uid == null) { return(new InternalBamlLocalizabilityResolver.ElementComments()); } for (int i = 0; i < this._comments.Length; i++) { if (this._comments[i] != null && this._comments[i].ElementId == node.Uid) { return(this._comments[i]); } } InternalBamlLocalizabilityResolver.ElementComments elementComments = new InternalBamlLocalizabilityResolver.ElementComments(); elementComments.ElementId = node.Uid; if (this._commentsDocument != null) { XmlElement xmlElement = InternalBamlLocalizabilityResolver.FindElementByID(this._commentsDocument, node.Uid); if (xmlElement != null) { string attribute = xmlElement.GetAttribute("Attributes"); this.SetLocalizationAttributes(node, elementComments, attribute); attribute = xmlElement.GetAttribute("Comments"); this.SetLocalizationComments(node, elementComments, attribute); } } if (node.Children != null) { int num = 0; while (num < node.Children.Count && (elementComments.LocalizationComments.Length == 0 || elementComments.LocalizationAttributes.Length == 0)) { BamlTreeNode bamlTreeNode = node.Children[num]; if (bamlTreeNode.NodeType == BamlNodeType.Property) { BamlPropertyNode bamlPropertyNode = (BamlPropertyNode)bamlTreeNode; if (LocComments.IsLocCommentsProperty(bamlPropertyNode.OwnerTypeFullName, bamlPropertyNode.PropertyName) && elementComments.LocalizationComments.Length == 0) { this.SetLocalizationComments(node, elementComments, bamlPropertyNode.Value); } else if (LocComments.IsLocLocalizabilityProperty(bamlPropertyNode.OwnerTypeFullName, bamlPropertyNode.PropertyName) && elementComments.LocalizationAttributes.Length == 0) { this.SetLocalizationAttributes(node, elementComments, bamlPropertyNode.Value); } } num++; } } this._comments[this._commentsIndex] = elementComments; this._commentsIndex = (this._commentsIndex + 1) % this._comments.Length; return(elementComments); }
internal override void Serialize(BamlWriter writer) { // skip seralizing Localization.Comments and Localization.Attributes properties if (!LocComments.IsLocCommentsProperty(_ownerTypeFullName, _propertyName) && !LocComments.IsLocLocalizabilityProperty(_ownerTypeFullName, _propertyName)) { writer.WriteProperty( _assemblyName, _ownerTypeFullName, _propertyName, _value, _attributeUsage ); } }
/// <summary> /// build a localizable resource from a baml tree node /// </summary> internal BamlLocalizableResource BuildFromNode(BamlLocalizableResourceKey key, BamlTreeNode node) { if (node.Formatted) { // the content of the node has been formatted to be part of // parents' content, so no need to create a seperate entry for the // element return(null); } BamlLocalizableResource resource = null; LocalizabilityAttribute localizability = null; string formattingTag; // // variable controling what comments gets applied // BamlStartElementNode commentNode = null; // node containing comment string commentTargetName = null; // the target of the comment, e.g. $Content, FontSize, etc. // // step 1: Get the localizability attribute from the source files // switch (node.NodeType) { case BamlNodeType.StartElement: { // For element commentNode = (BamlStartElementNode)node; GetLocalizabilityForElementNode(commentNode, out localizability, out formattingTag); commentTargetName = BamlConst.ContentSuffix; break; } case BamlNodeType.LiteralContent: { // For literal content, get the attribute from parent element GetLocalizabilityForElementNode((BamlStartElementNode)node.Parent, out localizability, out formattingTag); commentNode = (BamlStartElementNode)node.Parent; commentTargetName = BamlConst.ContentSuffix; break; } case BamlNodeType.Property: { BamlStartComplexPropertyNode propertyNode = (BamlStartComplexPropertyNode)node; if (LocComments.IsLocCommentsProperty(propertyNode.OwnerTypeFullName, propertyNode.PropertyName) || LocComments.IsLocLocalizabilityProperty(propertyNode.OwnerTypeFullName, propertyNode.PropertyName) ) { // skip Localization.Comments and Localization.Attributes properties. They aren't localizable return(null); } // For property GetLocalizabilityForPropertyNode(propertyNode, out localizability); commentTargetName = propertyNode.PropertyName; commentNode = (BamlStartElementNode)node.Parent; break; } default: { Invariant.Assert(false); // no localizable resource for such node break; } } // // Step 2: Find out the inheritance value // // The node participates in localizability inheritance // let's fill things in localizability = CombineAndPropagateInheritanceValues( node as ILocalizabilityInheritable, localizability ); // // Step 3: We finalized the localizability values. We now apply. // string content = null; if (localizability.Category != LocalizationCategory.NeverLocalize && localizability.Category != LocalizationCategory.Ignore && TryGetContent(key, node, out content)) { // we only create one if it is localizable resource = new BamlLocalizableResource(); resource.Readable = (localizability.Readability == Readability.Readable); resource.Modifiable = (localizability.Modifiability == Modifiability.Modifiable); resource.Category = localizability.Category; // continue to fill in content. resource.Content = content; resource.Comments = _resolver.GetStringComment(commentNode, commentTargetName); } // return the resource return(resource); }
private ElementComments LookupCommentForElement(BamlStartElementNode node) { Debug.Assert(node.NodeType == BamlNodeType.StartElement); if (node.Uid == null) { return(new ElementComments()); // return empty comments for null Uid } for (int i = 0; i < _comments.Length; i++) { if (_comments[i] != null && _comments[i].ElementId == node.Uid) { return(_comments[i]); } } ElementComments comment = new ElementComments(); comment.ElementId = node.Uid; if (_commentsDocument != null) { // select the xmlNode containing the comments XmlElement element = FindElementByID(_commentsDocument, node.Uid); if (element != null) { // parse the comments string locAttribute = element.GetAttribute(LocComments.LocLocalizabilityAttribute); SetLocalizationAttributes(node, comment, locAttribute); locAttribute = element.GetAttribute(LocComments.LocCommentsAttribute); SetLocalizationComments(node, comment, locAttribute); } } if (node.Children != null) { // // The baml itself might contain comments too // Grab the missing comments from Baml if there is any. // for (int i = 0; i < node.Children.Count && (comment.LocalizationComments.Length == 0 || comment.LocalizationAttributes.Length == 0); i++) { BamlTreeNode child = (BamlTreeNode)node.Children[i]; if (child.NodeType == BamlNodeType.Property) { BamlPropertyNode propertyNode = (BamlPropertyNode)child; if (LocComments.IsLocCommentsProperty(propertyNode.OwnerTypeFullName, propertyNode.PropertyName) && comment.LocalizationComments.Length == 0) { // grab comments from Baml SetLocalizationComments(node, comment, propertyNode.Value); } else if (LocComments.IsLocLocalizabilityProperty(propertyNode.OwnerTypeFullName, propertyNode.PropertyName) && comment.LocalizationAttributes.Length == 0) { // grab comments from Baml SetLocalizationAttributes(node, comment, propertyNode.Value); } } } } // cached it _comments[_commentsIndex] = comment; _commentsIndex = (_commentsIndex + 1) % _comments.Length; return(comment); }
// Token: 0x06006EB5 RID: 28341 RVA: 0x001FCDA0 File Offset: 0x001FAFA0 internal BamlLocalizableResource BuildFromNode(BamlLocalizableResourceKey key, BamlTreeNode node) { if (node.Formatted) { return(null); } BamlLocalizableResource bamlLocalizableResource = null; LocalizabilityAttribute localizabilityAttribute = null; BamlStartElementNode node2 = null; string localName = null; BamlNodeType nodeType = node.NodeType; if (nodeType != BamlNodeType.StartElement) { if (nodeType != BamlNodeType.Property) { if (nodeType != BamlNodeType.LiteralContent) { Invariant.Assert(false); } else { string text; this.GetLocalizabilityForElementNode((BamlStartElementNode)node.Parent, out localizabilityAttribute, out text); node2 = (BamlStartElementNode)node.Parent; localName = "$Content"; } } else { BamlStartComplexPropertyNode bamlStartComplexPropertyNode = (BamlStartComplexPropertyNode)node; if (LocComments.IsLocCommentsProperty(bamlStartComplexPropertyNode.OwnerTypeFullName, bamlStartComplexPropertyNode.PropertyName) || LocComments.IsLocLocalizabilityProperty(bamlStartComplexPropertyNode.OwnerTypeFullName, bamlStartComplexPropertyNode.PropertyName)) { return(null); } this.GetLocalizabilityForPropertyNode(bamlStartComplexPropertyNode, out localizabilityAttribute); localName = bamlStartComplexPropertyNode.PropertyName; node2 = (BamlStartElementNode)node.Parent; } } else { node2 = (BamlStartElementNode)node; string text; this.GetLocalizabilityForElementNode(node2, out localizabilityAttribute, out text); localName = "$Content"; } localizabilityAttribute = this.CombineAndPropagateInheritanceValues(node as ILocalizabilityInheritable, localizabilityAttribute); string content = null; if (localizabilityAttribute.Category != LocalizationCategory.NeverLocalize && localizabilityAttribute.Category != LocalizationCategory.Ignore && this.TryGetContent(key, node, out content)) { bamlLocalizableResource = new BamlLocalizableResource(); bamlLocalizableResource.Readable = (localizabilityAttribute.Readability == Readability.Readable); bamlLocalizableResource.Modifiable = (localizabilityAttribute.Modifiability == Modifiability.Modifiable); bamlLocalizableResource.Category = localizabilityAttribute.Category; bamlLocalizableResource.Content = content; bamlLocalizableResource.Comments = this._resolver.GetStringComment(node2, localName); } return(bamlLocalizableResource); }
// Token: 0x06006E82 RID: 28290 RVA: 0x001FC180 File Offset: 0x001FA380 internal override void Serialize(BamlWriter writer) { if (!LocComments.IsLocCommentsProperty(this._ownerTypeFullName, this._propertyName) && !LocComments.IsLocLocalizabilityProperty(this._ownerTypeFullName, this._propertyName)) { writer.WriteProperty(this._assemblyName, this._ownerTypeFullName, this._propertyName, this._value, this._attributeUsage); } }