本文整理汇总了C#中RequestContext类的典型用法代码示例。如果您正苦于以下问题:C# RequestContext类的具体用法?C# RequestContext怎么用?C# RequestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestContext类属于命名空间,在下文中一共展示了RequestContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainAsync
private static async void MainAsync(string cachePath, double zoomLevel)
{
var browserSettings = new BrowserSettings();
var requestContextSettings = new RequestContextSettings { CachePath = cachePath };
// RequestContext can be shared between browser instances and allows for custom settings
// e.g. CachePath
using(var requestContext = new RequestContext(requestContextSettings))
using (var browser = new ChromiumWebBrowser(TestUrl, browserSettings, requestContext))
{
if (zoomLevel > 1)
{
browser.FrameLoadStart += (s, argsi) =>
{
var b = (ChromiumWebBrowser)s;
if (argsi.Frame.IsMain)
{
b.SetZoomLevel(zoomLevel);
}
};
}
await LoadPageAsync(browser);
// Wait for the screenshot to be taken.
await browser.ScreenshotAsync().ContinueWith(DisplayBitmap);
await LoadPageAsync(browser, "http://github.com");
// Wait for the screenshot to be taken.
await browser.ScreenshotAsync().ContinueWith(DisplayBitmap);
}
}
示例2: execute
public override V3Message execute(Request message, RequestContext context)
{
Object returnValue = null;
#if(FULL_BUILD)
if (body.body == null)
body.body = new object[0];
else if (!body.body.GetType().IsArray)
body.body = new object[] { body.body };
try
{
if (Registry.ServiceRegistry.GetMapping(destination).Equals("*"))
destination = source;
ThreadContext.getProperties()[ORBConstants.REQUEST_HEADERS] = headers;
ThreadContext.getProperties()[ORBConstants.CLIENT_ID] = clientId;
returnValue = Invoker.handleInvoke( message, destination, operation, (Object[])( (Object[])body.body )[0], context );
}
catch (Exception exception)
{
return new ErrMessage(messageId, exception);
}
#endif
return new AckMessage(messageId, clientId, returnValue);
}
示例3: getForecast
/// <summary>
/// </summary>
/// <param name="context"></param>
/// <param name="model"></param>
/// <returns></returns>
public StatusCode getForecast(
RequestContext context,
WeatherStationModel model
)
{
return StatusCodes.BadNotImplemented;
}
示例4: GetAllRequests
public ActionResult GetAllRequests(int?page)
{
int pageSize = 5;
int pageNumber = (page ?? 1);
var colection = new RequestContext().Requests.OrderByDescending(x => x.InitialDate);
return View(colection.ToPagedList(pageNumber, pageSize));
}
示例5: GetControllerInstance
protected override IController GetControllerInstance(
RequestContext requestContext, Type controllerType)
{
try
{
if (controllerType == null)
return base.GetControllerInstance(requestContext, null);
var controller = funqBuilder.CreateInstance(controllerType) as IController;
return controller ?? base.GetControllerInstance(requestContext, controllerType);
}
catch (HttpException ex)
{
if (ex.GetHttpCode() == 404)
{
try
{
if (ServiceStackController.CatchAllController != null)
{
return ServiceStackController.CatchAllController(requestContext);
}
}
catch { } //ignore not found CatchAllController
}
throw;
}
}
示例6: Authenticate
public override void Authenticate(RequestContext<AuthenticateRequest, AuthenticateResponse> requestContext)
{
SslConnection connection = _context.Connection as SslConnection;
X509Certificate cert = connection.ClientCertificate;
string certHashString = cert.GetCertHashString();
foreach(User user in ServerContext.AccessControlList.Users)
{
SslAuthenticationParameters auth = (SslAuthenticationParameters)user.GetAuthentication("ssl_auth");
if(auth != null && auth.CertificateHash.Equals(certHashString))
{
ServerContext.ServerAuthenticationContext.AuthenticatedPermissionMember = user;
AuthenticateResponse response = requestContext.CreateResponse();
response.Succeeded = true;
response.Execute();
return;
}
}
_log.WarnFormat("Could not find user associated with certificate '{0}'", certHashString);
AuthenticateResponse errorResponse = requestContext.CreateResponse();
errorResponse.Succeeded = false;
errorResponse.CustomErrorMessage = "No client associated with specified certificate!";
errorResponse.Execute();
}
示例7: MetricsServices
public MetricsServices(RequestContext c,
SearchQueryRepository queries
)
{
context = c;
this.SearchQueries = queries;
}
示例8: FindView
public async Task<ViewEngineResult> FindView(RequestContext requestContext, string viewName)
{
var actionDescriptor = _actionDescriptorProvider.CreateDescriptor(requestContext) as ControllerBasedActionDescriptor;
if (actionDescriptor == null)
{
return null;
}
if (String.IsNullOrEmpty(viewName))
{
viewName = actionDescriptor.ActionName;
}
string controllerName = actionDescriptor.ControllerName;
var searchedLocations = new List<string>(_viewLocationFormats.Length);
for (int i = 0; i < _viewLocationFormats.Length; i++)
{
string path = String.Format(CultureInfo.InvariantCulture, _viewLocationFormats[i], viewName, controllerName);
IView view = await _virtualPathFactory.CreateInstance(path);
if (view != null)
{
return ViewEngineResult.Found(view);
}
searchedLocations.Add(path);
}
return ViewEngineResult.NotFound(searchedLocations);
}
示例9: InstantiateForMemory
public static MetricsServices InstantiateForMemory(RequestContext c)
{
return new MetricsServices(c,
SearchQueryRepository.InstantiateForMemory(c)
);
}
示例10: CanAddItemToOrderAndCalculate
public void CanAddItemToOrderAndCalculate()
{
RequestContext c = new RequestContext();
MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);
c.CurrentStore = new Accounts.Store();
c.CurrentStore.Id = 1;
Order target = new Order();
LineItem li = new LineItem() { BasePricePerItem = 19.99m,
ProductName = "Sample Product",
ProductSku = "ABC123",
Quantity = 2 };
target.Items.Add(li);
app.CalculateOrder(target);
Assert.AreEqual(39.98m, target.TotalOrderBeforeDiscounts, "SubTotal was Incorrect");
Assert.AreEqual(39.98m, target.TotalGrand, "Grand Total was incorrect");
bool upsertResult = app.OrderServices.Orders.Upsert(target);
Assert.IsTrue(upsertResult, "Order Upsert Failed");
Assert.AreEqual(c.CurrentStore.Id, target.StoreId, "Order store ID was not set correctly");
Assert.AreNotEqual(string.Empty, target.bvin, "Order failed to get a bvin");
Assert.AreEqual(1, target.Items.Count, "Item count should be one");
Assert.AreEqual(target.bvin, target.Items[0].OrderBvin, "Line item didn't receive order bvin");
Assert.AreEqual(target.StoreId, target.Items[0].StoreId, "Line item didn't recieve storeid");
}
示例11: InstantiateForMemory
public static ScheduleService InstantiateForMemory(RequestContext c)
{
return new ScheduleService(c,
QueuedTaskRepository.InstantiateForMemory(c)
);
}
示例12: SetsMetaHeaders
public void SetsMetaHeaders()
{
var request = new RequestContext(HttpMethods.Get, Enumerable.Empty<KeyValuePair<string, object>>());
request.Prepare();
Assert.AreEqual("dotnet", request.Request.Headers["X-Mashape-Language"]);
Assert.AreEqual("0.1", request.Request.Headers["X-Mashape-Version"]);
}
示例13: OnExecute
/// <summary>
/// Called when [execute].
/// </summary>
/// <param name="context">The context.</param>
/// <returns>Base return container</returns>
public override BaseReturnContainer OnExecute(RequestContext context)
{
GetUserTagsRequestContainer requestContainer = context.InParam as GetUserTagsRequestContainer;
GetUserTagsReturnContainer returnContainer = new GetUserTagsReturnContainer();
ISqlProvider sqlProvider = (ISqlProvider)ProviderFactory.Instance.CreateProvider<ISqlProvider>(requestContainer.ProviderName);
Dictionary<string, object> parameters = new Dictionary<string, object>() { { "@userId", requestContainer.UserId }, { "@deleted", false } };
DataSet returnedData = sqlProvider.ExecuteQuery(SqlQueries.GetUserProfileQuery, parameters);
if (returnedData.Tables.Count > 0 && returnedData.Tables[0].Rows.Count == 1)
{
DataRow row = returnedData.Tables[0].Rows[0];
returnContainer.Tags = row["Tags"].ToString().Split(new string[] { Constants.QuerySeparator }, StringSplitOptions.RemoveEmptyEntries).ToList<string>();
double tempDouble;
double.TryParse(row["AreaOfService"].ToString(), out tempDouble);
returnContainer.AreaOfService = tempDouble;
returnContainer.ReturnCode = ReturnCodes.C101;
}
else
{
// User does not exist
returnContainer.ReturnCode = ReturnCodes.C001;
}
return returnContainer;
}
示例14: HandleInitializeRequest
protected async Task HandleInitializeRequest(
InitializeRequest initializeParams,
RequestContext<InitializeResult> requestContext)
{
// Grab the workspace path from the parameters
editorSession.Workspace.WorkspacePath = initializeParams.RootPath;
await requestContext.SendResult(
new InitializeResult
{
Capabilities = new ServerCapabilities
{
TextDocumentSync = TextDocumentSyncKind.Incremental,
DefinitionProvider = true,
ReferencesProvider = true,
DocumentHighlightProvider = true,
DocumentSymbolProvider = true,
WorkspaceSymbolProvider = true,
HoverProvider = true,
CompletionProvider = new CompletionOptions
{
ResolveProvider = true,
TriggerCharacters = new string[] { ".", "-", ":", "\\" }
},
SignatureHelpProvider = new SignatureHelpOptions
{
TriggerCharacters = new string[] { " " } // TODO: Other characters here?
}
}
});
}
示例15: ChromiumWebBrowser
/// <summary>
/// Create a new OffScreen Chromium Browser
/// </summary>
/// <param name="address">Initial address (url) to load</param>
/// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
/// <param name="requestContext">See <see cref="RequestContext" /> for more details. Defaults to null</param>
/// <param name="automaticallyCreateBrowser">automatically create the underlying Browser</param>
/// <param name="blendPopup">Should the popup be blended in the background in the rendering</param>
/// <exception cref="System.InvalidOperationException">Cef::Initialize() failed</exception>
public ChromiumWebBrowser(string address = "", BrowserSettings browserSettings = null,
RequestContext requestContext = null, bool automaticallyCreateBrowser = true)
{
if (!Cef.IsInitialized && !Cef.Initialize())
{
throw new InvalidOperationException("Cef::Initialize() failed");
}
BitmapFactory = new BitmapFactory(BitmapLock);
ResourceHandlerFactory = new DefaultResourceHandlerFactory();
BrowserSettings = browserSettings ?? new BrowserSettings();
RequestContext = requestContext;
Cef.AddDisposable(this);
Address = address;
managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);
if (automaticallyCreateBrowser)
{
CreateBrowser(IntPtr.Zero);
}
popupPosition = new Point();
popupSize = new Size();
}