public static CommandStage Select <TStreamType>(this CommandStage stage, int index)
            where TStreamType : class, IStream
        {
            var streamId = stage.Command.StreamIdentifier <TStreamType>(index);

            return(stage.Select(streamId));
        }
        public static CommandStage WithInput <TStreamType>(this CommandStage command, string fileName, SettingsCollection settings)
            where TStreamType : class, IStream
        {
            command.Command.AddInput(fileName, settings);

            return(command.Select(command.Command.LastInputStream <TStreamType>()));
        }
        //command stage
        public static CommandStage WithInput <TStreamType>(this FFmpegCommand command, string fileName)
            where TStreamType : class, IStream
        {
            var commandStage = CommandStage.Create(command);

            return(commandStage.WithInput <TStreamType>(fileName));
        }
Esempio n. 4
0
        public async Task Command_Stage_MaskTest()
        {
            CommandResponse response     = null;
            CommandStage    commandStage = CommandStage.All;
            TestCommand     command      = null;

            command = new TestCommand(commandStage);
            command.SetComandStageMask = commandStage;
            response = await command.Execute();

            Assert.AreEqual(4, command.StagesExecuted.Count);


            commandStage = CommandStage.None;
            command      = new TestCommand(commandStage);
            command.SetComandStageMask = commandStage;
            response = await command.Execute();

            Assert.AreEqual(0, command.StagesExecuted.Count);


            commandStage = CommandStage.OnValidation;
            command      = new TestCommand(commandStage);
            command.SetComandStageMask = commandStage;
            response = await command.Execute();

            Assert.AreEqual(1, command.StagesExecuted.Count);
        }
        protected override async Task <CommandResponse <VoteTracker> > ExecuteStage(CommandStage stage, CommandResponse <VoteTracker> previous)
        {
            switch (stage)
            {
            case CommandStage.OnExecuting:

                var q    = new QueryVote(_voteID);
                var vote = await q.ExecuteAsync();

                var notPassed = vote.Restrictions.FirstOrDefault(x => {
                    var e = x.Evaluate(User);
                    return(!e.Success);
                });

                _restrictionsPassed = notPassed == null;

                break;

            case CommandStage.OnExecuted:

                if (previous.Success)
                {
                    CacheHandler.Instance.Remove(CachingKey.VoteStatistics(_voteID));
                }

                break;
            }
            return(await base.ExecuteStage(stage, previous));
        }
Esempio n. 6
0
        public static CommandOutput SetupCommandOutputMaps <TOutputType>(CommandStage stage, SettingsCollection settings, string fileName)
            where TOutputType : class, IContainer, new()
        {
            var settingsCopy  = settings.Copy();
            var commandOutput = CommandOutput.Create(Resource.CreateOutput <TOutputType>(), settingsCopy);

            stage.StreamIdentifiers.ForEach(streamId =>
            {
                var theStream   = StreamFromStreamIdentifier(stage.Command, streamId);
                var theResource = CommandInputFromStreamIdentifier(stage.Command, streamId);

                if (theResource == null)
                {
                    commandOutput.Settings.Merge(new Map(streamId), FFmpegMergeOptionType.NewWins);
                }
                else
                {
                    var resourceIndex = IndexOfResource(stage.Command, streamId);

                    commandOutput.Settings.Merge(new Map(string.Format("{0}:{1}", resourceIndex, theStream.ResourceIndicator)),
                                                 FFmpegMergeOptionType.NewWins);
                }

                commandOutput.Resource.Streams.Add(theStream.Copy());
            });

            if (!string.IsNullOrWhiteSpace(fileName))
            {
                commandOutput.Resource.Name = fileName;
            }

            return(commandOutput);
        }
        public static CommandStage Select(this CommandStage stage, List <StreamIdentifier> streamIds)
        {
            ValidateStreams(stage, streamIds);

            stage.StreamIdentifiers.AddRange(streamIds);

            return(stage);
        }
        public static CommandStage Select(this CommandStage stage, StreamIdentifier streamId)
        {
            var streamIdList = new List <StreamIdentifier> {
                streamId
            };

            return(stage.Select(streamIdList));
        }
        public static CommandStage Select(this CommandStage stage, params CommandStage[] stages)
        {
            if (stages == null || stages.Length == 0)
            {
                throw new ArgumentNullException("stages");
            }

            return(stage.Select(stages.ToList()));
        }
        public static CommandStage Select(this CommandStage stage, CommandInput resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            return(stage.Select(resource.GetStreamIdentifier()));
        }
        public static CommandStage Select <TStreamType>(this CommandStage stage, CommandInput resource)
            where TStreamType : class, IStream
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            return(stage.Select(resource.GetStreamIdentifier <TStreamType>()));
        }
 protected override async Task <CommandResponse <Vote> > ExecuteStage(CommandStage stage, CommandResponse <Vote> previous)
 {
     switch (stage)
     {
     case CommandStage.OnExecuting:
         //perform validationn return non-success if not success
         break;
     }
     return(await base.ExecuteStage(stage, previous));
 }
        public static void ValidateStreams(CommandStage stage, List <StreamIdentifier> streamIds)
        {
            if (stage.Command.Owner == null)
            {
                throw new ArgumentException("Command must contain an owner before sugar is allowed.", "stage");
            }

            if (streamIds == null)
            {
                throw new ArgumentNullException("streamIds");
            }
        }
