Пример #1
0
 private static void ZLib(Stream memoryStream, BinaryDataType binaryDataType, double[] values)
 {
     using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, true))
     {
         NoCompression(deflateStream, binaryDataType, values);
     }
 }
Пример #2
0
 internal PeakArray(
     BinaryDataCompressionType compressionType,
     BinaryDataType intensityDataType)
 {
     this.compressionType   = compressionType;
     this.intensityDataType = intensityDataType;
 }
Пример #3
0
 public Peak1DArray(
     [JsonProperty("CompressionType")] BinaryDataCompressionType compressionType,
     [JsonProperty("IntensityDataType")] BinaryDataType intensityDataType,
     [JsonProperty("MzDataType")] BinaryDataType mzDataType)
     : base(compressionType, intensityDataType)
 {
     this.mzDataType = mzDataType;
 }
Пример #4
0
 internal PeakArray(
     int arrayLength,
     BinaryDataCompressionType compressionType,
     BinaryDataType intensityDataType)
 {
     this.compressionType   = compressionType;
     this.intensityDataType = intensityDataType;
     this.arrayLength       = arrayLength;
 }
Пример #5
0
 private static void NoCompression(Stream memoryStream, BinaryDataType binaryDataType, double[] values)
 {
     using (var writer = new BinaryWriter(memoryStream, Encoding.UTF8, true))
     {
         foreach (var v in values)
         {
             WriteValue(writer, binaryDataType, v);
         }
     }
 }
Пример #6
0
 public Peak1DArray(
     [JsonProperty("ArrayLength")] int arrayLength,
     [JsonProperty("CompressionType")] BinaryDataCompressionType compressionType,
     [JsonProperty("IntensityDataType")] BinaryDataType intensityDataType,
     [JsonProperty("MzDataType")] BinaryDataType mzDataType)
     : base(arrayLength, compressionType, intensityDataType)
 {
     this.mzDataType = mzDataType;
     this.peaks      = new Peak1D[arrayLength];
 }
Пример #7
0
            /// <summary>
            /// Resolves the specified data type.
            /// </summary>
            /// <param name="dataType">Data type specification.</param>
            /// <returns>Resolved EDM Type.</returns>
            PrimitiveDataType IPrimitiveDataTypeVisitor <PrimitiveDataType> .Visit(BinaryDataType dataType)
            {
                int?           maxLength = null;
                MaxLengthFacet maxLengthFacet;

                if (dataType.TryGetFacet(out maxLengthFacet))
                {
                    maxLength = maxLengthFacet.Value;
                }

                return(EdmDataTypes.Binary(maxLength));
            }
Пример #8
0
 private TypeInfo CreateBinaryType(BinaryDataType binaryType)
 {
     if (binaryType.Width != null)
     {
         var width = evaluator_.EvaluateNonIndeterminate(binaryType.Width);
         return(new BinaryTypeInfo(width, binaryType.IsFixed));
     }
     else
     {
         return(TypeInfo.Binary);
     }
 }
Пример #9
0
        private BinaryData GetBinaryData(BinaryDataType type)
        {
            var binaryData = this.getBinaryData(type);

            if (!binaryDataToBufferIndex.ContainsKey(binaryData))
            {
                var buffer = CreateInstance <Schema.Buffer>();
                buffer.Uri = binaryData.Name;
                var bufferIndex = buffers.Count;
                buffers.Add(buffer);
                binaryDataToBufferIndex.Add(binaryData, bufferIndex);
            }
            return(binaryData);
        }
Пример #10
0
 public void Process()
 {
     rows    = int.Parse(data[rowsKey]);
     columns = int.Parse(data[columnsKey]);
     if (int.Parse(data[byteOrderKey]) != byteOrderLittleEndian)
     {
         throw new System.ArgumentException(
                   "Unsupported byte order " + byteOrderKey + "! (We currently only support little endian byte order)"
                   );
     }
     dataType = ProcessDataType();
     ProcessMapInfo();
     processingDone = true;
 }
