Ejemplo n.º 1
0
        //处理客户端的请求
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            BaseHandler handler = DictTool.GetValue <OperationCode, BaseHandler>(GameServer.Instance.HandlerDict, (OperationCode)operationRequest.OperationCode);

            if (handler != null)
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
            else
            {
                BaseHandler defaultHandler = DictTool.GetValue <OperationCode, BaseHandler>(GameServer.Instance.HandlerDict, OperationCode.Default);
                defaultHandler.OnOperationRequest(operationRequest, sendParameters, this);
            }
            //switch ((RequestCode)operationRequest.OperationCode)//要是code不在枚举范围内呢?应该用const int?
            //{
            //    case RequestCode.Test:
            //        {
            //            GameServer.log.Info("接收到数据:" + operationRequest.Parameters[1]);
            //            OperationResponse opResponse = new OperationResponse((int)RequestCode.Test, operationRequest.Parameters);
            //            SendOperationResponse(opResponse, sendParameters);//该方法仅能在该函数中调用

            //            EventData eData = new EventData(1, operationRequest.Parameters);
            //            SendEvent(eData, new SendParameters());//可以在该类中任意地方调用,服务端主动通知客户端
            //        }
            //        break;
            //    default: break;
            //}
        }
Ejemplo n.º 2
0
 public XsltHandler(BaseHandler baseHandler)
     : this()
 {
     this.BaseHandler = baseHandler;
     this.RootDirInfo = new DirectoryInfo(Path.Combine("C:\\temp\\", Guid.NewGuid().ToString()));
     this.RootDirInfo.Create();
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Export(
            [FromServices] BaseHandler json, [FromServices] XlsHandler xls, [FromServices] HtmlHandler html, [FromQuery] string format
            )
        {
            try
            {
                IActionResult file = null;
                switch (format.ToLower())
                {
                case "xlsx":
                case "xls":
                    file = this.File(await xls.GetExportAsync(this.UserId), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                    break;

                case "html":
                    file = this.File(await html.GetExportAsync(this.UserId), "text/html");
                    break;

                default:
                    file = this.File(await json.GetExportAsync(this.UserId), "application/json");
                    break;
                }
                return(file);
            }
            catch (Exception e)
            {
                return(this.Ok(e));
            }
        }
Ejemplo n.º 4
0
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            //Dictionary<byte, object> data = operationRequest.Parameters;
            //Object intvalue;
            //Object stringvalue;
            //data.TryGetValue(1, out intvalue);
            //data.TryGetValue(2, out stringvalue);
            //MyServer.Log.Info("得到请求的数据" + intvalue.ToString() + "," + stringvalue.ToString());
            //Dictionary<byte, object> responsedata = new Dictionary<byte, object>();
            //responsedata.Add(1, (int)intvalue + 111);
            //responsedata.Add(2, stringvalue.ToString() + "加上服务器响应");
            //OperationResponse operationresponse = new OperationResponse(1);
            //operationresponse.Parameters = responsedata;
            //SendOperationResponse(operationresponse, sendParameters);

            //Dictionary<byte, object> data2 = new Dictionary<byte, object>();
            //data2.Add(1, (int)intvalue + 100000);
            //data2.Add(2, stringvalue.ToString() + "加上事件的数据");
            //EventData eventdata = new EventData(1, data2);
            //SendEvent(eventdata, new SendParameters());
            BaseHandler handler = DictTool.GetValue(MyServer.Instance.HandlerDict, (OperationCode)operationRequest.OperationCode);

            if (handler != default(BaseHandler))
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
            else
            {
                handler = DictTool.GetValue(MyServer.Instance.HandlerDict, OperationCode.Default);
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
        }
Ejemplo n.º 5
0
        private void UpdatePHtext(ETextItemType ItemType, string txt)
        {
            var itemid = Convert.ToInt32(this.ComponentID);

            List <PluggComponent> comps  = this.PluggContainer.GetComponentList();
            PluggComponent        cToAdd = comps.Find(x => x.PluggComponentId == itemid);
            BaseHandler           bh     = new BaseHandler();

            var comtype = cToAdd.ComponentType;

            PHText phText = bh.GetCurrentVersionText(this.CurrentLanguage, itemid, ItemType);

            phText.Text = txt;
            phText.CultureCodeStatus = ECultureCodeStatus.GoogleTranslated;
            phText.CreatedByUserId   = this.UserID;
            if (this.EditCase == 2)
            {
                phText.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
                bh.SavePhText(phText);
            }
            else
            {
                bh.SavePhTextInAllCc(phText);
            }
            // bh.SavePhText(phText);
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(this.TabID, "", new string[] { "edit=1", "language=" + this.CurrentLanguage }));
        }
Ejemplo n.º 6
0
        private void InitHttpHandler()
        {
            Assembly assembly = typeof(MySqlService).Assembly;

            Type[] types = assembly.GetTypes();

            foreach (var type in types)
            {
                var attributes = type.GetCustomAttributes(typeof(HttpHandlerAttribute), false);

                foreach (var attr in attributes)
                {
                    HttpHandlerAttribute handlerAttribute = (HttpHandlerAttribute)attr;
                    object obj = Activator.CreateInstance(type);

                    BaseHandler baseHandler = obj as BaseHandler;
                    if (baseHandler == null)
                    {
                        log.Warn($"没有继承BaseHandler:{type.Name}");
                        continue;
                    }

                    if (!handlerDic.ContainsKey(handlerAttribute.Tag))
                    {
                        handlerDic.Add(handlerAttribute.Tag, baseHandler);
                    }
                    else
                    {
                        log.Warn($"key值重复:{handlerAttribute.Tag}");
                    }
                }
            }
            log.Info($"handlerCount:{handlerDic.Count}");
        }
Ejemplo n.º 7
0
        public void BindTree()
        {
            BaseHandler bh   = new BaseHandler();
            var         tree = bh.GetCoursePluggsAsTree(CourseId, Language);

            if (tree.Count() == 0)
            {
                if (Page.Request.QueryString["edit"] == "add")
                {
                    btnAddAfter.Visible  = false;
                    btnAddBefore.Visible = false;
                    btnAddChild.Visible  = false;
                    btnAdd.Visible       = true;
                }
                else
                {
                    lblNoCP.Visible         = true;
                    btnRemovePluggs.Enabled = false;
                    btnReorder.Enabled      = false;
                }
            }
            //JavaScriptSerializer TheSerializer = new JavaScriptSerializer();
            //hdnTreeData.Value = TheSerializer.Serialize(tree);
            hdnTreeData.Value = Newtonsoft.Json.JsonConvert.SerializeObject(tree);
        }
 public static void SetReturnValueIfCompositeHandler(this BaseHandler handler, object returnValue)
 {
     if (handler.Cast <ICompositeHandler>(out var castedHandler))
     {
         castedHandler.GetNextNotSkipReturnable().SetReturnValueToNext(returnValue);
     }
 }
Ejemplo n.º 9
0
 private void TryInvoke(BaseHandler handler)
 {
     if (entry.TriggerType == handler.TriggerType)
     {
         entry.Callback.Invoke();
     }
 }
 public static void SetReturnValueIfParametrizedHandler(this BaseHandler handler, object returnValue)
 {
     if (handler.Cast <IParameterContainer>(out var castedHandler))
     {
         castedHandler.SetReturnValue(returnValue);
     }
 }
Ejemplo n.º 11
0
        protected void btnSaveRRt_Click(object sender, EventArgs e)
        {
            var itemid = Convert.ToInt32(this.ComponentID);

            List <PluggComponent> comps  = this.PluggContainer.GetComponentList();
            PluggComponent        cToAdd = comps.Find(x => x.PluggComponentId == itemid);
            BaseHandler           bh     = new BaseHandler();

            var comtype = cToAdd.ComponentType;

            //switch (cToAdd.ComponentType)
            //{
            //    case EComponentType.RichRichText:
            //PHText RichRichText = bh.GetCurrentVersionText(curlan, itemid, ETextItemType.PluggComponentRichRichText);
            //RichRichText.Text = richrichtext.Text;

            PHText objPHtext = new PHText(System.Net.WebUtility.HtmlDecode(richrichtext.Text), this.CurrentLanguage, ETextItemType.PluggComponentRichRichText);

            objPHtext.CultureCodeStatus = ECultureCodeStatus.GoogleTranslated;
            objPHtext.ItemId            = itemid;
            objPHtext.CreatedByUserId   = this.UserID;

            if (EditCase == 2)
            {
                objPHtext.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
            }
            bh.SavePhTextInAllCc(objPHtext);

            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(this.TabID, "", new string[] { "edit=1", "language=" + this.CurrentLanguage }));
        }
