示例#1
0
 /** Creates a new instance of UrlByteReader */
 private UrlByteReader(IdentificationFile theIDFile, bool readFile) : base(theIDFile)
 {
     //super(theIDFile);
     if (readFile)
     {
         this.readUrl();
     }
 }
 /** Creates a new instance of UrlByteReader */
 private InputStreamByteReader(IdentificationFile theIDFile, bool readFile) : base(theIDFile)
 {
     //super(theIDFile);
     if (readFile)
     {
         this.readInputStream();
     }
 }
		/** Creates a new instance of UrlByteReader */
		private InputStreamByteReader(IdentificationFile theIDFile, bool readFile) : base(theIDFile)
		{
			//super(theIDFile);
			if (readFile)
			{
				this.readInputStream();
			}
		}
		/** Creates a new instance of UrlByteReader */
		private UrlByteReader(IdentificationFile theIDFile, bool readFile) : base(theIDFile)
		{
			//super(theIDFile);
			if (readFile)
			{
				this.readUrl();
			}

		}
 /**
  * Creates a new instance of FileByteReader
  *
  * <p>This constructor can set the <code>IdentificationFile</code> to
  * a different file than the actual file used. For example, if <code>theIDFile</code>
  * is a URL or stream, and is too big to be buffered in memory, it could be written
  * to a temporary file.  This file would then be used as a backing file to store
  * the data.
  *
  * @param theIDFile the file represented by this object
  * @param readFile <code>true</code> if the file is to be read
  * @param filePath the backing file (containing the data)
  */
 public FileByteReader(IdentificationFile theIDFile, bool readFile, String filePath) : base(theIDFile)
 {
     //super(theIDFile);
     this.file = new System.IO.FileInfo(filePath);
     if (readFile)
     {
         this.readFile();
     }
 }
	    /**
     * Creates a new instance of FileByteReader
     *
     * <p>This constructor can set the <code>IdentificationFile</code> to 
     * a different file than the actual file used. For example, if <code>theIDFile</code>
     * is a URL or stream, and is too big to be buffered in memory, it could be written
     * to a temporary file.  This file would then be used as a backing file to store
     * the data.
     * 
     * @param theIDFile the file represented by this object
     * @param readFile <code>true</code> if the file is to be read
     * @param filePath the backing file (containing the data)
     */
    public FileByteReader(IdentificationFile theIDFile, bool readFile, String filePath) : base(theIDFile)
    {
        //super(theIDFile);
        this.file = new System.IO.FileInfo(filePath);
        if (readFile)
        {
            this.readFile();
        }
        
    }
		/**
		 * Static constructor for class.  Trys to read url into a buffer. If it doesn't fit, 
		 * save it to a file, and return a FileByteReader with that file.
		 */
		public static IByteReader newUrlByteReader(IdentificationFile theIDFile, bool readFile)
		{
			UrlByteReader byteReader = new UrlByteReader(theIDFile, readFile);
			if (byteReader.tempFile == null)
			{
				return byteReader;
			}
			else
			{
				return new FileByteReader(theIDFile, readFile, byteReader.tempFile.FullName); //was getPath()
			}
		}
		/**
		 * Static constructor for class.  Trys to read stream into a buffer. If it doesn't fit, 
		 * save it to a file, and return a FileByteReader with that file.
		 */
		internal static IByteReader newInputStreamByteReader(IdentificationFile theIDFile, bool readFile) // was ByteReader
		{
			InputStreamByteReader byteReader = new InputStreamByteReader(theIDFile, readFile);
			if (byteReader.tempFile == null)
			{
				return byteReader;
			}
			else
			{
				return new FileByteReader(theIDFile, readFile, byteReader.tempFile.FullName); //getPath());
			}
		}
        /**
         * Static constructor for class.  Trys to read stream into a buffer. If it doesn't fit,
         * save it to a file, and return a FileByteReader with that file.
         */
        internal static IByteReader newInputStreamByteReader(IdentificationFile theIDFile, bool readFile)         // was ByteReader
        {
            InputStreamByteReader byteReader = new InputStreamByteReader(theIDFile, readFile);

            if (byteReader.tempFile == null)
            {
                return(byteReader);
            }
            else
            {
                return(new FileByteReader(theIDFile, readFile, byteReader.tempFile.FullName));                //getPath());
            }
        }
