// 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); } }
internal override void Serialize(BamlWriter writer) { writer.WriteEvent( _eventName, _handlerName ); }
internal override void Serialize(BamlWriter writer) { writer.WriteContentProperty( _assemblyName, _typeFullName, _propertyName ); }
internal override void Serialize(BamlWriter writer) { writer.WritePIMapping( _xmlNamespace, _clrNamespace, _assemblyName ); }
internal override void Serialize(BamlWriter writer) { writer.WriteStartComplexProperty( _assemblyName, _ownerTypeFullName, _propertyName ); }
internal override void Serialize(BamlWriter writer) { writer.WriteRoutedEvent( _assemblyName, _ownerTypeFullName, _eventIdName, _handlerName ); }
public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { var module = def as ModuleDefMD; if (module == null) { return; } var wpfResInfo = context.Annotations.Get <Dictionary <string, Dictionary <string, BamlDocument> > >(module, BAMLKey); if (wpfResInfo == null) { return; } foreach (var res in module.Resources.OfType <EmbeddedResource>()) { Dictionary <string, BamlDocument> resInfo; if (!wpfResInfo.TryGetValue(res.Name, out resInfo)) { continue; } var stream = new MemoryStream(); var writer = new ResourceWriter(stream); res.Data.Position = 0; var reader = new ResourceReader(new ImageStream(res.Data)); var enumerator = reader.GetEnumerator(); while (enumerator.MoveNext()) { var name = (string)enumerator.Key; string typeName; byte[] data; reader.GetResourceData(name, out typeName, out data); BamlDocument document; if (resInfo.TryGetValue(name, out document)) { var docStream = new MemoryStream(); docStream.Position = 4; BamlWriter.WriteDocument(document, docStream); docStream.Position = 0; docStream.Write(BitConverter.GetBytes((int)docStream.Length - 4), 0, 4); data = docStream.ToArray(); name = document.DocumentName; } writer.AddResourceData(name, typeName, data); } writer.Generate(); res.Data = MemoryImageStream.Create(stream.ToArray()); } }
public static byte[] ToResourceBytes(BamlDocument document) { using (var targetStream = new MemoryStream()) { BamlWriter.WriteDocument(document, targetStream); targetStream.Position = 0; return(BitConverter.GetBytes((int)targetStream.Length).Concat(targetStream.ToArray()).ToArray()); } }
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 ); } }
private void WriteDocuments(List <BamlDocument> documents) { var indexedDocuments = documents.ToDictionary(x => x.DocumentName); var newResources = new List <EmbeddedResource>(); foreach (var resource in Module.Resources.OfType <EmbeddedResource>()) { using (var stream = new MemoryStream()) { using (var resourceWriter = new ResourceWriter(stream)) { using (var resourceStream = resource.CreateReader().AsStream()) { using (var resourceReader = new ResourceReader(resourceStream)) { var enumerator = resourceReader.GetEnumerator(); while (enumerator.MoveNext()) { var name = (string)enumerator.Key; resourceReader.GetResourceData(name, out var typeName, out var data); if (indexedDocuments.TryGetValue(name, out var document)) { using (var documentStream = new MemoryStream()) { documentStream.Position = 4; BamlWriter.WriteDocument(document, documentStream); documentStream.Position = 0; documentStream.Write(BitConverter.GetBytes((int)documentStream.Length - 4), 0, 4); data = documentStream.ToArray(); } } resourceWriter.AddResourceData(name, typeName, data); } } } resourceWriter.Generate(); newResources.Add(new EmbeddedResource(resource.Name, stream.ToArray(), resource.Attributes)); } } } foreach (var resource in newResources) { var index = Module.Resources.IndexOfEmbeddedResource(resource.Name); Module.Resources[index] = resource; } }
//---------------------------------- // private method //---------------------------------- /// <summary> /// Serialize the tree out to the stream. /// </summary> private void SerializeImp( BamlLocalizer localizer, BamlTree tree, Stream output ) { Debug.Assert(output != null, "The output stream given is null"); Debug.Assert(tree != null && tree.Root != null, "The tree to be serialized is null."); _writer = new BamlWriter(output); _bamlTreeStack = new Stack <BamlTreeNode>(); // intialize the stack. _bamlTreeStack.Push(tree.Root); while (_bamlTreeStack.Count > 0) { BamlTreeNode currentNode = _bamlTreeStack.Pop(); if (!currentNode.Visited) { // Mark this node so that it won't be serialized again. currentNode.Visited = true; currentNode.Serialize(_writer); PushChildrenToStack(currentNode.Children); } else { BamlStartElementNode elementNode = currentNode as BamlStartElementNode; Debug.Assert(elementNode != null); if (elementNode != null) { localizer.RaiseErrorNotifyEvent( new BamlLocalizerErrorNotifyEventArgs( BamlTreeMap.GetKey(elementNode), BamlLocalizerError.DuplicateElement ) ); } } } // do not close stream as we don't own it. }
public void UpdateReference(Identifier old, Identifier @new) { EmbeddedResource res = mod.Resources[resId] as EmbeddedResource; foreach (KeyValuePair <string, BamlDocument> pair in (res as IAnnotationProvider).Annotations["Gbamls"] as Dictionary <string, BamlDocument> ) { Stream dst = new MemoryStream(); BamlWriter.WriteDocument(pair.Value, dst); ((res as IAnnotationProvider).Annotations["Gresources"] as Dictionary <string, object>)[pair.Key] = dst; } MemoryStream newRes = new MemoryStream(); ResourceWriter wtr = new ResourceWriter(newRes); foreach (KeyValuePair <string, object> pair in (res as IAnnotationProvider).Annotations["Gresources"] as Dictionary <string, object> ) { wtr.AddResource(pair.Key, pair.Value); } wtr.Generate(); mod.Resources[resId] = new EmbeddedResource(res.Name, res.Attributes, newRes.ToArray()); }
private EmbeddedResource ReloadResource(EmbeddedResource resource) { ResourceReader reader; try { reader = new ResourceReader(resource.CreateReader().AsStream()); } catch (ArgumentException) { Console.WriteLine("This resource can not be parsed."); return(resource); } MemoryStream m = new MemoryStream(); ResourceWriter writer = new ResourceWriter(m); var e = reader.GetEnumerator(); while (e.MoveNext()) { if (BamlFiles.ContainsKey(e.Key.ToString())) { //MARK:AF 3E 00 00 using var ms = new MemoryStream(); BamlWriter.WriteDocument(BamlFiles[e.Key.ToString()], ms); writer.AddResource(e.Key.ToString(), ms.ToArray()); } else { writer.AddResource(e.Key.ToString(), e.Value); } } //writer.AddResource(e.Key.ToString(), e.Value); writer.Generate(); EmbeddedResource embedded = new EmbeddedResource(resource.Name, m.ToArray()); writer.Close(); return(embedded); }
internal override void Serialize(BamlWriter writer) { writer.WriteEndComplexProperty(); }
// Token: 0x06006E89 RID: 28297 RVA: 0x001FC22F File Offset: 0x001FA42F internal override void Serialize(BamlWriter writer) { writer.WriteLiteralContent(this._literalContent); }
// Token: 0x06006E58 RID: 28248 RVA: 0x001FBE88 File Offset: 0x001FA088 internal override void Serialize(BamlWriter writer) { writer.WriteEndDocument(); }
// Token: 0x06006E70 RID: 28272 RVA: 0x001FC07F File Offset: 0x001FA27F internal override void Serialize(BamlWriter writer) { writer.WriteXmlnsProperty(this._prefix, this._xmlns); }
// Token: 0x06006E8F RID: 28303 RVA: 0x001FC285 File Offset: 0x001FA485 internal override void Serialize(BamlWriter writer) { writer.WriteText(this._content, this._typeConverterAssemblyName, this._typeConverterName); }
internal override void Serialize(BamlWriter writer) { writer.WriteDefAttribute(_name, _value); }
internal override void Serialize(BamlWriter writer) { writer.WriteEndConstructor(); }
internal override void Serialize(BamlWriter writer) { writer.WritePresentationOptionsAttribute(_name, _value); }
internal override void Serialize(BamlWriter writer) { writer.WriteStartElement(_assemblyName, _typeFullName, _isInjected, _useTypeConverter); }
internal override void Serialize(BamlWriter writer) { writer.WriteConnectionId(_connectionId); }
/// <summary> /// Serialize the node through BamlWriter /// </summary> internal abstract void Serialize(BamlWriter writer);