Exemplo n.º 1
0
		public ZOutputStream(System.IO.Stream out_Renamed):base()
		{
			InitBlock();
			this.out_Renamed = out_Renamed;
			z.inflateInit();
			compress = false;
		}
Exemplo n.º 2
0
		public ZOutputStream(System.IO.Stream out_Renamed, int level):base()
		{
			InitBlock();
			this.out_Renamed = out_Renamed;
			z.deflateInit(level);
			compress = true;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="p_Mode"></param>
		/// <param name="p_ImageFullPath">The path to write embedded images files</param>
		/// <param name="p_ImageRelativePath">The path used in the HTML source. If you save the images in the same path of the HTML file you can leave this path empty.</param>
		/// <param name="p_HtmlStream">The stream to write</param>
		public HTML(ExportHTMLMode p_Mode, string p_ImageFullPath , string p_ImageRelativePath, System.IO.Stream p_HtmlStream)
		{
			m_Mode = p_Mode;
			m_Stream = p_HtmlStream;
			m_ImageFullPath = p_ImageFullPath;
			m_ImageRelativePath = p_ImageRelativePath;
		}
Exemplo n.º 4
0
 public ReadableDataStorageOnStream(System.IO.Stream stream, bool ownsStream)
 {
     if (stream == null)
         throw new System.ArgumentNullException(nameof(stream));
     _stream = stream;
     _ownsStream = ownsStream;
 }
 public ProgressStream(System.IO.Stream file)
 {
     this.file = file;
     length = file.Length;
     bytesRead = 0;
     if (ProgressChanged != null) ProgressChanged(this, new ProgressChangedEventArgs(bytesRead, length));
 }
Exemplo n.º 6
0
 /// <summary>
 /// The  constructor.
 /// </summary>
 /// <param name="s">The underlying stream</param>
 /// <param name="mode">To either encrypt or decrypt.</param>
 /// <param name="cipher">The pre-initialized ZipCrypto object.</param>
 public ZipCipherStream(System.IO.Stream s, ZipCrypto cipher, CryptoMode mode)
     : base()
 {
     _cipher = cipher;
     _s = s;
     _mode = mode;
 }
Exemplo n.º 7
0
        public InputStreamSource(System.IO.Stream in_Renamed)
        {
            if (in_Renamed == null)
                throw new System.NullReferenceException("in");

            this.in_Renamed = in_Renamed;
        }
Exemplo n.º 8
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: static void init(boolean ignoreCase, String affix, String... dictionaries) throws java.io.IOException, java.text.ParseException
        internal static void init(bool ignoreCase, string affix, params string[] dictionaries)
        {
            if (dictionaries.Length == 0)
            {
              throw new System.ArgumentException("there must be at least one dictionary");
            }

            System.IO.Stream affixStream = typeof(StemmerTestBase).getResourceAsStream(affix);
            if (affixStream == null)
            {
              throw new FileNotFoundException("file not found: " + affix);
            }

            System.IO.Stream[] dictStreams = new System.IO.Stream[dictionaries.Length];
            for (int i = 0; i < dictionaries.Length; i++)
            {
              dictStreams[i] = typeof(StemmerTestBase).getResourceAsStream(dictionaries[i]);
              if (dictStreams[i] == null)
              {
            throw new FileNotFoundException("file not found: " + dictStreams[i]);
              }
            }

            try
            {
              Dictionary dictionary = new Dictionary(affixStream, Arrays.asList(dictStreams), ignoreCase);
              stemmer = new Stemmer(dictionary);
            }
            finally
            {
              IOUtils.closeWhileHandlingException(affixStream);
              IOUtils.closeWhileHandlingException(dictStreams);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="stream">The underlying stream</param>
 /// <param name="length">The length of the stream to slurp</param>
 public CrcCalculatorStream(System.IO.Stream stream, Int64 length)
     : base()
 {
     _InnerStream = stream;
     _Crc32 = new CRC32();
     _length = length;
 }
Exemplo n.º 10
0
 public OpenedFile(String path)
 {
     baseStream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
     filePath = path;
     overlay = new Dictionary<Int64, byte[]>();
     fileLength = baseStream.Length;
 }
Exemplo n.º 11
0
 public BackupReader(string path)
 {
         System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
         fs.ReadByte();
         inputStream = fs;
         inputStream.Seek(0, System.IO.SeekOrigin.Begin);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Adds a file to the archive
 /// </summary>
 /// <param name="entry">
 /// The backup metadata for the file
 /// </param>
 /// <param name="stream">
 /// The file stream to add to the archive
 /// </param>
 public void Backup(Backup.Entry entry, Stream stream)
 {
     // if we are not currently uploading a vault archive,
      // then attach a new uploader and create a blob for it
      if (this.uploader == null)
      {
     this.uploader = new GlacierUploader(
        this.archive.Glacier,
        this.archive.Vault
     );
     this.archive.BackupIndex.InsertBlob(
        new Backup.Blob()
        {
           Name = this.uploader.UploadID
        }
     );
      }
      // fetch the upload blob and sync it with the uploader's offset
      var blob = this.archive.BackupIndex.LookupBlob(this.uploader.UploadID);
      if (blob.Length != this.uploader.Length)
     blob.Length = this.uploader.Resync(blob.Length);
      // upload the incoming stream and update the backup entry
      var offset = this.uploader.Length;
      var length = this.uploader.Upload(stream);
      entry.Blob = blob;
      entry.Offset = offset;
      entry.Length = length;
 }
Exemplo n.º 13
0
 public Aleret()
 {
     strm = TestScriptCS.Properties.Resources.piri;
     wmp = new System.Media.SoundPlayer(strm);
     Interval = 500;
     this.Tick += new EventHandler(this.Bombat_Tick);
 }
Exemplo n.º 14
0
 public SignatureReadingStream(System.IO.Stream stream, System.Security.Cryptography.RSACryptoServiceProvider key)
 {
     if (!VerifySignature(stream, key))
         throw new System.IO.InvalidDataException("Unable to verify signature");
     m_stream = stream;
     this.Position = 0;
 }
Exemplo n.º 15
0
 public void Init(System.IO.Stream stream) {
     m_Stream = stream;
     m_ProcessedSize = 0;
     m_Limit = 0;
     m_Pos = 0;
     m_StreamWasExhausted = false;
 }
Exemplo n.º 16
0
		public BufferFile(System.IO.Stream fromfile, int buffersize, long seekStart)
		{
			this.seekStart = seekStart;
			this.fromfile = fromfile;
			this.buffersize = buffersize;
			this.headersize = HEADERPREFIX.Length + INTSTORAGE + 1; // +version byte+4 bytes for buffersize
			this.sanityCheck();
		}
Exemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgressStream"/> class from
        /// the specified <see cref="Stream"/> and <see cref="IProgress{T}"/> handler.
        /// </summary>
        /// <param name="underlyingStream">The stream to wrap.</param>
        /// <param name="progress">The handler to report progress updates to.</param>
        /// <param name="ownsStream">
        /// <para><see langword="true"/> if this object owns the wrapped stream, and should dispose
        /// of it when this instance is closed or disposed.</para>
        /// <para>-or-</para>
        /// <para><see langword="false"/> if this object should not dispose of the wrapped stream.</para>
        /// <para>The default value is <see langword="true"/>.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="underlyingStream"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="progress"/> is <see langword="null"/>.</para>
        /// </exception>
        public ProgressStream(Stream underlyingStream, IProgress<long> progress, bool ownsStream)
            : base(underlyingStream, ownsStream)
        {
            if (progress == null)
                throw new ArgumentNullException("progress");

            _progress = progress;
        }
Exemplo n.º 18
0
		/// <summary> Sets the underlying output stream to which messages are written. </summary>
		public virtual void  setOutputStream(System.IO.Stream out_Renamed)
		{
			lock (this)
			{
				myOutputStream = out_Renamed;
				myWriter = new System.IO.StreamWriter(getWriter(out_Renamed).BaseStream, getWriter(out_Renamed).Encoding);
			}
		}
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DelegatingStream"/> class from the specified
        /// <see cref="Stream"/>.
        /// </summary>
        /// <param name="underlyingStream">The stream to wrap.</param>
        /// <param name="ownsStream">
        /// <para><see langword="true"/> if this object owns the wrapped stream, and should dispose
        /// of it when this instance is closed or disposed.</para>
        /// <para>-or-</para>
        /// <para><see langword="false"/> if this object should not dispose of the wrapped stream.</para>
        /// <para>The default value is <see langword="true"/>.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="underlyingStream"/> is <see langword="null"/>.
        /// </exception>
        public DelegatingStream(Stream underlyingStream, bool ownsStream)
        {
            if (underlyingStream == null)
                throw new ArgumentNullException("underlyingStream");

            _underlyingStream = underlyingStream;
            _ownsStream = ownsStream;
        }
		/*
		* 
		*/
		public virtual void  openSocket()
		{
			socket = new System.Net.Sockets.TcpClient(host, port);
			socket.LingerState = new System.Net.Sockets.LingerOption(true, 1000);
			
			os = socket.GetStream();
			is_Renamed = socket.GetStream();
		}
 public void Dispose()
 {
     if (FileByteStream != null)
     {
         FileByteStream.Close();
         FileByteStream = null;
     }
 }
        /// <summary>
        /// Constructs a new <c>JavaInputStreamAdapter</c> instance
        /// with the given stream.
        /// </summary>
        /// <param name="stream">The stream delegate.</param>
        public JavaInputStreamAdapter(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            m_stream = stream;
        }
Exemplo n.º 23
0
        private RiffChunkHeader riff_header; // header for whole file

        #endregion Fields

        #region Constructors

        /// <summary> Dummy Constructor
        /// </summary>
        public RiffFile()
        {
            file = null;
            fmode = RFM_UNKNOWN;
            riff_header = new RiffChunkHeader(this);

            riff_header.ckID = FourCC("RIFF");
            riff_header.ckSize = 0;
        }
Exemplo n.º 24
0
 public TCDLE30(string devName, System.IO.Stream stream)
 {
     this.m_devName = devName;
     this.stream=stream;
     SendTaskThread = new System.Threading.Thread(SendTask);
     ReceiveTaskThread = new System.Threading.Thread(ReceiveTask);
     SendTaskThread.Start();
     ReceiveTaskThread.Start();
 }
Exemplo n.º 25
0
 protected override void Dispose(bool disposing)
 {
     if (!this.IsDisposed) {
         if (disposing && _ownsStream)
             _stream.Dispose();
         _stream = null;
     }
     base.Dispose(disposing);
 }
Exemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the StreamProxy class.
 /// </summary>
 /// <param name="wrapperScope">The wrapper scope.</param>
 /// <param name="underlyingImplementation">The underlying implementation of the proxy.</param>
 public StreamProxy(IWrapperScope wrapperScope, System.IO.Stream underlyingImplementation)
     : base()
 {
     ExceptionUtilities.CheckArgumentNotNull(wrapperScope, "wrapperScope");
     ExceptionUtilities.CheckArgumentNotNull(underlyingImplementation, "underlyingImplementation");
     
     this.Scope = wrapperScope;
     this.underlyingImplementation = underlyingImplementation;
 }
Exemplo n.º 27
0
 public void Dispose()
 {
     // close stream when the contract instance is disposed. this ensures that stream is closed when file download is complete, since download procedure is handled by the client and the stream must be closed on server.
     if (FileByteStream != null)
     {
         FileByteStream.Close();
         FileByteStream = null;
     }
 }
Exemplo n.º 28
0
 public void Init(System.IO.Stream stream)
 {
     _stream = stream;
     _bufferOffset = 0;
     _pos = 0;
     _streamPos = 0;
     _streamEndWasReached = false;
     ReadBlock();
 }
Exemplo n.º 29
0
 public SchemaTokenCreator(System.IO.Stream instream)
 {
     Initialise();
     if (instream == null)
     {
         throw new System.NullReferenceException();
     }
     input = instream;
 }
Exemplo n.º 30
0
 public void Init(System.IO.Stream stream, bool solid) {
     ReleaseStream();
     _stream = stream;
     if(!solid) {
         _streamPos = 0;
         _pos = 0;
         TrainSize = 0;
     }
 }
Exemplo n.º 31
0
 public BackupWriter(string path)
 {
     outputStream = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write);
 }
Exemplo n.º 32
0
        public override DecodedObject <object> decodeBitString(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Bitstring, elementInfo))
            {
                return(null);
            }
            DecodedObject <int> len = decodeLength(stream);
            int trailBitCnt         = stream.ReadByte();

            CoderUtils.checkConstraints(len.Value * 8 - trailBitCnt, elementInfo);
            byte[] byteBuf = new byte[len.Value - 1];
            stream.Read(byteBuf, 0, byteBuf.Length);
            return(new DecodedObject <object>(new BitString(byteBuf, trailBitCnt), len.Value + len.Size));
        }
Exemplo n.º 33
0
 public static T Deserialize <T>(System.IO.Stream strm)
 {
     return(ServiceStack.Text.JsonSerializer.DeserializeFromStream <T>(strm));
 }
Exemplo n.º 34
0
 public void Write(System.IO.Stream stream)
 {
     using (Writer writer = new Writer(stream))
         this.Write(writer);
 }
Exemplo n.º 35
0
        public override DecodedObject <object> decodeBoolean(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Boolean, elementInfo))
            {
                return(null);
            }
            DecodedObject <object> result = decodeIntegerValue(stream);
            int val = (int)result.Value;

            if (val != 0)
            {
                result.Value = true;
            }
            else
            {
                result.Value = false;
            }
            return(result);
        }
