예제 #1
0
 void DoStuff(IEnumerable <Thingie> things)
 {
     foreach (var thing in things)
     {
         GetAction(thing.condition)(); // <-- note the extra parens here
     }
 }
예제 #2
0
        protected override void DoProcess(ConsoleParameter p, DataCollection d)
        {
            _p = p;
            _d = d;
            ConsoleLogicData pd = new ConsoleLogicData();

            pd.Args = p.ExtentionObj.args;
            GetAction(_p.Action)(pd);
        }
        public virtual void Run(CancellationToken cancellation)
        {
            while (!cancellation.IsCancellationRequested)
            {
                var processorName = GetType().FullName;
                logger.Info(@"[ServiceStack.Webhooks.Azure.Worker.BasicContinuousProcessor] Running Processor: '{0}'".Fmt(processorName));
                GetAction(cancellation)();

                Task.Delay(GetInterval(), cancellation).Wait(cancellation);
            }
        }
예제 #4
0
        /// <summary>
        /// Writes the record to the CSV file.
        /// </summary>
        /// <typeparam name="T">The type of the record.</typeparam>
        /// <param name="record">The record to write.</param>
        public virtual void WriteRecord <T>(T record)
        {
            CheckDisposed();

            if (HasHeaderRecord && !hasHeaderBeenWritten)
            {
                WriteHeader(GetProperties <T>());
            }

            GetAction <T>()(this, record);

            NextRecord();
        }
예제 #5
0
        /// <summary>
        /// Writes the list of records to the CSV file.
        /// </summary>
        /// <typeparam name="T">The type of the record.</typeparam>
        /// <param name="records">The list of records to write.</param>
        public virtual void WriteRecords <T>(IEnumerable <T> records)
        {
            CheckDisposed();

            if (HasHeaderRecord && !hasHeaderBeenWritten)
            {
                WriteHeader(GetProperties <T>());
            }

            foreach (var record in records)
            {
                GetAction <T>()(this, record);
                NextRecord();
            }
        }
예제 #6
0
        public bool CGetData(ITableSource table, IEnumerable <string> keys, Action guiCallback)
        {
            if (m_wasError)
            {
                return(true);
            }
            if (m_loadedFullList)
            {
                return(true);
            }
            List <string> notloaded = new List <string>();

            lock (m_fkCaptions)
            {
                foreach (string key in keys)
                {
                    if (!m_fkCaptions.ContainsKey(key) && !String.IsNullOrEmpty(key))
                    {
                        notloaded.Add(key);
                    }
                }
            }
            if (notloaded.Count == 0)
            {
                return(true);
            }
            GetAction act = new GetAction {
                GuiCallback = guiCallback, Info = this, Keys = notloaded, Table = table
            };

            table.Connection.BeginInvoke(PriorityLevel.Low, true, (Action)act.Run, MainWindow.Instance.Invoker.CreateInvokeCallback(act.OnFinish));
            return(false);
        }
예제 #7
0
        public void OnLocationChanged(Location location)
        {
            _Latitude = location.Latitude.ToString();
            _longtude = location.Longitude.ToString();

            if (isLoggin)
            {
                GetAction action = Config.GetActions.Where(o => o.Code == ActionCode.location).SingleOrDefault();

                string status = string.Empty;
                if (firstLog == true)
                {
                    status = "1";
                    //  StartLocation(location);
                }
                else if (lastLog == true)
                {
                    status = "3";
                    //  StopUpdateLocation(location);
                }
                else
                {
                    status = "2";
                }

                object[] param = new[] { _Latitude, _longtude, status, txtRefNo.Text };

                if (_service == null)
                {
                    _service = new POCService();
                }
                _service.GetPost(this, action, param);
            }
        }