Ejemplo n.º 12
0
        protected void BtnRemove_Click(object sender, EventArgs e)
        {
            BaseHandler plugghandler = new BaseHandler();

            plugghandler.DeleteComponent(this.PluggContainer, this.Order);
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(this.TabID, "", new string[] { "edit=1", "language=" + this.CurrentLanguage }));
        }
Ejemplo n.º 13
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                Debug.Log("You selected the " + hit.transform.name); // ensure you picked right object
                //Debug.DrawRay(hit.point, 10f*Vector3.up, Color.magenta);
                //Debug.DrawLine(hit.point, Camera.main.transform.position, Color.yellow);
                //Debug.Break();
                BaseHandler bh = hit.transform.GetComponent <BaseHandler>();
                if (bh != null)
                {
                    bh.ImpactHandler(hit.point, ray.direction.normalized, hit.normal);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene(0);
        }
    }
        public void TestCase1()
        {
            BaseHandler baseHandler = new BaseHandler(messageControllerMock.Object, messageMock.Object);
            UserHandler userHandler = new UserHandler(messageControllerMock.Object, messageMock.Object);

            userHandler.updateRating("Gadget's Go Coaster", "4");

            expectedMessage = new Message
            {
                activityContent = new Activity
                {
                    name           = "Gadget's Go Coaster",
                    type           = "Entertainment",
                    hours          = "10-12, 14-16, 18-20",
                    location       = "Disneyland Park, Mickey's town",
                    available      = true,
                    maxNumber      = 29,
                    pricePerPerson = 4,
                    rate           = 4
                },
                messageType = MessageType.UPDATE_RATING
            };

            serverMock.Setup(x => x.handleAsync(It.IsAny <Message>())).Returns(expectedMessage);
            baseHandler.handle(expectedMessage);

            Assert.That(expectedMessage.activityContent != null);
        }
        public void TestCase()
        {
            BaseHandler baseHandler = new BaseHandler(messageControllerMock.Object, messageMock.Object);

            baseHandler.handleSearch("4 stars");

            expectedMessage = new Message
            {
                messageType = MessageType.HANDLE_SEARCH,
                activities  = new List <Activity>
                {
                    new Activity {
                        name           = "Gadget's Go Coaster",
                        type           = "Entertainment",
                        hours          = "10-12, 14-16, 18-20",
                        location       = "Disneyland Park, Mickey's town",
                        available      = true,
                        maxNumber      = 29,
                        pricePerPerson = 4,
                        rate           = 4
                    }
                }
            };
            serverMock.Setup(x => x.handleAsync(It.IsAny <Message>())).Returns(expectedMessage);
            baseHandler.handle(expectedMessage);

            Assert.That(expectedMessage.activities != null);
        }
 public AdministratorView(IntPtr handle) : base(handle)
 {
     baseHandler     = new BaseHandler(this);
     adminHandler    = new AdminHandler(this);
     segueName       = "";
     segueType       = "";
     segueLocation   = "";
     segueHours      = "";
     segueList       = "";
     segueAvailable  = "";
     segueMaxNumber  = "";
     segueFName      = "";
     segueLName      = "";
     segueCity       = "";
     segueAddress    = "";
     segueState      = "";
     segueCountry    = "";
     wasActivityName = false;
     wasActivity     = false;
     timer           = new Timer(10);
     timer.Enabled   = true;
     timer.Start();
     timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, KeyboardEventHandler);
 }
