Example #1
0
        public static void LoadBaseFormat(BaseFormat format, string destinationDirectory, string resourceName, BinaryReader binaryReader)
        {
            Directory.CreateDirectory(destinationDirectory);

            switch (format) {
                case BaseFormat.Font:
                    new FontLoader().Load(destinationDirectory, resourceName, binaryReader);
                    break;
                case BaseFormat.PlayerBitmap:
                    new PlayerBitmapLoader().Load(destinationDirectory, resourceName, binaryReader);
                    break;
                case BaseFormat.Palette:
                    new PaletteLoader().Load(binaryReader);
                    break;
                case BaseFormat.BitmapRLE:
                    new BitmapRleLoader().Load(destinationDirectory, resourceName, binaryReader);
                    break;
                case BaseFormat.RawBitmap:
                    new RawBitmapLoader().Load(destinationDirectory, resourceName, binaryReader);
                    break;
                case BaseFormat.ShadowBitmap:
                    new ShadowBitmapLoader().Load(destinationDirectory, resourceName, binaryReader);
                    break;
                case BaseFormat.Sound:
                    new SoundLoader().Load(destinationDirectory, resourceName, binaryReader);
                    break;
                default:
                    throw new Exception("Unsupported format : " + format.ToString());
            }
        }
Example #2
0
        public IHttpActionResult Add([FromBody] AddFormat format)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToAddFormats(GetTokenUserEmail()))
            {
                try
                {
                    Format     newStyleClass  = formatManagementService.Add(AddFormat.ToEntity(format));
                    BaseFormat modelNewFormat = BaseFormat.ToModel(newStyleClass);

                    return(CreatedAtRoute("AddFormat", new { formatname = modelNewFormat.Name }, modelNewFormat));
                }
                catch (MissingFormatException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }
Example #3
0
 public SerialCommand(SerialReader serial, command_queue cmd_queue, BaseFormat cmd)
 {
     this.serial    = serial;
     this.cmd_queue = cmd_queue;
     this.cmd       = cmd;
 }