예제 #8
0
        public async Task Invoke_Should_ReturnNotFound_When_ThingNotExists()
        {
            int code = default;

            _response.StatusCode = Arg.Do <int>(args => code = args);

            var thing = _fixture.Create <string>();

            _thingActivator.CreateInstance(_service, thing)
            .Returns(null as Thing);

            _routeValue.GetValue <string>("thing")
            .Returns(thing);

            _routeValue.GetValue <string>("name")
            .Returns(_fixture.Create <string>());

            await GetAction.Invoke(_httpContext);

            code.Should().Be((int)HttpStatusCode.NotFound);

            _thingActivator
            .Received(1)
            .CreateInstance(_service, thing);
        }
예제 #9
0
        public async Task Invoke_Should_Return404_When_ActionDoesNotContainsAction()
        {
            int code = default;

            _response.StatusCode = Arg.Do <int>(args => code = args);

            var thingId = _fixture.Create <string>();
            var thing   = Substitute.For <Thing>();

            _thingActivator.CreateInstance(_service, thingId)
            .Returns(thing);

            thing.Actions
            .Returns(new ActionCollection());

            _routeValue.GetValue <string>("thing")
            .Returns(thingId);

            _routeValue.GetValue <string>("name")
            .Returns(_fixture.Create <string>());

            await GetAction.Invoke(_httpContext);

            code.Should().Be((int)HttpStatusCode.NotFound);

            _thingActivator
            .Received(1)
            .CreateInstance(_service, thingId);
        }
예제 #10
0
        public async void GetObject(IServiceDeletegate <object> handler, GetAction action, params object[] prms)
        {
            try
            {
                var uri = new Uri(String.Format(Config.BASE_SERVICE_URL + action.Url + String.Join("/", prms), string.Empty));


                _response = await _httpClient.GetAsync(uri).ConfigureAwait(false);;
                if (_response.IsSuccessStatusCode)
                {
                    JsonSerializerSettings serSettings = new JsonSerializerSettings();
                    serSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    var data = _response.Content.ReadAsStringAsync();

                    handler.HandleServiceResults(data.Result, true, string.Empty);
                }
                else
                {
                    handler.HandleServiceResults(null, false, "Failed to connect to the web server, verify that you have airtime or switch off mobile data to work offline");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("A task was canceled"))
                {
                    handler.HandleServiceResults(null, false, "Failed to connect to the web server, verify that you have airtime or switch off mobile data to work offline");
                }
                else
                {
                    handler.HandleServiceResults(null, false, ex.Message);
                }
            }
        }
예제 #11
0
        public object GetObject(GetAction action, params object[] param)
        {
            string result = string.Empty;

            try
            {
                var uri = new Uri(String.Format(Config.BASE_SERVICE_URL + action.Url + String.Join("/", param), string.Empty));
                response = httpClient.GetAsync(uri).Result;
                if (response.IsSuccessStatusCode)
                {
                    JsonSerializerSettings serSettings = new JsonSerializerSettings();
                    serSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                    var data = response.Content.ReadAsStringAsync();

                    return(data.Result);
                }
                else
                {
                    return("Failed to connect to the web server, verify that you have airtime or switch off mobile data to work offline");
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("A task was canceled"))
                {
                    return("Failed to connect to the web server, verify that you have airtime or switch off mobile data to work offline");
                }
                else
                {
                    return(ex.Message);
                }
            }
        }
예제 #12
0
파일: Task.cs 프로젝트: RamiAhmed/R2R_Test2
    public Task Initialize(GetAction action)
    {
        this.Action = new Action(action);
        this.Condition = null;

        return this;
    }
예제 #13
0
파일: Task.cs 프로젝트: RamiAhmed/R2R_Test2
    public Task Initialize(GetAction action, GetCondition condition)
    {
        this.Action = new Action(action);
        this.Condition = new Condition(condition);

        return this;
    }
