Beispiel #1
0
        public static cvnBase Open(Stream fp, cvnType FileType, Stream pfp = null)
        {
            switch (FileType)
            {
            case cvnType.Text: return(new cv0(fp));

            case cvnType.CSV: return(new cv1(fp));

            case cvnType.Graphic:
                cv2 result = new cv2();
                try
                {
                    result.Open(fp, pfp);
                }
                catch (System.ArgumentException)
                {
                    result = null;
                }
                return(result);

            case cvnType.Audio: return(new cv3(fp));

            default: return(null);
            }
        }
Beispiel #2
0
        public static cvnBase Open(string Path, cvnType FileType = cvnType.Unknown, string PalettePath = "")
        {
            cvnType file_type = FileType;

            if (file_type == cvnType.Unknown)
            {
                string extension = Path.Substring(Path.IndexOf('.') + 1);
                switch (extension)
                {
                case "cv0": file_type = cvnType.Text; break;

                case "cv1": file_type = cvnType.CSV; break;

                case "cv2": file_type = cvnType.Graphic; break;

                case "cv3": file_type = cvnType.Audio; break;

                default: throw new FormatException("지원하지 않는 확장자입니다.");
                }
            }
            switch (file_type)
            {
            case cvnType.Text: return(new cv0(Path));

            case cvnType.CSV: return(new cv1(Path));

            case cvnType.Graphic:
                cv2 result = new cv2();
                try
                {
                    result.Open(Path, PalettePath);
                }
                catch (ArgumentException)
                {
                    result = null;
                }
                return(result);

            case cvnType.Audio: return(new cv3(Path));

            default: return(null);
            }
        }