private static SecurityElement ObjectToXml(string tag, Object obj) { BCLDebug.Assert(obj != null, "You need to pass in an object"); ISecurityEncodable encodableObj = obj as ISecurityEncodable; SecurityElement elObject; if (encodableObj != null) { elObject = encodableObj.ToXml(); if (!elObject.Tag.Equals(tag)) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } } MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); byte[] array = stream.ToArray(); elObject = new SecurityElement(tag); elObject.AddAttribute("Data", Hex.EncodeHexString(array)); return(elObject); }
private static SecurityElement ObjectToXml(string tag, object obj) { ISecurityEncodable encodable = obj as ISecurityEncodable; if ((encodable != null) && !encodable.ToXml().Tag.Equals(tag)) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } MemoryStream serializationStream = new MemoryStream(); new BinaryFormatter().Serialize(serializationStream, obj); byte[] sArray = serializationStream.ToArray(); SecurityElement element = new SecurityElement(tag); element.AddAttribute("Data", Hex.EncodeHexString(sArray)); return(element); }
private static SecurityElement ObjectToXml(string tag, object obj) { ISecurityEncodable securityEncodable = obj as ISecurityEncodable; if (securityEncodable != null && !securityEncodable.ToXml().Tag.Equals(tag)) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } MemoryStream memoryStream = new MemoryStream(); new BinaryFormatter().Serialize((Stream)memoryStream, obj); byte[] array = memoryStream.ToArray(); SecurityElement securityElement = new SecurityElement(tag); string name = "Data"; string str = Hex.EncodeHexString(array); securityElement.AddAttribute(name, str); return(securityElement); }
// Token: 0x06002883 RID: 10371 RVA: 0x00095330 File Offset: 0x00093530 private static SecurityElement ObjectToXml(string tag, object obj) { ISecurityEncodable securityEncodable = obj as ISecurityEncodable; SecurityElement securityElement; if (securityEncodable != null) { securityElement = securityEncodable.ToXml(); if (!securityElement.Tag.Equals(tag)) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); } } MemoryStream memoryStream = new MemoryStream(); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, obj); byte[] sArray = memoryStream.ToArray(); securityElement = new SecurityElement(tag); securityElement.AddAttribute("Data", Hex.EncodeHexString(sArray)); return(securityElement); }