internal byte[] StreamRecord(object dataObject) { Type type = dataObject.GetType(); IConcreteAction action = ActionFactory.MakeAction(type); List <byte> resultStream = action.Serialize(dataObject); return(resultStream.ToArray()); }
private Array ArraySetElementValue(int[] lengths, StreamExtractorHandler streamExtractor) //заполнение элементов массива значениями { IConcreteAction action = MakeActionForElementType(); var arrayIndex = new ArrayIterator(lengths); for (int i = 0; i < array.Length; i++) { object elementValue = action.Deserialize(streamExtractor); int[] indices = arrayIndex.GetNext(); array.SetValue(elementValue, indices); } return(array); }
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); } }
object IConcreteAction.Deserialize(StreamExtractorHandler streamExtractor) { object recordObject = Activator.CreateInstance(type); FieldInfo[] fieldInfos = type.GetFields(); foreach (FieldInfo field in fieldInfos) { IConcreteAction action = ActionFactory.MakeAction(field.FieldType); object fieldValue = action.Deserialize(streamExtractor); field.SetValue(recordObject, fieldValue); } return(recordObject); }
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); }
internal object ObjectRecord(Type type) { IConcreteAction action = ActionFactory.MakeAction(type); return(action.Deserialize(StreamExtractor)); }