Ejemplo n.º 17
0
        protected void btnYtSave_Click(object sender, EventArgs e)
        {
            //string curlan = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
            //int pluggid = Convert.ToInt32(((DotNetNuke.Framework.CDefault)this.Page).Title);
            //PluggContainer p = new PluggContainer(curlan, pluggid);

            //List<PluggComponent> comps = p.GetComponentList();

            //BaseHandler bh = new BaseHandler();


            //List<object> objToadd = new List<object>();
            BaseHandler bh = new BaseHandler();
            YouTube     yt = bh.GetYouTubeByComponentId(YouTubeId);

            if (yt == null)
            {
                yt = new YouTube();
            }
            try
            {
                yt.YouTubeTitle     = yttitle.Value;
                yt.YouTubeDuration  = Convert.ToInt32(ytduration.Value);
                yt.YouTubeCode      = ytYouTubeCode.Value;
                yt.YouTubeAuthor    = ytAuthor.Value;
                yt.YouTubeCreatedOn = Convert.ToDateTime(ytYouTubeCreatedOn.Value);
                yt.YouTubeComment   = ytYouTubeComment.Value;
                yt.PluggComponentId = YouTubeId;
            }
            catch
            {
            }

            bh.SaveYouTube(yt);
        }
Ejemplo n.º 18
0
    private void ReceiveSorket()
    {
        while (true)
        {
            if (!_socket.Connected)
            {
                Debug.Log("Failed to clientSocket server.");
                _socket.Close();
                break;
            }
            try {
                byte[] bytes = new byte[4096];
                int    i     = _socket.Receive(bytes);
                if (i > 0)
                {
                    string pack = Encoding.UTF8.GetString(bytes);
                    Debug.Log(pack);
                    SimpleJson.JsonObject json = (SimpleJson.JsonObject)SimpleJson.SimpleJson.DeserializeObject(pack);

                    int opCode = Convert.ToInt32(json ["opcode"]);
                    List <BaseHandler> bHandler = _handlers [opCode];

                    for (int j = 0; j < bHandler.Count; j++)
                    {
                        BaseHandler bh = bHandler [j];
                        bh.handle(opCode, json);
                    }
                }
            } catch (Exception e) {
                Debug.Log("Failed to clientSocket error." + e);
                Closed();
                break;
            }
        }
    }
        public override void ViewDidLoad()
        {
            String username = BaseHandler.username;

            baseHandler      = new BaseHandler(this);
            this.userHandler = new UserHandler(this);
        }