예제 #14
0
        private int _lastIndex; // INDEX OF LAST SPAWNED MONSTER

        #endregion Fields

        #region Constructors

        public LevelManager()
        {
            MoveMonster = false;
            // Creating Timer for Wave
            GetAction obj = new GetAction(ChangeWaveStatus);
            AccessFunction = new Action(obj);
            WaveTimerBreak = new TimeSpan(0, 0, 0, 30, 0);
            WaveServices.TimerFactory.CreateTimer("Wave_Break", Static.Const.L_Wave_Break_Timer[
                Static.Const.List_Counter], AccessFunction);

            WaveClock = new Stopwatch();
            WaveClock.Start();

            _counter = 0;
            BaseTowerEntity = new Entity("Tower_set");
            BaseMobEntity = new Entity("Monster_Set");
            TowersBar = new Entity("Towers_Bar");
            ScreenLayout = new Entity("Screen_layout");

            Player = new Player_Classes.Player_Base(20, 500);

            MonsterList = new List<Mobs.Mob_Base>();
            TowersList = new List<Towers_Classes.Tower_Base>();

            Level = new Map_Base("Content/Maps/Test/", 5, 0, 0, 4, 4);

            MonsterList.Add(new Mobs.Mob_Base(Level.starting_x, Level.starting_y, Level.map,BaseMobEntity.NumChildrens));
            _lastIndex= MonsterList.Count -1;

            BaseMobEntity.AddChild(MonsterList[0].Mob);

            Create_Layout();
            Create_Towers_Bar();
        }
예제 #15
0
        public LoadRedis(Func <string> action, ContainerBuilder builder)
            : base(action, builder)
        {
            var connection = GetAction.Invoke();

            RedisManager.Initialize(connection);
        }
        public static ServerMessage ReadFrom(System.IO.BinaryReader reader)
        {
            try
            {
                switch (reader.ReadInt32())
                {
                case GetAction.TAG:
                    return(GetAction.ReadFrom(reader));

                case Finish.TAG:
                    return(Finish.ReadFrom(reader));

                case DebugUpdate.TAG:
                    return(DebugUpdate.ReadFrom(reader));

                default:
                    throw new System.Exception("Unexpected tag value");
                }
            }
            catch (Exception e)
            {
                Environment.Exit(1);
                throw;
            }
        }
예제 #17
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            Console.WriteLine("BtnLogin Entry");



            _lblError.Text = string.Empty;
            if (_txtUserName.Text.Length == 0 || _txtPassword.Text.Length == 0)
            {
                _lblError.Text = "Username or password is required";
            }
            else
            {
                GetAction action = Config.GetActions.Where(o => o.Code == ActionCode.login).SingleOrDefault();

                if (action == null)
                {
                    throw new Exception(Config.ErrMissingAction);
                }

                object[] param = new[] { _txtUserName.Text, _txtPassword.Text };

                _service = new POCService();
                _progressBar.Visibility = ViewStates.Visible;
                Console.WriteLine("BtnLogin Calling the service");
                _service.GetObject(this, action, param);
            }

            Console.WriteLine("BtnLogin Exit");
        }
예제 #18
0
파일: Task.cs 프로젝트: RamiAhmed/R2R_Test2
    public Task Initialize(GetAction action, float priority)
    {
        this.Action = new Action(action);
        this.Condition = null;
        this.Priority = priority;

        return this;
    }
            public static new GetAction ReadFrom(System.IO.BinaryReader reader)
            {
                var result = new GetAction();

                result.PlayerView     = Model.PlayerView.ReadFrom(reader);
                result.DebugAvailable = reader.ReadBoolean();
                return(result);
            }
예제 #20
0
        public List <Song> GetTopSongsByDurationChart()
        {
            GetAction <Song> getAction = new GetAction <Song>();

            getAction.ProcedureName   = "dbo.Songs_GetTopByDuration";
            getAction.IDataRecordFunc = Song.FromDataRecord;
            return(getAction.Execute());
        }
예제 #21
0
        public List <Song> GetDecadeSongChart([FromUri] short decade)
        {
            GetAction <Song> getAction = new GetAction <Song>();

            getAction.AddParameter(new SqlParameter("@decade", decade));
            getAction.ProcedureName   = "dbo.Songs_GetDecade";
            getAction.IDataRecordFunc = Song.FromDataRecord;
            return(getAction.Execute());
        }
예제 #22
0
        private void button4_Click(object sender, EventArgs e)
        {
            GetAction Divition = new GetAction(Process.getQuotient);

            int a = Convert.ToInt32(textBox1.Text);
            int b = Convert.ToInt32(textBox2.Text);

            MessageBox.Show("Equal to:" + " " + Divition(a, b).ToString());
        }
