Ejemplo n.º 1
0
 void Start()
 {
     player  = FindObjectOfType <PlayerController>();
     ai      = FindObjectOfType <AIController>();
     score   = FindObjectOfType <ScoreController>();
     decider = FindObjectOfType <Decider>();
 }
    //Dokument kopieren
    public void DocumentCopy(string sDokument, string sZiel)
    {
        //gibt es das Dokument auch?
        if (File.Exists(sDokument))
        {
            //Dateinamen ermitteln
            string sDateiname = Path.GetFileName(sDokument);

            try
            {
                //Dokument kopieren, mit überschreiben
                File.Copy(sDokument, Path.Combine(sZiel, sDateiname), true);
            }
            catch (Exception exc)
            {
                String strMessage = exc.Message;
                MessageBox.Show("Exception: " + strMessage + "\n\n" + sZiel + " -- " + sDateiname, "Documentation-Tool, DocumentCopy", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        else
        {
            //Hinweis, Datei gibt es nicht
#if DEBUG
            MessageBox.Show("Das Dokument [" + sDokument + "] ist nicht auf dem Datenträger vorhanden!", "Documentation-Tool", MessageBoxButtons.OK, MessageBoxIcon.Information);
#else
            Decider eDecision = new Decider();
            eDecision.Decide(EnumDecisionType.eOkDecision, "Das Dokument [" + sDokument + "] ist nicht auf dem Datenträger vorhanden!", "Documentation-Tool", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
#endif
        }
        return;
    }
Ejemplo n.º 3
0
 protected override SupervisorStrategy SupervisorStrategy()
 {
     //return new OneForOneStrategy( //or AllForOneStrategy
     return(new AllForOneStrategy(
                10,
                TimeSpan.FromSeconds(30),
                Decider.From(x =>
     {
         if (x is DontBotherMeException)
         {
             return Directive.Resume;
         }
         else if (x is ExplosionException)
         {
             return Directive.Restart;
         }
         else if (x is IamGodException)
         {
             return Directive.Stop;
         }
         else
         {
             return Directive.Escalate;
         }
     })));
 }
Ejemplo n.º 4
0
        protected override SupervisorStrategy SupervisorStrategy()
        {
            return(new OneForOneStrategy(// or AllForOneStrategy
                       maxNrOfRetries: 5,
                       withinTimeRange: TimeSpan.FromMinutes(120),
                       decider: Decider.From(x =>
            {
                // Maybe ArithmeticException is not application critical
                // so we just ignore the error and keep going.
                if (x is ArithmeticException)
                {
                    _logger.Information("Resumed processing");
                    return Directive.Resume;
                }
                // Error that we have no idea what to do with
                else if (x is ApplicationException)
                {
                    return Directive.Escalate;
                }

                // Error that we can't recover from, stop the failing child
                else if (x is NotSupportedException)
                {
                    return Directive.Stop;
                }

                // otherwise restart the failing child
                else
                {
                    _logger.Information(string.Format("Received error: {0}. Restarting processing of child...", x.Message));
                    return Directive.Restart;
                };
            })));
        }
Ejemplo n.º 5
0
        public KafkaSourceStageLogic(KafkaSourceStage <K, V> stage, Attributes attributes, TaskCompletionSource <NotUsed> completion) : base(stage.Shape)
        {
            _settings     = stage.Settings;
            _subscription = stage.Subscription;
            _out          = stage.Out;
            _completion   = completion;
            _buffer       = new Queue <ConsumerRecord <K, V> >(stage.Settings.BufferSize);

            var supervisionStrategy = attributes.GetAttribute <ActorAttributes.SupervisionStrategy>(null);

            _decider = supervisionStrategy != null ? supervisionStrategy.Decider : Deciders.ResumingDecider;

            SetHandler(_out, onPull: () =>
            {
                if (_buffer.Count > 0)
                {
                    Push(_out, _buffer.Dequeue());
                }
                else
                {
                    if (_isPaused)
                    {
                        _consumer.Resume(_assignedPartitions);
                        _isPaused = false;
                        Log.Debug("Polling resumed, buffer is empty");
                    }
                    PullQueue();
                }
            });
        }
Ejemplo n.º 6
0
 public static EnumDecisionReturn Show(string message, string caption)
 {
     using (Decider decider = new Decider())
     {
         return(decider.Decide(EnumDecisionType.eOkDecision, message, caption, EnumDecisionReturn.eOK, EnumDecisionReturn.eOK));
     }
 }
Ejemplo n.º 7
0
        protected override SupervisorStrategy SupervisorStrategy()
        {
            return(new OneForOneStrategy(
                       maxNrOfRetries: 10,
                       withinTimeRange: TimeSpan.FromSeconds(4),
                       decider: Decider.From(x =>
            {
                //Maybe we consider ArithmeticException to not be application critical
                //so we just ignore the error and keep going.
                if (x is ArithmeticException)
                {
                    return Directive.Resume;
                }

                //Error that we cannot recover from, stop the failing actor
                else if (x is NotSupportedException)
                {
                    return Directive.Stop;
                }

                //In all other cases, just restart the failing actor
                else
                {
                    return Directive.Restart;
                }
            })));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a ZipActor pool.
        /// </summary>
        /// <remarks>
        /// We use a pool to avoid a build up of messages in the <see cref="ZipActor"/>, zip being a long-running operation.
        /// </remarks>
        private void CreateZipActorPool()
        {
            SupervisorStrategy strategy = new OneForOneStrategy(
                maxNrOfRetries: 0,
                withinTimeMilliseconds: 0,
                decider: Decider.From(exception =>
            {
                if (exception is IOException)
                {
                    Logger.Warning("{0}{1} - {2}", "Skipping folder because error in actor: ", Sender.Path.Name, exception.Message);

                    IncrementFolderCount();

                    return(Directive.Resume);
                }
                else
                {
                    Logger.Error("{0}{1} - {2}", LogMessageParts.ApplicationTerminating, Sender.Path.Name, exception.Message);

                    return(Directive.Stop);
                }
            }),
                loggingEnabled: false);

            _zipActor = Context
                        .ActorOf(Props.Create <ZipActor>()
                                 .WithRouter((new RoundRobinPool(_numberOfFolders))
                                             .WithSupervisorStrategy(strategy)), "Zip");
        }
Ejemplo n.º 9
0
 public static EnumDecisionReturn Show(EnumDecisionType decision, string message, string caption, EnumDecisionReturn decisionReturn, EnumDecisionIcon icon)
 {
     using (Decider decider = new Decider())
     {
         return(decider.Decide(decision, message, caption, decisionReturn, decisionReturn, "MessageDisplayHelper", false, icon));
     }
 }
Ejemplo n.º 10
0
 public override IEnumerable <EliminationDecider> FindDeciders(Func <EliminationDecider, bool> filter)
 {
     foreach (var match in Decider.FindDeciders(filter))
     {
         yield return(match);
     }
 }
Ejemplo n.º 11
0
        protected override SupervisorStrategy SupervisorStrategy()
        {
            return(new OneForOneStrategy( //or AllForOneStrategy
                       maxNrOfRetries: 10,
                       withinTimeRange: TimeSpan.FromSeconds(30),
                       decider: Decider.From(x =>
            {
                // if the error is because the franchise is not active yet,
                // then we can just resume.
                if (x is InactiveFranchiseException)
                {
                    return Directive.Resume;
                }

                // if it is an unknown francise id, then we have a message
                // that has been routed to the wrong actor, so the error
                // is really in the caller.
                else if (x is UnknownFranchiseException)
                {
                    return Directive.Resume;
                }

                // For other problems, we should reboot the actor.  This will
                // re-load it from persistance (if this demo had persistance enabled)
                else
                {
                    return Directive.Restart;
                }
            })));
        }
Ejemplo n.º 12
0
            public Logic(QueueSource source, Attributes attributes) : base(source.Shape)
            {
                _source  = source;
                _decider = attributes.GetDeciderOrDefault();

                SetHandler(source.Out, PullQueue);
            }
Ejemplo n.º 13
0
    private static Decider GetRandomDecider(int inputsCount, int neuronsCount, int outputsCount)
    {
        var decider = new Decider(inputsCount, neuronsCount, outputsCount);

        decider.SetRandomValues();
        return(decider);
    }
Ejemplo n.º 14
0
            public Logic(MaybeSelectMultipleValues <T> stage, Attributes inheritedAttributes) : base(stage.Shape)
            {
                this._stage   = stage;
                this._decider = inheritedAttributes.GetAttribute(new ActorAttributes.SupervisionStrategy(Deciders.StoppingDecider))
                                .Decider;

                this.SetHandler(stage._in, stage._out, this);
            }
Ejemplo n.º 15
0
 protected override SupervisorStrategy SupervisorStrategy()
 {
     return(new OneForOneStrategy(
                Decider.From(Directive.Resume,
                             Directive.Stop.When <ActorInitializationException>(),
                             Directive.Stop.When <ActorKilledException>(),
                             Directive.Stop.When <DeathPactException>())));
 }
Ejemplo n.º 16
0
    private static void TestPickOneForMe()
    {
        SmartSquare[,] dumbSquares = SmartSquare.StandardBoardSetUp();

        Decider game = new Decider(dumbSquares);

        game = game.Pick(game.PickOneForMe());
    }
Ejemplo n.º 17
0
 protected override SupervisorStrategy SupervisorStrategy()
 {
     return(new OneForOneStrategy(maxNrOfRetries: 100, withinTimeMilliseconds: 1000, loggingEnabled: true,
                                  decider: Decider.From(x =>
     {
         return Directive.Restart;
     })));
 }
Ejemplo n.º 18
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected override SupervisorStrategy SupervisorStrategy()
 {
     return(new OneForOneStrategy(maxNrOfRetries: 5, withinTimeMilliseconds: 2000,
                                  decider: Decider.From(x =>
     {
         return Directive.Stop;
     })));
 }
Ejemplo n.º 19
0
 /// <inheritdoc />
 protected override SupervisorStrategy SupervisorStrategy()
 {
     return(new OneForOneStrategy(10, TimeSpan.FromSeconds(10),
                                  Decider.From(x =>
     {
         var result = Directive.Restart;
         return result;
     })));
 }
Ejemplo n.º 20
0
    //---------------toggle computer above-----------------

    //-----------------on start up stuff below, also SyncWithGame----------------------------
    /// <summary>
    /// refresh button calls this
    /// </summary>
    public void SetUpNewGame()
    {
        Debug.Log("Setting up new Game");
        CurrentPlayer = player1;
        game          = new Decider(SmartSquare.StandardBoardSetUp());
        SetComputerPlayerIcon();
        SetComputerIcon();
        SyncWithGame();
    }
Ejemplo n.º 21
0
    public void Initialize(ActorStack stack)
    {
        this.myStack = stack;

        stateManager = Instantiate(stateManagerObject, transform).GetComponent <StateManager>();
        stateManager.Initialize(this);
        decider = Instantiate(deciderObject, transform).GetComponent <Decider>();
        decider.Initialize(this);
    }
Ejemplo n.º 22
0
    public void Function()
    {
        string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)");

        // Save
        FileSelectDecisionContext fsdcSave = new FileSelectDecisionContext();

        fsdcSave.Title             = "Datei auswählen";
        fsdcSave.OpenFileFlag      = false;
        fsdcSave.CustomDefaultPath = projectPath;
        fsdcSave.AllowMultiSelect  = false;
        fsdcSave.DefaultExtension  = "txt";
        fsdcSave.AddFilter("Textdatei (*.txt)", "*.txt");
        fsdcSave.AddFilter("Alle Dateien (*.*)", "*.*");

        Decider            deciderSave  = new Decider();
        EnumDecisionReturn decisionSave = deciderSave.Decide(fsdcSave);

        if (decisionSave == EnumDecisionReturn.eCANCEL)
        {
            return;
        }

        string     fullFileNameSave = fsdcSave.GetFiles()[0];
        FileStream fileStream       = File.Create(fullFileNameSave);

        fileStream.Dispose();
        MessageBox.Show("Datei wurde gespeichert:" + Environment.NewLine +
                        fullFileNameSave);

        // Open
        FileSelectDecisionContext fsdcOpen = new FileSelectDecisionContext();

        fsdcOpen.Title             = "Datei auswählen";
        fsdcOpen.OpenFileFlag      = true;
        fsdcOpen.CustomDefaultPath = projectPath;
        fsdcOpen.AllowMultiSelect  = false;
        fsdcOpen.DefaultExtension  = "txt";
        fsdcOpen.AddFilter("Textdatei (*.txt)", "*.txt");
        fsdcOpen.AddFilter("Alle Dateien (*.*)", "*.*");

        Decider            deciderOpen  = new Decider();
        EnumDecisionReturn decisionOpen = deciderOpen.Decide(fsdcOpen);

        if (decisionOpen == EnumDecisionReturn.eCANCEL)
        {
            return;
        }

        string fullFileNameOpen = fsdcOpen.GetFiles()[0];

        MessageBox.Show("Datei wurde geöffnet:" + Environment.NewLine +
                        fullFileNameOpen);
    }
Ejemplo n.º 23
0
        public Tree BuildTree()
        {
            if (InstancesAreSameClass || Instances.All(f => f.Features.Count() == 1))
            {
                return(LeafTreeForRemainingFeatures());
            }

            var best = Decider.SelectBestAxis(this);

            return(SplitByAxis(best));
        }
Ejemplo n.º 24
0
    public Decider Clone()
    {
        Decider clone = new Decider(-1, -1, -1);

        clone._wanters = new Wanter[_wanters.Length];
        for (int i = 0; i < _wanters.Length; i++)
        {
            clone._wanters [i] = _wanters [i].Clone();
        }
        return(clone);
    }
Ejemplo n.º 25
0
 protected override SupervisorStrategy SupervisorStrategy()
 {
     return(new OneForOneStrategy(
                Decider.From(x => {
         if (x is StripeException)
         {
             return Directive.Resume;
         }
         return Directive.Restart;
     })
                ));
 }
Ejemplo n.º 26
0
 public OpenMacroDialog()
 {
     decider = new Decider();
     fileSelectDecisionContext                  = new FileSelectDecisionContext("WindowMacroSelector", EnumDecisionReturn.eCANCEL);
     fileSelectDecisionContext.Title            = "Makro auswählen";
     fileSelectDecisionContext.AllowMultiSelect = false;
     fileSelectDecisionContext.DefaultExtension = "ema";
     fileSelectDecisionContext.AddFilter("Fenstermakro (*.ema)", "*.ema");
     fileSelectDecisionContext.AddFilter("Alle Dateien (*.*)", "*.*");
     fileSelectDecisionContext.CustomDefaultPath = PathMap.SubstitutePath("$(MD_MACROS)");
     this.File = "";
 }
Ejemplo n.º 27
0
        public void CanSerializeRandomPool()
        {
            var decider = Decider.From(
             Directive.Restart,
             Directive.Stop.When<ArgumentException>(),
             Directive.Stop.When<NullReferenceException>());

            var supervisor = new OneForOneStrategy(decider);

            var message = new RandomPool(10, new DefaultResizer(0, 1), supervisor, "abc");
            AssertEqual(message);
        }
Ejemplo n.º 28
0
        public void CanSerializeTailChoppingPool()
        {
            var decider = Decider.From(
             Directive.Restart,
             Directive.Stop.When<ArgumentException>(),
             Directive.Stop.When<NullReferenceException>());

            var supervisor = new OneForOneStrategy(decider);

            var message = new TailChoppingPool(10, null, supervisor, "abc", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(2));
            AssertEqual(message);
        }
Ejemplo n.º 29
0
        public void CanSerializeScatterGatherFirstCompletedPool()
        {
            var decider = Decider.From(
             Directive.Restart,
             Directive.Stop.When<ArgumentException>(),
             Directive.Stop.When<NullReferenceException>());

            var supervisor = new OneForOneStrategy(decider);

            var message = new ScatterGatherFirstCompletedPool(10, null, supervisor, "abc", TimeSpan.MaxValue);
            AssertEqual(message);
        }
Ejemplo n.º 30
0
        public void CanSerializeSmallestMailboxPool()
        {
            var decider = Decider.From(
             Directive.Restart,
             Directive.Stop.When<ArgumentException>(),
             Directive.Stop.When<NullReferenceException>());

            var supervisor = new OneForOneStrategy(decider);

            var message = new SmallestMailboxPool(10, null, supervisor, "abc");
            AssertEqual(message);
        }
Ejemplo n.º 31
0
        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "Please wait! The Menu is being generated based on your selection!";
            textBox1.Text = string.Empty;

            string restaurantCountry = string.Empty;
            string restaurantCategory = string.Empty;
            string outputFormat = string.Empty;
            string inputReader = string.Empty;

            var FD = new System.Windows.Forms.OpenFileDialog();
            if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                selectedPath = FD.FileName;
                inputFileExtension = Path.GetExtension(FD.FileName);
            }

            if (britishRadioBtn.Checked)
            {
                restaurantCountry = "British";
                inputReader = inputFileExtension.Replace('.',' ').Trim(); // "xml";
            }
            else if (americanRadioBtn.Checked)
            {
                restaurantCountry = "American";
                inputReader = inputFileExtension.Replace('.', ' ').Trim(); //"json";
            }

            if(dinerRadioBtn.Checked)
            {
                restaurantCategory = "Diner";
            }
            else if (eveningRadioBtn.Checked)
            {
                restaurantCategory = "Evening";
            }
            else if(allDayRadioBtn.Checked)
            {
                restaurantCategory = "All";
            }

            if(plainTextRadioBtn.Checked)
            {
                outputFormat = "txt";
            }
            else if(htmlRadioBtn.Checked)
            {
                outputFormat = "html";
            }
            else if(xmlRadioBtn.Checked)
            {
                outputFormat = "xml";
            }

            Decider objDecider = new Decider(inputReader, outputFormat);
            string fileExtension = Path.GetExtension(selectedPath);
            result = objDecider.getMenuDetail(restaurantCountry, restaurantCategory, selectedPath, fileExtension);

            if (!string.IsNullOrEmpty(result))
            {
                var savePath = Path.Combine(Application.StartupPath, "Menu." + outputFormat);
                File.WriteAllText(savePath, result);

                label1.Text = string.Format(@"Menu generated and saved. The path is displayed below in the text box. If you want to save the output to another location click the 'Save File' button.");
                textBox1.Text = savePath;
            }
            else
            {
                label1.Text = "No File generated";
            }
        }