本文整理汇总了C#中IContext类的典型用法代码示例。如果您正苦于以下问题:C# IContext类的具体用法?C# IContext怎么用?C# IContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IContext类属于命名空间,在下文中一共展示了IContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WriteIndexEntry
public virtual void WriteIndexEntry(IContext context, ByteArrayBuffer reader, object
obj)
{
MappedIDPair mappedIDs = (MappedIDPair)obj;
_origHandler.WriteIndexEntry(context, reader, mappedIDs.Orig());
_mappedHandler.WriteIndexEntry(context, reader, mappedIDs.Mapped());
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:7,代码来源:MappedIDPairHandler.cs
示例2: Page
public StringResult Page(XrcUrl url, object parameters = null, IContext callerContext = null)
{
try
{
var parentRequest = callerContext == null ? null : callerContext.Request;
var parentResponse = callerContext == null ? null : callerContext.Response;
using (var stream = new MemoryStream())
{
var request = new XrcRequest(url, parentRequest: parentRequest);
var response = new XrcResponse(stream, parentResponse: parentResponse);
var context = new Context(request, response);
context.CallerContext = callerContext;
AddParameters(context, parameters);
ProcessRequest(context);
context.CheckResponse();
response.Flush();
stream.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(stream, response.ContentEncoding))
{
return new StringResult(reader.ReadToEnd(), response.ContentEncoding, response.ContentType);
}
}
}
catch (Exception ex)
{
throw new PageException(url.AppRelaviteUrl, ex);
}
}
开发者ID:davideicardi,项目名称:xrc,代码行数:35,代码来源:XrcService.cs
示例3: GetLogger
/// <summary>
/// Gets the logger.
/// </summary>
/// <param name="ctx">The context.</param>
/// <returns>The logger for the given context.</returns>
private static ILog GetLogger(IContext ctx)
{
var filterContext = ctx.Request.ParentRequest.Parameters.OfType<FilterContextParameter>().SingleOrDefault();
return LogManager.GetLogger(filterContext == null ?
ctx.Request.Target.Member.DeclaringType :
filterContext.ActionDescriptor.ControllerDescriptor.ControllerType);
}
开发者ID:paigecook,项目名称:Ninject.Web.WebApi,代码行数:12,代码来源:FilterInjectionModule.cs
示例4: Render
public override void Render(HttpContextBase httpContext, IContext requestContext)
{
if (httpContext.Session != null)
foreach (object key in httpContext.Session.Keys)
{
if (requestContext.Contains(key))
throw new ApplicationException(String.Format("{0} is present on both the Session and the Request.", key));
requestContext.Add(key.ToString(), httpContext.Session[key.ToString()]);
}
try
{
var templateTuple = manager.RenderTemplate(requestContext.Response.RenderTarget, (IDictionary<string, object>)requestContext);
manager = templateTuple.Item1;
TextReader reader = templateTuple.Item2;
char[] buffer = new char[4096];
int count = 0;
while ((count = reader.ReadBlock(buffer, 0, 4096)) > 0)
httpContext.Response.Write(buffer, 0, count);
}
catch (Exception ex)
{
httpContext.Response.StatusCode = 500;
httpContext.Response.Write(RenderException(requestContext.Response.RenderTarget, ex, true));
}
}
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:27,代码来源:DjangoEngine.cs
示例5: ListenerRequest
internal ListenerRequest(HttpListenerRequest innerRequest, IContext context)
{
if (innerRequest == null) throw new ArgumentNullException("innerRequest");
if (context == null) throw new ArgumentNullException("context");
InnerRequest = innerRequest;
_context = context;
}
开发者ID:blesh,项目名称:ALE,代码行数:7,代码来源:ListenerRequest.cs
示例6: GetAll
public static List<IProject> GetAll(IContext context)
{
Context ctx = context as Context;
if (ctx == null)
throw new Exception(typeof(Context).FullName + " expected.");
SqlCommand command = new SqlCommand("select * from Project", ctx.Connection);
var adapter = new SqlDataAdapter(command);
var dataSet = new DataSet();
adapter.Fill(dataSet);
var dataTable = dataSet.Tables[0];
List<IProject> projects = new List<IProject>();
foreach (DataRow row in dataTable.Rows)
{
projects.Add(
new Project
{
ProjectID = Guid.Parse(row["id_project"].ToString()),
Name = row["name"].ToString(),
Description = row["description"].ToString(),
Status = row["status"].ToString(),
UserID = Guid.Parse(row["id_user"].ToString()),
GitHub_url = row["github_url"].ToString(),
Date_start = DateTime.Parse(row["date_start"].ToString()),
Date_end = DateTime.Parse(row["date_end"].ToString())
}
);
}
return projects;
}
开发者ID:NitrOxygeN1,项目名称:CrowdHunting,代码行数:34,代码来源:ProjectUtility.cs
示例7: ProcessRequest
/// <summary>
/// Processes the request.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="requestContext"></param>
public void ProcessRequest(HttpContextBase context, IContext requestContext)
{
// if transfer is requested, no rendering should be done
if (requestContext.TransferRequested)
return;
string renderTarget;
if (requestContext.Response.RenderTargets == null ||
(!requestContext.Response.RenderTargets.TryGetValue(renderType, out renderTarget) &&
requestContext.Response.RenderTargets.Count == 0))
{
if (requestContext.Response.CurrentReturnType == Bistro.Controllers.ReturnType.Template)
throw new ApplicationException("No template specified");
return;
}
// if the requested render type doesn't have a corresponding target supplied,
// default to the first non-empty target available.
if (String.IsNullOrEmpty(renderTarget))
renderTarget = requestContext.Response.RenderTargets.First(kvp => !String.IsNullOrEmpty(kvp.Value)).Value;
var attrs = (TemplateMappingAttribute[])GetType().GetCustomAttributes(typeof(TemplateMappingAttribute), true);
foreach (TemplateMappingAttribute attr in attrs)
if (renderTarget.EndsWith(attr.Extension))
{
((Bistro.Http.Module)context.Handler).GetTemplateEngine(EngineType).Render(context, requestContext, renderTarget);
return;
}
}
开发者ID:jijo-paulose,项目名称:bistro-framework,代码行数:36,代码来源:RenderingController.cs
示例8: Find
public static UserSession Find(string sid, IContext ctx)
{
Services.Log("UserSession.Find({0})", sid);
long ver = 0;
Buffer b = KeyValueStore.FindBuffer(sid, out ver);
UserSession ret = null;
if (b == null)
{
return null;
}
ret = Helpers.MarshalToObject<UserSession>(b);
ret.lastVersion = ver;
IPAddress addr = ctx.PeerAddress;
if (ret.peerAddress.ToString() != addr.ToString())
{
Console.WriteLine("Session {2} bound IP address changed: {0} to {1}", ret.peerAddress, addr, ret.sid);
ret.Invalidate(ctx);
return null;
}
if (ret.expiryTimeTicks < DateTime.Now.Ticks)
{
Console.WriteLine("Session {0} expired", ret.sid);
ret.Invalidate(ctx);
return null;
}
return ret;
}
开发者ID:jwatte,项目名称:mono-app-server,代码行数:27,代码来源:UserSession.cs
示例9: Title
public static IObservable<String> Title(IContext context, String url)
{
return _webRequest
.Request(url, x => x)
.Select(GetTitle)
;
}
开发者ID:Gohla,项目名称:Veda-plugins,代码行数:7,代码来源:HTTPPlugin.cs
示例10: TryHandleAsStaticContent
private static bool TryHandleAsStaticContent(IContext context)
{
var absolutePath = context.Request.Url.AbsolutePath;
string file;
if (SimpleWeb.Configuration.PublicFileMappings.ContainsKey(absolutePath))
{
file = SimpleWeb.Environment.PathUtility.MapPath(SimpleWeb.Configuration.PublicFileMappings[absolutePath]);
}
else if (
SimpleWeb.Configuration.PublicFolders.Any(
folder => absolutePath.StartsWith(folder + "/", StringComparison.OrdinalIgnoreCase)))
{
file = SimpleWeb.Environment.PathUtility.MapPath(absolutePath);
}
else
{
return false;
}
if (!File.Exists(file)) return false;
context.Response.Status = Status.OK;
context.Response.SetContentType(GetContentType(file, context.Request.GetAccept()));
context.Response.SetContentLength(new FileInfo(file).Length);
context.Response.WriteFunction = (stream) =>
{
using (var fileStream = File.OpenRead(file))
{
fileStream.CopyTo(stream);
return TaskHelper.Completed();
}
};
return true;
}
开发者ID:samsalisbury,项目名称:Simple.Web,代码行数:35,代码来源:Application.cs
示例11: TexturedExtensibleRectangle
public TexturedExtensibleRectangle(IContext context, Vector2I size, Texture texture, int fixedBorderRadius)
{
DeviceContext = context.DirectX.DeviceContext;
_shader = context.Shaders.Get<TextureShader>();
_texture = texture;
_fixedBorderRadius = fixedBorderRadius;
const int vertexCount = 16;
_vertices = new VertexDefinition.PositionTexture[vertexCount];
VertexBuffer = Buffer.Create(context.DirectX.Device, _vertices,
new BufferDescription
{
Usage = ResourceUsage.Dynamic,
SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionTexture>() * vertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
StructureByteStride = 0
});
IndexCount = 54;
uint[] indices = new uint[IndexCount];
for(uint i=0; i< 3; i++)
for (uint j = 0; j < 3; j++)
{
indices[(i * 3 + j) * 6] = (i + 1) * 4 + j + 1;
indices[(i * 3 + j) * 6 + 1] = i * 4 + j + 1;
indices[(i * 3 + j) * 6 + 2] = i * 4 + j;
indices[(i * 3 + j) * 6 + 3] = (i + 1) * 4 + j;
indices[(i * 3 + j) * 6 + 4] = (i + 1) * 4 + j + 1;
indices[(i * 3 + j) * 6 + 5] = i * 4 + j;
}
IndexBuffer = Buffer.Create(context.DirectX.Device, BindFlags.IndexBuffer, indices);
Size = size;
}
开发者ID:ndech,项目名称:Alpha,代码行数:35,代码来源:TexturedExtensibleRectangle.cs
示例12: PrepareComparison
public virtual IPreparedComparison PrepareComparison(IContext context, object source
)
{
MappedIDPair sourceIDPair = (MappedIDPair)source;
int sourceID = sourceIDPair.Orig();
return new _IPreparedComparison_50(sourceID);
}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:7,代码来源:MappedIDPairHandler.cs
示例13: GetNodeChildren
public override IEnumerable<INodeFactory> GetNodeChildren(IContext context)
{
foreach (ProjectItem item in _project.ProjectItems)
{
if (item is Project)
{
yield return new ProjectCodeModelNodeFactory(item as Project);
}
var projectItem = item as ProjectItem;
if (null != projectItem.SubProject)
{
yield return new ProjectCodeModelNodeFactory(projectItem.SubProject);
}
if (null != item.FileCodeModel)
{
yield return new ProjectItemCodeModelNodeFactory(item);
}
if (item.Kind == Constants.vsProjectItemKindPhysicalFolder)
{
yield return new ProjectFolderCodeModelItemNodeFactory(item);
}
}
}
开发者ID:wangchunlei,项目名称:MyGit,代码行数:27,代码来源:ProjectCodeModelNodeFactory.cs
示例14: AddExpenseViewModel
public AddExpenseViewModel(IContext context)
{
_context = context;
InitializeCommands();
InitilializeCategories();
}
开发者ID:Bitzie,项目名称:ExpenseManager,代码行数:7,代码来源:AddExpenseViewModel.cs
示例15: ResolveInstance
/*----------------------------------------------------------------------------------------*/
#region Protected Methods
/// <summary>
/// Resolves the dependency.
/// </summary>
/// <param name="outerContext">The context in which the dependency was requested.</param>
/// <param name="innerContext">The context in which the dependency should be resolved.</param>
/// <returns>An object that satisfies the dependency.</returns>
protected override object ResolveInstance(IContext outerContext, IContext innerContext)
{
var selector = outerContext.Binding.Components.BindingSelector;
IBinding binding = selector.SelectBinding(innerContext.Service, innerContext);
return (binding == null) ? null : binding.Provider;
}
开发者ID:jamarlthomas,项目名称:ninject1,代码行数:15,代码来源:ProviderResolver.cs
示例16: FixtureSetUp
public void FixtureSetUp()
{
_stateData = new Hashtable();
_context = MockRepository.GenerateStub<IContext>();
_context.Stub(x => x.HttpContext).Return(MockRepository.GenerateStub<HttpContextBase>());
_context.HttpContext.Stub(x => x.Session).Return(MockRepository.GenerateMock<HttpSessionStateBase>());
_context.HttpContext.Session.Stub(x => x.SyncRoot).Return(new object());
_context.HttpContext.Session.Stub(x => x.Clear()).WhenCalled(invocation => _stateData.Clear());
_context.HttpContext.Session.Stub(x => x.Remove(Arg<string>.Is.Anything)).WhenCalled(invocation =>
{
var key = invocation.Arguments[0];
_stateData.Remove(key);
});
_context.HttpContext.Session.Stub(x => x[Arg<string>.Is.Anything])
.Return("")
.WhenCalled(invocation =>
{
var key = invocation.Arguments[0];
invocation.ReturnValue = _stateData[key];
});
_context.HttpContext.Session.Stub(x => x[Arg<string>.Is.Anything] = Arg<object>.Is.Anything)
.WhenCalled(invocation =>
{
var key = invocation.Arguments[0];
var value = invocation.Arguments[1];
_stateData[key] = value;
});
//_context.HttpContext.Session.Expect(x => x[Utils.BuildFullKey<string>(null)])
// .Return("Blah")
// .Do(invocation => invocation.ReturnValue = "DEF");
//_context.HttpContext.Session[Utils.BuildFullKey<string>(null)] = _stateData[Utils.BuildFullKey<string>(null)];
//_context.HttpContext.Session["test_key".BuildFullKey<string>()] = _stateData["test_key".BuildFullKey<string>()];
}
开发者ID:jordanyaker,项目名称:ncommon,代码行数:35,代码来源:HttpSessionStateTests.cs
示例17: Render
public static void Render(object item, int count, bool isExpanded, IDrawingToolkit tk,
IContext context, Area backgroundArea, Area cellArea, CellState state)
{
if (item is EventType) {
RenderAnalysisCategory (item as EventType, count, isExpanded, tk,
context, backgroundArea, cellArea);
} else if (item is SubstitutionEvent) {
SubstitutionEvent s = item as SubstitutionEvent;
RenderSubstitution (s.Color, s.EventTime, s.In, s.Out, s.Selected, isExpanded, tk, context,
backgroundArea, cellArea, state);
} else if (item is TimelineEvent) {
TimelineEvent p = item as TimelineEvent;
RenderPlay (p.Color, p.Miniature, p.Players, p.Selected, p.Description, count, isExpanded, tk,
context, backgroundArea, cellArea, state);
} else if (item is Player) {
RenderPlayer (item as Player, count, isExpanded, tk, context, backgroundArea, cellArea);
} else if (item is Playlist) {
RenderPlaylist (item as Playlist, count, isExpanded, tk, context, backgroundArea, cellArea);
} else if (item is PlaylistPlayElement) {
PlaylistPlayElement p = item as PlaylistPlayElement;
RenderPlay (p.Play.EventType.Color, p.Miniature, null, p.Selected, p.Description, count, isExpanded, tk,
context, backgroundArea, cellArea, state);
} else if (item is IPlaylistElement) {
IPlaylistElement p = item as IPlaylistElement;
RenderPlay (Config.Style.PaletteActive, p.Miniature, null, p.Selected, p.Description,
count, isExpanded, tk, context, backgroundArea, cellArea, state);
} else {
Log.Error ("No renderer for type " + item.GetType ());
}
}
开发者ID:GNOME,项目名称:longomatch,代码行数:30,代码来源:PlayslistCellRenderer.cs
示例18: Activate
public override void Activate( IContext context, InstanceReference reference )
{
var messageBroker = context.Kernel.Components.Get<IMessageBroker>();
List<PublicationDirective> publications = context.Plan.GetAll<PublicationDirective>().ToList();
// I don't think this is needed in Ninject2
//if (publications.Count > 0)
// context.ShouldTrackInstance = true;
foreach ( PublicationDirective publication in publications )
{
IMessageChannel channel = messageBroker.GetChannel( publication.Channel );
channel.AddPublication( reference.Instance, publication.Event );
}
List<SubscriptionDirective> subscriptions = context.Plan.GetAll<SubscriptionDirective>().ToList();
// I don't think this is needed in Ninject2
//if (subscriptions.Count > 0)
// context.ShouldTrackInstance = true;
foreach ( SubscriptionDirective subscription in subscriptions )
{
IMessageChannel channel = messageBroker.GetChannel( subscription.Channel );
channel.AddSubscription( reference.Instance, subscription.Injector, subscription.Thread );
}
}
开发者ID:MiguelMadero,项目名称:ninject.extensions.messagebroker,代码行数:28,代码来源:EventBindingStrategy.cs
示例19: ConstructorsAmbiguous
/// <summary>
/// Generates a message saying that the constructor is ambiguous.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="bestDirectives">The best constructor directives.</param>
/// <returns>The exception message.</returns>
public static string ConstructorsAmbiguous(IContext context, IGrouping<int, ConstructorInjectionDirective> bestDirectives)
{
using (var sw = new StringWriter())
{
sw.WriteLine("Error activating {0} using {1}", context.Request.Service.Format(), context.Binding.Format(context));
sw.WriteLine("Several constructors have the same priority. Please specify the constructor using ToConstructor syntax or add an Inject attribute.");
sw.WriteLine();
sw.WriteLine("Constructors:");
foreach (var constructorInjectionDirective in bestDirectives)
{
FormatConstructor(constructorInjectionDirective.Constructor, sw);
}
sw.WriteLine();
sw.WriteLine("Activation path:");
sw.WriteLine(context.Request.FormatActivationPath());
sw.WriteLine("Suggestions:");
sw.WriteLine(" 1) Ensure that the implementation type has a public constructor.");
sw.WriteLine(" 2) If you have implemented the Singleton pattern, use a binding with InSingletonScope() instead.");
return sw.ToString();
}
}
开发者ID:remogloor,项目名称:ninject,代码行数:32,代码来源:ExceptionFormatter.cs
示例20: Process
/// <summary>
/// Wraps interfaces in a Castle dynamic proxy
/// </summary>
/// <param name="target">The target.</param>
/// <param name="context">The context.</param>
/// <returns></returns>
public object Process(object target, IContext context)
{
QueryTargetType(target.GetType());
var interceptors = context.GetAllInstances<IInterceptor>();
return new ProxyGenerator().CreateInterfaceProxyWithTargetInterface(_targetInterface, target, interceptors.ToArray());
}
开发者ID:jrobinson,项目名称:Snap,代码行数:13,代码来源:StructureMapAspectInterceptor.cs
注:本文中的IContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论