Exemplo n.º 36
0
        private void bgWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (System.IO.File.Exists(path))
            {
                return;
            }

            string sUrlToDnldFile;

            sUrlToDnldFile = "https://www.pc1.hr/pcpos/update/msgothic.zip";

            try
            {
                Uri    url           = new Uri(sUrlToDnldFile);
                string sFileSavePath = "";
                string sFileName     = System.IO.Path.GetFileName(url.LocalPath);

                sFileSavePath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\msgothic.ttc";

                System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);

                System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();

                response.Close();

                // gets the size of the file in bytes

                long iSize = response.ContentLength;

                // keeps track of the total bytes downloaded so we can update the progress bar

                long iRunningByteTotal = 0;

                System.Net.WebClient client = new System.Net.WebClient();

                System.IO.Stream strRemote = client.OpenRead(url);

                System.IO.FileStream strLocal = new System.IO.FileStream(sFileSavePath,
                                                                         System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None);

                int iByteSize = 0;

                byte[] byteBuffer = new byte[1024];

                while ((iByteSize = strRemote.Read(byteBuffer, 0, byteBuffer.Length)) > 0)
                {
                    // write the bytes to the file system at the file path specified

                    strLocal.Write(byteBuffer, 0, iByteSize);

                    iRunningByteTotal += iByteSize;

                    // calculate the progress out of a base "100"

                    double dIndex = iRunningByteTotal;

                    double dTotal = iSize;

                    double dProgressPercentage = (dIndex / dTotal);

                    int iProgressPercentage = (int)(dProgressPercentage * 100);

                    // update the progress bar

                    bgWorker1.ReportProgress(iProgressPercentage);
                }

                strRemote.Close();
                strLocal.Flush();
                strLocal.Close();

                System.IO.File.Copy(sFileSavePath, path, true);

                MessageBox.Show("Datoteka uspješno skinuta!", "");
                status = true;
            }
            catch (Exception exM)
            {
                //Show if any error Occured

                MessageBox.Show("Pokušaj skidanja datoteke s Interneta nije uspio.\n\n" +
                                exM.Message, "Upozorenje!");
                status = false;
            }
        }
 public object ReadObject(System.IO.Stream stream)
 {
     return(default(object));
 }