Ejemplo n.º 20
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            List <PluggComponent> comps = this.PluggContainer.GetComponentList();

            BaseHandler   bh       = new BaseHandler();
            List <object> objToadd = new List <object>();

            Plugghest.Base2.YouTube yt = bh.GetYouTubeByComponentId(this.ComponentID);
            if (yt == null)
            {
                yt = new Plugghest.Base2.YouTube();
            }
            try
            {
                yt.YouTubeTitle     = yttitle.Value;
                yt.YouTubeDuration  = Convert.ToInt32(ytduration.Value);
                yt.YouTubeCode      = ytYouTubeCode.Value;
                yt.YouTubeAuthor    = ytAuthor.Value;
                yt.YouTubeCreatedOn = Convert.ToDateTime(ytYouTubeCreatedOn.Value);
                yt.YouTubeComment   = ytYouTubeComment.Value;
                yt.PluggComponentId = this.ComponentID;
            }
            catch
            {
            }

            bh.SaveYouTube(yt);

            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(this.TabID, "", new string[] { "edit=1", "language=" + this.CurrentLanguage }));
        }
Ejemplo n.º 21
0
        public static string GetIframeString(int YouTubeId, string _PageCultureCode)
        {
            BaseHandler bh = new BaseHandler();

            Plugghest.Base2.YouTube yt = bh.GetYouTubeByComponentId(YouTubeId);
            return(yt != null?yt.GetIframeString(_PageCultureCode) : "(currently no video)");
        }
Ejemplo n.º 22
0
    private void loadHandler(System.Type type, BaseHandler handler)
    {
        object[] objs = type.GetCustomAttributes(typeof(OpCodeAttribute), true);
        foreach (object obj in objs)
        {
            OpCodeAttribute attr = obj as OpCodeAttribute;
            if (attr != null)
            {
                int[] opcodes = attr.opCodes;
                for (int i = 0; i < opcodes.Length; i++)
                {
                    int curOpcode = opcodes[i];
                    List <BaseHandler> handlerList = null;

                    if (!_handlers.ContainsKey(curOpcode))
                    {
                        handlerList          = new List <BaseHandler>();
                        _handlers[curOpcode] = handlerList;
                    }
                    else
                    {
                        handlerList = _handlers[curOpcode];
                    }

                    handlerList.Add(handler);
                }
            }
        }
    }
        public void TestCase2()
        {
            BaseHandler baseHandler = new BaseHandler(messageControllerMock.Object, messageMock.Object);
            UserHandler userHandler = new UserHandler(messageControllerMock.Object, messageMock.Object);

            userHandler.updateRating("Haunted Mansion", "3");

            expectedMessage = new Message
            {
                activityContent = new Activity
                {
                    name           = "Haunted Mansion",
                    type           = "Entertainment",
                    hours          = "10-12, 14-16",
                    location       = "Disneyland Park, New Orleans Square",
                    available      = true,
                    maxNumber      = 2,
                    pricePerPerson = 10,
                    rate           = 4
                },
                messageType = MessageType.UPDATE_RATING
            };

            serverMock.Setup(x => x.handleAsync(It.IsAny <Message>())).Returns(expectedMessage);
            baseHandler.handle(expectedMessage);

            Assert.That(expectedMessage.activityContent.rate == 4);
        }