예제 #23
0
        public List <Song> GetArtistSongChart([FromUri] int artist)
        {
            GetAction <Song> getAction = new GetAction <Song>();

            getAction.AddParameter(new SqlParameter("@artistId", artist));
            getAction.ProcedureName   = "dbo.Songs_GetArtist";
            getAction.IDataRecordFunc = Song.FromDataRecord;
            return(getAction.Execute());
        }
예제 #24
0
        private void Divition_Click(object sender, EventArgs e)
        {
            GetAction DivAction = new GetAction(formula.getDiv);

            int a = Convert.ToInt32(num1.Text);
            int b = Convert.ToInt32(num2.Text);

            MessageBox.Show("The Quotient is:" + " " + DivAction(a, b).ToString());
        }
예제 #25
0
        private void Multiply_Click(object sender, EventArgs e)
        {
            GetAction MultiAction = new GetAction(formula.getMulti);

            int a = Convert.ToInt32(num1.Text);
            int b = Convert.ToInt32(num2.Text);

            MessageBox.Show("The Product is:" + " " + MultiAction(a, b).ToString());
        }
예제 #26
0
        private void Subtract_Click(object sender, EventArgs e)
        {
            GetAction SubAction = new GetAction(formula.getSub);

            int a = Convert.ToInt32(num1.Text);
            int b = Convert.ToInt32(num2.Text);

            MessageBox.Show("The Difference is:" + " " + SubAction(a, b).ToString());
        }
예제 #27
0
        public List <Song> GetYearSongChart([FromUri] short year)
        {
            GetAction <Song> getAction = new GetAction <Song>();

            getAction.AddParameter(new SqlParameter("@year", year));
            getAction.ProcedureName   = "dbo.Songs_GetYear";
            getAction.IDataRecordFunc = Song.FromDataRecord;
            return(getAction.Execute());
        }
예제 #28
0
        private void button2_Click(object sender, EventArgs e)
        {
            GetAction Subtraction = new GetAction(Process.getDifference);

            int a = Convert.ToInt32(textBox1.Text);
            int b = Convert.ToInt32(textBox2.Text);

            MessageBox.Show("Equal to:" + " " + Subtraction(a, b).ToString());
        }
예제 #29
0
        private void button3_Click(object sender, EventArgs e)
        {
            GetAction Multiplication = new GetAction(Process.getProduct);

            int a = Convert.ToInt32(textBox1.Text);
            int b = Convert.ToInt32(textBox2.Text);

            MessageBox.Show("Equal to:" + " " + Multiplication(a, b).ToString());
        }
예제 #30
0
 public CreateProductHttpAction(GetAction get, ExecuteAction execute, RevertAction revert, PostProductRequest createProductRequest) : base(get, execute, revert)
 {
     CreateRequest = createProductRequest;
     GetRequest    = new GetProductRequest {
         ExternalIdentifier = createProductRequest.ExternalIdentifier
     };
     DeleteRequest = new DeleteProductRequest {
         ExternalIdentifier = createProductRequest.ExternalIdentifier
     };
 }