Exemplo n.º 38
0
        private void MenuItemLoadScript_Click(object sender, EventArgs e)
        {
            System.IO.Stream stream          = null;
            OpenFileDialog   openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = @"c:\";
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((stream = openFileDialog1.OpenFile()) != null)
                    {
                        System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
                        string        line = "";
                        List <string> list = new List <string>();

                        // empty richTextBox1
                        richTextBox1.Text = "";

                        // get the first line
                        line = streamReader.ReadLine();

                        // process the line
                        while (line != null && line.Length > 0)
                        {
                            // add the line
                            list.Add(line);

                            // get the next line
                            line = streamReader.ReadLine();
                        }

                        if (list.Count > 0)
                        {
                            // load the arguments
                            string[] args = new string[list.Count];
                            for (int i = 0; i < list.Count; i++)
                            {
                                args[i] = list[i];
                            }

                            // run the script and save the output
                            VDeskTool.CVDT program = new VDeskTool.CVDT();
                            richTextBox1.Text = program.VDTRun(args);

                            // display the form with the output
                            this.WindowState = FormWindowState.Normal;
                            Show();
                        }
                        else
                        {
                            // something is wrong, show them the help text
                            MenuItemHelp_Click(sender, e);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string text    = "There was a problem opening or running the script. Original error:\n" + ex.Message;
                    string caption = "You're exceptional!";

                    MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 39
0
 public Image(System.IO.Stream stream) : this()
 {
     LoadFromStream(stream);
 }
Exemplo n.º 40
0
 public static JSONNode LoadFromCompressedStream(System.IO.Stream aData)
 {
     throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON");
 }
Exemplo n.º 41
0
 public CustomModelAddition(System.IO.Stream stream, uint refStringStart, EndianUtils.Endianness endian)
 {
     Str = stream.ReadAsciiNulltermFromLocationAndReset(stream.ReadUInt32().FromEndian(endian) + refStringStart);
 }
Exemplo n.º 42
0
 void _saveRTasPNG(RenderTarget2D rt, string filename)
 {
     stream = System.IO.File.Create(filename);
     rt.SaveAsPng(stream, rt.Width, rt.Height);
     stream.Close();
 }
Exemplo n.º 43
0
        public override DecodedObject <object> decodeString(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, CoderUtils.getStringTagForElement(elementInfo), elementInfo))
            {
                return(null);
            }
            DecodedObject <int> len = decodeLength(stream);

            CoderUtils.checkConstraints(len.Value, elementInfo);
            byte[] byteBuf = new byte[len.Value];
            stream.Read(byteBuf, 0, byteBuf.Length);
            string result = CoderUtils.bufferToASN1String(byteBuf, elementInfo);

            return(new DecodedObject <object>(result, len.Value + len.Size));
        }
Exemplo n.º 44
0
 public static void Write(TimeSpan obj, System.IO.Stream stream)
 {
     BigEndianPrimitiveTypeSerializer.Instance.WriteValue(stream, obj);
 }
Exemplo n.º 45
0
        protected DecodedObject <object> decodeLongValue(System.IO.Stream stream)
        {
            DecodedObject <int> len = decodeLength(stream);

            return(decodeLongValue(stream, len));
        }
Exemplo n.º 46
0
 public override DecodedObject <object> decodeInteger(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
 {
     if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Integer, elementInfo))
     {
         return(null);
     }
     if (objectClass.Equals(typeof(int)))
     {
         DecodedObject <object> result = decodeIntegerValue(stream);
         CoderUtils.checkConstraints((int)result.Value, elementInfo);
         return(result);
     }
     else
     {
         DecodedObject <object> result = decodeLongValue(stream);
         CoderUtils.checkConstraints((long)result.Value, elementInfo);
         return(result);
     }
 }
