/// <summary>
        /// Serialisiert das Objekt
        /// </summary>
        /// <param name="objectToSerialize"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static byte[] Serialize(this System.Object objectToSerialize, ByteArrayExtensions.DataFormatType format)
        {
            MemoryStream ms = new MemoryStream();

            //try {
            switch (format)
            {
            case ByteArrayExtensions.DataFormatType.Binary:
                BinaryFormatter bFormatter = new BinaryFormatter();
                bFormatter.Serialize(ms, objectToSerialize);
                break;

            case ByteArrayExtensions.DataFormatType.Soap:
                throw new NotImplementedException();

            /*SoapFormatter sFormatter = new SoapFormatter();
             * sFormatter.Serialize(ms, objectToSerialize);
             * break;*/
            case ByteArrayExtensions.DataFormatType.XML:
                XmlSerializer xFormatter = new XmlSerializer(objectToSerialize.GetType());
                xFormatter.Serialize(ms, objectToSerialize);
                break;
            }
            //} catch (Exception ex) { }
            return(ms.ToArray());
        }
Example #2
0
 public DB(string file, ByteArrayExtensions.DataFormatType format)
 {
     this.FormatType = format;
     this.initDB(file);
 }
Example #3
0
 public DB(string file)
 {
     this.FormatType = DefaultFormatType;
     this.initDB(file);
 }