JMX File Editor/ViewModels/Application/ApplicationViewModel.cs
/// <summary>
/// Creates and loads the JMX file
/// </summary>
Creates and loads the JMX file
Creates and loads the JMX file
private IJMXFile LoadJMXFile(string Path)
        {
            IJMXFile file = null;
            using (FileStream fs = new FileStream(Path,FileMode.Open,FileAccess.Read))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    if (br.BaseStream.Length < 12)
                        return null;
                    var header = new string(br.ReadChars(12));
                    switch (header)
                    {
                        case JMXVRES_0109.FileHeader:
                            file = new JMXVRES_0109();
                            break;
                        case JMXVBMT_0102.FileHeader:
                            file = new JMXVBMT_0102();
                            break;
                        default:
                            throw new FileFormatException("JMX Header not found! File not supported.");
                    }
                    fs.Seek(0, SeekOrigin.Begin);
                    file.Load(fs);
                }
            }
            return file;
        }
private IJMXFile LoadJMXFile ( string Path ) { IJMXFile file = null ; using ( FileStream fs = new FileStream ( Path , FileMode . Open , FileAccess . Read ) ) { using ( BinaryReader br = new BinaryReader ( fs ) ) { if ( br . BaseStream . Length < 12 ) return null ; var header = new string ( br . ReadChars ( 12 ) ) ; switch ( header ) { case JMXVRES_0109 . FileHeader : file = new JMXVRES_0109 ( ) ; break ; case JMXVBMT_0102 . FileHeader : file = new JMXVBMT_0102 ( ) ; break ; default : throw new FileFormatException ( " " ) ; } fs . Seek ( 0 , SeekOrigin . Begin ) ; file . Load ( fs ) ; } } return file ; }
Creates and loads the JMX file
Creates and loads the JMX file
// Instance to be created and returned as result // Check the header exist at least // Read file type and create format // Load it
Path
string