예제 #31
0
파일: ActionTest.cs 프로젝트: ayuexs/C-
    // Start is called before the first frame update
    void Start()
    {
        // var a1 = new DelayAction(2f);
        // var a2 = new DelayAction(5f);
        // var a3 = new DelayAction(8f);

        // a1.BindCallback(ACTION_CALLBACK_TYPE.COMPLETED, () =>
        // {
        //     Debug.Log("a1 completed " + Time.realtimeSinceStartup);
        // });
        // a2.BindCallback(ACTION_CALLBACK_TYPE.COMPLETED, () =>
        // {
        //     Debug.Log("a2 completed " + Time.realtimeSinceStartup);
        // });
        // a3.BindCallback(ACTION_CALLBACK_TYPE.COMPLETED, () =>
        // {
        //     Debug.Log("a3 completed " + Time.realtimeSinceStartup);
        // });

        // var sq = new SequenceAction(a1, a2, a3);
        // sq.BindCallback(ACTION_CALLBACK_TYPE.COMPLETED, () =>
        // {
        //     Debug.Log("SequenceAction completed " + Time.realtimeSinceStartup);
        // });
        // sq.Start();

        // GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        // cube.transform.position = new Vector3(0, 0, 0);
        // cube.transform.DOMove(new Vector3(10, 0, 0), 2).SetAutoKill(false);
        // cube.transform.D

        // var DGA1 = new DGMoveAction(cube.transform, cube.transform.position, new Vector3(10, 0, 0), 2);
        // var DGA2 = new DGRotateAction(cube.transform, cube.transform.eulerAngles, new Vector3(0, 180, 0), 2);
        // var DGA3 = new DGScaleAction(cube.transform, cube.transform.localScale, new Vector3(3, 3, 3), 2);
        // new SequenceAction(DGA1, DGA2, DGA3).Start();

        // var DGA4 = new DGJumpAction(cube.transform, cube.transform.position, new Vector3(10, 0, 0), 10, 1, 1).SetRestoreValue(true);
        // new RepeatAction(DGA4, -1).Start();

        var http1 = new GetAction("http://192.168.1.253/platform/devConfig.json");

        http1.BindCallback <HttpResponseMessage>(ACTION_CALLBACK_TYPE.HTTP_SUCCEED, (rep) =>
        {
            Debug.Log("HTTP Get Succeed! ");
        });
        http1.BindCallback <HttpResponseMessage>(ACTION_CALLBACK_TYPE.HTTP_FAILLED, (rep) =>
        {
            Debug.Log("HTTP Get Failled! " + rep.StatusCode);
        });
        http1.SetTimeout(30);

        new RepeatAction(http1, -1).Start();
    }
예제 #32
0
        private void Listen()
        {
            try {
                _listener = new HttpListener();
                _listener.Prefixes.Add("http://*:" + Port + "/");
                _listener.Start();
            }
            catch (Exception ex) {
                OnException?.Invoke(ex);
                return;
            }

            ThreadPool.QueueUserWorkItem(o => {
                try {
                    while (_listener.IsListening)
                    {
                        ThreadPool.QueueUserWorkItem(c => {
                            if (!(c is HttpListenerContext context))
                            {
                                throw new ArgumentNullException(nameof(context));
                            }
                            try {
                                GetAction(context.Request.Url.AbsolutePath)(ref context);
                            }
                            catch (Exception ex) {
                                MessageBox.Show(ex.Message);
                                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                            }
                            finally {
                                context.Response.OutputStream.Close();
                            }
                        }, _listener.GetContext());
                    }
                }
                catch {
                    // ignored
                }
            });
        }
예제 #33
0
 public static object Get(string url, GetAction action)
 {
     try
     {
         WebClient wc = new WebClient();
         ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)SecurityProtocolType.Tls | (System.Net.SecurityProtocolType)SecurityProtocolType.Ssl3 | (System.Net.SecurityProtocolType)SecurityProtocolType.Tls11 | (System.Net.SecurityProtocolType)SecurityProtocolType.Tls12;
         ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult;
         string cmd = wc.DownloadString(url);
         wc.Dispose();
         return(action?.Invoke(cmd));
     }
     catch { return(null); }
 }
    IEnumerator GetTextureData(string url, GetTextureAction OnSuccess, GetAction OnFail)
    {
        UnityWebRequest www = UnityWebRequestTexture.GetTexture(url);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.LogError(www.error);
            OnFail(www.error);
        }
        else
        {
            Texture myTexture = ((DownloadHandlerTexture)www.downloadHandler).texture;
            OnSuccess(myTexture);
        }
    }
예제 #35
0
 public Action(GetAction action)
 {
     this.AddAction(action);
 }
예제 #36
0
 public void AddAction(GetAction action)
 {
     this.OnAction += action;
 }
예제 #37
0
 public void RemoveAction(GetAction action)
 {
     this.OnAction -= action;
 }