Пример #11
0
        private void WriteBinaryDataArray(double[] values, BinaryDataType binaryDataType, UserDescription pars)
        {
            BinaryDataEncoder encoder = new BinaryDataEncoder(values.Length * 8);
            string            base64  = encoder.EncodeBase64(values, BinaryDataCompressionType.NoCompression, binaryDataType);
            int len = base64.Length;

            writer.WriteStartElement("binaryDataArray");
            WriteXmlAttribute("encodedLength", len.ToString(formatProvider));

            WriteParamGroup(pars);

            writer.WriteStartElement("binary");
            writer.WriteString(base64);
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Пример #12
0
 /// <summary>
 /// Initializes static members of the DataTypes class.
 /// </summary>
 static DataTypes()
 {
     Integer = new IntegerDataType();
     Stream = new StreamDataType();
     String = new StringDataType();
     Boolean = new BooleanDataType();
     FixedPoint = new FixedPointDataType();
     FloatingPoint = new FloatingPointDataType();
     DateTime = new DateTimeDataType();
     Binary = new BinaryDataType();
     Guid = new GuidDataType();
     TimeOfDay = new TimeOfDayDataType();
     ComplexType = new ComplexDataType();
     EntityType = new EntityDataType();
     CollectionType = new CollectionDataType();
     ReferenceType = new ReferenceDataType();
     RowType = new RowDataType();
     EnumType = new EnumDataType();
     Spatial = new SpatialDataType();
 }
Пример #13
0
        private static double ReadValue(BinaryReader reader, BinaryDataType binaryDataType)
        {
            switch (binaryDataType)
            {
            case BinaryDataType.Float32:
                return(decimal.ToDouble(new decimal(reader.ReadSingle())));

            case BinaryDataType.Float64:
                return(reader.ReadDouble());

            case BinaryDataType.Int32:
                return((double)reader.ReadInt32());

            case BinaryDataType.Int64:
                return((double)reader.ReadInt64());

            default:
                throw new NotSupportedException("Data type not supported: " + binaryDataType.ToString());
            }
        }
Пример #14
0
        public static IParamContainer SetBinaryDataType(
            this IParamContainer pc,
            BinaryDataType binaryDataType)
        {
            switch (binaryDataType)
            {
            case BinaryDataType.Float32:
                return(pc.Set32BitFloat());

            case BinaryDataType.Float64:
                return(pc.Set64BitFloat());

            case BinaryDataType.Int32:
                return(pc.Set32BitInteger());

            case BinaryDataType.Int64:
                return(pc.Set64BitInteger());

            default:
                throw new NotSupportedException("Data type not supported: " + binaryDataType.ToString());
            }
        }
Пример #15
0
        private static void WriteValue(BinaryWriter writer, BinaryDataType binaryDataType, double value)
        {
            switch (binaryDataType)
            {
            case BinaryDataType.Float32:
                writer.Write((double)value);
                break;

            case BinaryDataType.Float64:
                writer.Write(value);
                break;

            case BinaryDataType.Int32:
                writer.Write((int)value);
                break;

            case BinaryDataType.Int64:
                writer.Write((long)value);
                break;

            default:
                throw new NotSupportedException("Data type not supported: " + binaryDataType.ToString());
            }
        }
Пример #16
0
 public BinaryDataAttribute(int index, int length = 0, BinaryDataType binaryDataType = BinaryDataType.MetaData)
 {
     Index          = index;
     Length         = length;
     BinaryDataType = binaryDataType;
 }
Пример #17
0
        public string EncodeBase64(double[] values, BinaryDataCompressionType compressionType, BinaryDataType binaryDataType)
        {
            memoryStream.Position = 0;
            switch (compressionType)
            {
            case BinaryDataCompressionType.NoCompression:
                NoCompression(memoryStream, binaryDataType, values);
                break;

            case BinaryDataCompressionType.ZLib:
                ZLib(memoryStream, binaryDataType, values);
                break;

            default:
                throw new NotSupportedException("Compression type not supported: " + compressionType.ToString());
            }
            memoryStream.Position = 0;
            return(Convert.ToBase64String(memoryStream.ToArray()));
        }
Пример #18
0
 public virtual void VisitBinaryDataType(BinaryDataType binaryDataType)
 {
     DefaultVisit(binaryDataType);
 }
        IEdmPrimitiveTypeReference IPrimitiveDataTypeVisitor <IEdmPrimitiveTypeReference> .Visit(BinaryDataType dataType)
        {
            IEdmPrimitiveType typeDefinition = this.GetEdmTypeDefinition(dataType);

            int?maxLength = null;

            if (dataType.HasFacet <MaxLengthFacet>())
            {
                maxLength = dataType.GetFacet <MaxLengthFacet>().Value;
            }

            var typeReference = new EdmBinaryTypeReference(
                typeDefinition,
                dataType.IsNullable,
                false,
                maxLength);

            return(typeReference);
        }