Beispiel #1
0
        internal byte[] StreamRecord(object dataObject)
        {
            Type type = dataObject.GetType();

            IConcreteAction action       = ActionFactory.MakeAction(type);
            List <byte>     resultStream = action.Serialize(dataObject);

            return(resultStream.ToArray());
        }
        private void DeserealizeElement(int[] lengths)
        {
            IConcreteAction action         = MakeActionForElementType();
            var             arrayIndexator = new ArrayIterator(lengths);

            for (int i = 0; i < array.Length; i++)
            {
                int[]  index     = arrayIndexator.GetNext();
                object arrayItem = array.GetValue(index);

                List <byte> data = action.Serialize(arrayItem);
                resultStream.AddRange(data);
            }
        }
        List <byte> IConcreteAction.Serialize(object dataObject)
        {
            var resultStream = new List <byte>();

            FieldInfo[] fieldInfos = type.GetFields();
            foreach (FieldInfo field in fieldInfos)
            {
                object          fieldObject    = field.GetValue(dataObject);
                IConcreteAction action         = ActionFactory.MakeAction(field.FieldType);
                List <byte>     representBytes = action.Serialize(fieldObject);
                resultStream.AddRange(representBytes);
            }

            return(resultStream);
        }