当前位置: 首页>>代码示例>>C#>>正文


C# IContext类代码示例

本文整理汇总了C#中IContext的典型用法代码示例。如果您正苦于以下问题:C# IContext类的具体用法?C# IContext怎么用?C# IContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IContext类属于命名空间,在下文中一共展示了IContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的IContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。