本文整理汇总了C#中Core.Unload方法的典型用法代码示例。如果您正苦于以下问题:C# Core.Unload方法的具体用法?C# Core.Unload怎么用?C# Core.Unload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core.Unload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageRequest
public PageRequest(Server server, HttpContext context)
{
//the Pipeline.PageRequest is simply the first page request for a Websilk website.
S = new Core(server, context);
var page = new Page(S);
S.isFirstLoad = true;
if (S.isFirstLoad == true)
{
getUserAgent(context);
}
//parse URL
page.Url = page.parseUrl(S.Request.Path.ToString().ToLower().Replace(" ", "-"));
//get page Info
page.getPageInfoFromUrl();
//register initial javascript
S.javascript.Add("init", "S.init(" + (S.User.useAjax ? "true" : "false") + "," + page.pageId + "," + page.pageType + ",'" + page.pagePathName + "','" + page.pageTitle + "','" + page.PageTitleForBrowserTab + "'," + page.websiteId + ",'" + page.websiteTitle + "', '" + (S.Request.IsHttps ? "https://" : "http://") + "','" + page.Url.host + "');");
//render the page
var response = page.Render();
//unload the core (before sending response)
S.Unload();
//render the server response
S.Response.ContentType = "text/html";
S.Response.WriteAsync(response);
}
示例2: WebService
//.........这里部分代码省略.........
foreach (KeyValuePair<string, object> item in attr)
{
val = item.Value.ToString(); ;
if (item.Key == "viewstateId")
{
viewstate = val;
}
else
{
//convert value into integer or float
if (IsNumeric(val))
{
if (val.IndexOf('.') >= 0)
{
parms[x] = float.Parse(val);
}
else
{
parms[x] = Int32.Parse(val);
}
}
else
{
parms[x] = item.Value;
}
x = x + 1;
}
}
}
else if (data.IndexOf("=") >= 0)
{
//form post data
dataType = 1;
}
}
else
{
//get viewstate from query string
viewstate = context.Request.Query["v"];
}
R = new Core(server, context, viewstate, "service");
R.Page.GetPageUrl();
//load service class from URL path
string className = "Rennder.Services." + paths[1];
string methodName = paths[2];
if(paths.Length == 4) { className += "." + paths[2]; methodName = paths[3]; }
Type type =Type.GetType(className);
Service service = (Service)Activator.CreateInstance(type, new object[] { R, paths });
if (dataType == 1)
{
//form post data
string[] items = R.Server.UrlDecode(data).Split('&');
string[] item;
for(int x = 0; x < items.Length; x++)
{
item = items[x].Split('=');
service.Form.Add(item[0], item[1]);
}
}else if(dataType == 2)
{
//multi-part file upload
service.Files = form.Files;
}
//execute method from service class
MethodInfo method = type.GetMethod(methodName);
object result = method.Invoke(service, parms);
if(result != null)
{
switch (result.GetType().FullName)
{
case "Rennder.WebRequest":
//send raw content (HTML)
WebRequest res = (WebRequest)result;
context.Response.ContentType = res.contentType;
context.Response.WriteAsync(res.html);
break;
default:
//JSON serialize web service response
string serialized = "{\"type\":\"" + result.GetType().FullName + "\", \"d\":" + JsonConvert.SerializeObject(result) + "}";
context.Response.ContentType = "text/json";
context.Response.WriteAsync(serialized);
break;
}
}else {
context.Response.ContentType = "text/json";
context.Response.WriteAsync("{\"type\":\"Empty\",\"d\":{}}");
}
//finally, unload the Rennder Core:
//close SQL connection, save ViewState, save User info
R.Unload();
}
示例3: WebService
//.........这里部分代码省略.........
//start building Web API response (find method to execute & return results)
S = new Core(server, context);
//load service class from URL path
string className = "Websilk.Services." + paths[1];
string methodName = paths[2];
if(paths.Length == 4) { className += "." + paths[2]; methodName = paths[3]; }
var service = GetService(className);
if (S.Util.Str.IsNumeric(pageId))
{
service.pageId = int.Parse(pageId);
}
if (dataType == 1)
{
//parse HTML form POST data and send to new Service instance
string[] items = S.Server.UrlDecode(data).Split('&');
string[] item;
for(var x = 0; x < items.Length; x++)
{
item = items[x].Split('=');
service.Form.Add(item[0], item[1]);
}
}else if(dataType == 2)
{
//send multi-part file upload data to new Service instance
service.Files = form.Files;
}
//execute method from new Service instance
Type type = Type.GetType(className);
MethodInfo method = type.GetMethod(methodName);
//try to cast params to correct types
ParameterInfo[] methodParams = method.GetParameters();
paramVals = new object[methodParams.Length];
for(var x = 0; x < methodParams.Length; x++)
{
//find correct key/value pair
param = "";
foreach(var item in parms)
{
if(item.Key == methodParams[x].Name.ToLower())
{
param = item.Value;
}
}
//cast params to correct (supported) types
switch (methodParams[x].ParameterType.Name.ToLower())
{
case "int32":
paramVals[x] = Int32.Parse(param);
break;
case "boolean":
paramVals[x] = param.ToLower() == "true" ? true : false;
break;
case "double":
paramVals[x] = double.Parse(param);
break;
default:
paramVals[x] = param;
break;
}
}
object result = method.Invoke(service, paramVals);
//finally, unload the Websilk Core:
//close SQL connection, save User info, etc (before sending response)
S.Unload();
if (result != null)
{
switch (result.GetType().FullName)
{
case "Websilk.Services.WebRequest":
//send raw content (HTML)
var res = (Services.WebRequest)result;
context.Response.ContentType = res.contentType;
context.Response.WriteAsync(res.html);
break;
default:
//JSON serialize web service response
string serialized = "{\"type\":\"" + result.GetType().FullName + "\", \"d\":" + JsonConvert.SerializeObject(result) + "}";
context.Response.ContentType = "text/json";
context.Response.WriteAsync(serialized);
break;
}
}else {
context.Response.ContentType = "text/json";
context.Response.WriteAsync("{\"type\":\"Empty\",\"d\":{}}");
}
}
示例4: App
//.........这里部分代码省略.........
//get browser type
scaffold.Data["body-class"] = R.Util.GetBrowserType();
//parse URL
R.Page.GetPageUrl();
if(R.isLocal == true)
{
scaffold.Data["https-url"] = "http://" + R.Page.Url.host.Replace("/","");
}else
{
scaffold.Data["https-url"] = "https://" + R.Page.Url.host.Replace("/", "");
}
//get page Info
SqlReader reader = R.Page.GetPageInfoFromUrlPath();
if(reader.Rows.Count > 0)
{
//load initial web page
R.Page.LoadPageInfo(reader);
if(R.Page.pageId > 0)
{
string js = "";
//load page
R.Page.LoadPage(R.Page.pageFolder + "page.xml", 1, R.Page.pageId, R.Page.pageTitle);
//load website.css
scaffold.Data["website-css"] = "/content/websites/" + R.Page.websiteId + "/website.css?v=" + R.Version;
//load iframe resize code, so if a Rennder web page is loaded within an iframe, it can communicate
//with the parent web page whenever the iframe resizes.
if (R.Request.Query[ "ifr"] == "1")
{
js += "var frameSize = 0;" + "function checkResize(){" + "var wurl = \"" + R.Request.Query["w"] + "\";" + "if(frameHeight != frameSize){" + "parent.postMessage(\"resize|\"+(frameHeight),wurl);" + "}" + "frameSize = frameHeight;" + "setTimeout(\"checkResize();\",1000);" + "}" + "checkResize();";
R.Page.isEditable = false;
}
//register app javascript
js += "R.init(" + R.Page.useAJAX.ToString().ToLower() + ",'" + R.ViewStateId + "',R.page.title);";
R.Page.RegisterJS("app", js);
//display Page Editor
if (R.Page.isEditable == true)
{
Editor editor = new Editor(R);
string[] result = editor.LoadEditor();
scaffold.Data["editor"] = result[0];
R.Page.RegisterJS("editor", result[1]);
}
//setup scripts
string scripts;
if(R.isLocal == true)
{
scripts = "<script type=\"text/javascript\" src=\"/scripts/utility/jquery-2.1.3.min.js\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/core/global.js\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/core/fixes.js\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/core/rml.js\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/core/view.js\"></script>\n" +
//"<script type=\"text/javascript\" src=\"/scripts/core/responsive.js\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/utility.js?v=" + R.Version + "\"></script>";
if(R.Page.isEditable == true)
{
scripts += "<script type=\"text/javascript\" src=\"/scripts/core/editor.js?v=" + R.Version + "\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/rangy/rangy-compiled.js?v=" + R.Version + "\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/utility/dropzone.js?v=" + R.Version + "\"></script>\n" +
"<script type=\"text/javascript\">R.editor.load();</script>";
}
}
else
{
scripts = "<script type=\"text/javascript\" src=\"/scripts/rennder.js?v=" + R.Version + "\"></script>\n" +
"<script type=\"text/javascript\" src=\"/scripts/utility.js?v=" + R.Version + "\"></script>";
if (R.Page.isEditable == true)
{
scripts += "<script type=\"text/javascript\" src=\"/scripts/editor.js?v=" + R.Version + "\"></script>\n" +
"<script type=\"text/javascript\">R.editor.load();</script>";
}
}
if(R.Page.postJScode.Length > 0)
{
R.Page.postJS += string.Join("\n", R.Page.postJScode) + R.Page.postJSLast;
}
scaffold.Data["scripts"] = scripts + "\n" + "<script type=\"text/javascript\">" + R.Page.postJS + "</script>";
//render web page
scaffold.Data["body"] = R.Page.Render();
}
}
//finally, scaffold Rennder platform HTML
R.Response.ContentType = "text/html";
R.Response.WriteAsync(scaffold.Render());
//unload the core
R.Unload();
}