Exemplo n.º 47
0
        public override DecodedObject <object> decodeReal(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Real, elementInfo))
            {
                return(null);
            }
            DecodedObject <int> len = decodeLength(stream);
            int realPreamble        = stream.ReadByte();

            Double result = 0.0D;

            if (realPreamble == 0x40)
            {
                // 01000000 Value is PLUS-INFINITY
                result = Double.PositiveInfinity;
            }
            else if (realPreamble == 0x41)
            {
                // 01000001 Value is MINUS-INFINITY
                result = Double.NegativeInfinity;
            }
            else if (len.Value > 0)
            {
                int szOfExp = 1 + (realPreamble & 0x3);
                int sign    = realPreamble & 0x40;
                int ff      = (realPreamble & 0x0C) >> 2;
                DecodedObject <object> exponentEncFrm = decodeLongValue(stream, new DecodedObject <int>(szOfExp));
                long exponent = (long)exponentEncFrm.Value;
                DecodedObject <object> mantissaEncFrm = decodeLongValue(stream, new DecodedObject <int>(len.Value - szOfExp - 1));
                // Unpack mantissa & decrement exponent for base 2
                long mantissa = (long)mantissaEncFrm.Value << ff;
                while ((mantissa & 0x000ff00000000000L) == 0x0)
                {
                    exponent  -= 8;
                    mantissa <<= 8;
                }
                while ((mantissa & 0x0010000000000000L) == 0x0)
                {
                    exponent  -= 1;
                    mantissa <<= 1;
                }
                mantissa &= 0x0FFFFFFFFFFFFFL;
                long lValue = (exponent + 1023 + 52) << 52;
                lValue |= mantissa;
                if (sign == 0x40)
                {
                    lValue = (long)((ulong)lValue | 0x8000000000000000L);
                }
                result = System.BitConverter.Int64BitsToDouble(lValue);
            }
            return(new DecodedObject <object>(result, len.Value + len.Size));
        }
