Exemplo n.º 1
0
        /// <summary>
        /// The open.
        /// </summary>
        /// <param name="filePath">
        /// The file path.
        /// </param>
        /// <param name="mode">
        /// The mode.
        /// </param>
        /// <param name="classRegistry">
        /// The class Registry.
        /// </param>
        /// <param name="resourceResolver">
        /// The resource Resolver.
        /// </param>
        /// <param name="ram">
        /// The ram.
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// </exception>
        public static IwSerialise Open(
            string filePath,
            IwSerialiseMode mode,
            ClassRegistry classRegistry,
            IResourceResolver resourceResolver,
            bool ram = false)
        {
            switch (mode)
            {
            case IwSerialiseMode.Read:
                return(new IwSerialise(
                           File.OpenRead(resourceResolver.ResolveFilePath(filePath, ram)), mode, classRegistry, resourceResolver));

            case IwSerialiseMode.Write:
                return(new IwSerialise(
                           File.OpenWrite(resourceResolver.ResolveFilePath(filePath, ram)), mode, classRegistry, resourceResolver));

            default:
                throw new ArgumentOutOfRangeException("mode");
            }
        }