/// <summary>Sets the <see cref="F:System.Windows.Localization.CommentsProperty" /> attached property to the specified element.</summary> /// <param name="element">A <see cref="T:System.Object" /> that represents the element whose attached property you want to set.</param> /// <param name="comments">A <see cref="T:System.String" /> that specifies the localization comments.</param> // Token: 0x0600075D RID: 1885 RVA: 0x00016F91 File Offset: 0x00015191 public static void SetComments(object element, string comments) { if (element == null) { throw new ArgumentNullException("element"); } LocComments.ParsePropertyComments(comments); Localization.SetValue(element, Localization.CommentsProperty, comments); }
/// <summary>Sets the <see cref="F:System.Windows.Localization.AttributesProperty" /> attached property for the specified element.</summary> /// <param name="element">A <see cref="T:System.Object" /> that represents the element whose attached property you want to set.</param> /// <param name="attributes">A <see cref="T:System.String" /> that specifies the localization attributes.</param> // Token: 0x0600075F RID: 1887 RVA: 0x00016FCF File Offset: 0x000151CF public static void SetAttributes(object element, string attributes) { if (element == null) { throw new ArgumentNullException("element"); } LocComments.ParsePropertyLocalizabilityAttributes(attributes); Localization.SetValue(element, Localization.AttributesProperty, attributes); }
internal override ParserAction LoadNode(XamlNode tokenNode) { switch (tokenNode.TokenType) { case XamlNodeType.DocumentStart: { // A single ParserHooks might be used to parse multiple bamls. // We need to clear the comments list at the begining of each baml. _commentList.Clear(); _currentComment = new LocalizationComment(); return(ParserAction.Normal); } case XamlNodeType.DefAttribute: { XamlDefAttributeNode node = (XamlDefAttributeNode)tokenNode; if (node.Name == XamlReaderHelper.DefinitionUid) { _currentComment.Uid = node.Value; } return(ParserAction.Normal); } case XamlNodeType.Property: { XamlPropertyNode node = (XamlPropertyNode)tokenNode; // When this parer hook is invoked, comments is always output to a seperate file. if (LocComments.IsLocCommentsProperty(node.TypeFullName, node.PropName)) { // try parse the value. Exception will be thrown if not valid. LocComments.ParsePropertyComments(node.Value); _currentComment.Comments = node.Value; return(ParserAction.Skip); // skips outputing this node to baml } if (_directivesToFile == LocalizationDirectivesToLocFile.All && LocComments.IsLocLocalizabilityProperty(node.TypeFullName, node.PropName)) { // try parse the value. Exception will be thrown if not valid. LocComments.ParsePropertyLocalizabilityAttributes(node.Value); _currentComment.Attributes = node.Value; return(ParserAction.Skip); // skips outputing this node to baml } return(ParserAction.Normal); } case XamlNodeType.EndAttributes: { FlushCommentToList(ref _currentComment); return(ParserAction.Normal); } case XamlNodeType.DocumentEnd: { // // When reaching document end, we output all the comments we have collected // so far into a localization comment file. If the parsing was aborted in // MarkupCompilePass1, we would not out the incomplete set of comments because // it will not reach document end. // if (_commentList.Count > 0) { string absoluteOutputPath = _compiler.TargetPath + _compiler.SourceFileInfo.RelativeSourceFilePath + SharedStrings.LocExtension; MemoryStream memStream = new MemoryStream(); // TaskFileService.WriteFile adds BOM for UTF8 Encoding, thus don't add here // when creating XmlTextWriter. using (XmlTextWriter writer = new XmlTextWriter(memStream, new UTF8Encoding(false))) { // output XML for each piece of comment writer.Formatting = Formatting.Indented; writer.WriteStartElement(LocComments.LocResourcesElement); writer.WriteAttributeString(LocComments.LocFileNameAttribute, _compiler.SourceFileInfo.RelativeSourceFilePath); foreach (LocalizationComment comment in _commentList) { writer.WriteStartElement(LocComments.LocCommentsElement); writer.WriteAttributeString(LocComments.LocCommentIDAttribute, comment.Uid); if (comment.Attributes != null) { writer.WriteAttributeString(LocComments.LocLocalizabilityAttribute, comment.Attributes); } if (comment.Comments != null) { writer.WriteAttributeString(LocComments.LocCommentsAttribute, comment.Comments); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.Flush(); _compiler.TaskFileService.WriteFile(memStream.ToArray(), absoluteOutputPath); } } return(ParserAction.Normal); } default: { return(ParserAction.Normal); } } }