Exemplo n.º 48
0
 protected internal virtual DecodedObject <int> decodeLength(System.IO.Stream stream)
 {
     return(BERCoderUtils.decodeLength(stream));
 }
Exemplo n.º 49
0
 public override TimeSpan Deserialize(System.IO.Stream stream)
 {
     return(Read(stream));
 }
Exemplo n.º 50
0
        public void SaveToStream(System.IO.Stream aData)
        {
            var W = new System.IO.BinaryWriter(aData);

            Serialize(W);
        }
Exemplo n.º 51
0
        public override DecodedObject <object> decodeNull(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Null, elementInfo))
            {
                return(null);
            }
            stream.ReadByte();             // ignore null length
            object obj = createInstanceForElement(objectClass, elementInfo);
            DecodedObject <object> result = new DecodedObject <object>(obj, 1);

            return(result);
        }
Exemplo n.º 52
0
 public override void Serialize(TimeSpan obj, System.IO.Stream stream)
 {
     Write(obj, stream);
 }
Exemplo n.º 53
0
        public override DecodedObject <object> decodeSequence(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            bool isSet = false;

            if (!CoderUtils.isSequenceSet(elementInfo))
            {
                if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Constructed, UniversalTags.Sequence, elementInfo))
                {
                    return(null);
                }
            }
            else
            {
                if (checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Constructed, UniversalTags.Set, elementInfo))
                {
                    isSet = true;
                }
                else
                {
                    return(null);
                }
            }
            DecodedObject <int> len = decodeLength(stream);
            int saveMaxAvailableLen = elementInfo.MaxAvailableLen;

            elementInfo.MaxAvailableLen = (len.Value);

            DecodedObject <object> result = null;

            if (!isSet)
            {
                result = base.decodeSequence(decodedTag, objectClass, elementInfo, stream);
            }
            else
            {
                result = decodeSet(decodedTag, objectClass, elementInfo, len.Value, stream);
            }
            if (result.Size != len.Value)
            {
                throw new System.ArgumentException("Sequence '" + objectClass.ToString() + "' size is incorrect!");
            }
            result.Size = result.Size + len.Size;
            elementInfo.MaxAvailableLen = (saveMaxAvailableLen);
            return(result);
        }
