├── .gitignore ├── README.md └── src ├── AW.Pay.Core ├── AW.Pay.Core.csproj ├── AliPay.cs ├── App.config ├── Common │ ├── BizResult.cs │ ├── Config.cs │ ├── HTTPHelper.cs │ ├── MD5Helper.cs │ └── RSAFromPkcs8.cs ├── Enum │ ├── EnumAliPayTradeType.cs │ ├── EnumBizCode.cs │ ├── EnumSignType.cs │ └── EnumWePayTradeType.cs ├── Interface │ ├── IAlipay.cs │ └── IWePay.cs ├── Model │ ├── AlipayReturnModel.cs │ └── WepayReturnModel.cs ├── Properties │ └── AssemblyInfo.cs ├── WePay.cs └── packages.config ├── AW.Webapi.Sample ├── AW.Webapi.Sample.csproj ├── App_Start │ ├── Bootstrapper.cs │ ├── BundleConfig.cs │ ├── FilterConfig.cs │ ├── IdentityConfig.cs │ ├── RouteConfig.cs │ ├── Startup.Auth.cs │ └── WebApiConfig.cs ├── Areas │ ├── Api │ │ └── Controllers │ │ │ └── PaymentController.cs │ └── HelpPage │ │ ├── ApiDescriptionExtensions.cs │ │ ├── App_Start │ │ └── HelpPageConfig.cs │ │ ├── Controllers │ │ └── HelpController.cs │ │ ├── HelpPage.css │ │ ├── HelpPageAreaRegistration.cs │ │ ├── HelpPageConfigurationExtensions.cs │ │ ├── ModelDescriptions │ │ ├── CollectionModelDescription.cs │ │ ├── ComplexTypeModelDescription.cs │ │ ├── DictionaryModelDescription.cs │ │ ├── EnumTypeModelDescription.cs │ │ ├── EnumValueDescription.cs │ │ ├── IModelDocumentationProvider.cs │ │ ├── KeyValuePairModelDescription.cs │ │ ├── ModelDescription.cs │ │ ├── ModelDescriptionGenerator.cs │ │ ├── ModelNameAttribute.cs │ │ ├── ModelNameHelper.cs │ │ ├── ParameterAnnotation.cs │ │ ├── ParameterDescription.cs │ │ └── SimpleTypeModelDescription.cs │ │ ├── Models │ │ └── HelpPageApiModel.cs │ │ ├── SampleGeneration │ │ ├── HelpPageSampleGenerator.cs │ │ ├── HelpPageSampleKey.cs │ │ ├── ImageSample.cs │ │ ├── InvalidSample.cs │ │ ├── ObjectGenerator.cs │ │ ├── SampleDirection.cs │ │ └── TextSample.cs │ │ ├── TestClient.css │ │ ├── Views │ │ ├── Help │ │ │ ├── Api.cshtml │ │ │ ├── DisplayTemplates │ │ │ │ ├── ApiGroup.cshtml │ │ │ │ ├── CollectionModelDescription.cshtml │ │ │ │ ├── ComplexTypeModelDescription.cshtml │ │ │ │ ├── DictionaryModelDescription.cshtml │ │ │ │ ├── EnumTypeModelDescription.cshtml │ │ │ │ ├── HelpPageApiModel.cshtml │ │ │ │ ├── ImageSample.cshtml │ │ │ │ ├── InvalidSample.cshtml │ │ │ │ ├── KeyValuePairModelDescription.cshtml │ │ │ │ ├── ModelDescriptionLink.cshtml │ │ │ │ ├── Parameters.cshtml │ │ │ │ ├── Samples.cshtml │ │ │ │ ├── SimpleTypeModelDescription.cshtml │ │ │ │ ├── TestClientDialogs.cshtml │ │ │ │ ├── TestClientReferences.cshtml │ │ │ │ └── TextSample.cshtml │ │ │ ├── Index.cshtml │ │ │ └── ResourceModel.cshtml │ │ ├── Shared │ │ │ └── _Layout.cshtml │ │ ├── Web.config │ │ └── _ViewStart.cshtml │ │ └── XmlDocumentationProvider.cs ├── Content │ ├── Site.css │ ├── bootstrap.css │ ├── bootstrap.min.css │ └── themes │ │ └── base │ │ ├── images │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ ├── ui-icons_222222_256x240.png │ │ ├── ui-icons_2e83ff_256x240.png │ │ ├── ui-icons_454545_256x240.png │ │ ├── ui-icons_888888_256x240.png │ │ └── ui-icons_cd0a0a_256x240.png │ │ ├── jquery-ui.css │ │ ├── jquery.ui.accordion.css │ │ ├── jquery.ui.all.css │ │ ├── jquery.ui.autocomplete.css │ │ ├── jquery.ui.base.css │ │ ├── jquery.ui.button.css │ │ ├── jquery.ui.core.css │ │ ├── jquery.ui.datepicker.css │ │ ├── jquery.ui.dialog.css │ │ ├── jquery.ui.menu.css │ │ ├── jquery.ui.progressbar.css │ │ ├── jquery.ui.resizable.css │ │ ├── jquery.ui.selectable.css │ │ ├── jquery.ui.slider.css │ │ ├── jquery.ui.spinner.css │ │ ├── jquery.ui.tabs.css │ │ ├── jquery.ui.theme.css │ │ ├── jquery.ui.tooltip.css │ │ └── minified │ │ ├── images │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ ├── ui-icons_222222_256x240.png │ │ ├── ui-icons_2e83ff_256x240.png │ │ ├── ui-icons_454545_256x240.png │ │ ├── ui-icons_888888_256x240.png │ │ └── ui-icons_cd0a0a_256x240.png │ │ ├── jquery-ui.min.css │ │ ├── jquery.ui.accordion.min.css │ │ ├── jquery.ui.autocomplete.min.css │ │ ├── jquery.ui.button.min.css │ │ ├── jquery.ui.core.min.css │ │ ├── jquery.ui.datepicker.min.css │ │ ├── jquery.ui.dialog.min.css │ │ ├── jquery.ui.menu.min.css │ │ ├── jquery.ui.progressbar.min.css │ │ ├── jquery.ui.resizable.min.css │ │ ├── jquery.ui.selectable.min.css │ │ ├── jquery.ui.slider.min.css │ │ ├── jquery.ui.spinner.min.css │ │ ├── jquery.ui.tabs.min.css │ │ ├── jquery.ui.theme.min.css │ │ └── jquery.ui.tooltip.min.css ├── Controllers │ ├── AccountController.cs │ ├── HomeController.cs │ ├── PaymentController.cs │ └── ValuesController.cs ├── Global.asax ├── Global.asax.cs ├── Models │ ├── AccountBindingModels.cs │ ├── AccountViewModels.cs │ ├── IdentityModels.cs │ └── PayModel │ │ ├── AliPayReqParam.cs │ │ └── WePayReqParam.cs ├── Project_Readme.html ├── Properties │ └── AssemblyInfo.cs ├── Providers │ └── ApplicationOAuthProvider.cs ├── Results │ └── ChallengeResult.cs ├── Scripts │ ├── WebApiTestClient.js │ ├── _references.js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery-1.10.2.intellisense.js │ ├── jquery-1.10.2.js │ ├── jquery-1.10.2.min.js │ ├── jquery-1.10.2.min.map │ ├── jquery-ui-1.9.2.js │ ├── jquery-ui-1.9.2.min.js │ ├── jquery.qrcode.min.js │ ├── jquery.validate-vsdoc.js │ ├── jquery.validate.js │ ├── jquery.validate.min.js │ ├── jquery.validate.unobtrusive.js │ ├── jquery.validate.unobtrusive.min.js │ ├── knockout-3.2.0.debug.js │ ├── knockout-3.2.0.js │ ├── modernizr-2.6.2.js │ ├── respond.js │ └── respond.min.js ├── Startup.cs ├── Views │ ├── Home │ │ └── Index.cshtml │ ├── Payment │ │ ├── AliPayDemo.cshtml │ │ ├── Index.cshtml │ │ ├── WePay.cshtml │ │ └── WePayDemo.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ └── _Layout.cshtml │ ├── Web.config │ └── _ViewStart.cshtml ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff └── packages.config ├── AlipayAndWepay.Net.sln └── ConsoleTest ├── App.config ├── ConsoleTest.csproj ├── Program.cs └── Properties └── AssemblyInfo.cs /.gitignore: -------------------------------------------------------------------------------- 1 | /src/AW.Pay.Core/bin 2 | /src/AW.Pay.Core/obj 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AlipayandWepay-NETAPI 2 | 3 | 由于工作中手上项目需要实现后台封装支付相关的功能,所以做了相应的开发工作,发现.NET后台封装这些支付功能在开发中还是有很多坑的,为了方便大家免于重复我的痛苦,所以整理了一下,把这些功能开放出来,其实算不上SDK,但还算有点价值,大家将就着参看参考吧。 4 | 5 | 本SDK主要是对国内经常用到的支付宝和微信的.NET后台封装,主要包括: 6 | 7 | 支付宝: 8 | 1.网站支付 9 | 2.Wap支付 10 | 3.APP支付 11 | 12 | 微信: 13 | 1.公众号支付 14 | 2.原生扫码支付 15 | 3.app支付 16 | 4.wap支付(浏览器调用微信app,目前腾讯还未对外开放) 17 | 18 | PS: 19 | 1.其中关于支付宝以及微信的app支付,此SDK仅提供后台的封装参数,具体调用仍需将这些封装后的参数扔进相应的原生SDK中。 20 | 2.关于微信扫码支付的API,需要将本SDK返回的URL自己转换成二维码方式,以便客户端扫码。 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/AW.Pay.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E} 8 | Library 9 | Properties 10 | AW.Pay.Core 11 | AW.Pay.Core 12 | v4.6.1 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll 35 | True 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 79 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Common/BizResult.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core.Enum; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AW.Pay.Core.Common 9 | { 10 | /// 11 | /// HTTP请求返回信息 12 | /// 13 | /// 14 | public class BizResult 15 | { 16 | private EnumBizCode _code; 17 | private string _message = ""; 18 | private T _returnObject; 19 | 20 | /// 21 | /// 编码 22 | /// 23 | public EnumBizCode Code 24 | { 25 | get 26 | { 27 | return _code; 28 | } 29 | set 30 | { 31 | _code = value; 32 | } 33 | } 34 | 35 | /// 36 | /// 返回信息 37 | /// 38 | public string Message 39 | { 40 | get 41 | { 42 | return _message; 43 | } 44 | set 45 | { 46 | _message = value; 47 | } 48 | } 49 | 50 | /// 51 | /// 返回对象 52 | /// 53 | public T ReturnObject 54 | { 55 | get 56 | { 57 | return _returnObject; 58 | } 59 | set 60 | { 61 | _returnObject = value; 62 | } 63 | } 64 | 65 | public BizResult(EnumBizCode resultCode = EnumBizCode.Success, string message = "操作成功") 66 | { 67 | this._code = resultCode; 68 | this._message = message; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Common/Config.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | 3 | namespace AW.Pay.Core 4 | { 5 | public static class AlipayConfig 6 | { 7 | #region Alipay config 8 | public static string ALIPay_URL = ConfigurationManager.AppSettings["ALIPay_URL"]; 9 | public static string ALIPay_NotifyURL = ConfigurationManager.AppSettings["ALIPay_NotifyURL"]; 10 | public static string ALIPay_ErrorURL = ConfigurationManager.AppSettings["ALIPay_ErrorURL"]; 11 | public static string ALI_PARTER = ConfigurationManager.AppSettings["ALI_PARTER"]; 12 | public static string ALI_KEY = ConfigurationManager.AppSettings["ALI_KEY"]; 13 | public static string ALI_ACCOUNT = ConfigurationManager.AppSettings["ALI_ACCOUNT"]; 14 | public static string CHARTSET = "utf-8";//固定值 15 | public static string PAYMENT_TYPE = "1";//固定值 16 | public static string ALI_SELLERID = ConfigurationManager.AppSettings["ALI_SELLERID"]; 17 | public static string ALI_SELLEREMAIL = ConfigurationManager.AppSettings["ALI_SELLEREMAIL"]; 18 | public static string ALI_HTTPS_VERYFY_URL = ConfigurationManager.AppSettings["ALI_HTTPS_VERYFY_URL"]; 19 | 20 | public static string ALIPay_WAP_SERVICE = ConfigurationManager.AppSettings["ALIPay_WAP_SERVICE"]; 21 | public static string ALIPay_WEB_SERVICE = ConfigurationManager.AppSettings["ALIPay_WEB_SERVICE"]; 22 | public static string ALIPay_MOBILE_SERVICE = ConfigurationManager.AppSettings["ALIPay_MOBILE_SERVICE"]; 23 | 24 | public static string ALIPay_RSA_PUBLICKEY = ConfigurationManager.AppSettings["ALIPay_RSA_PUBLICKEY"]; 25 | public static string ALIPay_RSA_PRIVATEKEY = ConfigurationManager.AppSettings["ALIPay_RSA_PRIVATEKEY"]; 26 | public static string ALIPay_RSA_ALI_PUBLICKEY = ConfigurationManager.AppSettings["ALIPay_RSA_ALI_PUBLICKEY"]; 27 | #endregion 28 | } 29 | 30 | public static class WepayConfig 31 | { 32 | public static string WEPAY_CHARTSET = "utf-8"; 33 | public static string WEPAY_PAY_URL = ConfigurationManager.AppSettings["WEPAY_PAY_URL"];//统一下单URL 34 | public static string WEPAY_ORDERQUERY_URL = ConfigurationManager.AppSettings["WEPAY_ORDERQUERY_URL"]; 35 | 36 | #region 微信开发者平台(APP支付) 37 | public static string WEPAY_APP_APPID = ConfigurationManager.AppSettings["WEPAY_MP_APPID"]; 38 | public static string WEPAY_APP_MCH_ID = ConfigurationManager.AppSettings["WEPAY_MP_MCH_ID"]; 39 | public static string WEPAY_APP_NOTIFY_URL = ConfigurationManager.AppSettings["WEPAY_MP_NOTIFY_URL"]; 40 | public static string WEPAY_APP_URL = ConfigurationManager.AppSettings["WEPAY_MP_URL"]; 41 | public static string WEPAY_APP_KEY = ConfigurationManager.AppSettings["WEPAY_APP_KEY"]; 42 | 43 | 44 | #endregion 45 | 46 | #region 微信公众平台(扫码、公众号支付) 47 | public static string WEPAY_WEB_APPID = ConfigurationManager.AppSettings["WEPAY_WEB_APPID"]; 48 | public static string WEPAY_WEB_MCH_ID = ConfigurationManager.AppSettings["WEPAY_WEB_MCH_ID"]; 49 | public static string WEPAY_WEB_NOTIFY_URL = ConfigurationManager.AppSettings["WEPAY_WEB_NOTIFY_URL"]; 50 | public static string WEPAY_WEB_URL = ConfigurationManager.AppSettings["WEPAY_WEB_URL"]; 51 | public static string WEPAY_WEB_KEY = ConfigurationManager.AppSettings["WEPAY_WEB_KEY"]; 52 | #endregion 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Common/HTTPHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Net.Http.Formatting; 6 | using System.Net.Http.Headers; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace AW.Pay.Core 11 | { 12 | public static class HTTPHelper 13 | { 14 | public static string Post(string url, string content, string contentType = "application/x-www-form-urlencoded") 15 | { 16 | string result = string.Empty; 17 | try 18 | { 19 | using (var client = new HttpClient()) 20 | { 21 | client.DefaultRequestHeaders.Accept.Clear(); 22 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(contentType)); 23 | var stringContent = new StringContent(content, Encoding.UTF8); 24 | var response = client.PostAsync(url, stringContent).Result; 25 | result = response.Content.ReadAsStringAsync().Result; 26 | } 27 | } 28 | catch (Exception e) 29 | { 30 | throw new Exception("POST请求错误" + e.ToString()); 31 | } 32 | return result; 33 | } 34 | 35 | public static string Get(string url, int timeout, string contentType = "application/x-www-form-urlencoded") 36 | { 37 | string result = string.Empty; 38 | try 39 | { 40 | using (var client = new HttpClient()) 41 | { 42 | client.Timeout = new TimeSpan(0, 0, 0, 0, timeout); 43 | var response = client.GetAsync(url).Result; 44 | result = response.Content.ReadAsStringAsync().Result; 45 | }; 46 | } 47 | catch (Exception e) 48 | { 49 | throw new Exception("GET请求错误" + e.ToString()); 50 | } 51 | return result; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Common/MD5Helper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Cryptography; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace AW.Pay.Core 9 | { 10 | public sealed class MD5Helper 11 | { 12 | public static string Sign(string prestr, string _input_charset) 13 | { 14 | StringBuilder sb = new StringBuilder(32); 15 | MD5 md5 = new MD5CryptoServiceProvider(); 16 | byte[] t = md5.ComputeHash(Encoding.GetEncoding(_input_charset).GetBytes(prestr)); 17 | for (int i = 0; i < t.Length; i++) 18 | { 19 | sb.Append(t[i].ToString("x").PadLeft(2, '0')); 20 | } 21 | 22 | return sb.ToString(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Enum/EnumAliPayTradeType.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Pay.Core 2 | { 3 | /// 4 | /// AliPay交易类型 5 | /// 6 | public enum EnumAliPayTradeType 7 | { 8 | /// 9 | /// 网站支付 10 | /// 11 | Website = 0, 12 | /// 13 | /// wap支付 14 | /// 15 | Wap, 16 | /// 17 | /// APP支付 18 | /// 19 | APP 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Enum/EnumBizCode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AW.Pay.Core.Enum 8 | { 9 | /// 10 | /// 业务返回code 11 | /// 12 | public enum EnumBizCode 13 | { 14 | /// 15 | /// 成功 16 | /// 17 | Success = 1000, 18 | 19 | /// 20 | /// 失败 21 | /// 22 | Failed 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Enum/EnumSignType.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Pay.Core 2 | { 3 | public enum EnumSignType 4 | { 5 | /// 6 | /// MD5 7 | /// 8 | MD5 = 0, 9 | /// 10 | /// RSA 11 | /// 12 | RSA, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Enum/EnumWePayTradeType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AW.Pay.Core.Enum 8 | { 9 | public enum EnumWePayTradeType 10 | { 11 | /// 12 | /// 公众号支付 13 | /// 14 | JSAPI = 0, 15 | /// 16 | /// 原生扫码支付 17 | /// 18 | NATIVE, 19 | /// 20 | /// app支付 21 | /// 22 | APP, 23 | /// 24 | /// wap支付(浏览器调用微信app,目前腾讯还未对外开放) 25 | /// 26 | WAP 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Interface/IAlipay.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core.Model; 2 | using System.Web; 3 | 4 | namespace AW.Pay.Core.Interface 5 | { 6 | public interface IAlipay 7 | { 8 | /// 9 | /// 创建支付宝支付 10 | /// 11 | /// 订单号 12 | /// 标题 13 | /// 支付金额 14 | /// 交易类型(网站支付、wap支付、APP支付) 15 | /// 16 | string BuildAliPay(string orderNo, string subject, decimal payAmount, EnumAliPayTradeType tradeType); 17 | 18 | /// 19 | /// 验证支付宝回调,并获取相关返回参数 20 | /// 21 | /// HTTP请求 22 | /// 当验证成功后,获取主要返回参数 23 | /// 验证结果 24 | bool VerifyReturnURL(HttpRequestBase request, out AliPayReturnModel model); 25 | 26 | /// 27 | /// 验证支付宝异步通知,并获取相关返回参数 28 | /// 29 | /// HTTP请求 30 | /// 当验证成功后,获取主要返回参数 31 | /// 验证结果 32 | bool VerfyNotify(HttpRequestBase request, out AliPayReturnModel model); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Interface/IWePay.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core.Enum; 2 | using AW.Pay.Core.Model; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Web; 9 | 10 | namespace AW.Pay.Core.Interface 11 | { 12 | public interface IWePay 13 | { 14 | /// 15 | /// 创建微信支付 16 | /// 17 | /// 订单号 18 | /// 产品名称 19 | /// 总金额,单位分 20 | /// 调用IP 21 | /// 交易类型(公众号支付、扫码支付、APP、WAP支付) 22 | /// 23 | /// 扫码支付:返回支付URL 24 | /// APP支付:返回Json字符串,包含支付sdk支付参数 25 | /// 公众号支付&WAP支付:暂未实现 26 | /// 27 | string BuildWePay(string orderNo, string productName, int totalFee, string customerIP, EnumWePayTradeType tradeType); 28 | 29 | /// 30 | /// 微信支付异步通知验证 31 | /// 32 | /// HTTP请求 33 | /// 当验证成功后,获取主要返回参数 34 | /// 验证结果 35 | bool VerifyNotify(HttpRequestBase request, out WePayReturnModel model); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Model/AlipayReturnModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AW.Pay.Core.Model 8 | { 9 | public class AliPayReturnModel 10 | { 11 | /// 12 | /// 商户订单号 13 | /// 14 | public string OutTradeNo { get; set; } 15 | 16 | /// 17 | /// 交易订单号 18 | /// 19 | public string TradeNo { get; set; } 20 | 21 | /// 22 | /// 交易总金额 23 | /// 24 | public decimal TotalFee { get; set; } 25 | 26 | /// 27 | /// 交易状态 28 | /// 29 | public string TradeStatus { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Model/WepayReturnModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AW.Pay.Core.Model 8 | { 9 | public class WePayReturnModel 10 | { 11 | /// 12 | /// 商户订单号 13 | /// 14 | public string OutTradeNo { get; set; } 15 | 16 | /// 17 | /// 交易订单号 18 | /// 19 | public string TradeNo { get; set; } 20 | 21 | /// 22 | /// 交易金额(单位元) 23 | /// 24 | public decimal TotalFee { get; set; } 25 | 26 | /// 27 | /// 交易状态 28 | /// 29 | public string TradeStatus { get; set; } 30 | 31 | /// 32 | /// 返回xml 33 | /// 34 | public string ReturnXml { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("AW.Pay.Core")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AW.Pay.Core")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("3c998ee8-7f0b-4d26-a5b9-abc15ad6298e")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/AW.Pay.Core/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/Bootstrapper.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Integration.Mvc; 3 | using Autofac.Integration.WebApi; 4 | using AW.Pay.Core; 5 | using AW.Pay.Core.Interface; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Reflection; 10 | using System.Web; 11 | using System.Web.Http; 12 | using System.Web.Mvc; 13 | 14 | namespace AW.Webapi.Sample.App_Start 15 | { 16 | public class Bootstrapper 17 | { 18 | public static void Run() 19 | { 20 | SetAutoFacContainer(); 21 | } 22 | 23 | private static void SetAutoFacContainer() 24 | { 25 | var builder = new ContainerBuilder(); 26 | 27 | //Get HttpConfiguration 28 | var config = GlobalConfiguration.Configuration; 29 | 30 | //Register MVC Controller 31 | builder.RegisterControllers(Assembly.GetExecutingAssembly()); 32 | 33 | //Register Web Api Controller 34 | builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); 35 | 36 | //Register Pay Interface 37 | builder.RegisterType().As().InstancePerRequest(); 38 | builder.RegisterType().As().InstancePerRequest(); 39 | 40 | //Set the dependency resolver to be Autofac 41 | var container = builder.Build(); 42 | config.DependencyResolver = new AutofacWebApiDependencyResolver(container); //Web Api 43 | DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); //MVC 44 | 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace AW.Webapi.Sample 5 | { 6 | public class BundleConfig 7 | { 8 | // 有关绑定的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | // 使用要用于开发和学习的 Modernizr 的开发版本。然后,当你做好 15 | // 生产准备时,请使用 http://modernizr.com 上的生成工具来仅选择所需的测试。 16 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 17 | "~/Scripts/modernizr-*")); 18 | 19 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 20 | "~/Scripts/bootstrap.js", 21 | "~/Scripts/respond.js")); 22 | 23 | bundles.Add(new StyleBundle("~/Content/css").Include( 24 | "~/Content/bootstrap.css", 25 | "~/Content/site.css")); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace AW.Webapi.Sample 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/IdentityConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNet.Identity; 3 | using Microsoft.AspNet.Identity.EntityFramework; 4 | using Microsoft.AspNet.Identity.Owin; 5 | using Microsoft.Owin; 6 | using AW.Webapi.Sample.Models; 7 | 8 | namespace AW.Webapi.Sample 9 | { 10 | // 配置此应用程序中使用的应用程序用户管理器。UserManager 在 ASP.NET Identity 中定义,并由此应用程序使用。 11 | 12 | public class ApplicationUserManager : UserManager 13 | { 14 | public ApplicationUserManager(IUserStore store) 15 | : base(store) 16 | { 17 | } 18 | 19 | public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) 20 | { 21 | var manager = new ApplicationUserManager(new UserStore(context.Get())); 22 | // 配置用户名的验证逻辑 23 | manager.UserValidator = new UserValidator(manager) 24 | { 25 | AllowOnlyAlphanumericUserNames = false, 26 | RequireUniqueEmail = true 27 | }; 28 | // 配置密码的验证逻辑 29 | manager.PasswordValidator = new PasswordValidator 30 | { 31 | RequiredLength = 6, 32 | RequireNonLetterOrDigit = true, 33 | RequireDigit = true, 34 | RequireLowercase = true, 35 | RequireUppercase = true, 36 | }; 37 | var dataProtectionProvider = options.DataProtectionProvider; 38 | if (dataProtectionProvider != null) 39 | { 40 | manager.UserTokenProvider = new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")); 41 | } 42 | return manager; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace AW.Webapi.Sample 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/Startup.Auth.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNet.Identity; 5 | using Microsoft.AspNet.Identity.EntityFramework; 6 | using Microsoft.Owin; 7 | using Microsoft.Owin.Security.Cookies; 8 | using Microsoft.Owin.Security.Google; 9 | using Microsoft.Owin.Security.OAuth; 10 | using Owin; 11 | using AW.Webapi.Sample.Providers; 12 | using AW.Webapi.Sample.Models; 13 | 14 | namespace AW.Webapi.Sample 15 | { 16 | public partial class Startup 17 | { 18 | public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; } 19 | 20 | public static string PublicClientId { get; private set; } 21 | 22 | // 有关配置身份验证的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=301864 23 | public void ConfigureAuth(IAppBuilder app) 24 | { 25 | // 将数据库上下文和用户管理器配置为对每个请求使用单个实例 26 | app.CreatePerOwinContext(ApplicationDbContext.Create); 27 | app.CreatePerOwinContext(ApplicationUserManager.Create); 28 | 29 | // 使应用程序可以使用 Cookie 来存储已登录用户的信息 30 | // 并使用 Cookie 来临时存储有关使用第三方登录提供程序登录的用户的信息 31 | app.UseCookieAuthentication(new CookieAuthenticationOptions()); 32 | app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 33 | 34 | // 针对基于 OAuth 的流配置应用程序 35 | PublicClientId = "self"; 36 | OAuthOptions = new OAuthAuthorizationServerOptions 37 | { 38 | TokenEndpointPath = new PathString("/Token"), 39 | Provider = new ApplicationOAuthProvider(PublicClientId), 40 | AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), 41 | AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), 42 | //在生产模式下设 AllowInsecureHttp = false 43 | AllowInsecureHttp = true 44 | }; 45 | 46 | // 使应用程序可以使用不记名令牌来验证用户身份 47 | app.UseOAuthBearerTokens(OAuthOptions); 48 | 49 | // 取消注释以下行可允许使用第三方登录提供程序登录 50 | //app.UseMicrosoftAccountAuthentication( 51 | // clientId: "", 52 | // clientSecret: ""); 53 | 54 | //app.UseTwitterAuthentication( 55 | // consumerKey: "", 56 | // consumerSecret: ""); 57 | 58 | //app.UseFacebookAuthentication( 59 | // appId: "", 60 | // appSecret: ""); 61 | 62 | //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 63 | //{ 64 | // ClientId = "", 65 | // ClientSecret = "" 66 | //}); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Web.Http; 6 | using Microsoft.Owin.Security.OAuth; 7 | using Newtonsoft.Json.Serialization; 8 | 9 | namespace AW.Webapi.Sample 10 | { 11 | public static class WebApiConfig 12 | { 13 | public static void Register(HttpConfiguration config) 14 | { 15 | // Web API 配置和服务 16 | // 将 Web API 配置为仅使用不记名令牌身份验证。 17 | config.SuppressDefaultHostAuthentication(); 18 | config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); 19 | 20 | // Web API 路由 21 | config.MapHttpAttributeRoutes(); 22 | 23 | config.Routes.MapHttpRoute( 24 | name: "DefaultApi", 25 | routeTemplate: "api/{controller}/{action}/{id}", 26 | defaults: new { id = RouteParameter.Optional } 27 | ); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/Api/Controllers/PaymentController.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core.Common; 2 | using AW.Pay.Core.Interface; 3 | using AW.Pay.Core.Model; 4 | using AW.Webapi.Sample.Models.PayModel; 5 | using System.Net.Http; 6 | using System.Web; 7 | using System.Web.Http; 8 | 9 | namespace AW.Webapi.Sample.Areas.Api.Controllers 10 | { 11 | public class PaymentController : ApiController 12 | { 13 | private readonly IAlipay _aliPay; 14 | private readonly IWePay _wePay; 15 | public PaymentController(IAlipay aliPay, IWePay wePay) 16 | { 17 | this._aliPay = aliPay; 18 | this._wePay = wePay; 19 | } 20 | /// 21 | /// 生成支付宝请求参数 22 | /// 23 | /// 24 | /// 25 | [HttpPost] 26 | public BizResult CreateAliPayRequestParam(AliPayReqParam payInfo) 27 | { 28 | BizResult biz = new BizResult(); 29 | biz.ReturnObject = this._aliPay.BuildAliPay(payInfo.OrderNo, payInfo.Subject, payInfo.TotalAmount, payInfo.Type); ; 30 | return biz; 31 | } 32 | 33 | /// 34 | /// 支付宝支付结果异步通知 35 | /// 36 | /// Form表单 37 | [HttpPost] 38 | public void AlipayNotify() 39 | { 40 | AliPayReturnModel payResult = new AliPayReturnModel(); 41 | HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context 42 | HttpRequestBase request = context.Request;//定义传统request对象 43 | var result = this._aliPay.VerfyNotify(request,out payResult); 44 | } 45 | 46 | /// 47 | /// 生成支付宝请求参数 48 | /// 49 | /// 50 | /// 51 | [HttpPost] 52 | public BizResult CreateWePayRequestParam(WePayReqParam payInfo) 53 | { 54 | BizResult biz = new BizResult(); 55 | biz.ReturnObject = this._wePay.BuildWePay(payInfo.OrderNo,payInfo.ProductName,payInfo.TotalFee,payInfo.CustomerIp,payInfo.TradeType); ; 56 | return biz; 57 | } 58 | 59 | /// 60 | /// 微信支付支付结果异步通知 61 | /// 62 | /// 63 | [HttpPost] 64 | public void WePayNotify() 65 | { 66 | WePayReturnModel payResult = new WePayReturnModel(); 67 | HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context 68 | HttpRequestBase request = context.Request;//定义传统request对象 69 | var result = this._wePay.VerifyNotify(request, out payResult); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ApiDescriptionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Web; 4 | using System.Web.Http.Description; 5 | 6 | namespace AW.Webapi.Sample.Areas.HelpPage 7 | { 8 | public static class ApiDescriptionExtensions 9 | { 10 | /// 11 | /// Generates an URI-friendly ID for the . E.g. "Get-Values-id_name" instead of "GetValues/{id}?name={name}" 12 | /// 13 | /// The . 14 | /// The ID as a string. 15 | public static string GetFriendlyId(this ApiDescription description) 16 | { 17 | string path = description.RelativePath; 18 | string[] urlParts = path.Split('?'); 19 | string localPath = urlParts[0]; 20 | string queryKeyString = null; 21 | if (urlParts.Length > 1) 22 | { 23 | string query = urlParts[1]; 24 | string[] queryKeys = HttpUtility.ParseQueryString(query).AllKeys; 25 | queryKeyString = String.Join("_", queryKeys); 26 | } 27 | 28 | StringBuilder friendlyPath = new StringBuilder(); 29 | friendlyPath.AppendFormat("{0}-{1}", 30 | description.HttpMethod.Method, 31 | localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty)); 32 | if (queryKeyString != null) 33 | { 34 | friendlyPath.AppendFormat("_{0}", queryKeyString.Replace('.', '-')); 35 | } 36 | return friendlyPath.ToString(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/App_Start/HelpPageConfig.cs: -------------------------------------------------------------------------------- 1 | // Uncomment the following to provide samples for PageResult. Must also add the Microsoft.AspNet.WebApi.OData 2 | // package to your project. 3 | ////#define Handle_PageResultOfT 4 | 5 | using System; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.Diagnostics.CodeAnalysis; 10 | using System.Linq; 11 | using System.Net.Http.Headers; 12 | using System.Reflection; 13 | using System.Web; 14 | using System.Web.Http; 15 | #if Handle_PageResultOfT 16 | using System.Web.Http.OData; 17 | #endif 18 | 19 | namespace AW.Webapi.Sample.Areas.HelpPage 20 | { 21 | /// 22 | /// Use this class to customize the Help Page. 23 | /// For example you can set a custom to supply the documentation 24 | /// or you can provide the samples for the requests/responses. 25 | /// 26 | public static class HelpPageConfig 27 | { 28 | [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", 29 | MessageId = "AW.Webapi.Sample.Areas.HelpPage.TextSample.#ctor(System.String)", 30 | Justification = "End users may choose to merge this string with existing localized resources.")] 31 | [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", 32 | MessageId = "bsonspec", 33 | Justification = "Part of a URI.")] 34 | public static void Register(HttpConfiguration config) 35 | { 36 | //// Uncomment the following to use the documentation from XML documentation file. 37 | //config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"))); 38 | 39 | //// Uncomment the following to use "sample string" as the sample for all actions that have string as the body parameter or return type. 40 | //// Also, the string arrays will be used for IEnumerable. The sample objects will be serialized into different media type 41 | //// formats by the available formatters. 42 | //config.SetSampleObjects(new Dictionary 43 | //{ 44 | // {typeof(string), "sample string"}, 45 | // {typeof(IEnumerable), new string[]{"sample 1", "sample 2"}} 46 | //}); 47 | 48 | // Extend the following to provide factories for types not handled automatically (those lacking parameterless 49 | // constructors) or for which you prefer to use non-default property values. Line below provides a fallback 50 | // since automatic handling will fail and GeneratePageResult handles only a single type. 51 | #if Handle_PageResultOfT 52 | config.GetHelpPageSampleGenerator().SampleObjectFactories.Add(GeneratePageResult); 53 | #endif 54 | 55 | // Extend the following to use a preset object directly as the sample for all actions that support a media 56 | // type, regardless of the body parameter or return type. The lines below avoid display of binary content. 57 | // The BsonMediaTypeFormatter (if available) is not used to serialize the TextSample object. 58 | config.SetSampleForMediaType( 59 | new TextSample("Binary JSON content. See http://bsonspec.org for details."), 60 | new MediaTypeHeaderValue("application/bson")); 61 | 62 | //// Uncomment the following to use "[0]=foo&[1]=bar" directly as the sample for all actions that support form URL encoded format 63 | //// and have IEnumerable as the body parameter or return type. 64 | //config.SetSampleForType("[0]=foo&[1]=bar", new MediaTypeHeaderValue("application/x-www-form-urlencoded"), typeof(IEnumerable)); 65 | 66 | //// Uncomment the following to use "1234" directly as the request sample for media type "text/plain" on the controller named "Values" 67 | //// and action named "Put". 68 | //config.SetSampleRequest("1234", new MediaTypeHeaderValue("text/plain"), "Values", "Put"); 69 | 70 | //// Uncomment the following to use the image on "../images/aspNetHome.png" directly as the response sample for media type "image/png" 71 | //// on the controller named "Values" and action named "Get" with parameter "id". 72 | //config.SetSampleResponse(new ImageSample("../images/aspNetHome.png"), new MediaTypeHeaderValue("image/png"), "Values", "Get", "id"); 73 | 74 | //// Uncomment the following to correct the sample request when the action expects an HttpRequestMessage with ObjectContent. 75 | //// The sample will be generated as if the controller named "Values" and action named "Get" were having string as the body parameter. 76 | //config.SetActualRequestType(typeof(string), "Values", "Get"); 77 | 78 | //// Uncomment the following to correct the sample response when the action returns an HttpResponseMessage with ObjectContent. 79 | //// The sample will be generated as if the controller named "Values" and action named "Post" were returning a string. 80 | //config.SetActualResponseType(typeof(string), "Values", "Post"); 81 | } 82 | 83 | #if Handle_PageResultOfT 84 | private static object GeneratePageResult(HelpPageSampleGenerator sampleGenerator, Type type) 85 | { 86 | if (type.IsGenericType) 87 | { 88 | Type openGenericType = type.GetGenericTypeDefinition(); 89 | if (openGenericType == typeof(PageResult<>)) 90 | { 91 | // Get the T in PageResult 92 | Type[] typeParameters = type.GetGenericArguments(); 93 | Debug.Assert(typeParameters.Length == 1); 94 | 95 | // Create an enumeration to pass as the first parameter to the PageResult constuctor 96 | Type itemsType = typeof(List<>).MakeGenericType(typeParameters); 97 | object items = sampleGenerator.GetSampleObject(itemsType); 98 | 99 | // Fill in the other information needed to invoke the PageResult constuctor 100 | Type[] parameterTypes = new Type[] { itemsType, typeof(Uri), typeof(long?), }; 101 | object[] parameters = new object[] { items, null, (long)ObjectGenerator.DefaultCollectionSize, }; 102 | 103 | // Call PageResult(IEnumerable items, Uri nextPageLink, long? count) constructor 104 | ConstructorInfo constructor = type.GetConstructor(parameterTypes); 105 | return constructor.Invoke(parameters); 106 | } 107 | } 108 | 109 | return null; 110 | } 111 | #endif 112 | } 113 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Controllers/HelpController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Http; 3 | using System.Web.Mvc; 4 | using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions; 5 | using AW.Webapi.Sample.Areas.HelpPage.Models; 6 | 7 | namespace AW.Webapi.Sample.Areas.HelpPage.Controllers 8 | { 9 | /// 10 | /// The controller that will handle requests for the help page. 11 | /// 12 | public class HelpController : Controller 13 | { 14 | private const string ErrorViewName = "Error"; 15 | 16 | public HelpController() 17 | : this(GlobalConfiguration.Configuration) 18 | { 19 | } 20 | 21 | public HelpController(HttpConfiguration config) 22 | { 23 | Configuration = config; 24 | } 25 | 26 | public HttpConfiguration Configuration { get; private set; } 27 | 28 | public ActionResult Index() 29 | { 30 | ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider(); 31 | return View(Configuration.Services.GetApiExplorer().ApiDescriptions); 32 | } 33 | 34 | public ActionResult Api(string apiId) 35 | { 36 | if (!String.IsNullOrEmpty(apiId)) 37 | { 38 | HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId); 39 | if (apiModel != null) 40 | { 41 | return View(apiModel); 42 | } 43 | } 44 | 45 | return View(ErrorViewName); 46 | } 47 | 48 | public ActionResult ResourceModel(string modelName) 49 | { 50 | if (!String.IsNullOrEmpty(modelName)) 51 | { 52 | ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator(); 53 | ModelDescription modelDescription; 54 | if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription)) 55 | { 56 | return View(modelDescription); 57 | } 58 | } 59 | 60 | return View(ErrorViewName); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/HelpPage.css: -------------------------------------------------------------------------------- 1 | .help-page h1, 2 | .help-page .h1, 3 | .help-page h2, 4 | .help-page .h2, 5 | .help-page h3, 6 | .help-page .h3, 7 | #body.help-page, 8 | .help-page-table th, 9 | .help-page-table pre, 10 | .help-page-table p { 11 | font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; 12 | } 13 | 14 | .help-page pre.wrapped { 15 | white-space: -moz-pre-wrap; 16 | white-space: -pre-wrap; 17 | white-space: -o-pre-wrap; 18 | white-space: pre-wrap; 19 | } 20 | 21 | .help-page .warning-message-container { 22 | margin-top: 20px; 23 | padding: 0 10px; 24 | color: #525252; 25 | background: #EFDCA9; 26 | border: 1px solid #CCCCCC; 27 | } 28 | 29 | .help-page-table { 30 | width: 100%; 31 | border-collapse: collapse; 32 | text-align: left; 33 | margin: 0px 0px 20px 0px; 34 | border-top: 1px solid #D4D4D4; 35 | } 36 | 37 | .help-page-table th { 38 | text-align: left; 39 | font-weight: bold; 40 | border-bottom: 1px solid #D4D4D4; 41 | padding: 5px 6px 5px 6px; 42 | } 43 | 44 | .help-page-table td { 45 | border-bottom: 1px solid #D4D4D4; 46 | padding: 10px 8px 10px 8px; 47 | vertical-align: top; 48 | } 49 | 50 | .help-page-table pre, 51 | .help-page-table p { 52 | margin: 0px; 53 | padding: 0px; 54 | font-family: inherit; 55 | font-size: 100%; 56 | } 57 | 58 | .help-page-table tbody tr:hover td { 59 | background-color: #F3F3F3; 60 | } 61 | 62 | .help-page a:hover { 63 | background-color: transparent; 64 | } 65 | 66 | .help-page .sample-header { 67 | border: 2px solid #D4D4D4; 68 | background: #00497E; 69 | color: #FFFFFF; 70 | padding: 8px 15px; 71 | border-bottom: none; 72 | display: inline-block; 73 | margin: 10px 0px 0px 0px; 74 | } 75 | 76 | .help-page .sample-content { 77 | display: block; 78 | border-width: 0; 79 | padding: 15px 20px; 80 | background: #FFFFFF; 81 | border: 2px solid #D4D4D4; 82 | margin: 0px 0px 10px 0px; 83 | } 84 | 85 | .help-page .api-name { 86 | width: 40%; 87 | } 88 | 89 | .help-page .api-documentation { 90 | width: 60%; 91 | } 92 | 93 | .help-page .parameter-name { 94 | width: 20%; 95 | } 96 | 97 | .help-page .parameter-documentation { 98 | width: 40%; 99 | } 100 | 101 | .help-page .parameter-type { 102 | width: 20%; 103 | } 104 | 105 | .help-page .parameter-annotations { 106 | width: 20%; 107 | } 108 | 109 | .help-page h1, 110 | .help-page .h1 { 111 | font-size: 36px; 112 | line-height: normal; 113 | } 114 | 115 | .help-page h2, 116 | .help-page .h2 { 117 | font-size: 24px; 118 | } 119 | 120 | .help-page h3, 121 | .help-page .h3 { 122 | font-size: 20px; 123 | } 124 | 125 | #body.help-page { 126 | font-size: 14px; 127 | line-height: 143%; 128 | color: #333; 129 | } 130 | 131 | .help-page a { 132 | color: #0000EE; 133 | text-decoration: none; 134 | } 135 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/HelpPageAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Http; 2 | using System.Web.Mvc; 3 | 4 | namespace AW.Webapi.Sample.Areas.HelpPage 5 | { 6 | public class HelpPageAreaRegistration : AreaRegistration 7 | { 8 | public override string AreaName 9 | { 10 | get 11 | { 12 | return "HelpPage"; 13 | } 14 | } 15 | 16 | public override void RegisterArea(AreaRegistrationContext context) 17 | { 18 | context.MapRoute( 19 | "HelpPage_Default", 20 | "Help/{action}/{apiId}", 21 | new { controller = "Help", action = "Index", apiId = UrlParameter.Optional }); 22 | 23 | HelpPageConfig.Register(GlobalConfiguration.Configuration); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class CollectionModelDescription : ModelDescription 4 | { 5 | public ModelDescription ElementDescription { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ComplexTypeModelDescription : ModelDescription 6 | { 7 | public ComplexTypeModelDescription() 8 | { 9 | Properties = new Collection(); 10 | } 11 | 12 | public Collection Properties { get; private set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class DictionaryModelDescription : KeyValuePairModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class EnumTypeModelDescription : ModelDescription 7 | { 8 | public EnumTypeModelDescription() 9 | { 10 | Values = new Collection(); 11 | } 12 | 13 | public Collection Values { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class EnumValueDescription 4 | { 5 | public string Documentation { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public string Value { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 5 | { 6 | public interface IModelDocumentationProvider 7 | { 8 | string GetDocumentation(MemberInfo member); 9 | 10 | string GetDocumentation(Type type); 11 | } 12 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class KeyValuePairModelDescription : ModelDescription 4 | { 5 | public ModelDescription KeyModelDescription { get; set; } 6 | 7 | public ModelDescription ValueModelDescription { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/ModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Describes a type model. 7 | /// 8 | public abstract class ModelDescription 9 | { 10 | public string Documentation { get; set; } 11 | 12 | public Type ModelType { get; set; } 13 | 14 | public string Name { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Use this attribute to change the name of the generated for a type. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = false, Inherited = false)] 9 | public sealed class ModelNameAttribute : Attribute 10 | { 11 | public ModelNameAttribute(string name) 12 | { 13 | Name = name; 14 | } 15 | 16 | public string Name { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 7 | { 8 | internal static class ModelNameHelper 9 | { 10 | // Modify this to provide custom model name mapping. 11 | public static string GetModelName(Type type) 12 | { 13 | ModelNameAttribute modelNameAttribute = type.GetCustomAttribute(); 14 | if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name)) 15 | { 16 | return modelNameAttribute.Name; 17 | } 18 | 19 | string modelName = type.Name; 20 | if (type.IsGenericType) 21 | { 22 | // Format the generic type name to something like: GenericOfAgurment1AndArgument2 23 | Type genericType = type.GetGenericTypeDefinition(); 24 | Type[] genericArguments = type.GetGenericArguments(); 25 | string genericTypeName = genericType.Name; 26 | 27 | // Trim the generic parameter counts from the name 28 | genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); 29 | string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray(); 30 | modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames)); 31 | } 32 | 33 | return modelName; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ParameterAnnotation 6 | { 7 | public Attribute AnnotationAttribute { get; set; } 8 | 9 | public string Documentation { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class ParameterDescription 7 | { 8 | public ParameterDescription() 9 | { 10 | Annotations = new Collection(); 11 | } 12 | 13 | public Collection Annotations { get; private set; } 14 | 15 | public string Documentation { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public ModelDescription TypeDescription { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class SimpleTypeModelDescription : ModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Models/HelpPageApiModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Net.Http.Headers; 4 | using System.Web.Http.Description; 5 | using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions; 6 | 7 | namespace AW.Webapi.Sample.Areas.HelpPage.Models 8 | { 9 | /// 10 | /// The model that represents an API displayed on the help page. 11 | /// 12 | public class HelpPageApiModel 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public HelpPageApiModel() 18 | { 19 | UriParameters = new Collection(); 20 | SampleRequests = new Dictionary(); 21 | SampleResponses = new Dictionary(); 22 | ErrorMessages = new Collection(); 23 | } 24 | 25 | /// 26 | /// Gets or sets the that describes the API. 27 | /// 28 | public ApiDescription ApiDescription { get; set; } 29 | 30 | /// 31 | /// Gets or sets the collection that describes the URI parameters for the API. 32 | /// 33 | public Collection UriParameters { get; private set; } 34 | 35 | /// 36 | /// Gets or sets the documentation for the request. 37 | /// 38 | public string RequestDocumentation { get; set; } 39 | 40 | /// 41 | /// Gets or sets the that describes the request body. 42 | /// 43 | public ModelDescription RequestModelDescription { get; set; } 44 | 45 | /// 46 | /// Gets the request body parameter descriptions. 47 | /// 48 | public IList RequestBodyParameters 49 | { 50 | get 51 | { 52 | return GetParameterDescriptions(RequestModelDescription); 53 | } 54 | } 55 | 56 | /// 57 | /// Gets or sets the that describes the resource. 58 | /// 59 | public ModelDescription ResourceDescription { get; set; } 60 | 61 | /// 62 | /// Gets the resource property descriptions. 63 | /// 64 | public IList ResourceProperties 65 | { 66 | get 67 | { 68 | return GetParameterDescriptions(ResourceDescription); 69 | } 70 | } 71 | 72 | /// 73 | /// Gets the sample requests associated with the API. 74 | /// 75 | public IDictionary SampleRequests { get; private set; } 76 | 77 | /// 78 | /// Gets the sample responses associated with the API. 79 | /// 80 | public IDictionary SampleResponses { get; private set; } 81 | 82 | /// 83 | /// Gets the error messages associated with this model. 84 | /// 85 | public Collection ErrorMessages { get; private set; } 86 | 87 | private static IList GetParameterDescriptions(ModelDescription modelDescription) 88 | { 89 | ComplexTypeModelDescription complexTypeModelDescription = modelDescription as ComplexTypeModelDescription; 90 | if (complexTypeModelDescription != null) 91 | { 92 | return complexTypeModelDescription.Properties; 93 | } 94 | 95 | CollectionModelDescription collectionModelDescription = modelDescription as CollectionModelDescription; 96 | if (collectionModelDescription != null) 97 | { 98 | complexTypeModelDescription = collectionModelDescription.ElementDescription as ComplexTypeModelDescription; 99 | if (complexTypeModelDescription != null) 100 | { 101 | return complexTypeModelDescription.Properties; 102 | } 103 | } 104 | 105 | return null; 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/SampleGeneration/HelpPageSampleKey.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Net.Http.Headers; 5 | 6 | namespace AW.Webapi.Sample.Areas.HelpPage 7 | { 8 | /// 9 | /// This is used to identify the place where the sample should be applied. 10 | /// 11 | public class HelpPageSampleKey 12 | { 13 | /// 14 | /// Creates a new based on media type. 15 | /// 16 | /// The media type. 17 | public HelpPageSampleKey(MediaTypeHeaderValue mediaType) 18 | { 19 | if (mediaType == null) 20 | { 21 | throw new ArgumentNullException("mediaType"); 22 | } 23 | 24 | ActionName = String.Empty; 25 | ControllerName = String.Empty; 26 | MediaType = mediaType; 27 | ParameterNames = new HashSet(StringComparer.OrdinalIgnoreCase); 28 | } 29 | 30 | /// 31 | /// Creates a new based on media type and CLR type. 32 | /// 33 | /// The media type. 34 | /// The CLR type. 35 | public HelpPageSampleKey(MediaTypeHeaderValue mediaType, Type type) 36 | : this(mediaType) 37 | { 38 | if (type == null) 39 | { 40 | throw new ArgumentNullException("type"); 41 | } 42 | 43 | ParameterType = type; 44 | } 45 | 46 | /// 47 | /// Creates a new based on , controller name, action name and parameter names. 48 | /// 49 | /// The . 50 | /// Name of the controller. 51 | /// Name of the action. 52 | /// The parameter names. 53 | public HelpPageSampleKey(SampleDirection sampleDirection, string controllerName, string actionName, IEnumerable parameterNames) 54 | { 55 | if (!Enum.IsDefined(typeof(SampleDirection), sampleDirection)) 56 | { 57 | throw new InvalidEnumArgumentException("sampleDirection", (int)sampleDirection, typeof(SampleDirection)); 58 | } 59 | if (controllerName == null) 60 | { 61 | throw new ArgumentNullException("controllerName"); 62 | } 63 | if (actionName == null) 64 | { 65 | throw new ArgumentNullException("actionName"); 66 | } 67 | if (parameterNames == null) 68 | { 69 | throw new ArgumentNullException("parameterNames"); 70 | } 71 | 72 | ControllerName = controllerName; 73 | ActionName = actionName; 74 | ParameterNames = new HashSet(parameterNames, StringComparer.OrdinalIgnoreCase); 75 | SampleDirection = sampleDirection; 76 | } 77 | 78 | /// 79 | /// Creates a new based on media type, , controller name, action name and parameter names. 80 | /// 81 | /// The media type. 82 | /// The . 83 | /// Name of the controller. 84 | /// Name of the action. 85 | /// The parameter names. 86 | public HelpPageSampleKey(MediaTypeHeaderValue mediaType, SampleDirection sampleDirection, string controllerName, string actionName, IEnumerable parameterNames) 87 | : this(sampleDirection, controllerName, actionName, parameterNames) 88 | { 89 | if (mediaType == null) 90 | { 91 | throw new ArgumentNullException("mediaType"); 92 | } 93 | 94 | MediaType = mediaType; 95 | } 96 | 97 | /// 98 | /// Gets the name of the controller. 99 | /// 100 | /// 101 | /// The name of the controller. 102 | /// 103 | public string ControllerName { get; private set; } 104 | 105 | /// 106 | /// Gets the name of the action. 107 | /// 108 | /// 109 | /// The name of the action. 110 | /// 111 | public string ActionName { get; private set; } 112 | 113 | /// 114 | /// Gets the media type. 115 | /// 116 | /// 117 | /// The media type. 118 | /// 119 | public MediaTypeHeaderValue MediaType { get; private set; } 120 | 121 | /// 122 | /// Gets the parameter names. 123 | /// 124 | public HashSet ParameterNames { get; private set; } 125 | 126 | public Type ParameterType { get; private set; } 127 | 128 | /// 129 | /// Gets the . 130 | /// 131 | public SampleDirection? SampleDirection { get; private set; } 132 | 133 | public override bool Equals(object obj) 134 | { 135 | HelpPageSampleKey otherKey = obj as HelpPageSampleKey; 136 | if (otherKey == null) 137 | { 138 | return false; 139 | } 140 | 141 | return String.Equals(ControllerName, otherKey.ControllerName, StringComparison.OrdinalIgnoreCase) && 142 | String.Equals(ActionName, otherKey.ActionName, StringComparison.OrdinalIgnoreCase) && 143 | (MediaType == otherKey.MediaType || (MediaType != null && MediaType.Equals(otherKey.MediaType))) && 144 | ParameterType == otherKey.ParameterType && 145 | SampleDirection == otherKey.SampleDirection && 146 | ParameterNames.SetEquals(otherKey.ParameterNames); 147 | } 148 | 149 | public override int GetHashCode() 150 | { 151 | int hashCode = ControllerName.ToUpperInvariant().GetHashCode() ^ ActionName.ToUpperInvariant().GetHashCode(); 152 | if (MediaType != null) 153 | { 154 | hashCode ^= MediaType.GetHashCode(); 155 | } 156 | if (SampleDirection != null) 157 | { 158 | hashCode ^= SampleDirection.GetHashCode(); 159 | } 160 | if (ParameterType != null) 161 | { 162 | hashCode ^= ParameterType.GetHashCode(); 163 | } 164 | foreach (string parameterName in ParameterNames) 165 | { 166 | hashCode ^= parameterName.ToUpperInvariant().GetHashCode(); 167 | } 168 | 169 | return hashCode; 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/SampleGeneration/ImageSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an image sample on the help page. There's a display template named ImageSample associated with this class. 7 | /// 8 | public class ImageSample 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The URL of an image. 14 | public ImageSample(string src) 15 | { 16 | if (src == null) 17 | { 18 | throw new ArgumentNullException("src"); 19 | } 20 | Src = src; 21 | } 22 | 23 | public string Src { get; private set; } 24 | 25 | public override bool Equals(object obj) 26 | { 27 | ImageSample other = obj as ImageSample; 28 | return other != null && Src == other.Src; 29 | } 30 | 31 | public override int GetHashCode() 32 | { 33 | return Src.GetHashCode(); 34 | } 35 | 36 | public override string ToString() 37 | { 38 | return Src; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/SampleGeneration/InvalidSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an invalid sample on the help page. There's a display template named InvalidSample associated with this class. 7 | /// 8 | public class InvalidSample 9 | { 10 | public InvalidSample(string errorMessage) 11 | { 12 | if (errorMessage == null) 13 | { 14 | throw new ArgumentNullException("errorMessage"); 15 | } 16 | ErrorMessage = errorMessage; 17 | } 18 | 19 | public string ErrorMessage { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | InvalidSample other = obj as InvalidSample; 24 | return other != null && ErrorMessage == other.ErrorMessage; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return ErrorMessage.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return ErrorMessage; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/SampleGeneration/SampleDirection.cs: -------------------------------------------------------------------------------- 1 | namespace AW.Webapi.Sample.Areas.HelpPage 2 | { 3 | /// 4 | /// Indicates whether the sample is used for request or response 5 | /// 6 | public enum SampleDirection 7 | { 8 | Request = 0, 9 | Response 10 | } 11 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/SampleGeneration/TextSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AW.Webapi.Sample.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents a preformatted text sample on the help page. There's a display template named TextSample associated with this class. 7 | /// 8 | public class TextSample 9 | { 10 | public TextSample(string text) 11 | { 12 | if (text == null) 13 | { 14 | throw new ArgumentNullException("text"); 15 | } 16 | Text = text; 17 | } 18 | 19 | public string Text { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | TextSample other = obj as TextSample; 24 | return other != null && Text == other.Text; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return Text.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return Text; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/TestClient.css: -------------------------------------------------------------------------------- 1 | .httpMethod { 2 | width: 20%; 3 | } 4 | 5 | .uriPath { 6 | width: 70%; 7 | } 8 | 9 | .sampleArea { 10 | width: 95%; 11 | } 12 | 13 | #testClientButton { 14 | position: fixed; 15 | right: 0; 16 | bottom: 0; 17 | width: 150px; 18 | font-size: x-large; 19 | } 20 | 21 | select { 22 | margin-top: 10px; 23 | } 24 | 25 | .panel { 26 | max-height: 120px; 27 | overflow: auto; 28 | } 29 | 30 | .panel input { 31 | width: 150px; 32 | } 33 | 34 | .uriParameterLabel { 35 | width: 100px; 36 | float: left; 37 | border: none; 38 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/Api.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using AW.Webapi.Sample.Areas.HelpPage.Models 3 | @model HelpPageApiModel 4 | @section Scripts { 5 | @Html.DisplayForModel("TestClientDialogs") 6 | @Html.DisplayForModel("TestClientReferences") 7 | } 8 | 9 | @{ 10 | var description = Model.ApiDescription; 11 | ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath; 12 | } 13 | 14 | 15 |
16 | 23 |
24 | @Html.DisplayForModel() 25 |
26 |
27 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using AW.Webapi.Sample.Areas.HelpPage 5 | @using AW.Webapi.Sample.Areas.HelpPage.Models 6 | @model IGrouping 7 | 8 | @{ 9 | var controllerDocumentation = ViewBag.DocumentationProvider != null ? 10 | ViewBag.DocumentationProvider.GetDocumentation(Model.Key) : 11 | null; 12 | } 13 | 14 |

@Model.Key.ControllerName

15 | @if (!String.IsNullOrEmpty(controllerDocumentation)) 16 | { 17 |

@controllerDocumentation

18 | } 19 | 20 | 21 | 22 | 23 | 24 | @foreach (var api in Model) 25 | { 26 | 27 | 28 | 38 | 39 | } 40 | 41 |
APIDescription
@api.HttpMethod.Method @api.RelativePath 29 | @if (api.Documentation != null) 30 | { 31 |

@api.Documentation

32 | } 33 | else 34 | { 35 |

No documentation available.

36 | } 37 |
-------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model CollectionModelDescription 3 | @if (Model.ElementDescription is ComplexTypeModelDescription) 4 | { 5 | @Html.DisplayFor(m => m.ElementDescription) 6 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model ComplexTypeModelDescription 3 | @Html.DisplayFor(m => m.Properties, "Parameters") -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model DictionaryModelDescription 3 | Dictionary of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model EnumTypeModelDescription 3 | 4 |

Possible enumeration values:

5 | 6 | 7 | 8 | 9 | 10 | 11 | @foreach (EnumValueDescription value in Model.Values) 12 | { 13 | 14 | 15 | 18 | 21 | 22 | } 23 | 24 |
NameValueDescription
@value.Name 16 |

@value.Value

17 |
19 |

@value.Documentation

20 |
-------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Description 3 | @using AW.Webapi.Sample.Areas.HelpPage.Models 4 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 5 | @model HelpPageApiModel 6 | 7 | @{ 8 | ApiDescription description = Model.ApiDescription; 9 | } 10 |

@description.HttpMethod.Method @description.RelativePath

11 |
12 |

@description.Documentation

13 | 14 |

Request Information

15 | 16 |

URI Parameters

17 | @Html.DisplayFor(m => m.UriParameters, "Parameters") 18 | 19 |

Body Parameters

20 | 21 |

@Model.RequestDocumentation

22 | 23 | @if (Model.RequestModelDescription != null) 24 | { 25 | @Html.DisplayFor(m => m.RequestModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.RequestModelDescription }) 26 | if (Model.RequestBodyParameters != null) 27 | { 28 | @Html.DisplayFor(m => m.RequestBodyParameters, "Parameters") 29 | } 30 | } 31 | else 32 | { 33 |

None.

34 | } 35 | 36 | @if (Model.SampleRequests.Count > 0) 37 | { 38 |

Request Formats

39 | @Html.DisplayFor(m => m.SampleRequests, "Samples") 40 | } 41 | 42 |

Response Information

43 | 44 |

Resource Description

45 | 46 |

@description.ResponseDescription.Documentation

47 | 48 | @if (Model.ResourceDescription != null) 49 | { 50 | @Html.DisplayFor(m => m.ResourceDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ResourceDescription }) 51 | if (Model.ResourceProperties != null) 52 | { 53 | @Html.DisplayFor(m => m.ResourceProperties, "Parameters") 54 | } 55 | } 56 | else 57 | { 58 |

None.

59 | } 60 | 61 | @if (Model.SampleResponses.Count > 0) 62 | { 63 |

Response Formats

64 | @Html.DisplayFor(m => m.SampleResponses, "Samples") 65 | } 66 | 67 |
-------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage 2 | @model ImageSample 3 | 4 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage 2 | @model InvalidSample 3 | 4 | @if (HttpContext.Current.IsDebuggingEnabled) 5 | { 6 |
7 |

@Model.ErrorMessage

8 |
9 | } 10 | else 11 | { 12 |

Sample not available.

13 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model KeyValuePairModelDescription 3 | Pair of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model Type 3 | @{ 4 | ModelDescription modelDescription = ViewBag.modelDescription; 5 | if (modelDescription is ComplexTypeModelDescription || modelDescription is EnumTypeModelDescription) 6 | { 7 | if (Model == typeof(Object)) 8 | { 9 | @:Object 10 | } 11 | else 12 | { 13 | @Html.ActionLink(modelDescription.Name, "ResourceModel", "Help", new { modelName = modelDescription.Name }, null) 14 | } 15 | } 16 | else if (modelDescription is CollectionModelDescription) 17 | { 18 | var collectionDescription = modelDescription as CollectionModelDescription; 19 | var elementDescription = collectionDescription.ElementDescription; 20 | @:Collection of @Html.DisplayFor(m => elementDescription.ModelType, "ModelDescriptionLink", new { modelDescription = elementDescription }) 21 | } 22 | else 23 | { 24 | @Html.DisplayFor(m => modelDescription) 25 | } 26 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Collections.Generic 2 | @using System.Collections.ObjectModel 3 | @using System.Web.Http.Description 4 | @using System.Threading 5 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 6 | @model IList 7 | 8 | @if (Model.Count > 0) 9 | { 10 | 11 | 12 | 13 | 14 | 15 | @foreach (ParameterDescription parameter in Model) 16 | { 17 | ModelDescription modelDescription = parameter.TypeDescription; 18 | 19 | 20 | 23 | 26 | 39 | 40 | } 41 | 42 |
NameDescriptionTypeAdditional information
@parameter.Name 21 |

@parameter.Documentation

22 |
24 | @Html.DisplayFor(m => modelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = modelDescription }) 25 | 27 | @if (parameter.Annotations.Count > 0) 28 | { 29 | foreach (var annotation in parameter.Annotations) 30 | { 31 |

@annotation.Documentation

32 | } 33 | } 34 | else 35 | { 36 |

None.

37 | } 38 |
43 | } 44 | else 45 | { 46 |

None.

47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Net.Http.Headers 2 | @model Dictionary 3 | 4 | @{ 5 | // Group the samples into a single tab if they are the same. 6 | Dictionary samples = Model.GroupBy(pair => pair.Value).ToDictionary( 7 | pair => String.Join(", ", pair.Select(m => m.Key.ToString()).ToArray()), 8 | pair => pair.Key); 9 | var mediaTypes = samples.Keys; 10 | } 11 |
12 | @foreach (var mediaType in mediaTypes) 13 | { 14 |

@mediaType

15 |
16 | Sample: 17 | @{ 18 | var sample = samples[mediaType]; 19 | if (sample == null) 20 | { 21 |

Sample not available.

22 | } 23 | else 24 | { 25 | @Html.DisplayFor(s => sample); 26 | } 27 | } 28 |
29 | } 30 |
-------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 2 | @model SimpleTypeModelDescription 3 | @Model.Documentation -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/TestClientDialogs.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using AW.Webapi.Sample.Areas.HelpPage.Models 3 | @model HelpPageApiModel 4 | 5 | @{ 6 | var description = Model.ApiDescription; 7 | string applicationPath = Request.ApplicationPath; 8 | if (!applicationPath.EndsWith("/")) 9 | { 10 | applicationPath += "/"; 11 | } 12 | } 13 | 14 | 15 |
16 | 17 | 18 |
19 |
URI parameters
20 |
21 |
22 |
23 | 24 | = 25 | 26 | 27 |
28 |
29 |
30 |
31 |
Headers | Add header 32 |
33 |
34 |
35 |
36 | 37 | : 38 | 39 | Delete 40 |
41 |
42 |
43 |
44 | Body
45 |
46 |
47 | Samples: 48 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |
56 |
Status
57 | 58 |
59 |
60 |
Headers
61 | 62 |
63 |
64 |
Body
65 | 66 |
67 |
68 | 69 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/TestClientReferences.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Text.RegularExpressions 2 | 3 | 4 | @* Automatically grabs the installed version of JQuery/JQueryUI/KnockoutJS *@ 5 | @{var filePattern = @"(jquery-[0-9]+.[0-9]+.[0-9]+.js|jquery-ui-[0-9]+.[0-9]+.[0-9]+.js|knockout-[0-9]+.[0-9]+.[0-9]+.js)";} 6 | @foreach (var item in Directory.GetFiles(Server.MapPath(@"~/Scripts")).Where(f => Regex.IsMatch(f, filePattern))) 7 | { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml: -------------------------------------------------------------------------------- 1 | @using AW.Webapi.Sample.Areas.HelpPage 2 | @model TextSample 3 | 4 |
5 | @Model.Text
6 | 
-------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using System.Collections.ObjectModel 5 | @using AW.Webapi.Sample.Areas.HelpPage.Models 6 | @model Collection 7 | 8 | @{ 9 | ViewBag.Title = "ASP.NET Web API Help Page"; 10 | 11 | // Group APIs by controller 12 | ILookup apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor); 13 | } 14 | 15 | 16 |
17 |
18 |
19 |

@ViewBag.Title

20 |
21 |
22 |
23 |
24 | 32 |
33 | @foreach (var group in apiGroups) 34 | { 35 | @Html.DisplayFor(m => group, "ApiGroup") 36 | } 37 |
38 |
39 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Help/ResourceModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions 3 | @model ModelDescription 4 | 5 | 6 |
7 | 14 |

@Model.Name

15 |

@Model.Documentation

16 |
17 | @Html.DisplayFor(m => Model) 18 |
19 |
20 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewBag.Title 7 | @RenderSection("scripts", required: false) 8 | 9 | 10 | @RenderBody() 11 | 12 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | // Change the Layout path below to blend the look and feel of the help page with your existing web pages 3 | Layout = "~/Views/Shared/_Layout.cshtml"; 4 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Areas/HelpPage/XmlDocumentationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Web.Http.Controllers; 6 | using System.Web.Http.Description; 7 | using System.Xml.XPath; 8 | using AW.Webapi.Sample.Areas.HelpPage.ModelDescriptions; 9 | 10 | namespace AW.Webapi.Sample.Areas.HelpPage 11 | { 12 | /// 13 | /// A custom that reads the API documentation from an XML documentation file. 14 | /// 15 | public class XmlDocumentationProvider : IDocumentationProvider, IModelDocumentationProvider 16 | { 17 | private XPathNavigator _documentNavigator; 18 | private const string TypeExpression = "/doc/members/member[@name='T:{0}']"; 19 | private const string MethodExpression = "/doc/members/member[@name='M:{0}']"; 20 | private const string PropertyExpression = "/doc/members/member[@name='P:{0}']"; 21 | private const string FieldExpression = "/doc/members/member[@name='F:{0}']"; 22 | private const string ParameterExpression = "param[@name='{0}']"; 23 | 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | /// The physical path to XML document. 28 | public XmlDocumentationProvider(string documentPath) 29 | { 30 | if (documentPath == null) 31 | { 32 | throw new ArgumentNullException("documentPath"); 33 | } 34 | XPathDocument xpath = new XPathDocument(documentPath); 35 | _documentNavigator = xpath.CreateNavigator(); 36 | } 37 | 38 | public string GetDocumentation(HttpControllerDescriptor controllerDescriptor) 39 | { 40 | XPathNavigator typeNode = GetTypeNode(controllerDescriptor.ControllerType); 41 | return GetTagValue(typeNode, "summary"); 42 | } 43 | 44 | public virtual string GetDocumentation(HttpActionDescriptor actionDescriptor) 45 | { 46 | XPathNavigator methodNode = GetMethodNode(actionDescriptor); 47 | return GetTagValue(methodNode, "summary"); 48 | } 49 | 50 | public virtual string GetDocumentation(HttpParameterDescriptor parameterDescriptor) 51 | { 52 | ReflectedHttpParameterDescriptor reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor; 53 | if (reflectedParameterDescriptor != null) 54 | { 55 | XPathNavigator methodNode = GetMethodNode(reflectedParameterDescriptor.ActionDescriptor); 56 | if (methodNode != null) 57 | { 58 | string parameterName = reflectedParameterDescriptor.ParameterInfo.Name; 59 | XPathNavigator parameterNode = methodNode.SelectSingleNode(String.Format(CultureInfo.InvariantCulture, ParameterExpression, parameterName)); 60 | if (parameterNode != null) 61 | { 62 | return parameterNode.Value.Trim(); 63 | } 64 | } 65 | } 66 | 67 | return null; 68 | } 69 | 70 | public string GetResponseDocumentation(HttpActionDescriptor actionDescriptor) 71 | { 72 | XPathNavigator methodNode = GetMethodNode(actionDescriptor); 73 | return GetTagValue(methodNode, "returns"); 74 | } 75 | 76 | public string GetDocumentation(MemberInfo member) 77 | { 78 | string memberName = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", GetTypeName(member.DeclaringType), member.Name); 79 | string expression = member.MemberType == MemberTypes.Field ? FieldExpression : PropertyExpression; 80 | string selectExpression = String.Format(CultureInfo.InvariantCulture, expression, memberName); 81 | XPathNavigator propertyNode = _documentNavigator.SelectSingleNode(selectExpression); 82 | return GetTagValue(propertyNode, "summary"); 83 | } 84 | 85 | public string GetDocumentation(Type type) 86 | { 87 | XPathNavigator typeNode = GetTypeNode(type); 88 | return GetTagValue(typeNode, "summary"); 89 | } 90 | 91 | private XPathNavigator GetMethodNode(HttpActionDescriptor actionDescriptor) 92 | { 93 | ReflectedHttpActionDescriptor reflectedActionDescriptor = actionDescriptor as ReflectedHttpActionDescriptor; 94 | if (reflectedActionDescriptor != null) 95 | { 96 | string selectExpression = String.Format(CultureInfo.InvariantCulture, MethodExpression, GetMemberName(reflectedActionDescriptor.MethodInfo)); 97 | return _documentNavigator.SelectSingleNode(selectExpression); 98 | } 99 | 100 | return null; 101 | } 102 | 103 | private static string GetMemberName(MethodInfo method) 104 | { 105 | string name = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", GetTypeName(method.DeclaringType), method.Name); 106 | ParameterInfo[] parameters = method.GetParameters(); 107 | if (parameters.Length != 0) 108 | { 109 | string[] parameterTypeNames = parameters.Select(param => GetTypeName(param.ParameterType)).ToArray(); 110 | name += String.Format(CultureInfo.InvariantCulture, "({0})", String.Join(",", parameterTypeNames)); 111 | } 112 | 113 | return name; 114 | } 115 | 116 | private static string GetTagValue(XPathNavigator parentNode, string tagName) 117 | { 118 | if (parentNode != null) 119 | { 120 | XPathNavigator node = parentNode.SelectSingleNode(tagName); 121 | if (node != null) 122 | { 123 | return node.Value.Trim(); 124 | } 125 | } 126 | 127 | return null; 128 | } 129 | 130 | private XPathNavigator GetTypeNode(Type type) 131 | { 132 | string controllerTypeName = GetTypeName(type); 133 | string selectExpression = String.Format(CultureInfo.InvariantCulture, TypeExpression, controllerTypeName); 134 | return _documentNavigator.SelectSingleNode(selectExpression); 135 | } 136 | 137 | private static string GetTypeName(Type type) 138 | { 139 | string name = type.FullName; 140 | if (type.IsGenericType) 141 | { 142 | // Format the generic type name to something like: Generic{System.Int32,System.String} 143 | Type genericType = type.GetGenericTypeDefinition(); 144 | Type[] genericArguments = type.GetGenericArguments(); 145 | string genericTypeName = genericType.FullName; 146 | 147 | // Trim the generic parameter counts from the name 148 | genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); 149 | string[] argumentTypeNames = genericArguments.Select(t => GetTypeName(t)).ToArray(); 150 | name = String.Format(CultureInfo.InvariantCulture, "{0}{{{1}}}", genericTypeName, String.Join(",", argumentTypeNames)); 151 | } 152 | if (type.IsNested) 153 | { 154 | // Changing the nested type name from OuterType+InnerType to OuterType.InnerType to match the XML documentation syntax. 155 | name = name.Replace("+", "."); 156 | } 157 | 158 | return name; 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Set width on the form input elements since they're 100% wide by default */ 13 | input, 14 | select, 15 | textarea { 16 | max-width: 280px; 17 | } 18 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.accordion.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Accordion 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Accordion#theming 10 | */ 11 | .ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; } 12 | .ui-accordion .ui-accordion-icons { padding-left: 2.2em; } 13 | .ui-accordion .ui-accordion-noicons { padding-left: .7em; } 14 | .ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; } 15 | .ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } 16 | .ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; } 17 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.all.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI CSS Framework 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Theming 10 | */ 11 | @import "jquery.ui.base.css"; 12 | @import "jquery.ui.theme.css"; 13 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.autocomplete.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Autocomplete 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Autocomplete#theming 10 | */ 11 | .ui-autocomplete { 12 | position: absolute; 13 | top: 0; /* #8656 */ 14 | cursor: default; 15 | } 16 | 17 | /* workarounds */ 18 | * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ 19 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.base.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI CSS Framework 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Theming 10 | */ 11 | @import url("jquery.ui.core.css"); 12 | 13 | @import url("jquery.ui.accordion.css"); 14 | @import url("jquery.ui.autocomplete.css"); 15 | @import url("jquery.ui.button.css"); 16 | @import url("jquery.ui.datepicker.css"); 17 | @import url("jquery.ui.dialog.css"); 18 | @import url("jquery.ui.menu.css"); 19 | @import url("jquery.ui.progressbar.css"); 20 | @import url("jquery.ui.resizable.css"); 21 | @import url("jquery.ui.selectable.css"); 22 | @import url("jquery.ui.slider.css"); 23 | @import url("jquery.ui.spinner.css"); 24 | @import url("jquery.ui.tabs.css"); 25 | @import url("jquery.ui.tooltip.css"); 26 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.button.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Button 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Button#theming 10 | */ 11 | .ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ 12 | .ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; } 13 | .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ 14 | button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ 15 | .ui-button-icons-only { width: 3.4em; } 16 | button.ui-button-icons-only { width: 3.7em; } 17 | 18 | /*button text element */ 19 | .ui-button .ui-button-text { display: block; line-height: 1.4; } 20 | .ui-button-text-only .ui-button-text { padding: .4em 1em; } 21 | .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } 22 | .ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } 23 | .ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } 24 | .ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } 25 | /* no icon support for input elements, provide padding by default */ 26 | input.ui-button { padding: .4em 1em; } 27 | 28 | /*button icon element(s) */ 29 | .ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } 30 | .ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } 31 | .ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } 32 | .ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } 33 | .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } 34 | 35 | /*button sets*/ 36 | .ui-buttonset { margin-right: 7px; } 37 | .ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } 38 | 39 | /* workarounds */ 40 | button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ 41 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.core.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI CSS Framework 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Theming/API 10 | */ 11 | 12 | /* Layout helpers 13 | ----------------------------------*/ 14 | .ui-helper-hidden { display: none; } 15 | .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } 16 | .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } 17 | .ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; } 18 | .ui-helper-clearfix:after { clear: both; } 19 | .ui-helper-clearfix { zoom: 1; } 20 | .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } 21 | 22 | 23 | /* Interaction Cues 24 | ----------------------------------*/ 25 | .ui-state-disabled { cursor: default !important; } 26 | 27 | 28 | /* Icons 29 | ----------------------------------*/ 30 | 31 | /* states and images */ 32 | .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } 33 | 34 | 35 | /* Misc visuals 36 | ----------------------------------*/ 37 | 38 | /* Overlays */ 39 | .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } 40 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.datepicker.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Datepicker 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Datepicker#theming 10 | */ 11 | .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } 12 | .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } 13 | .ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } 14 | .ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } 15 | .ui-datepicker .ui-datepicker-prev { left:2px; } 16 | .ui-datepicker .ui-datepicker-next { right:2px; } 17 | .ui-datepicker .ui-datepicker-prev-hover { left:1px; } 18 | .ui-datepicker .ui-datepicker-next-hover { right:1px; } 19 | .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } 20 | .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } 21 | .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } 22 | .ui-datepicker select.ui-datepicker-month-year {width: 100%;} 23 | .ui-datepicker select.ui-datepicker-month, 24 | .ui-datepicker select.ui-datepicker-year { width: 49%;} 25 | .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } 26 | .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } 27 | .ui-datepicker td { border: 0; padding: 1px; } 28 | .ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } 29 | .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } 30 | .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } 31 | .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } 32 | 33 | /* with multiple calendars */ 34 | .ui-datepicker.ui-datepicker-multi { width:auto; } 35 | .ui-datepicker-multi .ui-datepicker-group { float:left; } 36 | .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } 37 | .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } 38 | .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } 39 | .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } 40 | .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } 41 | .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } 42 | .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } 43 | .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; } 44 | 45 | /* RTL support */ 46 | .ui-datepicker-rtl { direction: rtl; } 47 | .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } 48 | .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } 49 | .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } 50 | .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } 51 | .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } 52 | .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } 53 | .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } 54 | .ui-datepicker-rtl .ui-datepicker-group { float:right; } 55 | .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } 56 | .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } 57 | 58 | /* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ 59 | .ui-datepicker-cover { 60 | position: absolute; /*must have*/ 61 | z-index: -1; /*must have*/ 62 | filter: mask(); /*must have*/ 63 | top: -4px; /*must have*/ 64 | left: -4px; /*must have*/ 65 | width: 200px; /*must have*/ 66 | height: 200px; /*must have*/ 67 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.dialog.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Dialog 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Dialog#theming 10 | */ 11 | .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } 12 | .ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; } 13 | .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; } 14 | .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } 15 | .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } 16 | .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } 17 | .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } 18 | .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } 19 | .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } 20 | .ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } 21 | .ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } 22 | .ui-draggable .ui-dialog-titlebar { cursor: move; } 23 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.menu.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Menu 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Menu#theming 10 | */ 11 | .ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; } 12 | .ui-menu .ui-menu { margin-top: -3px; position: absolute; } 13 | .ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; } 14 | .ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; } 15 | .ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; } 16 | .ui-menu .ui-menu-item a.ui-state-focus, 17 | .ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; } 18 | 19 | .ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; } 20 | .ui-menu .ui-state-disabled a { cursor: default; } 21 | 22 | /* icon support */ 23 | .ui-menu-icons { position: relative; } 24 | .ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; } 25 | 26 | /* left-aligned */ 27 | .ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; } 28 | 29 | /* right-aligned */ 30 | .ui-menu .ui-menu-icon { position: static; float: right; } 31 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.progressbar.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Progressbar 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Progressbar#theming 10 | */ 11 | .ui-progressbar { height:2em; text-align: left; overflow: hidden; } 12 | .ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.resizable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Resizable 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Resizable#theming 10 | */ 11 | .ui-resizable { position: relative;} 12 | .ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; } 13 | .ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } 14 | .ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } 15 | .ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } 16 | .ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } 17 | .ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } 18 | .ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } 19 | .ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } 20 | .ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } 21 | .ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.selectable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Selectable 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Selectable#theming 10 | */ 11 | .ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } 12 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.slider.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Slider 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Slider#theming 10 | */ 11 | .ui-slider { position: relative; text-align: left; } 12 | .ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; } 13 | .ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; } 14 | 15 | .ui-slider-horizontal { height: .8em; } 16 | .ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } 17 | .ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } 18 | .ui-slider-horizontal .ui-slider-range-min { left: 0; } 19 | .ui-slider-horizontal .ui-slider-range-max { right: 0; } 20 | 21 | .ui-slider-vertical { width: .8em; height: 100px; } 22 | .ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } 23 | .ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } 24 | .ui-slider-vertical .ui-slider-range-min { bottom: 0; } 25 | .ui-slider-vertical .ui-slider-range-max { top: 0; } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.spinner.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Spinner 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Spinner#theming 10 | */ 11 | .ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; } 12 | .ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; } 13 | .ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; } 14 | .ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */ 15 | .ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */ 16 | .ui-spinner-up { top: 0; } 17 | .ui-spinner-down { bottom: 0; } 18 | 19 | /* TR overrides */ 20 | .ui-spinner .ui-icon-triangle-1-s { 21 | /* need to fix icons sprite */ 22 | background-position:-65px -16px; 23 | } 24 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.tabs.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Tabs 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | * 9 | * http://docs.jquery.com/UI/Tabs#theming 10 | */ 11 | .ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ 12 | .ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } 13 | .ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; } 14 | .ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } 15 | .ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; } 16 | .ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; } 17 | .ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ 18 | .ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } 19 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/jquery.ui.tooltip.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Tooltip 1.9.1 3 | * http://jqueryui.com 4 | * 5 | * Copyright 2012 jQuery Foundation and other contributors 6 | * Released under the MIT license. 7 | * http://jquery.org/license 8 | */ 9 | .ui-tooltip { 10 | padding: 8px; 11 | position: absolute; 12 | z-index: 9999; 13 | max-width: 300px; 14 | -webkit-box-shadow: 0 0 5px #aaa; 15 | box-shadow: 0 0 5px #aaa; 16 | } 17 | /* Fades and background-images don't work well together in IE6, drop the image */ 18 | * html .ui-tooltip { 19 | background-image: none; 20 | } 21 | body .ui-tooltip { border-width: 2px; } 22 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Content/themes/base/minified/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.accordion.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.accordion.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;zoom:1}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto;zoom:1} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.autocomplete.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.autocomplete.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-autocomplete{position:absolute;top:0;cursor:default}* html .ui-autocomplete{width:1px} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.button.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.button.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.core.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.core.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px);clip:rect(1px,1px,1px,1px)}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{zoom:1}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.datepicker.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.datepicker.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0em}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.dialog.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.dialog.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-dialog{position:absolute;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.menu.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.menu.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-menu{list-style:none;padding:2px;margin:0;display:block;outline:none}.ui-menu .ui-menu{margin-top:-3px;position:absolute}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;width:100%}.ui-menu .ui-menu-divider{margin:5px -2px 5px -2px;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:2px .4em;line-height:1.5;zoom:1;font-weight:normal}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-menu .ui-state-disabled{font-weight:normal;margin:.4em 0 .2em;line-height:1.5}.ui-menu .ui-state-disabled a{cursor:default}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item a{position:relative;padding-left:2em}.ui-menu .ui-icon{position:absolute;top:.2em;left:.2em}.ui-menu .ui-menu-icon{position:static;float:right} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.progressbar.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.progressbar.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.resizable.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.resizable.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.selectable.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.selectable.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.slider.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.slider.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.spinner.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.spinner.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:none;background:none;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:none;border-bottom:none;border-right:none}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.tabs.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.tabs.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-tabs-loading a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Content/themes/base/minified/jquery.ui.tooltip.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.9.1 - 2012-10-25 2 | * http://jqueryui.com 3 | * Includes: jquery.ui.tooltip.css 4 | * Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */ 5 | .ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip{background-image:none}body .ui-tooltip{border-width:2px} -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace AW.Webapi.Sample.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public ActionResult Index() 12 | { 13 | ViewBag.Title = "Home Page"; 14 | 15 | return View(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Controllers/PaymentController.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core.Common; 2 | using AW.Pay.Core.Enum; 3 | using AW.Webapi.Sample.Models.PayModel; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Net.Http; 8 | using System.Net.Http.Headers; 9 | using System.Threading.Tasks; 10 | using System.Web; 11 | using System.Web.Mvc; 12 | 13 | namespace AW.Webapi.Sample.Controllers 14 | { 15 | public class PaymentController : Controller 16 | { 17 | public static HttpClient _client = new HttpClient(); 18 | // GET: Payment 19 | public ActionResult Index() 20 | { 21 | return View(); 22 | } 23 | 24 | public ActionResult AliPayDemo() 25 | { 26 | return View(); 27 | } 28 | 29 | public async Task AliPayAsync(AliPayReqParam payInfo) 30 | { 31 | using (var client = new HttpClient()) 32 | { 33 | client.BaseAddress = new Uri("http://localhost:8115/"); 34 | client.DefaultRequestHeaders.Accept.Clear(); 35 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); 36 | // HTTP POST 37 | var gizmo = new AliPayReqParam { OrderNo = payInfo.OrderNo, Subject = payInfo.Subject, TotalAmount = payInfo.TotalAmount, Type = 0 }; 38 | var response = await client.PostAsJsonAsync("api/Payment/CreateAliPayRequestParam", gizmo); 39 | var resultValue =await response.Content.ReadAsAsync>(); 40 | if (resultValue.Code == EnumBizCode.Failed) 41 | { 42 | return string.Empty; 43 | } 44 | return resultValue.ReturnObject; 45 | } 46 | } 47 | 48 | public ActionResult WePayDemo() 49 | { 50 | return View(); 51 | } 52 | 53 | public async Task WePayAsync(WePayReqParam payInfo) 54 | { 55 | using (var client = new HttpClient()) 56 | { 57 | client.BaseAddress = new Uri("http://localhost:8115/"); 58 | client.DefaultRequestHeaders.Accept.Clear(); 59 | client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); 60 | // HTTP POST 61 | var gizmo = new WePayReqParam { OrderNo = payInfo.OrderNo, ProductName = payInfo.ProductName, CustomerIp="127.0.0.1", TotalFee = payInfo.TotalFee, TradeType = EnumWePayTradeType.NATIVE}; 62 | var response = await client.PostAsJsonAsync("api/Payment/CreateWePayRequestParam", gizmo); 63 | var resultValue = await response.Content.ReadAsAsync>(); 64 | if (resultValue.Code == EnumBizCode.Failed) 65 | { 66 | throw new Exception("微信支付失败"); 67 | } 68 | ViewBag.OrderId = payInfo.OrderNo; 69 | ViewBag.PayAmount = payInfo.TotalFee; 70 | ViewBag.PayUrl = resultValue.ReturnObject; 71 | return View("WePay"); 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Web.Http; 7 | 8 | namespace AW.Webapi.Sample.Controllers 9 | { 10 | public class ValuesController : ApiController 11 | { 12 | // GET api/values 13 | public IEnumerable Get() 14 | { 15 | return new string[] { "value1", "value2" }; 16 | } 17 | 18 | // GET api/values/5 19 | public string Get(int id) 20 | { 21 | return "value"; 22 | } 23 | 24 | // POST api/values 25 | public void Post([FromBody]string value) 26 | { 27 | } 28 | 29 | // PUT api/values/5 30 | public void Put(int id, [FromBody]string value) 31 | { 32 | } 33 | 34 | // DELETE api/values/5 35 | public void Delete(int id) 36 | { 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="AW.Webapi.Sample.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using AW.Webapi.Sample.App_Start; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Http; 7 | using System.Web.Mvc; 8 | using System.Web.Optimization; 9 | using System.Web.Routing; 10 | 11 | namespace AW.Webapi.Sample 12 | { 13 | public class WebApiApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | GlobalConfiguration.Configure(WebApiConfig.Register); 19 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 20 | RouteConfig.RegisterRoutes(RouteTable.Routes); 21 | BundleConfig.RegisterBundles(BundleTable.Bundles); 22 | Bootstrapper.Run(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Models/AccountBindingModels.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using Newtonsoft.Json; 4 | 5 | namespace AW.Webapi.Sample.Models 6 | { 7 | // 用作 AccountController 操作的参数的模型。 8 | 9 | public class AddExternalLoginBindingModel 10 | { 11 | [Required] 12 | [Display(Name = "外部访问令牌")] 13 | public string ExternalAccessToken { get; set; } 14 | } 15 | 16 | public class ChangePasswordBindingModel 17 | { 18 | [Required] 19 | [DataType(DataType.Password)] 20 | [Display(Name = "当前密码")] 21 | public string OldPassword { get; set; } 22 | 23 | [Required] 24 | [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)] 25 | [DataType(DataType.Password)] 26 | [Display(Name = "新密码")] 27 | public string NewPassword { get; set; } 28 | 29 | [DataType(DataType.Password)] 30 | [Display(Name = "确认新密码")] 31 | [Compare("NewPassword", ErrorMessage = "新密码和确认密码不匹配。")] 32 | public string ConfirmPassword { get; set; } 33 | } 34 | 35 | public class RegisterBindingModel 36 | { 37 | [Required] 38 | [Display(Name = "电子邮件")] 39 | public string Email { get; set; } 40 | 41 | [Required] 42 | [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)] 43 | [DataType(DataType.Password)] 44 | [Display(Name = "密码")] 45 | public string Password { get; set; } 46 | 47 | [DataType(DataType.Password)] 48 | [Display(Name = "确认密码")] 49 | [Compare("Password", ErrorMessage = "密码和确认密码不匹配。")] 50 | public string ConfirmPassword { get; set; } 51 | } 52 | 53 | public class RegisterExternalBindingModel 54 | { 55 | [Required] 56 | [Display(Name = "电子邮件")] 57 | public string Email { get; set; } 58 | } 59 | 60 | public class RemoveLoginBindingModel 61 | { 62 | [Required] 63 | [Display(Name = "登录提供程序")] 64 | public string LoginProvider { get; set; } 65 | 66 | [Required] 67 | [Display(Name = "提供程序密钥")] 68 | public string ProviderKey { get; set; } 69 | } 70 | 71 | public class SetPasswordBindingModel 72 | { 73 | [Required] 74 | [StringLength(100, ErrorMessage = "{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)] 75 | [DataType(DataType.Password)] 76 | [Display(Name = "新密码")] 77 | public string NewPassword { get; set; } 78 | 79 | [DataType(DataType.Password)] 80 | [Display(Name = "确认新密码")] 81 | [Compare("NewPassword", ErrorMessage = "新密码和确认密码不匹配。")] 82 | public string ConfirmPassword { get; set; } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Models/AccountViewModels.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace AW.Webapi.Sample.Models 5 | { 6 | // AccountController 操作返回的模型。 7 | 8 | public class ExternalLoginViewModel 9 | { 10 | public string Name { get; set; } 11 | 12 | public string Url { get; set; } 13 | 14 | public string State { get; set; } 15 | } 16 | 17 | public class ManageInfoViewModel 18 | { 19 | public string LocalLoginProvider { get; set; } 20 | 21 | public string Email { get; set; } 22 | 23 | public IEnumerable Logins { get; set; } 24 | 25 | public IEnumerable ExternalLoginProviders { get; set; } 26 | } 27 | 28 | public class UserInfoViewModel 29 | { 30 | public string Email { get; set; } 31 | 32 | public bool HasRegistered { get; set; } 33 | 34 | public string LoginProvider { get; set; } 35 | } 36 | 37 | public class UserLoginInfoViewModel 38 | { 39 | public string LoginProvider { get; set; } 40 | 41 | public string ProviderKey { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Models/IdentityModels.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Claims; 2 | using System.Threading.Tasks; 3 | using Microsoft.AspNet.Identity; 4 | using Microsoft.AspNet.Identity.EntityFramework; 5 | using Microsoft.AspNet.Identity.Owin; 6 | 7 | namespace AW.Webapi.Sample.Models 8 | { 9 | // 可以通过向 ApplicationUser 类添加更多属性来为用户添加个人资料数据,若要了解详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=317594。 10 | public class ApplicationUser : IdentityUser 11 | { 12 | public async Task GenerateUserIdentityAsync(UserManager manager, string authenticationType) 13 | { 14 | // 请注意,authenticationType 必须与 CookieAuthenticationOptions.AuthenticationType 中定义的相应项匹配 15 | var userIdentity = await manager.CreateIdentityAsync(this, authenticationType); 16 | // 在此处添加自定义用户声明 17 | return userIdentity; 18 | } 19 | } 20 | 21 | public class ApplicationDbContext : IdentityDbContext 22 | { 23 | public ApplicationDbContext() 24 | : base("DefaultConnection", throwIfV1Schema: false) 25 | { 26 | } 27 | 28 | public static ApplicationDbContext Create() 29 | { 30 | return new ApplicationDbContext(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Models/PayModel/AliPayReqParam.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | namespace AW.Webapi.Sample.Models.PayModel 8 | { 9 | public class AliPayReqParam 10 | { 11 | public string OrderNo { get; set; } 12 | public string Subject { get; set; } 13 | public decimal TotalAmount { get; set; } 14 | public EnumAliPayTradeType Type { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Models/PayModel/WePayReqParam.cs: -------------------------------------------------------------------------------- 1 | using AW.Pay.Core.Enum; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | 7 | namespace AW.Webapi.Sample.Models.PayModel 8 | { 9 | public class WePayReqParam 10 | { 11 | public string OrderNo { get; set; } 12 | public string ProductName { get; set; } 13 | public int TotalFee { get; set; } 14 | public string CustomerIp { get; set; } 15 | public EnumWePayTradeType TradeType { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Project_Readme.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 你的 ASP.NET 应用程序 7 | 96 | 97 | 98 | 99 | 103 | 104 |
105 |
106 |

此应用程序包含:

107 |
    108 |
  • 用于记录你的 Web API 的帮助页
  • 109 |
  • 使用 Bootstrap 进行主题定位
  • 110 |
  • 身份验证,如果选择此项,则将显示如何注册和登录
  • 111 |
  • 使用 NuGet 管理的 ASP.NET 功能
  • 112 |
113 |
114 | 115 | 131 | 132 |
133 |

部署

134 | 139 |
140 | 141 |
142 |

获取帮助

143 | 147 |
148 |
149 | 150 | 151 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的常规信息是通过以下项进行控制的 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("AW.Webapi.Sample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("AW.Webapi.Sample")] 13 | [assembly: AssemblyCopyright("版权所有(C) 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 将使此程序集中的类型 18 | // 对 COM 组件不可见。如果需要 19 | // 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID 23 | [assembly: Guid("6f24ebef-4948-47da-ab79-b85b1f197130")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 内部版本号 30 | // 修订版本 31 | // 32 | // 你可以指定所有值,也可以让修订版本和内部版本号采用默认值, 33 | // 方法是按如下所示使用 "*": 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Providers/ApplicationOAuthProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNet.Identity; 7 | using Microsoft.AspNet.Identity.EntityFramework; 8 | using Microsoft.AspNet.Identity.Owin; 9 | using Microsoft.Owin.Security; 10 | using Microsoft.Owin.Security.Cookies; 11 | using Microsoft.Owin.Security.OAuth; 12 | using AW.Webapi.Sample.Models; 13 | 14 | namespace AW.Webapi.Sample.Providers 15 | { 16 | public class ApplicationOAuthProvider : OAuthAuthorizationServerProvider 17 | { 18 | private readonly string _publicClientId; 19 | 20 | public ApplicationOAuthProvider(string publicClientId) 21 | { 22 | if (publicClientId == null) 23 | { 24 | throw new ArgumentNullException("publicClientId"); 25 | } 26 | 27 | _publicClientId = publicClientId; 28 | } 29 | 30 | public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) 31 | { 32 | var userManager = context.OwinContext.GetUserManager(); 33 | 34 | ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); 35 | 36 | if (user == null) 37 | { 38 | context.SetError("invalid_grant", "用户名或密码不正确。"); 39 | return; 40 | } 41 | 42 | ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, 43 | OAuthDefaults.AuthenticationType); 44 | ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, 45 | CookieAuthenticationDefaults.AuthenticationType); 46 | 47 | AuthenticationProperties properties = CreateProperties(user.UserName); 48 | AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); 49 | context.Validated(ticket); 50 | context.Request.Context.Authentication.SignIn(cookiesIdentity); 51 | } 52 | 53 | public override Task TokenEndpoint(OAuthTokenEndpointContext context) 54 | { 55 | foreach (KeyValuePair property in context.Properties.Dictionary) 56 | { 57 | context.AdditionalResponseParameters.Add(property.Key, property.Value); 58 | } 59 | 60 | return Task.FromResult(null); 61 | } 62 | 63 | public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) 64 | { 65 | // 资源所有者密码凭据未提供客户端 ID。 66 | if (context.ClientId == null) 67 | { 68 | context.Validated(); 69 | } 70 | 71 | return Task.FromResult(null); 72 | } 73 | 74 | public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context) 75 | { 76 | if (context.ClientId == _publicClientId) 77 | { 78 | Uri expectedRootUri = new Uri(context.Request.Uri, "/"); 79 | 80 | if (expectedRootUri.AbsoluteUri == context.RedirectUri) 81 | { 82 | context.Validated(); 83 | } 84 | } 85 | 86 | return Task.FromResult(null); 87 | } 88 | 89 | public static AuthenticationProperties CreateProperties(string userName) 90 | { 91 | IDictionary data = new Dictionary 92 | { 93 | { "userName", userName } 94 | }; 95 | return new AuthenticationProperties(data); 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Results/ChallengeResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using System.Web.Http; 9 | 10 | namespace AW.Webapi.Sample.Results 11 | { 12 | public class ChallengeResult : IHttpActionResult 13 | { 14 | public ChallengeResult(string loginProvider, ApiController controller) 15 | { 16 | LoginProvider = loginProvider; 17 | Request = controller.Request; 18 | } 19 | 20 | public string LoginProvider { get; set; } 21 | public HttpRequestMessage Request { get; set; } 22 | 23 | public Task ExecuteAsync(CancellationToken cancellationToken) 24 | { 25 | Request.GetOwinContext().Authentication.Challenge(LoginProvider); 26 | 27 | HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Unauthorized); 28 | response.RequestMessage = Request; 29 | return Task.FromResult(response); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/Scripts/_references.js -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Scripts/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /* 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | (function(a){var d=a.validator,b,e="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function j(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function f(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function h(a){return a.substr(0,a.lastIndexOf(".")+1)}function g(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function m(c,e){var b=a(this).find("[data-valmsg-for='"+f(e[0].name)+"']"),d=b.attr("data-valmsg-replace"),g=d?a.parseJSON(d)!==false:null;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(g){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function l(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("
  • ").html(this.message).appendTo(b)})}}function k(d){var b=d.data("unobtrusiveContainer"),c=b.attr("data-valmsg-replace"),e=c?a.parseJSON(c):null;if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");d.removeData("unobtrusiveContainer");e&&b.empty()}}function n(){var b=a(this),c="__jquery_unobtrusive_validation_form_reset";if(b.data(c))return;b.data(c,true);try{b.data("validator").resetForm()}finally{b.removeData(c)}b.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors");b.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}function i(b){var c=a(b),f=c.data(e),i=a.proxy(n,b),g=d.unobtrusive.options||{},h=function(e,d){var c=g[e];c&&a.isFunction(c)&&c.apply(b,d)};if(!f){f={options:{errorClass:g.errorClass||"input-validation-error",errorElement:g.errorElement||"span",errorPlacement:function(){m.apply(b,arguments);h("errorPlacement",arguments)},invalidHandler:function(){l.apply(b,arguments);h("invalidHandler",arguments)},messages:{},rules:{},success:function(){k.apply(b,arguments);h("success",arguments)}},attachValidation:function(){c.off("reset."+e,i).on("reset."+e,i).validate(this.options)},validate:function(){c.validate();return c.valid()}};c.data(e,f)}return f}d.unobtrusive={adapters:[],parseElement:function(b,h){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=i(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});a.extend(e,{__dummy__:true});!h&&c.attachValidation()},parse:function(c){var b=a(c),e=b.parents().addBack().filter("form").add(b.find("form")).has("[data-val=true]");b.find("[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});e.each(function(){var a=i(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});d.addMethod("nonalphamin",function(c,d,b){var a;if(b){a=c.match(/\W/g);a=a&&a.length>=b}return a});if(d.methods.extension){b.addSingleVal("accept","mimtype");b.addSingleVal("extension","extension")}else b.addSingleVal("extension","extension","accept");b.addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength");b.add("equalto",["other"],function(b){var i=h(b.element.name),j=b.params.other,d=g(j,i),e=a(b.form).find(":input").filter("[name='"+f(d)+"']")[0];c(b,"equalTo",e)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},e=h(b.element.name);a.each(j(b.params.additionalfields||b.element.name),function(i,h){var c=g(h,e);d.data[c]=function(){var d=a(b.form).find(":input").filter("[name='"+f(c)+"']");return d.is(":checkbox")?d.filter(":checked").val()||d.filter(":hidden").val()||"":d.is(":radio")?d.filter(":checked").val()||"":d.val()}});c(b,"remote",d)});b.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&c(a,"minlength",a.params.min);a.params.nonalphamin&&c(a,"nonalphamin",a.params.nonalphamin);a.params.regex&&c(a,"regex",a.params.regex)});a(function(){d.unobtrusive.parse(document)})})(jQuery); -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='­';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document); 18 | 19 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 20 | (function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this); -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.Owin; 5 | using Owin; 6 | 7 | [assembly: OwinStartup(typeof(AW.Webapi.Sample.Startup))] 8 | 9 | namespace AW.Webapi.Sample 10 | { 11 | public partial class Startup 12 | { 13 | public void Configuration(IAppBuilder app) 14 | { 15 | ConfigureAuth(app); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | 
    2 |

    ASP.NET

    3 |

    ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS, and JavaScript.

    4 |

    Learn more »

    5 |
    6 |
    7 |
    8 |

    Getting started

    9 |

    ASP.NET Web API is a framework that makes it easy to build HTTP services that reach 10 | a broad range of clients, including browsers and mobile devices. ASP.NET Web API 11 | is an ideal platform for building RESTful applications on the .NET Framework.

    12 |

    Learn more »

    13 |
    14 |
    15 |

    Get more libraries

    16 |

    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

    17 |

    Learn more »

    18 |
    19 |
    20 |

    Web Hosting

    21 |

    You can easily find a web hosting company that offers the right mix of features and price for your applications.

    22 |

    Learn more »

    23 |
    24 |
    25 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Payment/AliPayDemo.cshtml: -------------------------------------------------------------------------------- 1 | @model AW.Webapi.Sample.Models.PayModel.AliPayReqParam 2 | 3 | @{ 4 | ViewBag.Title = "PayDemo"; 5 | } 6 | 7 |

    PayDemo

    8 | 9 | @using (Html.BeginForm("AliPayAsync","Payment",FormMethod.Get)) 10 | { 11 |
    12 |

    AliPayReqParam

    13 |
    14 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 15 |
    16 | @Html.LabelFor(model => model.OrderNo, htmlAttributes: new { @class = "control-label col-md-2" }) 17 |
    18 | @Html.EditorFor(model => model.OrderNo, new { htmlAttributes = new { @class = "form-control" } }) 19 | @Html.ValidationMessageFor(model => model.OrderNo, "", new { @class = "text-danger" }) 20 |
    21 |
    22 | 23 |
    24 | @Html.LabelFor(model => model.Subject, htmlAttributes: new { @class = "control-label col-md-2" }) 25 |
    26 | @Html.EditorFor(model => model.Subject, new { htmlAttributes = new { @class = "form-control" } }) 27 | @Html.ValidationMessageFor(model => model.Subject, "", new { @class = "text-danger" }) 28 |
    29 |
    30 | 31 |
    32 | @Html.LabelFor(model => model.TotalAmount, htmlAttributes: new { @class = "control-label col-md-2" }) 33 |
    34 | @Html.EditorFor(model => model.TotalAmount, new { htmlAttributes = new { @class = "form-control" } }) 35 | @Html.ValidationMessageFor(model => model.TotalAmount, "", new { @class = "text-danger" }) 36 |
    37 |
    38 | 39 |
    40 |
    41 | 42 |
    43 |
    44 |
    45 | } 46 | 47 |
    48 | @Html.ActionLink("Back to List", "Index") 49 |
    50 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Payment/Index.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewBag.Title = "Index"; 4 | } 5 |

    Index

    6 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Payment/WePay.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewBag.Title = "WePayAsync"; 4 | } 5 | 6 |

    WePayAsync

    7 | 8 | 9 |
    10 |
    11 | @section scripts{ 12 | 13 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Payment/WePayDemo.cshtml: -------------------------------------------------------------------------------- 1 | @model AW.Webapi.Sample.Models.PayModel.WePayReqParam 2 | 3 | @{ 4 | ViewBag.Title = "WePayDemo"; 5 | } 6 | 7 |

    WePayDemo

    8 | 9 | @using (Html.BeginForm("WePayAsync","Payment",FormMethod.Get)) 10 | { 11 |
    12 |

    WePayReqParam

    13 |
    14 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 15 |
    16 | @Html.LabelFor(model => model.OrderNo, htmlAttributes: new { @class = "control-label col-md-2" }) 17 |
    18 | @Html.EditorFor(model => model.OrderNo, new { htmlAttributes = new { @class = "form-control" } }) 19 | @Html.ValidationMessageFor(model => model.OrderNo, "", new { @class = "text-danger" }) 20 |
    21 |
    22 | 23 |
    24 | @Html.LabelFor(model => model.ProductName, htmlAttributes: new { @class = "control-label col-md-2" }) 25 |
    26 | @Html.EditorFor(model => model.ProductName, new { htmlAttributes = new { @class = "form-control" } }) 27 | @Html.ValidationMessageFor(model => model.ProductName, "", new { @class = "text-danger" }) 28 |
    29 |
    30 | 31 |
    32 | @Html.LabelFor(model => model.TotalFee, htmlAttributes: new { @class = "control-label col-md-2" }) 33 |
    34 | @Html.EditorFor(model => model.TotalFee, new { htmlAttributes = new { @class = "form-control" } }) 35 | @Html.ValidationMessageFor(model => model.TotalFee, "", new { @class = "text-danger" }) 36 |
    37 |
    38 | 39 |
    40 |
    41 | 42 |
    43 |
    44 |
    45 | } 46 | 47 |
    48 | @Html.ActionLink("Back to List", "Index") 49 |
    50 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 错误 7 | 8 | 9 |
    10 |

    错误。

    11 |

    处理你的请求时出错。

    12 |
    13 | 14 | 15 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | @ViewBag.Title 8 | @Styles.Render("~/Content/css") 9 | @Scripts.Render("~/bundles/modernizr") 10 | 11 | 12 | 13 | 31 |
    32 | @RenderBody() 33 |
    34 |
    35 |

    © @DateTime.Now.Year - 我的 ASP.NET 应用程序

    36 |
    37 |
    38 | 39 | @Scripts.Render("~/bundles/jquery") 40 | @Scripts.Render("~/bundles/bootstrap") 41 | @RenderSection("scripts", required: false) 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
    7 |
    8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/favicon.ico -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xBoo/AlipayandWepay-NETAPI/a5342e78b905fd3fa064ddfb4c1ee32e3a3fee04/src/AW.Webapi.Sample/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/AW.Webapi.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/AlipayAndWepay.Net.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{46D007D7-8FC1-48F4-BC00-F58FCD1B4FA8}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{8536529D-D461-4EDB-A4EF-1A9E497A3DDC}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{B286F10D-6A31-4E64-8782-AFB16063B76D}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTest", "ConsoleTest\ConsoleTest.csproj", "{E2D8A1EE-4143-452A-8065-E20E2BFBA5C6}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AW.Pay.Core", "AW.Pay.Core\AW.Pay.Core.csproj", "{3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AW.Webapi.Sample", "AW.Webapi.Sample\AW.Webapi.Sample.csproj", "{B893532E-AE5A-4F99-A6AF-672C6918C2F9}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {E2D8A1EE-4143-452A-8065-E20E2BFBA5C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {E2D8A1EE-4143-452A-8065-E20E2BFBA5C6}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {E2D8A1EE-4143-452A-8065-E20E2BFBA5C6}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {E2D8A1EE-4143-452A-8065-E20E2BFBA5C6}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {B893532E-AE5A-4F99-A6AF-672C6918C2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {B893532E-AE5A-4F99-A6AF-672C6918C2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {B893532E-AE5A-4F99-A6AF-672C6918C2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {B893532E-AE5A-4F99-A6AF-672C6918C2F9}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(NestedProjects) = preSolution 41 | {E2D8A1EE-4143-452A-8065-E20E2BFBA5C6} = {B286F10D-6A31-4E64-8782-AFB16063B76D} 42 | {3C998EE8-7F0B-4D26-A5B9-ABC15AD6298E} = {46D007D7-8FC1-48F4-BC00-F58FCD1B4FA8} 43 | {B893532E-AE5A-4F99-A6AF-672C6918C2F9} = {8536529D-D461-4EDB-A4EF-1A9E497A3DDC} 44 | EndGlobalSection 45 | GlobalSection(ExtensibilityGlobals) = postSolution 46 | EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.Common.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.Logging.6.0.1304.0\lib\NET45 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /src/ConsoleTest/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/ConsoleTest/ConsoleTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E2D8A1EE-4143-452A-8065-E20E2BFBA5C6} 8 | Exe 9 | Properties 10 | ConsoleTest 11 | ConsoleTest 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | -------------------------------------------------------------------------------- /src/ConsoleTest/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ConsoleTest 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ConsoleTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("ConsoleTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConsoleTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | //将 ComVisible 设置为 false 将使此程序集中的类型 18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("e2d8a1ee-4143-452a-8065-e20e2bfba5c6")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, 33 | // 方法是按如下所示使用“*”: : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | --------------------------------------------------------------------------------