Пример #1
0
        object IPrimitive.GetValueField(StreamExtractorHandler streamExtractor)
        {
            byte[] bytes      = streamExtractor(length);
            byte   singleByte = bytes[0];

            return(singleByte);
        }
Пример #2
0
        object IConcreteAction.Deserialize(StreamExtractorHandler streamExtractor)
        {
            IPrimitive lenStrPrimitive = PrimitiveFactory.MakePrimitive(typeof(ushort));
            ushort     lenStr          = (ushort)lenStrPrimitive.GetValueField(streamExtractor);

            lenStr *= 2;
            byte[] bytesRepresentString = streamExtractor(lenStr);
            object recordObject         = Encoding.Unicode.GetString(bytesRepresentString);

            return(recordObject);
        }
Пример #3
0
        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);
        }
Пример #4
0
        private int[] RecoveryDimensional(StreamExtractorHandler streamExtractor) //восстановление измерений
        {
            byte rank = RankRecovery(streamExtractor);

            int[]      lengths         = new int[rank];
            IPrimitive lengthPrimitive = PrimitiveFactory.MakePrimitive(typeof(ushort));

            for (int dimension = 0; dimension < rank; dimension++)
            {
                lengths[dimension] = (ushort)lengthPrimitive.GetValueField(streamExtractor);
            }
            return(lengths);
        }
        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);
        }
 object IPrimitive.GetValueField(StreamExtractorHandler streamExtractor)
 {
     byte[] bytes = streamExtractor(length);
     return(BitConverter.ToDouble(bytes, 0));
 }
Пример #7
0
        private byte RankRecovery(StreamExtractorHandler streamExtractor) // восстановление числа измерений
        {
            IPrimitive rankPrimitive = PrimitiveFactory.MakePrimitive(typeof(byte));

            return((byte)rankPrimitive.GetValueField(streamExtractor));
        }
Пример #8
0
 object IConcreteAction.Deserialize(StreamExtractorHandler streamExtractor)
 {
     int[] lengths = RecoveryDimensional(streamExtractor);
     array = ActivateInstance(lengths);
     return(ArraySetElementValue(lengths, streamExtractor));
 }
        object IConcreteAction.Deserialize(StreamExtractorHandler streamExtractor)
        {
            IPrimitive primitive = PrimitiveFactory.MakePrimitive(type);

            return(primitive.GetValueField(streamExtractor));
        }