Exemplo n.º 54
0
        public override DecodedObject <object> decodeObjectIdentifier(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.ObjectIdentifier, elementInfo))
            {
                return(null);
            }
            DecodedObject <int> len = decodeLength(stream);

            byte[] byteBuf = new byte[len.Value];
            stream.Read(byteBuf, 0, byteBuf.Length);
            string dottedDecimal = BERObjectIdentifier.Decode(byteBuf);

            return(new DecodedObject <object>(new ObjectIdentifier(dottedDecimal)));
        }
Exemplo n.º 55
0
        public override DecodedObject <object> decodeAny(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            int bufSize = elementInfo.MaxAvailableLen;

            if (bufSize == 0)
            {
                return(null);
            }
            System.IO.MemoryStream anyStream = new System.IO.MemoryStream(1024);

            /*int tagValue = (int)decodedTag.Value;
             * for (int i = 0; i < decodedTag.Size; i++)
             * {
             *  anyStream.WriteByte((byte)tagValue);
             *  tagValue = tagValue >> 8;
             * }*/

            if (bufSize < 0)
            {
                bufSize = 1024;
            }
            int len = 0;

            if (bufSize > 0)
            {
                byte[] buffer = new byte[bufSize];
                int    readed = stream.Read(buffer, 0, buffer.Length);
                while (readed > 0)
                {
                    anyStream.Write(buffer, 0, readed);
                    len += readed;
                    if (elementInfo.MaxAvailableLen > 0)
                    {
                        break;
                    }
                    readed = stream.Read(buffer, 0, buffer.Length);
                }
            }
            CoderUtils.checkConstraints(len, elementInfo);
            return(new DecodedObject <object>(anyStream.ToArray(), len));
        }
