# HG changeset patch # User Kazuma Takeda # Date 1484865823 -32400 # Node ID 07318c10b894f8b01b87f735f7e4cf4dc7de41a4 # Parent 1466993c104caf0398869d81630ac0c14213d128 add getBytes method. diff -r 1466993c104c -r 07318c10b894 Main/jungle-main/core/Attributes.cs --- a/Main/jungle-main/core/Attributes.cs Fri Jan 20 07:08:03 2017 +0900 +++ b/Main/jungle-main/core/Attributes.cs Fri Jan 20 07:43:43 2017 +0900 @@ -2,5 +2,6 @@ public interface Attributes{ object get (string key); T get (string key); + byte[] getBytes(string key); string getString (string key); } diff -r 1466993c104c -r 07318c10b894 Main/jungle-main/transaction/DefaultTreeNodeAttribute.cs --- a/Main/jungle-main/transaction/DefaultTreeNodeAttribute.cs Fri Jan 20 07:08:03 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultTreeNodeAttribute.cs Fri Jan 20 07:43:43 2017 +0900 @@ -3,6 +3,8 @@ using System.Collections.Generic; using System; using System.Text; +using System.Runtime.Serialization.Formatters.Binary; +using System.IO; namespace JungleDB { public class DefaultTreeNodeAttribute : TreeNodeAttributes { @@ -68,6 +70,23 @@ return attrs.get(key).ToString(); } + /// + /// Gets the bytes. + /// need Serializable to class. + /// + /// byte[] + /// Key. + public byte[] getBytes(string key) + { + var formatter = new BinaryFormatter(); + object source = attrs.get (key); + using (var stream = new MemoryStream()) + { + formatter.Serialize(stream, source); + return stream.ToArray(); + } + } + public IEnumerator getKeys(){ return attrs.keys (); }