zoukankan      html  css  js  c++  java
  • OWIN详细介绍

    1.OWIN.dll介绍

    用反编译工具打开Owin.dll,你会发现类库中就只有一个IAppBuilder接口,所以说OWIN是针对.NET平台的开放Web接口。

    public interface IAppBuilder
    {
    IDictionary Properties
    {
    get;
    }
    IAppBuilder Use(object middleware, params object[] args);
    object Build(Type returnType);
    IAppBuilder New();
    }

    2.Microsoft.Owin.dll
    Microsoft.Owin.dll是微软对Owin的具体实现,其中就包括"中间件"。下文将使用代码描述自定义基于Owin的"中间件"。

    // Copyright (c) .NET Foundation. All rights reserved.
    // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
    
    using System.Threading.Tasks;
    
    namespace Microsoft.Owin
    {
    /// <summary>
    /// An abstract base class for a standard middleware pattern.
    /// </summary>
    public abstract class OwinMiddleware
    {
    /// <summary>
    /// Instantiates the middleware with an optional pointer to the next component.
    /// </summary>
    /// <param name="next"></param>
    protected OwinMiddleware(OwinMiddleware next)
    {
    Next = next;
    }
    
    /// <summary>
    /// The optional next component.
    /// </summary>
    protected OwinMiddleware Next { get; set; }
    
    /// <summary>
    /// Process an individual request.
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public abstract Task Invoke(IOwinContext context);
    }
    }

    Next是下一步处理用到的中间件。
    自定义的中间件主要是重写Invoke来实现自己的功能需求。

  • 相关阅读:
    志愿者招募 [NOI2008] [鬼畜网络流]
    莫队入门
    分块入门
    高速公路 [HAOI2012] [线段树]
    游历校园 [COGS 614] [欧拉图]
    网络吞吐量 [CQOI2015] [网络流]
    LeetCode 27. Remove Element
    LeetCode 26. Remove Duplicates from Sorted Array
    LeetCode 21. Merge Two Sorted Lists
    LeetCode 20. Valid Parentheses
  • 原文地址:https://www.cnblogs.com/zkb9604/p/11529111.html
Copyright © 2011-2022 走看看