Esempio n. 14
0
 protected override async Task <CommandResponse <Submission> > ExecuteStage(CommandStage stage, CommandResponse <Submission> previous)
 {
     switch (stage)
     {
     case CommandStage.OnValidation:
         if (_userSubmission.Content.Length > 10000)
         {
             return(CommandResponse.FromStatus <Submission>(null, Status.Invalid, "Content can not exceed 10,000 characters"));
         }
         break;
     }
     return(await base.ExecuteStage(stage, previous));
 }
Esempio n. 15
0
        public void Command_FilterWithNoStream()
        {
            var command = CommandHelper.CreateCommand();

            var filterchain = Filterchain.FilterTo <AudioStream>(new AEvalSrc {
                Expression = "0"
            });

            CommandStage stage = null;

            Assert.DoesNotThrow(() => stage = command.Filter(filterchain));

            Assert.True(stage.StreamIdentifiers.Count == 1);
        }
Esempio n. 16
0
 protected override async Task <CommandResponse <Submission> > ExecuteStage(CommandStage stage, CommandResponse <Submission> previous)
 {
     switch (stage)
     {
     case CommandStage.OnValidation:
         var results = ValidationHandler.Validate(_userSubmission);
         if (!results.IsNullOrEmpty())
         {
             return(CommandResponse.Invalid <Submission>(results));
         }
         break;
     }
     return(await base.ExecuteStage(stage, previous));
 }
        public static List <CommandOutput> To <TOutputType>(this CommandStage stage, string fileName, SettingsCollection settings)
            where TOutputType : class, IContainer, new()
        {
            ValidateTo(stage.Command);

            var commandOutput = CommandHelperUtility.SetupCommandOutput <TOutputType>(stage.Command, settings, fileName);

            stage.Command.OutputManager.Add(commandOutput);

            return(new List <CommandOutput>
            {
                commandOutput
            });
        }
Esempio n. 18
0
        public void Command_WithInputVsAddInput_Verify()
        {
            var command = CommandHelper.CreateCommand();

            Assert.Throws <ArgumentException>(() => command.AddInput(string.Empty));
            Assert.Throws <ArgumentException>(() => command.WithInput <VideoStream>(string.Empty));

            var stage = CommandStage.Create(command);

            stage = command.AddInput(Assets.Utilities.GetVideoFile())
                    .WithInput <VideoStream>(Assets.Utilities.GetVideoFile());

            Assert.True(command.Inputs.Count == 2);
            Assert.True(stage.StreamIdentifiers.Count == 1);
        }
        public static CommandStage Select(this CommandStage stage, List <CommandStage> stages)
        {
            var streams = new List <StreamIdentifier>();

            foreach (var commandStage in stages)
            {
                if (commandStage.StreamIdentifiers == null)
                {
                    continue;
                }

                streams.AddRange(commandStage.StreamIdentifiers);
            }

            return(stage.Select(streams));
        }
        public static CommandStage WithInput <TStreamType>(this CommandStage command, List <string> files)
            where TStreamType : class, IStream
        {
            if (files == null || files.Count == 0)
            {
                throw new ArgumentException("Files cannot be null or empty.", "files");
            }

            var streamIds = files.Select(fileName =>
            {
                command.Command.AddInput(fileName);

                return(command.Command.LastInputStream <TStreamType>());
            }).ToList();

            return(command.Select(streamIds));
        }
        private static void RemuxToMpeg4Container(JobConfiguration jobConfiguration)
        {
            CommandFactory factory = CommandFactory.Create();
            FFmpegCommand  command = factory.CreateOutputCommand();

            CommandStage chain = command.WithInput <VideoStream>(jobConfiguration.InputFile);

            SettingsCollection outputSettings = SettingsCollection.ForOutput(new CodecVideo(VideoCodecType.Copy),
                                                                             new CodecAudio(AudioCodecType.Copy));

            chain.To <Mp4>(jobConfiguration.OutputFile, outputSettings);

            Console.WriteLine($"Remuxing {jobConfiguration.InputFile}");
            try {
                factory.Render();
//                Console.WriteLine($"Remuxed  {jobConfiguration.OutputFile}");
                if (jobConfiguration.RemoveInputFileAfterRemux && File.Exists(jobConfiguration.OutputFile))
                {
                    File.Delete(jobConfiguration.InputFile);
                }
            } catch (FFmpegRenderingException e) {
                Console.WriteLine($"Remuxing failed for file {jobConfiguration.InputFile}: {e.Message}");
            }
        }
        public static CommandStage WithInput <TStreamType>(this CommandStage command, string fileName)
            where TStreamType : class, IStream

        {
            return(command.WithInput <TStreamType>(fileName, SettingsCollection.ForInput()));
        }
