Exemplo n.º 1
0
        /// <summary>
        /// Loads the specified input stream containing the TEBO file.
        /// </summary>
        /// <param name="input">The input stream.</param>
        /// <exception cref="System.IO.InvalidDataException">Thrown if the stream does not contain a valid TEBO file.</exception>
        /// <returns>The loaded savable</returns>
        public ISavable Load(Stream input)
        {
            //Read header
            if (!ReadHeader(input))
            {
                throw new InvalidDataException("Invalid binary file, either it is not a tesla engine binary object or the version is not compatible.");
            }

            BinarySavableReader reader  = new BinarySavableReader(input, ContentManager);
            ISavable            savable = reader.ReadSavable <ISavable>();

            reader.Dispose();
            return(savable);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the specified resource.
        /// </summary>
        /// <param name="resource">The resource to load</param>
        /// <param name="parameters">Any loading parameters</param>
        /// <exception cref="System.IO.InvalidDataException">Thrown if the stream does not contain a valid TEBO file.</exception>
        /// <returns>The loaded resource</returns>
        public override ISavable Load(IResource resource, LoaderParameters parameters)
        {
            //Read header
            Stream stream = resource.OpenStream();

            if (!ReadHeader(stream))
            {
                throw new InvalidDataException("Invalid binary file, either it is not a tesla engine binary object or the version is not compatible.");
            }

            BinarySavableReader reader  = new BinarySavableReader(stream, ContentManager);
            ISavable            savable = reader.ReadSavable <ISavable>();

            reader.Dispose();
            return(savable);
        }