示例#10
0
        /**
         * Static constructor for class.  Trys to read url into a buffer. If it doesn't fit,
         * save it to a file, and return a FileByteReader with that file.
         */
        public static IByteReader newUrlByteReader(IdentificationFile theIDFile, bool readFile)
        {
            UrlByteReader byteReader = new UrlByteReader(theIDFile, readFile);

            if (byteReader.tempFile == null)
            {
                return(byteReader);
            }
            else
            {
                return(new FileByteReader(theIDFile, readFile, byteReader.tempFile.FullName));                //was getPath()
            }
        }
 /**
  * Static constructor for a ByteReader object, and depending on the readFile setting,
  * it may or may not read in the binary file specified.
  *
  * This may create a FileByteReader, UrlByteReader or InputStreamByteReader, depending on the
  * the nature of the IdentificationFile passed in.
  *
  *
  * @param theIDFile   The file to be read in
  * @param readFile   Flag specifying whether file should be read in or not
  */
 public static IByteReader newByteReader(IdentificationFile theIDFile, bool readFile)         //was ByteReader
 {
     if (InputStreamByteReader.isInputStream(theIDFile.getFilePath()))
     {
         return(InputStreamByteReader.newInputStreamByteReader(theIDFile, readFile));
     }
     else if (UrlByteReader.isURL(theIDFile.getFilePath()))
     {
         return(UrlByteReader.newUrlByteReader(theIDFile, readFile));
     }
     else
     {
         return(new FileByteReader(theIDFile, readFile));
     }
 }
示例#12
0
        private void OnSaveInfo()
        {
            App.DisplayStatusMessage("Starting saving of info.", StatusMessageType.USER);

            var dialog = new SaveFileDialog();

            dialog.DefaultExt       = IdentificationFile.EXT;      //gets long extensions to work properly when they are added to a filename when saved
            dialog.Filter           = IdentificationFile.FILTER;
            dialog.OverwritePrompt  = true;
            dialog.Title            = "Select Location to Save Info File";
            dialog.InitialDirectory = Directory.GetCurrentDirectory();            //TODO: remember last used directory

            if (dialog.ShowDialog() == true)
            {
                //replace .xml with .Info.xml
                var actualFileName = ExtensionFixer.SwitchToLongExtension(dialog.FileName, IdentificationFile.SHORT_EXT, IdentificationFile.EXT);

                try
                {
                    using (var fileStream = new FileStream(actualFileName, FileMode.Create, FileAccess.Write))
                    {
                        var infoFile = new IdentificationFile();

                        foreach (var entry in ECUInfo)
                        {
                            infoFile.IdentificationValues.Add(entry);
                        }

                        App.SerializeToXML(fileStream, infoFile);
                        App.DisplayStatusMessage("Successfully saved info to file.", StatusMessageType.USER);
                    }
                }
                catch
                {
                    App.DisplayStatusMessage("Failed to save info to file.", StatusMessageType.USER);
                }
            }
            else
            {
                App.DisplayStatusMessage("Cancelling saving of info.", StatusMessageType.USER);
            }
        }
示例#13
0
 /**
  * Creates a new instance of FileByteReader
  *
  * <p>This constructor uses the same file to contain the data as is specified by
  * <code>theIDFile</code>.
  * 
  * @param theIDFile the source file from which the bytes will be read.
  * @param readFile <code>true</code> if the file is to be read
  */   
 public FileByteReader(IdentificationFile theIDFile, bool readFile) : this(theIDFile, readFile, theIDFile.getFilePath())
 {        
 }
		/** Creates a new instance of StreamByteReader */
		protected StreamByteReader(IdentificationFile theIDFile) : base(theIDFile)
		{
			//super(theIDFile);
		}
 /**
  * Creates a ByteReader object, and depending on the readFile setting,
  * it may or may not read in the binary file specified
  *
  * @param theIDFile   The file to be read in
  */
 public static IByteReader newByteReader(IdentificationFile theIDFile)         // was ByteReader
 {
     return(newByteReader(theIDFile, true));
 }
示例#16
0
 /**
  * Creates a new instance of FileByteReader
  *
  * <p>This constructor uses the same file to contain the data as is specified by
  * <code>theIDFile</code>.
  *
  * @param theIDFile the source file from which the bytes will be read.
  * @param readFile <code>true</code> if the file is to be read
  */
 public FileByteReader(IdentificationFile theIDFile, bool readFile) : this(theIDFile, readFile, theIDFile.getFilePath())
 {
 }
示例#17
0
 /** Creates a new instance of StreamByteReader */
 protected StreamByteReader(IdentificationFile theIDFile) : base(theIDFile)
 {
     //super(theIDFile);
 }
 /**
  * Creates a ByteReader object, and depending on the readFile setting,
  * it may or may not read in the binary file specified
  *
  * @param theIDFile   The file to be read in
  */
 protected AbstractByteReader(IdentificationFile theIDFile)
 {
     myIDFile = theIDFile;
 }