Ejemplo n.º 24
0
        public void AddOperationHandler <T>(Action <T> action) where T : BaseOperation, new()
        {
            var obj     = new T();
            var handler = new BaseHandler <T>();

            handler.Action += action;
            _operationHandlers.Add(obj.Code, handler);
        }
Ejemplo n.º 25
0
        public void AddEventHandler <T>(Action <T> action) where T : BaseEvent, new()
        {
            var obj     = new T();
            var handler = new BaseHandler <T>();

            handler.Action += action;
            _eventHandlers.Add(obj.Code, handler);
        }
Ejemplo n.º 26
0
        private void CaseDisplay()
        {
            BaseHandler bh = new BaseHandler();
            YouTube     yt = bh.GetYouTubeByComponentId(YouTubeId);

            pnYoutubeIFrame.Visible = true;
            pnYoutubeIFrame.Controls.Add(new LiteralControl(yt.GetIframeString((Page as DotNetNuke.Framework.PageBase).PageCulture.Name)));
        }
 public static HttpServer AddHandler(this HttpServer server, BaseHandler handler)
 {
     foreach (var method in handler.Methods)
     {
         server.AddHandler(method.ToString(), handler.Path, handler.Handle);
     }
     return(server);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 新消息
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMessage(WebSocketSharp.MessageEventArgs e)
        {
            try
            {
                LastRecvTime = DateTime.Now;
                if (e.IsText)
                {
                    switch (e.Data)
                    {
                    case "HeartBeat":
                        this.Send(Newtonsoft.Json.JsonConvert.SerializeObject(new WSResModel(ResCode.HeartBeatRes)));
                        return;

                    case "TaskIsExist":
                        if (HandlerTaskManager.ContainsTask(this.TaskId))
                        {
                            this.Send(Newtonsoft.Json.JsonConvert.SerializeObject(new WSResModel(ResCode.Wait)));
                        }
                        else
                        {
                            SendAndClose(new WSResModel(ResCode.Err, "任务不存在!"));
                        }
                        return;
                    }
                }
                BaseHandler handler = HandlerManager.CreateHandler(PathName);
                if (handler == null)
                {
                    SendAndClose(new WSResModel(ResCode.Err, string.Format("请求路径{0}未找到对应Handler", PathName)));
                    return;
                }
                handler.Path           = this.PathName;
                handler.TaskId         = this.TaskId;
                handler.ReqIsWebSocket = true;
                handler.InPara         = e.Data;
                //添加任务并执行
                if (HandlerTaskManager.AddTask(handler))
                {
                    ThreadPool.QueueUserWorkItem((state) =>
                    {
                        BaseHandler bh = state as BaseHandler;
                        try
                        {
                            bh.HandlerTask(bh.InPara);
                        }
                        catch (Exception ex)
                        {
                            bh.ReturnToClient(new WSResModel(ResCode.Err, ex.Message));
                        }
                    }, handler);
                }
            }
            catch (Exception ex)
            {
                CommonInfo.Output("WS处理消息异常:{0}", ex.Message);
                SendAndClose(new WSResModel(ResCode.Err, string.Format("服务器WS处理消息异常", ex.Message)));
            }
        }
Ejemplo n.º 29
0
        //处理客户端得请求    分发Handler 请求   客户端通过OpCustom发送过来的
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            BaseHandler handler = (BaseHandler)PureDictTool.GetValue <OperationCode, BaseHandler>(PureGameServer._instance.handlerDictionary, (OperationCode)operationRequest.OperationCode);

            if (handler != null)
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
        }
Ejemplo n.º 30
0
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            BaseHandler handler = DictionaryUtils.getValue <OPCode, BaseHandler>(Application.handlerDict, (OPCode)operationRequest.OperationCode);

            if (handler != null)
            {
                handler.doResponse(operationRequest, sendParameters, this);
            }
        }
