SmartApp.Sample3.Contracts.Comment.TryGetFromBinary C# (CSharp) Method

TryGetFromBinary() public static method

public static TryGetFromBinary ( byte data ) : Comment
data byte
return Comment
        public static Comment TryGetFromBinary(byte[] data)
        {
            using (var mem = new MemoryStream(data))
            using (var bin = new BinaryReader(mem))
            {
                var retrieved = bin.ReadInt32();
                if (retrieved != Signature)
                    return null;

                return new Comment()
                    {
                        Id = bin.ReadInt64(),
                        PostId = bin.ReadInt64(),
                        UserId = bin.ReadInt64(),
                        CreationDate = DateTime.FromBinary(bin.ReadInt64()),
                        Text = bin.ReadString(),
                        Score = bin.ReadInt32()
                    };
            }
        }