Exemplo n.º 56
0
        public override DecodedObject <object> decodeSequenceOf(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!CoderUtils.isSequenceSetOf(elementInfo))
            {
                if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Constructed, UniversalTags.Sequence, elementInfo))
                {
                    return(null);
                }
            }
            else
            {
                if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Constructed, UniversalTags.Set, elementInfo))
                {
                    return(null);
                }
            }

            Type   paramType         = (System.Type)objectClass.GetGenericArguments()[0];
            Type   collectionType    = typeof(List <>);
            Type   genCollectionType = collectionType.MakeGenericType(paramType);
            Object param             = Activator.CreateInstance(genCollectionType);

            DecodedObject <int> len = decodeLength(stream);

            if (len.Value != 0)
            {
                int lenOfItems = 0;
                int itemsCnt   = 0;
                do
                {
                    ElementInfo info = new ElementInfo();
                    info.ParentAnnotatedClass = elementInfo.AnnotatedClass;
                    info.AnnotatedClass       = paramType;

                    if (elementInfo.hasPreparedInfo())
                    {
                        ASN1SequenceOfMetadata seqOfMeta = (ASN1SequenceOfMetadata)elementInfo.PreparedInfo.TypeMetadata;
                        info.PreparedInfo = (seqOfMeta.getItemClassMetadata());
                    }

                    DecodedObject <object> itemTag = decodeTag(stream);
                    DecodedObject <object> item    = decodeClassType(itemTag, paramType, info, stream);
                    MethodInfo             method  = param.GetType().GetMethod("Add");
                    if (item != null)
                    {
                        lenOfItems += item.Size + itemTag.Size;
                        method.Invoke(param, new object[] { item.Value });
                        itemsCnt++;
                    }
                }while (lenOfItems < len.Value);
                CoderUtils.checkConstraints(itemsCnt, elementInfo);
            }
            return(new DecodedObject <object>(param, len.Value + len.Size));
        }
 public void WriteObject(System.IO.Stream stream, object graph)
 {
 }
Exemplo n.º 58
0
        public static JSONNode LoadFromCompressedStream(System.IO.Stream aData)
        {
            var zin = new ICSharpCode.SharpZipLib.BZip2.BZip2InputStream(aData);

            return(LoadFromStream(zin));
        }
Exemplo n.º 59
0
 public Tiles128x128(System.IO.Stream strm) : this(new Reader(strm))
 {
 }
Exemplo n.º 60
0
 public override DecodedObject <object> decodeEnumItem(DecodedObject <object> decodedTag, System.Type objectClass, System.Type enumClass, ElementInfo elementInfo, System.IO.Stream stream)
 {
     if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Enumerated, elementInfo))
     {
         return(null);
     }
     return(decodeIntegerValue(stream));
 }