Ejemplo n.º 31
0
		protected void DoAction(BaseHandler innerCallback, string action, ParameterList qry = null, ParameterList data = null)
		{
			this.innerCallback = innerCallback;
			StringBuilder sb = new StringBuilder(connection.BaseUrl);
			sb.Append(action);
			sb.Append("?");
			if (qry != null) sb.Append(qry.BuildQueryString());
			string url = sb.ToString();
			this.url = url;
			if (data != null)
				client.UploadStringAsync(new Uri(url), data.BuildQueryString());
			else
				client.DownloadStringAsync(new Uri(url));
		}
Ejemplo n.º 32
0
		public BaseRequest(Connection connection, BaseHandler callback)
		{
			this.connection = connection;
			this.callback = callback;
			this.innerCallback = null;

			client = new WebClient();
			client.Encoding = Utils.Enc;
			client.UploadStringCompleted += client_UploadStringCompleted;
			client.DownloadStringCompleted += client_DownloadStringCompleted;
			if (connection.Cookie != null)
			{
				client.Headers["Cookie"] = connection.Cookie;
			}
		}
Ejemplo n.º 33
0
 public Transform(
     BeginHandler Begin = null,
     EndHandler End = null,
     IEnumerable<IField> Fields = null,
     UnknownFieldHandler UnknownField = null,
     BaseHandler Base = null,
     UnknownEndHandler UnknownEnd = null)
 {
     begin = Begin;
     end = End;
     base_ = Base;
     unknownEnd = UnknownEnd;
     fields = Fields ?? new IField[0];
     unknownField = UnknownField;
 }
Ejemplo n.º 34
0
 public void RegisterHandler(BaseHandler handler)
 {
     var typeName = handler.GetType().Name;
     if (typeName.EndsWith("Handler"))
     {
         var handlerPrefix = typeName.Replace("Handler", "");
         var methods = from m in handler.GetType().GetMethods()
             where m.Name == "Handle"
             select m;
         foreach (var methodInfo in methods)
         {
             var parameters = methodInfo.GetParameters();
             if (parameters.Length == 1)
             {
                 var header = handlerPrefix + "." + parameters[0].ParameterType.Name;
                 _handlers.Add(header, handler);
                 _types.Add(header,
                     new InOutMessageType {In = parameters[0].ParameterType, Out = methodInfo.ReturnType});
             }
         }
     }
 }
Ejemplo n.º 35
0
		public void FetchTopic(BaseHandler callback, string board, int pid, int? start=null)
		{
			FetchTopicRequest req = new FetchTopicRequest(this, callback);
			req.FetchTopic(board, pid, start);
		}
Ejemplo n.º 36
0
		public LoginRequest(Connection connection, BaseHandler callback)
			: base(connection, callback)
		{
		}
Ejemplo n.º 37
0
		public SendPostRequest(Connection connection, BaseHandler callback)
			: base(connection, callback)
		{
		}
Ejemplo n.º 38
0
		public FetchHotListRequest(Connection connection, BaseHandler callback)
			: base(connection, callback)
		{
		}
Ejemplo n.º 39
0
		public void FetchBoardList(BaseHandler callback)
		{
			FetchBoardListRequest req = new FetchBoardListRequest(this, callback);
			req.FetchBoardList();
		}
Ejemplo n.º 40
0
		public void FetchPage(BaseHandler callback, string board, int? start=null)
		{
			FetchPageRequest req = new FetchPageRequest(this, callback);
			req.FetchPage(board, start);
		}
Ejemplo n.º 41
0
		public void FetchPost(BaseHandler callback, string board, int pid, int num)
		{
			FetchPostRequest req = new FetchPostRequest(this, callback);
			req.FetchPost(board, pid, num);
		}
Ejemplo n.º 42
0
		public void SendPost(BaseHandler callback, string brd, string title, string text, int? pid=null, int? gid=null, int signature=1, string autocr="on")
		{
			SendPostRequest req = new SendPostRequest(this, callback);
			req.SendPost(brd, title, text, pid, gid);
		}
Ejemplo n.º 43
0
		public void ValidateLogin(BaseHandler callback)
		{
			ValidateLoginRequest req = new ValidateLoginRequest(this, callback);
			req.ValidateLogin();
		}
Ejemplo n.º 44
0
		public void Login(BaseHandler callback, string username, string password)
		{
			LoginRequest req = new LoginRequest(this, callback);
			req.Login(username, password);
		}