Esempio n. 23
0
    public void SelectMinion(PositionVO _position)
    {
        Minion selectedMinion;
        switch (stage)
        {
        case GameStage.Command:
            switch(commandStage)
            {
            case CommandStage.WaitingForSelection:
                selectedMinion = MinionManager.Instance.GetMinionByPosition(_position);
                if (selectedMinion != null)
                {
                    selectedMinionID = selectedMinion.ID;
                    commandStage = CommandStage.WaitingForOrder;
                    GameUIManager.Instance.ControlCommandButton(true);
                }
                break;
            case CommandStage.WaitingForOrder:
                selectedMinion = MinionManager.Instance.GetMinionByPosition(_position);
                if (selectedMinion != null)
                {
                    selectedMinionID = selectedMinion.ID;
                    commandStage = CommandStage.WaitingForOrder;
                    GameUIManager.Instance.ControlCommandButton(true);
                }
                else
                {
                    selectedMinionID = -1;
                    commandStage = CommandStage.WaitingForSelection;
                    GameUIManager.Instance.ControlCommandButton(false);
                }
                break;
            case CommandStage.SelectingTarget:
                if (selectedMinionID == -1)
                { 
                    Debug.LogError("SelectingTarget but no minion Selected");
                    return;
                }
                Result _result = MinionManager.Instance.GetMinionByID(selectedMinionID).CheckCommandValid(commandType, skillNum, _position);
                if(_result.Success)
                {
                    CommandManager.Instance.SetCommand(selectedMinionID, commandType, skillNum, _position);
                    commandStage = CommandStage.WaitingForSelection;
                }
                else
                {
					
                    // Show Info To Player The reason why it failed
					Debug.Log ("Command Failed: " + _result.Reason);
                }
                GameUIManager.Instance.ControlCommandButton(false);
                break;
            }
            break;
        case GameStage.Fight:
            break;
        }
        Debug.Log("after commandStage: " + commandStage);
    }
Esempio n. 24
0
 public void SelectCommand(int _commandButtonIndex)
 {
     Debug.Log("before commandStage: " + commandStage);
     if (commandStage != CommandStage.WaitingForOrder)
     {
         Debug.LogError("commandStage is not WaitingForOrder");
         return;
     }
     if(selectedMinionID == -1)
     {
         Debug.LogError("No Minion Selected");
         return;
     }
     Minion minion = MinionManager.Instance.GetMinionByID(selectedMinionID);
     if (minion == null)
     {
         Debug.LogError("Selected Minion ID Not Valid");
         return;
     }
     switch(_commandButtonIndex)
     {
         case 0:
             commandType = CommandType.StandBy;
             commandStage = CommandStage.WaitingForSelection;
             break;
         case 1:
             commandType = CommandType.Attack;
             commandStage = CommandStage.SelectingTarget;
             break;
         case 2:
             commandType = CommandType.Move;
             commandStage = CommandStage.SelectingTarget;
             break;
         default:
             commandType = CommandType.Skill;
             skillNum = _commandButtonIndex - 3;
             commandStage = CommandStage.SelectingTarget;
             break;
     }
     GameUIManager.Instance.ControlCommandButton(false);
     Debug.Log("after commandStage: " + commandStage);
 }
        public static CommandStage Select(this CommandStage stage, int index)
        {
            var streamId = stage.Command.StreamIdentifier(index);

            return(stage.Select(streamId));
        }
        public static CommandStage WithInputNoLoad(this CommandStage command, string fileName)
        {
            command.Command.AddInputNoLoad(fileName);

            return(command.Select(command.Command.LastInputStream()));
        }
        public static CommandStage OnError(this CommandStage stage, Action <ICommandFactory, ICommand, ICommandProcessor> action)
        {
            stage.Command.OnErrorAction = action;

            return(stage);
        }
        public static CommandStage Filter(this CommandStage stage, FilterchainTemplate filterchainTemplate)
        {
            var outputStreamIdentifiers = filterchainTemplate.SetupTemplate(stage.Command, stage.StreamIdentifiers);

            return(stage.Command.Select(outputStreamIdentifiers));
        }
        public static CommandStage AfterRender(this CommandStage stage, Action <ICommandFactory, ICommand, bool> action)
        {
            stage.Command.PostExecutionAction = action;

            return(stage);
        }
 public static List <CommandOutput> To <TOutputType>(this CommandStage stage, SettingsCollection settings)
     where TOutputType : class, IContainer, new()
 {
     return(stage.To <TOutputType>(string.Empty, settings));
 }
 public static List <CommandOutput> To <TOutputType>(this CommandStage stage)
     where TOutputType : class, IContainer, new()
 {
     return(stage.To <TOutputType>(SettingsCollection.ForOutput()));
 }
        public static CommandStage FilterEach(this CommandStage stage, Filterchain filterchain)
        {
            var outputStreamIdentifiers = stage.Command.FilterchainManager.AddToEach(filterchain, stage.StreamIdentifiers.ToArray());

            return(stage.Command.Select(outputStreamIdentifiers));
        }