static AjaxLoader() { string[] names = new string[5]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[5]; names[0] = "Call.Add"; infos[0] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 0, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsPost = false, IsReferer = false, IsAsynchronous = false }; names[1] = "Call.Xor"; infos[1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsPost = false, IsReferer = false, IsAsynchronous = true }; names[2] = "/WebView.html"; infos[2] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 2, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsAsynchronous = false, IsReferer = false, IsViewPage = true }; names[3] = "/WebViewAsynchronous.html"; infos[3] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 3, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsAsynchronous = true, IsReferer = false, IsViewPage = true }; names[5 - 1] = AutoCSer.WebView.AjaxBase.PubErrorCallName; infos[5 - 1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 5 - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.SubBuffer.Size.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; setMethods(names, infos); }
static AjaxLoader() { string[] names = new string[6]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[6]; names[0] = "Example.GetCode"; infos[0] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 0, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304 }; names[1] = "Example2.GetCode"; infos[1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304 }; names[2] = "TestCase.GetCode"; infos[2] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 2, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304 }; names[3] = "/Search.html"; infos[3] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 3, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[4] = "/WebView/Template.html"; infos[4] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 4, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[6 - 1] = AutoCSer.WebView.AjaxBase.PubErrorCallName; infos[6 - 1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 6 - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.Memory.BufferSize.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; setMethods(names, infos); CompileJsonSerialize(new System.Type[] { typeof(_p1), null }, new System.Type[] { typeof(_p2), null }); }
static AjaxLoader() { string[] names = new string[5]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[5]; names[0] = "Call.Add"; infos[0] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 0, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304 }; names[1] = "Call.Xor"; infos[1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304, IsAsynchronous = true }; names[2] = "/WebView.html"; infos[2] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 2, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[3] = "/WebViewAsynchronous.html"; infos[3] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 3, MaxMemoryStreamSize = (AutoCSer.Memory.BufferSize) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[5 - 1] = AutoCSer.WebView.AjaxBase.PubErrorCallName; infos[5 - 1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 5 - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.Memory.BufferSize.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; setMethods(names, infos); CompileJsonSerialize(new System.Type[] { typeof(_p1), null }, new System.Type[] { typeof(_p2), null }); }
protected override void loadAjax(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 4 - 1: pubError(); return; default: return; } }
protected override void loadAjax(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 0: loadAjax(AutoCSer.Web.Ajax.Example/**/.Pop() ?? new AutoCSer.Web.Ajax.Example(), ajaxInfo); return; case 1: loadAjax(AutoCSer.Web.Ajax.TestCase/**/.Pop() ?? new AutoCSer.Web.Ajax.TestCase(), ajaxInfo); return; case 5 - 1: pubError(); return; default: return; } }
protected override void loadView(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { #region LOOP ViewMethods case @MethodIndex: loadView(/*IF:IsPoolType*/ @WebViewMethodType.FullName /**/.Pop() ?? /*IF:IsPoolType*/ new @WebViewMethodType.FullName(), ajaxInfo); return; #endregion LOOP ViewMethods default: return; } }
protected override void loadView(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 2: loadView(AutoCSer.TestCase.WebPerformance.WebView /**/.Pop() ?? new AutoCSer.TestCase.WebPerformance.WebView(), ajaxInfo); return; case 3: loadView(AutoCSer.TestCase.WebPerformance.WebViewAsynchronous /**/.Pop() ?? new AutoCSer.TestCase.WebPerformance.WebViewAsynchronous(), ajaxInfo); return; default: return; } }
protected override void loadAjax(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 0: loadAjax(AutoCSer.TestCase.WebPerformance.Ajax.Call /**/.Pop() ?? new AutoCSer.TestCase.WebPerformance.Ajax.Call(), ajaxInfo); return; case 1: loadAjax(AutoCSer.TestCase.WebPerformance.Ajax.Call /**/.Pop() ?? new AutoCSer.TestCase.WebPerformance.Ajax.Call(), ajaxInfo); return; case 5 - 1: pubError(); return; default: return; } }
protected override void loadView(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 2: loadView(AutoCSer.Web.Search/**/.Pop() ?? new AutoCSer.Web.Search(), ajaxInfo); return; case 3: loadView(AutoCSer.Web.WebView.Template/**/.Pop() ?? new AutoCSer.Web.WebView.Template(), ajaxInfo); return; default: return; } }
/// <summary> /// 加载 AJAX 调用 /// </summary> /// <param name="ajax"></param> /// <param name="ajaxInfo"></param> protected void loadAjax(AutoCSer.WebView.Ajax ajax, AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { AutoCSer.Net.Http.Header header = Socket.HttpHeader; ajax.LoadHeader(DomainServer, Socket, ajaxInfo.IsAsynchronous); if (header.Method == AutoCSer.Net.Http.MethodType.POST && header.ContentLength != 0) { ajax.SetLoader(this, ajaxInfo); Socket.GetForm(ajax, AutoCSer.Net.Http.GetFormType.Ajax); } else if (!this.callAjax(ajaxInfo.MethodIndex, ajax)) { Socket.ResponseError(SocketIdentity, AutoCSer.Net.Http.ResponseState.ServerError500); } }
/// <summary> /// AJAX调用 /// </summary> protected void load() { try { AutoCSer.Net.Http.SocketBase socket = Socket; AutoCSer.Net.Http.Header header = Socket.HttpHeader; if ((header.Flag & Net.Http.HeaderFlag.IsSetAjaxCallName) != 0) { #if MONO AutoCSer.WebView.AjaxMethodInfo call = methods.Get(header.AjaxCallNameData); #else AutoCSer.WebView.AjaxMethodInfo call = DomainServer.WebConfigIgnoreCase ? methods.GetLower(header.AjaxCallNameData) : methods.Get(header.AjaxCallNameData); #endif if (call == null) { byte[] path = DomainServer.GetViewRewrite(header.AjaxCallNameData); if (path.length() != 0) { call = methods.GetNotEmpty(path); } } if (call != null && (!call.IsReferer || header.IsReferer != 0))// || AutoCSer.Config.Pub.Default.IsDebug { if (call.IsViewPage) { if (header.Method == Net.Http.MethodType.GET) { loadView(call); return; } } else if ((header.Method == Net.Http.MethodType.POST || !call.IsPost)) { if (header.ContentLength <= call.MaxPostDataSize) { loadAjax(call); } else { socket.ResponseErrorIdentity(AutoCSer.Net.Http.ResponseState.ServerError500); } return; } } } socket.ResponseErrorIdentity(AutoCSer.Net.Http.ResponseState.NotFound404); } finally { PushPool(); } }
protected override void loadAjax(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { #region LOOP Methods case @MethodIndex: loadAjax(/*IF:IsPoolType*/ @WebAjaxMethodType.FullName /**/.Pop() ?? /*IF:IsPoolType*/ new @WebAjaxMethodType.FullName(), ajaxInfo); return; #endregion LOOP Methods #region NOT IsPubError case @MethodCount - 1: pubError(); return; #endregion NOT IsPubError default: return; } }
/// <summary> /// 加载 AJAX 调用 /// </summary> /// <param name="ajax"></param> /// <param name="ajaxInfo"></param> protected void loadAjax <ajaxType>(ajaxType ajax, AutoCSer.WebView.AjaxMethodInfo ajaxInfo) where ajaxType : AutoCSer.WebView.Ajax <ajaxType> { AutoCSer.Net.Http.Header header = Socket.HttpHeader; ajax.LoadHeader(DomainServer, Socket, ajaxInfo.IsAsynchronous, ajax); if (header.Method == AutoCSer.Net.Http.MethodType.POST && header.ContentLength != 0) { ajax.SetLoader(this, ajaxInfo); Socket.GetForm(ajax, AutoCSer.Net.Http.GetFormType.Ajax); return; } if (this.callAjax(ajaxInfo.MethodIndex, ajax)) { return; } Socket.ResponseError(SocketIdentity, AutoCSer.Net.Http.ResponseState.ServerError500); ajax.PushPool(); }
static AjaxLoader() { string[] names = new string[4]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[4]; names[0] = "Example.GetCode"; infos[0] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 0, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsPost = false, IsReferer = false, IsAsynchronous = false }; names[1] = "TestCase.GetCode"; infos[1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsPost = false, IsReferer = false, IsAsynchronous = false }; names[2] = "/WebView/Template.html"; infos[2] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 2, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsAsynchronous = false, IsReferer = false, IsViewPage = true }; names[4 - 1] = AutoCSer.WebView.AjaxBase.PubErrorCallName; infos[4 - 1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 4 - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.SubBuffer.Size.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; setMethods(names, infos); }
static AjaxLoader() { string[] names = new string[4]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[4]; names[0] = "/Class.html"; infos[0] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 0, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[1] = "/ClassList.html"; infos[1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[2] = "/Student.html"; infos[2] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 2, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 131072, MaxPostDataSize = 4194304, IsViewPage = true }; names[4 - 1] = AutoCSer.WebView.AjaxBase.PubErrorCallName; infos[4 - 1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 4 - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.SubBuffer.Size.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; setMethods(names, infos); CompileJsonSerialize(new System.Type[] { null }, new System.Type[] { null }); }
protected override void loadView(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { #region LOOP ViewMethods case @MethodIndex: #region IF IsSetPage #region IF IsPoolType @WebViewMethodType.FullName @PageName = @WebViewMethodType.FullName /**/.Pop(); if (@PageName == null) { setPage(@PageName = new @WebViewMethodType.FullName() /*PUSH:Attribute*/, @IsAsynchronous /*PUSH:Attribute*/, @IsAwaitMethod); } loadView(@PageName, ajaxInfo); #endregion IF IsPoolType #region NOT IsPoolType loadView(/*NOTE*/ (AutoCSer.WebView.View)(object) /*NOTE*/ new @WebViewMethodType.FullName(), ajaxInfo /*PUSH:Attribute*/, @IsAsynchronous /*PUSH:Attribute*/, @IsAwaitMethod); #endregion NOT IsPoolType #endregion IF IsSetPage #region NOT IsSetPage loadView(/*IF:IsPoolType*/ @WebViewMethodType.FullName /**/.Pop() ?? /*IF:IsPoolType*/ new @WebViewMethodType.FullName(), ajaxInfo); #endregion NOT IsSetPage return;
static AjaxLoader() { string[] names = new string[@MethodCount]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[@MethodCount]; #region LOOP Methods names[@MethodIndex] = "@CallName"; infos[@MethodIndex] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = @MethodIndex, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size)@MaxMemoryStreamSize /*PUSH:Attribute*/, MaxPostDataSize = @MaxPostDataSize, IsPost = @IsOnlyPost, IsReferer = @IsReferer /*PUSH:Attribute*/, IsAsynchronous = @IsAsynchronousCallback }; #endregion LOOP Methods #region LOOP ViewMethods names[@MethodIndex] = "@CallName"; infos[@MethodIndex] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = @MethodIndex, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size)@MaxMemoryStreamSize /*PUSH:Attribute*/, MaxPostDataSize = @MaxPostDataSize, IsAsynchronous = @IsAsynchronous /*PUSH:Attribute*/, IsReferer = false, IsViewPage = true }; #endregion LOOP ViewMethods #region NOT IsPubError names[@MethodCount - 1 /*NOTE*/ + 1 /*NOTE*/] = AutoCSer.WebView.AjaxBase.PubErrorCallName /*IF:AutoParameter.WebConfig.IgnoreCase*/.ToLower() /*IF:AutoParameter.WebConfig.IgnoreCase*/; infos[@MethodCount - 1 /*NOTE*/ + 1 /*NOTE*/] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = @MethodCount - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.SubBuffer.Size.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; #endregion NOT IsPubError setMethods(names, infos); }
protected override void loadView(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 0: loadView(AutoCSer.TestCase.SqlTableWeb.Class /**/.Pop() ?? new AutoCSer.TestCase.SqlTableWeb.Class(), ajaxInfo); return; case 1: loadView(AutoCSer.TestCase.SqlTableWeb.ClassList /**/.Pop() ?? new AutoCSer.TestCase.SqlTableWeb.ClassList(), ajaxInfo); return; case 2: loadView(AutoCSer.TestCase.SqlTableWeb.Student /**/.Pop() ?? new AutoCSer.TestCase.SqlTableWeb.Student(), ajaxInfo); return; default: return; } } protected override void loadAjax(AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { switch (ajaxInfo.MethodIndex) { case 4 - 1: pubError(); return; default: return; } } protected override bool callAjax(int callIndex, AutoCSer.WebView.AjaxBase page) { switch (callIndex) { default: return(false); } } static AjaxLoader() { string[] names = new string[4]; AutoCSer.WebView.AjaxMethodInfo[] infos = new AutoCSer.WebView.AjaxMethodInfo[4]; names[0] = "/Class.html"; infos[0] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 0, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsAsynchronous = false, IsReferer = false, IsViewPage = true }; names[1] = "/ClassList.html"; infos[1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsAsynchronous = false, IsReferer = false, IsViewPage = true }; names[2] = "/Student.html"; infos[2] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 2, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsAsynchronous = false, IsReferer = false, IsViewPage = true }; names[4 - 1] = AutoCSer.WebView.AjaxBase.PubErrorCallName; infos[4 - 1] = new AutoCSer.WebView.AjaxMethodInfo { MethodIndex = 4 - 1, MaxPostDataSize = 2048, MaxMemoryStreamSize = AutoCSer.SubBuffer.Size.Kilobyte2, IsReferer = true, IsAsynchronous = true, IsPost = true }; setMethods(names, infos); } } } namespace AutoCSer.TestCase.SqlTableWeb { /// <summary> /// WEB服务器 /// </summary> public partial class WebServer : AutoCSer.Net.HttpDomainServer.ViewServer <int> { protected override string[] calls { get { string[] names = new string[2]; names[0] = "/Ajax"; names[1] = "/"; return(names); } } private static readonly AutoCSer.WebView.CallMethodInfo _i1 = new AutoCSer.WebView.CallMethodInfo { MethodIndex = 1, MaxMemoryStreamSize = (AutoCSer.SubBuffer.Size) 65536, MaxPostDataSize = 4194304, IsOnlyPost = false }; protected override void call(int callIndex, AutoCSer.Net.Http.SocketBase socket) { switch (callIndex) { case 0: AutoCSer.TestCase.SqlTableWeb.AjaxLoader loader = AutoCSer.TestCase.SqlTableWeb.AjaxLoader /**/.Pop() ?? new AutoCSer.TestCase.SqlTableWeb.AjaxLoader(); ajaxLoader(loader, socket); loader.Load(); return; case 1: load(socket, AutoCSer.TestCase.SqlTableWeb.Index /**/.Pop() ?? new AutoCSer.TestCase.SqlTableWeb.Index(), _i1); return; } }
protected void loadView(AutoCSer.WebView.View view, AutoCSer.WebView.AjaxMethodInfo ajaxInfo, bool isAsynchronous, bool isAwaitMethod) { view.SetAsynchronousAwaitMethod(isAsynchronous, isAwaitMethod); DomainServer.LoadAjax(Socket, view); }
/// <summary> /// 加载页面视图 /// </summary> /// <param name="ajaxInfo"></param> protected abstract void loadView(AutoCSer.WebView.AjaxMethodInfo ajaxInfo);
protected void loadView(AutoCSer.WebView.View view, AutoCSer.WebView.AjaxMethodInfo ajaxInfo) { DomainServer.LoadAjax(Socket, view); }
protected void loadView <viewType>(viewType view, AutoCSer.WebView.AjaxMethodInfo ajaxInfo) where viewType : AutoCSer.WebView.View <viewType> { DomainServer.LoadAjax <viewType>(Socket, view); }