Beispiel #1
0
        /// <summary>Initializes the systems of this application.</summary>
        private void InitializeSystems()
        {
            this.viewEngine = new ViewEngine {
                ReplaceNewLine = false
            };
            this.viewEngine.AddContext("MudAttributes", MudEngineAttributes.Instance);

            this.Notify(this.DisplayStartup());
            this.Notify("Starting Application.");

            // Add environment variables needed by the program.
            VariableProcessor.Set("app.path", AppDomain.CurrentDomain.BaseDirectory);

            // Find and prepare all the application's most recent systems from those discovered by MEF.
            var systemExporters = this.GetLatestSystems();

            CoreManager.Instance.SubSystems = new List <ISystem>();
            foreach (var systemExporter in systemExporters)
            {
                CoreManager.Instance.SubSystems.Add(systemExporter.Instance);
            }

            CoreManager.Instance.SubscribeToSystem(this);
            CoreManager.Instance.Start();

            this.Notify("All services are started. Server is fully operational.");
        }
    // Use this for initialization
    void Start()
    {
        Debug.Log(testText.text);
        textLoader = new TextLoader(testText.text);
        resourceLoader.Initialize(this);

        sounder = new SoundProcessor();
        sounder.Initialize(resourceLoader);
        varProcessor = new VariableProcessor();
        varProcessor.Initialize(textLoader);
        sceneProcessor = new SceneProcessor();
        sceneProcessor.Initialize(this, resourceLoader);
        messenger.Initialize(textLoader, varProcessor);
        imager.Initialize(resourceLoader);

        processorList = new List <CommandProcessor>();
        processorList.Add(messenger);
        processorList.Add(imager);
        processorList.Add(sounder);
        processorList.Add(varProcessor);
        processorList.Add(sceneProcessor);
        processIndex = -1;

        onEnd = false;
    }
        public void VariableProcessor_ExtractComplexVariables_ReturnVariableList()
        {
            // Arrange
            var expression = "-x12 + IsValid + min(x1, -3.14) + max(a+b, x+1) / -sqrt(X11) + m_name * CalculateSalary(\"Salary (includes taxes)\", -1+x, 2.5x)";

            processor = new VariableProcessor();

            // Act
            var match  = processor.ExtractVariables(expression);
            var result = match.Variables;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreNotEqual(string.Empty, result);
            Assert.AreEqual(8, result.Count);

            Assert.IsTrue(result.Contains("x12"));
            Assert.IsTrue(result.Contains("IsValid"));
            Assert.IsTrue(result.Contains("x1"));
            Assert.IsTrue(result.Contains("a"));
            Assert.IsTrue(result.Contains("b"));
            Assert.IsTrue(result.Contains("x"));
            Assert.IsTrue(result.Contains("X11"));
            Assert.IsTrue(result.Contains("m_name"));
        }
    public void Initialize(TextLoader loader, VariableProcessor vProcessor)
    {
        trigger = 'm';

        commandList = new List <Func <bool> >();
        commandList.Add(WriteMessage);//default command
        commandList.Add(WaitInitialize);
        commandList.Add(Wait);
        commandList.Add(InitializeBox);
        commandList.Add(ChangeSpeed);
        commandList.Add(AddChoice);//[m\5\〇〇]
        commandList.Add(WaitSelect);
        commandList.Add(EnableAuto);
        commandList.Add(DisableAuto);

        waitImage.enabled = false;

        messageWaiter = new Waiter(defaultCount);
        inputWaiter   = new Waiter(inputWaitCount);

        messageLengthCounter = new Counter(1, true);
        messageBoxCounter    = new Counter(500);

        lineCounter   = new Counter(maxLineCount);
        lineUpCounter = new Counter(10);

        waitCounter = new Counter(waitCount);
        autoWaitLim = 30;
        autoWaiter  = new Waiter(autoWaitLim);

        choicesCounter = new Counter(0);
        FocusChoice(choicesCounter.Now, true);
        foreach (Transform t in choicesTransform)
        {
            EventTrigger trigger = t.gameObject.AddComponent <EventTrigger>();
            trigger.triggers = new List <EventTrigger.Entry>();

            EventTrigger.Entry entry = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.PointerEnter;
            entry.callback.AddListener(x => ChangeChoice(t.GetSiblingIndex()));
            trigger.triggers.Add(entry);

            t.GetComponent <Button>().onClick.AddListener(ClickChoice);
            t.gameObject.SetActive(false);
        }
        this.loader  = loader;
        varProcessor = vProcessor;
    }
        public void TestMethod1()
        {
            VariableProcessor variableProcessor = new VariableProcessor(
                new Dictionary <string, string>()
            {
                { "nick", (string)this.configurationProvider("nick") },
                { "path", @"c:\windows\System32" }
            },
                new Dictionary <string, string>()
            {
                { "version", "1.3" }
            },
                new Dictionary <string, Func <string, string> >()
            {
                { "tolower", s => s.ToLower() },
                { "sslsafe", s => s.Replace(".", "-") },
            });

            Assert.AreEqual("subject: shade, 1-3", variableProcessor.ProcessValue("subject: {var:nick}, {env:version:sslSafe}"));
        }
Beispiel #6
0
        public async Task <IHttpActionResult> Update([FromBody] VariableInfo variableInfo)
        {
            try
            {
                if (variableInfo == null)
                {
                    var message = "Variable Info is null";
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, message)));
                }
                var variableProcessor = new VariableProcessor(WebApiApplication.PviApp);
                await variableProcessor.UpdateVariables(variableInfo.CpuName, variableInfo.Variables);

                return(Ok());
            }
            catch (Exception ex)
            {
                ex.Data.Add("VariableController.Operation", "Update");
                _log.Error(ex.Message, ex);
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #7
0
        public async Task <IHttpActionResult> GetDetails(string id)
        {
            try
            {
                var variableProcessor = new VariableProcessor(WebApiApplication.PviApp);

                var settings = await variableProcessor.GetVariableDetails(id);

                if (settings == null)
                {
                    var message = "Variables not found";
                    return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, message)));
                }
                return(Ok(settings));
            }
            catch (Exception ex)
            {
                ex.Data.Add("VariableController.Operation", "GetVariables");
                _log.Error(ex.Message, ex);
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
 public void Init()
 {
     // Arrange
     processor = new VariableProcessor();
 }