4 |
7 |
8 | @Html.Partial("_ValidationSummary")
9 |
10 |
11 |
12 | @if (Model.EnableLocalLogin)
13 | {
14 |
15 |
16 |
17 |
Local Login
18 |
19 |
48 |
49 |
50 | }
51 |
52 | @if (Model.ExternalProviders.Any())
53 | {
54 |
55 |
56 |
57 |
External Login
58 |
59 |
74 |
75 |
76 | }
77 |
78 | @if (!Model.EnableLocalLogin && !Model.ExternalProviders.Any())
79 | {
80 |
81 | Invalid login request
82 | There are no login schemes configured for this client.
83 |
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/IdentityServer4OpenID/Views/Account/Logout.cshtml:
--------------------------------------------------------------------------------
1 | @model LogoutViewModel
2 |
3 | ()
20 | .Build();
21 |
22 | host.Run();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:9199/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "MvcClient": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "launchUrl": "http://localhost:5000",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development"
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace MvcClient
12 | {
13 | public class Startup
14 | {
15 | public Startup(IHostingEnvironment env)
16 | {
17 | var builder = new ConfigurationBuilder()
18 | .SetBasePath(env.ContentRootPath)
19 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
20 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
21 | .AddEnvironmentVariables();
22 | Configuration = builder.Build();
23 | }
24 |
25 | public IConfigurationRoot Configuration { get; }
26 |
27 | // This method gets called by the runtime. Use this method to add services to the container.
28 | public void ConfigureServices(IServiceCollection services)
29 | {
30 | // Add framework services.
31 | services.AddMvc();
32 | }
33 |
34 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
35 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
36 | {
37 | loggerFactory.AddConsole(Configuration.GetSection("Logging"));
38 | loggerFactory.AddDebug();
39 |
40 | if (env.IsDevelopment())
41 | {
42 | app.UseDeveloperExceptionPage();
43 | app.UseBrowserLink();
44 | }
45 | else
46 | {
47 | app.UseExceptionHandler("/Home/Error");
48 | }
49 | app.UseCookieAuthentication(new CookieAuthenticationOptions
50 | {
51 | AuthenticationScheme = "Cookies"
52 | });
53 |
54 | app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
55 | {
56 | AuthenticationScheme = "oidc",
57 | SignInScheme = "Cookies",
58 |
59 | Authority = "http://localhost:5000",
60 | RequireHttpsMetadata = false,
61 |
62 | ClientId = "mvc",
63 | SaveTokens = true
64 | });
65 |
66 | app.UseStaticFiles();
67 |
68 | app.UseMvc(routes =>
69 | {
70 | routes.MapRoute(
71 | name: "default",
72 | template: "{controller=Home}/{action=Index}/{id?}");
73 | });
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/Home/About.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "About";
3 | }
4 | @ViewData["Title"].
5 | @ViewData["Message"]
6 |
7 | Use this area to provide additional information.
8 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/Home/Contact.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Contact";
3 | }
4 | @ViewData["Title"].
5 | @ViewData["Message"]
6 |
7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P:
11 | 425.555.0100
12 |
13 |
14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com
17 |
18 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Home Page";
3 | }
4 |
5 |
6 | @foreach (var claim in User.Claims)
7 | {
8 | @claim.Type
9 | @claim.Value
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Error";
3 | }
4 |
5 | Error.
6 | An error occurred while processing your request.
7 |
8 | Development Mode
9 |
10 | Swapping to Development environment will display more detailed information about the error that occurred.
11 |
12 |
13 | Development environment should not be enabled in deployed applications , as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development , and restarting the application.
14 |
15 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @ViewData["Title"] - MvcClient
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
40 |
41 | @RenderBody()
42 |
43 |
44 | © 2016 - MvcClient
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
58 |
62 |
63 |
64 |
65 | @RenderSection("scripts", required: false)
66 |
67 |
68 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/_ViewImports.cshtml:
--------------------------------------------------------------------------------
1 | @using MvcClient
2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
3 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "_Layout";
3 | }
4 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "asp.net",
3 | "private": true,
4 | "dependencies": {
5 | "bootstrap": "3.3.6",
6 | "jquery": "2.2.0",
7 | "jquery-validation": "1.14.0",
8 | "jquery-validation-unobtrusive": "3.2.6"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/bundleconfig.json:
--------------------------------------------------------------------------------
1 | // Configure bundling and minification for the project.
2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241
3 | [
4 | {
5 | "outputFileName": "wwwroot/css/site.min.css",
6 | // An array of relative input file paths. Globbing patterns supported
7 | "inputFiles": [
8 | "wwwroot/css/site.css"
9 | ]
10 | },
11 | {
12 | "outputFileName": "wwwroot/js/site.min.js",
13 | "inputFiles": [
14 | "wwwroot/js/site.js"
15 | ],
16 | // Optionally specify minification options
17 | "minify": {
18 | "enabled": true,
19 | "renameLocals": true
20 | },
21 | // Optinally generate .map file
22 | "sourceMap": false
23 | }
24 | ]
25 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "Microsoft.NETCore.App": {
4 | "version": "1.0.1",
5 | "type": "platform"
6 | },
7 | "Microsoft.AspNetCore.Diagnostics": "1.0.0",
8 | "Microsoft.AspNetCore.Mvc": "1.0.1",
9 | "Microsoft.AspNetCore.Razor.Tools": {
10 | "version": "1.0.0-preview2-final",
11 | "type": "build"
12 | },
13 | "Microsoft.AspNetCore.Routing": "1.0.1",
14 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
15 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
16 | "Microsoft.AspNetCore.StaticFiles": "1.0.0",
17 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
18 | "Microsoft.Extensions.Configuration.Json": "1.0.0",
19 | "Microsoft.Extensions.Logging": "1.0.0",
20 | "Microsoft.Extensions.Logging.Console": "1.0.0",
21 | "Microsoft.Extensions.Logging.Debug": "1.0.0",
22 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
23 | "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
24 | "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
25 | "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0"
26 | },
27 |
28 | "tools": {
29 | "BundlerMinifier.Core": "2.0.238",
30 | "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
31 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
32 | },
33 |
34 | "frameworks": {
35 | "netcoreapp1.0": {
36 | "imports": [
37 | "dotnet5.6",
38 | "portable-net45+win8"
39 | ]
40 | }
41 | },
42 |
43 | "buildOptions": {
44 | "emitEntryPoint": true,
45 | "preserveCompilationContext": true
46 | },
47 |
48 | "runtimeOptions": {
49 | "configProperties": {
50 | "System.GC.Server": true
51 | }
52 | },
53 |
54 | "publishOptions": {
55 | "include": [
56 | "wwwroot",
57 | "**/*.cshtml",
58 | "appsettings.json",
59 | "web.config"
60 | ]
61 | },
62 |
63 | "scripts": {
64 | "prepublish": [ "bower install", "dotnet bundle" ],
65 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/_references.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 | ///
6 | ///
7 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 50px;
3 | padding-bottom: 20px;
4 | }
5 |
6 | /* Wrapping element */
7 | /* Set some basic padding to keep content from hitting the edges */
8 | .body-content {
9 | padding-left: 15px;
10 | padding-right: 15px;
11 | }
12 |
13 | /* Set widths on the form inputs since otherwise they're 100% wide */
14 | input,
15 | select,
16 | textarea {
17 | max-width: 280px;
18 | }
19 |
20 | /* Carousel */
21 | .carousel-caption p {
22 | font-size: 20px;
23 | line-height: 1.4;
24 | }
25 |
26 | /* Make .svg files in the carousel display properly in older browsers */
27 | .carousel-inner .item img[src$=".svg"]
28 | {
29 | width: 100%;
30 | }
31 |
32 | /* Hide/rearrange for smaller screens */
33 | @media screen and (max-width: 767px) {
34 | /* Hide captions */
35 | .carousel-caption {
36 | display: none
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/css/site.min.css:
--------------------------------------------------------------------------------
1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}@media screen and (max-width:767px){.carousel-caption{display:none}}
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/js/site.js:
--------------------------------------------------------------------------------
1 | // Write your Javascript code.
2 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/js/site.min.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/js/site.min.js
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap",
3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
4 | "keywords": [
5 | "css",
6 | "js",
7 | "less",
8 | "mobile-first",
9 | "responsive",
10 | "front-end",
11 | "framework",
12 | "web"
13 | ],
14 | "homepage": "http://getbootstrap.com",
15 | "license": "MIT",
16 | "moduleType": "globals",
17 | "main": [
18 | "less/bootstrap.less",
19 | "dist/js/bootstrap.js"
20 | ],
21 | "ignore": [
22 | "/.*",
23 | "_config.yml",
24 | "CNAME",
25 | "composer.json",
26 | "CONTRIBUTING.md",
27 | "docs",
28 | "js/tests",
29 | "test-infra"
30 | ],
31 | "dependencies": {
32 | "jquery": "1.9.1 - 2"
33 | },
34 | "version": "3.3.6",
35 | "_release": "3.3.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.3.6",
39 | "commit": "81df608a40bf0629a1dc08e584849bb1e43e0b7a"
40 | },
41 | "_source": "git://github.com/twbs/bootstrap.git",
42 | "_target": "3.3.6",
43 | "_originalSource": "bootstrap"
44 | }
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2015 Twitter, Inc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/bootstrap/dist/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery-validation-unobtrusive/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation-unobtrusive",
3 | "version": "3.2.6",
4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive",
5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.",
6 | "main": [
7 | "jquery.validate.unobtrusive.js"
8 | ],
9 | "ignore": [
10 | "**/.*",
11 | "*.json",
12 | "*.md",
13 | "*.txt",
14 | "gulpfile.js"
15 | ],
16 | "keywords": [
17 | "jquery",
18 | "asp.net",
19 | "mvc",
20 | "validation",
21 | "unobtrusive"
22 | ],
23 | "authors": [
24 | "Microsoft"
25 | ],
26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm",
27 | "repository": {
28 | "type": "git",
29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git"
30 | },
31 | "dependencies": {
32 | "jquery-validation": ">=1.8",
33 | "jquery": ">=1.8"
34 | },
35 | "_release": "3.2.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.2.6",
39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7"
40 | },
41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git",
42 | "_target": "3.2.6",
43 | "_originalSource": "jquery-validation-unobtrusive"
44 | }
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery-validation/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation",
3 | "homepage": "http://jqueryvalidation.org/",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/jzaefferer/jquery-validation.git"
7 | },
8 | "authors": [
9 | "Jörn Zaefferer "
10 | ],
11 | "description": "Form validation made easy",
12 | "main": "dist/jquery.validate.js",
13 | "keywords": [
14 | "forms",
15 | "validation",
16 | "validate"
17 | ],
18 | "license": "MIT",
19 | "ignore": [
20 | "**/.*",
21 | "node_modules",
22 | "bower_components",
23 | "test",
24 | "demo",
25 | "lib"
26 | ],
27 | "dependencies": {
28 | "jquery": ">= 1.7.2"
29 | },
30 | "version": "1.14.0",
31 | "_release": "1.14.0",
32 | "_resolution": {
33 | "type": "version",
34 | "tag": "1.14.0",
35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48"
36 | },
37 | "_source": "git://github.com/jzaefferer/jquery-validation.git",
38 | "_target": ">=1.8",
39 | "_originalSource": "jquery-validation"
40 | }
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "main": "dist/jquery.js",
4 | "license": "MIT",
5 | "ignore": [
6 | "package.json"
7 | ],
8 | "keywords": [
9 | "jquery",
10 | "javascript",
11 | "browser",
12 | "library"
13 | ],
14 | "homepage": "https://github.com/jquery/jquery-dist",
15 | "version": "2.2.0",
16 | "_release": "2.2.0",
17 | "_resolution": {
18 | "type": "version",
19 | "tag": "2.2.0",
20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5"
21 | },
22 | "_source": "git://github.com/jquery/jquery-dist.git",
23 | "_target": "2.2.0",
24 | "_originalSource": "jquery"
25 | }
--------------------------------------------------------------------------------
/IdentityServer4OpenID/src/MvcClient/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright jQuery Foundation and other contributors, https://jquery.org/
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/jquery/jquery
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | All files located in the node_modules and external directories are
34 | externally maintained libraries used by this software which have their
35 | own licenses; we recommend you read them, as their terms may differ from
36 | the terms above.
37 |
--------------------------------------------------------------------------------
/NETCoreLogging/NETCoreLogging.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{750DB4F6-4C5E-47F8-9BD9-D30181C64F39}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{83FED358-0394-485F-BB82-0C59D67701BC}"
9 | ProjectSection(SolutionItems) = preProject
10 | global.json = global.json
11 | EndProjectSection
12 | EndProject
13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreLogging", "src\NETCoreLogging\NETCoreLogging.xproj", "{CB2F89A8-8E72-4084-936F-C2A0D27F161E}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E}.Release|Any CPU.Build.0 = Release|Any CPU
25 | EndGlobalSection
26 | GlobalSection(SolutionProperties) = preSolution
27 | HideSolutionNode = FALSE
28 | EndGlobalSection
29 | GlobalSection(NestedProjects) = preSolution
30 | {CB2F89A8-8E72-4084-936F-C2A0D27F161E} = {750DB4F6-4C5E-47F8-9BD9-D30181C64F39}
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/NETCoreLogging/README.md:
--------------------------------------------------------------------------------
1 | #NETCoreLogging
2 |
3 | [ASP.NET Core 开发-Logging 使用NLog 写日志文件](http://www.cnblogs.com/linezero/p/Logging.html)
--------------------------------------------------------------------------------
/NETCoreLogging/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "projects": [ "src", "test" ],
3 | "sdk": {
4 | "version": "1.0.0-preview1-002702"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "wwwroot/lib"
3 | }
4 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace NETCoreLogging.Controllers
9 | {
10 | public class HomeController : Controller
11 | {
12 | private readonly ILogger _logger;
13 |
14 | public HomeController(ILogger logger)
15 | {
16 | _logger = logger;
17 | }
18 | public IActionResult Index()
19 | {
20 | _logger.LogInformation("你访问了首页");
21 | _logger.LogWarning("警告信息");
22 | _logger.LogError("错误信息");
23 | return View();
24 | }
25 |
26 | public IActionResult About()
27 | {
28 | ViewData["Message"] = "Your application description page.";
29 |
30 | return View();
31 | }
32 |
33 | public IActionResult Contact()
34 | {
35 | ViewData["Message"] = "Your contact page.";
36 |
37 | return View();
38 | }
39 |
40 | public IActionResult Error()
41 | {
42 | return View();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/NETCoreLogging.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | cb2f89a8-8e72-4084-936f-c2a0d27f161e
10 | NETCoreLogging
11 | .\obj
12 | .\bin\
13 | v4.5.2
14 |
15 |
16 | 2.0
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Hosting;
7 |
8 | namespace NETCoreLogging
9 | {
10 | public class Program
11 | {
12 | public static void Main(string[] args)
13 | {
14 | var host = new WebHostBuilder()
15 | .UseKestrel()
16 | .UseContentRoot(Directory.GetCurrentDirectory())
17 | .UseIISIntegration()
18 | .UseStartup()
19 | .Build();
20 |
21 | host.Run();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:5382/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "NETCoreLogging": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "launchUrl": "http://localhost:5000",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development"
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Logging;
10 | using System.Text;
11 | using NLog.Extensions.Logging;
12 |
13 | namespace NETCoreLogging
14 | {
15 | public class Startup
16 | {
17 | public Startup(IHostingEnvironment env)
18 | {
19 | var builder = new ConfigurationBuilder()
20 | .SetBasePath(env.ContentRootPath)
21 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
22 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
23 | .AddEnvironmentVariables();
24 | Configuration = builder.Build();
25 | }
26 |
27 | public IConfigurationRoot Configuration { get; }
28 |
29 | // This method gets called by the runtime. Use this method to add services to the container.
30 | public void ConfigureServices(IServiceCollection services)
31 | {
32 | // Add framework services.
33 | services.AddMvc();
34 | }
35 |
36 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
37 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
38 | {
39 | loggerFactory.AddNLog();//添加NLog
40 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
41 | loggerFactory.AddConsole(Configuration.GetSection("Logging"));
42 | loggerFactory.AddDebug();
43 |
44 | if (env.IsDevelopment())
45 | {
46 | app.UseDeveloperExceptionPage();
47 | app.UseBrowserLink();
48 | }
49 | else
50 | {
51 | app.UseExceptionHandler("/Home/Error");
52 | }
53 |
54 | app.UseStaticFiles();
55 |
56 | app.UseMvc(routes =>
57 | {
58 | routes.MapRoute(
59 | name: "default",
60 | template: "{controller=Home}/{action=Index}/{id?}");
61 | });
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Views/Home/About.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "About";
3 | }
4 | @ViewData["Title"].
5 | @ViewData["Message"]
6 |
7 | Use this area to provide additional information.
8 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Views/Home/Contact.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Contact";
3 | }
4 | @ViewData["Title"].
5 | @ViewData["Message"]
6 |
7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P:
11 | 425.555.0100
12 |
13 |
14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com
17 |
18 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Error";
3 | }
4 |
5 | Error.
6 | An error occurred while processing your request.
7 |
8 | Development Mode
9 |
10 | Swapping to Development environment will display more detailed information about the error that occurred.
11 |
12 |
13 | Development environment should not be enabled in deployed applications , as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development , and restarting the application.
14 |
15 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @ViewData["Title"] - NETCoreLogging
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
40 |
41 | @RenderBody()
42 |
43 |
44 | © 2016 - NETCoreLogging
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
58 |
62 |
63 |
64 |
65 | @RenderSection("scripts", required: false)
66 |
67 |
68 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Views/_ViewImports.cshtml:
--------------------------------------------------------------------------------
1 | @using NETCoreLogging
2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
3 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "_Layout";
3 | }
4 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "asp.net",
3 | "private": true,
4 | "dependencies": {
5 | "bootstrap": "3.3.6",
6 | "jquery": "2.2.0",
7 | "jquery-validation": "1.14.0",
8 | "jquery-validation-unobtrusive": "3.2.6"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/gulpfile.js:
--------------------------------------------------------------------------------
1 | ///
2 | "use strict";
3 |
4 | var gulp = require("gulp"),
5 | rimraf = require("rimraf"),
6 | concat = require("gulp-concat"),
7 | cssmin = require("gulp-cssmin"),
8 | uglify = require("gulp-uglify");
9 |
10 | var webroot = "./wwwroot/";
11 |
12 | var paths = {
13 | js: webroot + "js/**/*.js",
14 | minJs: webroot + "js/**/*.min.js",
15 | css: webroot + "css/**/*.css",
16 | minCss: webroot + "css/**/*.min.css",
17 | concatJsDest: webroot + "js/site.min.js",
18 | concatCssDest: webroot + "css/site.min.css"
19 | };
20 |
21 | gulp.task("clean:js", function (cb) {
22 | rimraf(paths.concatJsDest, cb);
23 | });
24 |
25 | gulp.task("clean:css", function (cb) {
26 | rimraf(paths.concatCssDest, cb);
27 | });
28 |
29 | gulp.task("clean", ["clean:js", "clean:css"]);
30 |
31 | gulp.task("min:js", function () {
32 | return gulp.src([paths.js, "!" + paths.minJs], { base: "." })
33 | .pipe(concat(paths.concatJsDest))
34 | .pipe(uglify())
35 | .pipe(gulp.dest("."));
36 | });
37 |
38 | gulp.task("min:css", function () {
39 | return gulp.src([paths.css, "!" + paths.minCss])
40 | .pipe(concat(paths.concatCssDest))
41 | .pipe(cssmin())
42 | .pipe(gulp.dest("."));
43 | });
44 |
45 | gulp.task("min", ["min:js", "min:css"]);
46 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/nlog.config:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "asp.net",
3 | "version": "0.0.0",
4 | "private": true,
5 | "devDependencies": {
6 | "gulp": "3.8.11",
7 | "gulp-concat": "2.5.2",
8 | "gulp-cssmin": "0.1.7",
9 | "gulp-uglify": "1.2.0",
10 | "rimraf": "2.2.8"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/project.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/project.json
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/_references.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 | ///
6 | ///
7 | ///
8 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 50px;
3 | padding-bottom: 20px;
4 | }
5 |
6 | /* Wrapping element */
7 | /* Set some basic padding to keep content from hitting the edges */
8 | .body-content {
9 | padding-left: 15px;
10 | padding-right: 15px;
11 | }
12 |
13 | /* Set widths on the form inputs since otherwise they're 100% wide */
14 | input,
15 | select,
16 | textarea {
17 | max-width: 280px;
18 | }
19 |
20 | /* Carousel */
21 | .carousel-caption p {
22 | font-size: 20px;
23 | line-height: 1.4;
24 | }
25 | /* Hide/rearrange for smaller screens */
26 | @media screen and (max-width: 767px) {
27 | /* Hide captions */
28 | .carousel-caption {
29 | display: none
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/css/site.min.css:
--------------------------------------------------------------------------------
1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}input,select,textarea{max-width:280px}.carousel-caption p{font-size:20px;line-height:1.4}@media screen and (max-width:767px){.carousel-caption{display:none}}
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/js/site.js:
--------------------------------------------------------------------------------
1 | // Write your Javascript code.
2 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/js/site.min.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/js/site.min.js
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap",
3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
4 | "keywords": [
5 | "css",
6 | "js",
7 | "less",
8 | "mobile-first",
9 | "responsive",
10 | "front-end",
11 | "framework",
12 | "web"
13 | ],
14 | "homepage": "http://getbootstrap.com",
15 | "license": "MIT",
16 | "moduleType": "globals",
17 | "main": [
18 | "less/bootstrap.less",
19 | "dist/js/bootstrap.js"
20 | ],
21 | "ignore": [
22 | "/.*",
23 | "_config.yml",
24 | "CNAME",
25 | "composer.json",
26 | "CONTRIBUTING.md",
27 | "docs",
28 | "js/tests",
29 | "test-infra"
30 | ],
31 | "dependencies": {
32 | "jquery": "1.9.1 - 2"
33 | },
34 | "version": "3.3.6",
35 | "_release": "3.3.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.3.6",
39 | "commit": "81df608a40bf0629a1dc08e584849bb1e43e0b7a"
40 | },
41 | "_source": "git://github.com/twbs/bootstrap.git",
42 | "_target": "3.3.6",
43 | "_originalSource": "bootstrap"
44 | }
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2015 Twitter, Inc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linezero/Blog/17196a5bafac527b92362f22ffec6e0ab628ac4f/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/bootstrap/dist/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery-validation-unobtrusive/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation-unobtrusive",
3 | "version": "3.2.6",
4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive",
5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.",
6 | "main": [
7 | "jquery.validate.unobtrusive.js"
8 | ],
9 | "ignore": [
10 | "**/.*",
11 | "*.json",
12 | "*.md",
13 | "*.txt",
14 | "gulpfile.js"
15 | ],
16 | "keywords": [
17 | "jquery",
18 | "asp.net",
19 | "mvc",
20 | "validation",
21 | "unobtrusive"
22 | ],
23 | "authors": [
24 | "Microsoft"
25 | ],
26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm",
27 | "repository": {
28 | "type": "git",
29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git"
30 | },
31 | "dependencies": {
32 | "jquery-validation": ">=1.8",
33 | "jquery": ">=1.8"
34 | },
35 | "_release": "3.2.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.2.6",
39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7"
40 | },
41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git",
42 | "_target": "3.2.6",
43 | "_originalSource": "jquery-validation-unobtrusive"
44 | }
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery-validation/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation",
3 | "homepage": "http://jqueryvalidation.org/",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/jzaefferer/jquery-validation.git"
7 | },
8 | "authors": [
9 | "Jörn Zaefferer "
10 | ],
11 | "description": "Form validation made easy",
12 | "main": "dist/jquery.validate.js",
13 | "keywords": [
14 | "forms",
15 | "validation",
16 | "validate"
17 | ],
18 | "license": "MIT",
19 | "ignore": [
20 | "**/.*",
21 | "node_modules",
22 | "bower_components",
23 | "test",
24 | "demo",
25 | "lib"
26 | ],
27 | "dependencies": {
28 | "jquery": ">= 1.7.2"
29 | },
30 | "version": "1.14.0",
31 | "_release": "1.14.0",
32 | "_resolution": {
33 | "type": "version",
34 | "tag": "1.14.0",
35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48"
36 | },
37 | "_source": "git://github.com/jzaefferer/jquery-validation.git",
38 | "_target": ">=1.8",
39 | "_originalSource": "jquery-validation"
40 | }
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "main": "dist/jquery.js",
4 | "license": "MIT",
5 | "ignore": [
6 | "package.json"
7 | ],
8 | "keywords": [
9 | "jquery",
10 | "javascript",
11 | "browser",
12 | "library"
13 | ],
14 | "homepage": "https://github.com/jquery/jquery-dist",
15 | "version": "2.2.0",
16 | "_release": "2.2.0",
17 | "_resolution": {
18 | "type": "version",
19 | "tag": "2.2.0",
20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5"
21 | },
22 | "_source": "git://github.com/jquery/jquery-dist.git",
23 | "_target": "2.2.0",
24 | "_originalSource": "jquery"
25 | }
--------------------------------------------------------------------------------
/NETCoreLogging/src/NETCoreLogging/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright jQuery Foundation and other contributors, https://jquery.org/
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/jquery/jquery
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | All files located in the node_modules and external directories are
34 | externally maintained libraries used by this software which have their
35 | own licenses; we recommend you read them, as their terms may differ from
36 | the terms above.
37 |
--------------------------------------------------------------------------------
/NETCoreMySQL/NETCoreMySQL.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{927FDD21-3815-43C3-8EF6-D47AA09B4DBA}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5D5EF17A-AF3C-440B-9D74-38904EC935A0}"
9 | ProjectSection(SolutionItems) = preProject
10 | global.json = global.json
11 | EndProjectSection
12 | EndProject
13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreMySQL", "src\NETCoreMySQL\NETCoreMySQL.xproj", "{DE5B5364-4955-42F5-95C0-BD0E2AECF10B}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B}.Release|Any CPU.Build.0 = Release|Any CPU
25 | EndGlobalSection
26 | GlobalSection(SolutionProperties) = preSolution
27 | HideSolutionNode = FALSE
28 | EndGlobalSection
29 | GlobalSection(NestedProjects) = preSolution
30 | {DE5B5364-4955-42F5-95C0-BD0E2AECF10B} = {927FDD21-3815-43C3-8EF6-D47AA09B4DBA}
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/NETCoreMySQL/README.md:
--------------------------------------------------------------------------------
1 | #NETCoreMySQL
2 |
3 | [.NET Core 使用Dapper 操作MySQL](http://www.cnblogs.com/linezero/p/NETCoreMySQL.html)
4 |
5 | [MySQL官方.NET Core驱动已出,支持EF Core](http://www.cnblogs.com/linezero/p/5806814.html)
--------------------------------------------------------------------------------
/NETCoreMySQL/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "projects": [ "src", "test" ],
3 | "sdk": {
4 | "version": "1.0.0-preview2-003121"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/NETCoreMySQL/src/NETCoreMySQL/NETCoreMySQL.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | de5b5364-4955-42f5-95c0-bd0e2aecf10b
10 | NETCoreMySQL
11 | .\obj
12 | .\bin\
13 | v4.5.2
14 |
15 |
16 | 2.0
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/NETCoreMySQL/src/NETCoreMySQL/Program.cs:
--------------------------------------------------------------------------------
1 | using MySql.Data.MySqlClient;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Dapper;
7 | using System.Text;
8 | using Microsoft.Extensions.Configuration;
9 | using System.IO;
10 |
11 | namespace NETCoreMySQL
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
18 | MySqlConnection con = new MySqlConnection("server=127.0.0.1;database=test;uid=root;pwd=;charset='gbk';SslMode=None");
19 | //新增数据
20 | con.Execute("insert into user values(null, '测试', 'http://www.cnblogs.com/linezero/', 18)");
21 | //新增数据返回自增id
22 | var id = con.QueryFirst("insert into user values(null, 'linezero', 'http://www.cnblogs.com/linezero/', 18);select last_insert_id();");
23 | //修改数据
24 | con.Execute("update user set UserName = 'linezero123' where Id = @Id", new { Id = id });
25 | //查询数据
26 | var list = con.Query("select * from user");
27 | foreach (var item in list)
28 | {
29 | Console.WriteLine($"用户名:{item.UserName} 链接:{item.Url}");
30 | }
31 | //删除数据
32 | con.Execute("delete from user where Id = @Id", new { Id = id });
33 | Console.WriteLine("删除数据后的结果");
34 | list = con.Query("select * from user");
35 | foreach (var item in list)
36 | {
37 | Console.WriteLine($"用户名:{item.UserName} 链接:{item.Url}");
38 | }
39 | Console.ReadKey();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/NETCoreMySQL/src/NETCoreMySQL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("NETCoreMySQL")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("de5b5364-4955-42f5-95c0-bd0e2aecf10b")]
20 |
--------------------------------------------------------------------------------
/NETCoreMySQL/src/NETCoreMySQL/User.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace NETCoreMySQL
7 | {
8 | public class User
9 | {
10 | public int Id { get; set; }
11 | public string UserName { get; set; }
12 | public string Url { get; set; }
13 | public int Age { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/NETCoreMySQL/src/NETCoreMySQL/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "buildOptions": {
4 | "emitEntryPoint": true
5 | },
6 |
7 | "dependencies": {
8 | "Dapper": "1.50.2",
9 | "Microsoft.Extensions.Configuration": "1.0.0",
10 | "Microsoft.Extensions.Configuration.Json": "1.0.0",
11 | "Microsoft.NETCore.App": {
12 | "type": "platform",
13 | "version": "1.0.0"
14 | },
15 | "MySql.Data.Core": "7.0.4-IR-191",
16 | "System.Text.Encoding.CodePages": "4.0.1"
17 | },
18 |
19 | "frameworks": {
20 | "netcoreapp1.0": {
21 | "imports": "dnxcore50"
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/NETCoreTests/NETCoreTests.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D8DEB2DD-9E0B-4A51-8382-BF1BE12C9927}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AA861EC4-F571-485E-BF6C-AD32569363C6}"
9 | ProjectSection(SolutionItems) = preProject
10 | global.json = global.json
11 | EndProjectSection
12 | EndProject
13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreTests", "src\NETCoreTests\NETCoreTests.xproj", "{5E1F4593-16B7-4F5F-8F3C-512537E7820D}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Release|Any CPU = Release|Any CPU
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D}.Release|Any CPU.Build.0 = Release|Any CPU
25 | EndGlobalSection
26 | GlobalSection(SolutionProperties) = preSolution
27 | HideSolutionNode = FALSE
28 | EndGlobalSection
29 | GlobalSection(NestedProjects) = preSolution
30 | {5E1F4593-16B7-4F5F-8F3C-512537E7820D} = {D8DEB2DD-9E0B-4A51-8382-BF1BE12C9927}
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/NETCoreTests/README.md:
--------------------------------------------------------------------------------
1 | #NETCoreTests
2 |
3 | [.NET Core 单元测试 MSTest](http://www.cnblogs.com/linezero/p/MSTest.html)
--------------------------------------------------------------------------------
/NETCoreTests/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "projects": [ "src", "test" ],
3 | "sdk": {
4 | "version": "1.0.0-preview1-002702"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/NETCoreTests/src/NETCoreTests/NETCoreTests.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | 5e1f4593-16b7-4f5f-8f3c-512537e7820d
10 | NETCoreTests
11 | .\obj
12 | .\bin\
13 | v4.5.2
14 |
15 |
16 | 2.0
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/NETCoreTests/src/NETCoreTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("NETCoreTests")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("5e1f4593-16b7-4f5f-8f3c-512537e7820d")]
20 |
--------------------------------------------------------------------------------
/NETCoreTests/src/NETCoreTests/TestClass.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 |
3 | namespace NETCoreTests
4 | {
5 | // This project can output the Class library as a NuGet Package.
6 | // To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build".
7 | [TestClass]
8 | public class TestClass
9 | {
10 | [TestMethod]
11 | public void TestMethodPassing()
12 | {
13 | Assert.IsTrue(true);
14 | }
15 |
16 | [TestMethod]
17 | public void TestMethodFailing()
18 | {
19 | Assert.IsTrue(false);
20 | }
21 |
22 | [TestMethod]
23 | public void TestStringEqual()
24 | {
25 | var blogname = "linezero";
26 | Assert.AreEqual(blogname,"LineZero");
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/NETCoreTests/src/NETCoreTests/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 |
4 | "testRunner": "mstest",
5 |
6 | "dependencies": {
7 | "dotnet-test-mstest": "1.0.0-preview",
8 | "MSTest.TestFramework": "1.0.0-preview"
9 | },
10 |
11 | "frameworks": {
12 | "netcoreapp1.0": {
13 | "imports": [
14 | "dnxcore50",
15 | "portable-net45+win8"
16 | ],
17 |
18 | "dependencies": {
19 | "Microsoft.NETCore.App": {
20 | "version": "1.0.0-rc2-3002702",
21 | "type": "platform"
22 | }
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NETCoreWCF", "NETCoreWCF\NETCoreWCF.csproj", "{5BDB0773-0A70-47D8-8937-4072137B2713}"
7 | EndProject
8 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "NETCoreWCFClient", "NETCoreWCFClient\NETCoreWCFClient.xproj", "{C9652E3B-F6F1-4106-9EE5-150140D7B84F}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {5BDB0773-0A70-47D8-8937-4072137B2713}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {C9652E3B-F6F1-4106-9EE5-150140D7B84F}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/INETCoreService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Web;
7 | using System.Text;
8 |
9 | namespace NETCoreWCF
10 | {
11 | // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
12 | [ServiceContract]
13 | public interface INETCoreService
14 | {
15 |
16 | [OperationContract]
17 | string GetData(int value);
18 |
19 | [OperationContract]
20 | CompositeType GetDataUsingDataContract(CompositeType composite);
21 |
22 | [OperationContract]
23 | List GetList();
24 |
25 | // TODO: 在此添加您的服务操作
26 | }
27 |
28 |
29 | // 使用下面示例中说明的数据约定将复合类型添加到服务操作。
30 | [DataContract]
31 | public class CompositeType
32 | {
33 | bool boolValue = true;
34 | string stringValue = "Hello ";
35 |
36 | [DataMember]
37 | public bool BoolValue
38 | {
39 | get { return boolValue; }
40 | set { boolValue = value; }
41 | }
42 |
43 | [DataMember]
44 | public string StringValue
45 | {
46 | get { return stringValue; }
47 | set { stringValue = value; }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/NETCoreService.svc:
--------------------------------------------------------------------------------
1 | <%@ ServiceHost Language="C#" Debug="true" Service="NETCoreWCF.NETCoreService" CodeBehind="NETCoreService.svc.cs" %>
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/NETCoreService.svc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Web;
7 | using System.Text;
8 |
9 | namespace NETCoreWCF
10 | {
11 | // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service1”。
12 | // 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Service1.svc 或 Service1.svc.cs,然后开始调试。
13 | public class NETCoreService : INETCoreService
14 | {
15 | public string GetData(int value)
16 | {
17 | return string.Format("You entered: {0}", value);
18 | }
19 |
20 | public CompositeType GetDataUsingDataContract(CompositeType composite)
21 | {
22 | if (composite == null)
23 | {
24 | throw new ArgumentNullException("composite");
25 | }
26 | if (composite.BoolValue)
27 | {
28 | composite.StringValue += "Suffix";
29 | }
30 | return composite;
31 | }
32 |
33 | public List GetList()
34 | {
35 | var list = new List();
36 | list.Add("cnblogs");
37 | list.Add("linezero");
38 | list.Add("测试");
39 | return list;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("NETCoreWCF")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("NETCoreWCF")]
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("5bdb0773-0a70-47d8-8937-4072137b2713")]
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 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
30 |
31 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
31 |
32 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCF/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 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCFClient/NETCoreWCFClient.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | c9652e3b-f6f1-4106-9ee5-150140d7b84f
11 | NETCoreWCFClient
12 | .\obj
13 | .\bin\
14 | v4.5.2
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCFClient/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using NETCoreService;
6 | using System.Text;
7 |
8 | namespace NETCoreWCFClient
9 | {
10 | public class Program
11 | {
12 | public static void Main(string[] args)
13 | {
14 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
15 | NETCoreServiceClient client = new NETCoreServiceClient();
16 | var t = client.GetDataAsync(100);
17 | Console.WriteLine(t.Result);
18 | var t1 = client.GetListAsync();
19 | foreach (var item in t1.Result)
20 | {
21 | Console.WriteLine(item);
22 | }
23 | CompositeType composite = new CompositeType();
24 | composite.BoolValue = true;
25 | composite.StringValue = "客户端调用";
26 | var t2 = client.GetDataUsingDataContractAsync(composite);
27 | Console.WriteLine(t2.Result.StringValue);
28 | Console.ReadKey();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCFClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("NETCoreWCFClient")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("c9652e3b-f6f1-4106-9ee5-150140d7b84f")]
20 |
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCFClient/Service References/NETCoreService/ConnectedService.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
3 | "Version": "0.2.20609.0",
4 | "GettingStartedDocument": {
5 | "Uri": "http://go.microsoft.com/fwlink/?LinkId=703956"
6 | }
7 | }
--------------------------------------------------------------------------------
/NETCoreWCF/NETCoreWCFClient/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "buildOptions": {
4 | "emitEntryPoint": true
5 | },
6 | "dependencies": {
7 | "Microsoft.NETCore.App": {
8 | "type": "platform",
9 | "version": "1.0.0-rc2-3002702"
10 | },
11 | "System.Text.Encoding.CodePages": "4.0.1-rc2-24027"
12 | },
13 | "frameworks": {
14 | "netcoreapp1.0": {
15 | "imports": "dnxcore50",
16 | "dependencies": {
17 | "System.Diagnostics.Tools": "4.0.1-rc2-24027",
18 | "System.Net.NameResolution": "4.0.0-rc2-24027",
19 | "System.Net.Security": "4.0.0-rc2-24027",
20 | "System.Private.ServiceModel": "4.1.0-rc2-24027",
21 | "System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
22 | "System.Runtime.Serialization.Xml": "4.1.1-rc2-24027",
23 | "System.Security.Principal.Windows": "4.0.0-rc2-24027",
24 | "System.ServiceModel.Duplex": "4.0.1-rc2-24027",
25 | "System.ServiceModel.Http": "4.1.0-rc2-24027",
26 | "System.ServiceModel.NetTcp": "4.1.0-rc2-24027",
27 | "System.ServiceModel.Primitives": "4.1.0-rc2-24027",
28 | "System.ServiceModel.Security": "4.0.1-rc2-24027"
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/NETCoreWCF/README.md:
--------------------------------------------------------------------------------
1 | #NETCoreWCF
2 |
3 | [.NET Core 调用WCF 服务](http://www.cnblogs.com/linezero/p/NETCoreWCF.html)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Blog
2 | Blog Sample Code
3 |
4 | 博客示例代码
5 |
6 | 博客地址:http://www.cnblogs.com/linezero
7 |
--------------------------------------------------------------------------------
/SOAPService/README.md:
--------------------------------------------------------------------------------
1 | #SOAPService
2 |
3 | [ASP.NET Core中间件(Middleware)实现WCF SOAP服务端解析](http://www.cnblogs.com/linezero/p/aspnetcoresoap.html)
--------------------------------------------------------------------------------
/SOAPService/SOAPService.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{47C331FE-90FF-4C1E-BCD1-98152CE2CCF8}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3CCB24EC-179D-4B74-A33C-67E4E8D22CA0}"
9 | ProjectSection(SolutionItems) = preProject
10 | global.json = global.json
11 | EndProjectSection
12 | EndProject
13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SOAPService", "src\SOAPService\SOAPService.xproj", "{3DDF128C-8E5A-4222-8AA3-9808BA4CA880}"
14 | EndProject
15 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SOAPClient", "src\SOAPClient\SOAPClient.xproj", "{2B13196B-7529-4E79-AA72-9AF00F71C459}"
16 | EndProject
17 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CustomMiddleware", "src\CustomMiddleware\CustomMiddleware.xproj", "{4524A25D-3510-48A1-A645-7DCD9D88E40F}"
18 | EndProject
19 | Global
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
21 | Debug|Any CPU = Debug|Any CPU
22 | Release|Any CPU = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {2B13196B-7529-4E79-AA72-9AF00F71C459}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {4524A25D-3510-48A1-A645-7DCD9D88E40F}.Release|Any CPU.Build.0 = Release|Any CPU
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | GlobalSection(NestedProjects) = preSolution
42 | {3DDF128C-8E5A-4222-8AA3-9808BA4CA880} = {47C331FE-90FF-4C1E-BCD1-98152CE2CCF8}
43 | {2B13196B-7529-4E79-AA72-9AF00F71C459} = {47C331FE-90FF-4C1E-BCD1-98152CE2CCF8}
44 | {4524A25D-3510-48A1-A645-7DCD9D88E40F} = {47C331FE-90FF-4C1E-BCD1-98152CE2CCF8}
45 | EndGlobalSection
46 | EndGlobal
47 |
--------------------------------------------------------------------------------
/SOAPService/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "projects": [ "src", "test" ],
3 | "sdk": {
4 | "version": "1.0.0-preview2-003121"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/ContractDescription.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.ServiceModel;
6 | using System.Threading.Tasks;
7 |
8 | namespace CustomMiddleware
9 | {
10 | public class ContractDescription
11 | {
12 | public ServiceDescription Service { get; private set; }
13 | public string Name { get; private set; }
14 | public string Namespace { get; private set; }
15 | public Type ContractType { get; private set; }
16 | public IEnumerable Operations { get; private set; }
17 |
18 | public ContractDescription(ServiceDescription service, Type contractType, ServiceContractAttribute attribute)
19 | {
20 | Service = service;
21 | ContractType = contractType;
22 | Namespace = attribute.Namespace ?? "http://tempuri.org/"; // Namespace defaults to http://tempuri.org/
23 | Name = attribute.Name ?? ContractType.Name; // Name defaults to the type name
24 |
25 | var operations = new List();
26 | foreach (var operationMethodInfo in ContractType.GetTypeInfo().DeclaredMethods)
27 | {
28 | foreach (var operationContract in operationMethodInfo.GetCustomAttributes())
29 | {
30 | operations.Add(new OperationDescription(this, operationMethodInfo, operationContract));
31 | }
32 | }
33 | Operations = operations;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/CustomMiddleware.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | 4524a25d-3510-48a1-a645-7dcd9d88e40f
11 | CustomMiddleware
12 | .\obj
13 | .\bin\
14 | v4.5.2
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/OperationDescription.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.ServiceModel;
6 | using System.Threading.Tasks;
7 |
8 | namespace CustomMiddleware
9 | {
10 | public class OperationDescription
11 | {
12 | public ContractDescription Contract { get; private set; }
13 | public string SoapAction { get; private set; }
14 | public string ReplyAction { get; private set; }
15 | public string Name { get; private set; }
16 | public MethodInfo DispatchMethod { get; private set; }
17 | public bool IsOneWay { get; private set; }
18 |
19 | public OperationDescription(ContractDescription contract, MethodInfo operationMethod, OperationContractAttribute contractAttribute)
20 | {
21 | Contract = contract;
22 | Name = contractAttribute.Name ?? operationMethod.Name;
23 | SoapAction = contractAttribute.Action ?? $"{contract.Namespace.TrimEnd('/')}/{contract.Name}/{Name}";
24 | IsOneWay = contractAttribute.IsOneWay;
25 | ReplyAction = contractAttribute.ReplyAction;
26 | DispatchMethod = operationMethod;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("CustomMiddleware")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("4524a25d-3510-48a1-a645-7dcd9d88e40f")]
20 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/ServiceBodyWriter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.ServiceModel.Channels;
6 | using System.Threading.Tasks;
7 | using System.Xml;
8 |
9 | namespace CustomMiddleware
10 | {
11 | public class ServiceBodyWriter : BodyWriter
12 | {
13 | string ServiceNamespace;
14 | string EnvelopeName;
15 | string ResultName;
16 | object Result;
17 |
18 | public ServiceBodyWriter(string serviceNamespace, string envelopeName, string resultName, object result) : base(isBuffered: true)
19 | {
20 | ServiceNamespace = serviceNamespace;
21 | EnvelopeName = envelopeName;
22 | ResultName = resultName;
23 | Result = result;
24 | }
25 |
26 | protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
27 | {
28 | writer.WriteStartElement(EnvelopeName, ServiceNamespace);
29 | var serializer = new DataContractSerializer(Result.GetType(), ResultName, ServiceNamespace);
30 | serializer.WriteObject(writer, Result);
31 | writer.WriteEndElement();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/ServiceDescription.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.ServiceModel;
6 | using System.Threading.Tasks;
7 |
8 | namespace CustomMiddleware
9 | {
10 | public class ServiceDescription
11 | {
12 | public Type ServiceType { get; private set; }
13 | public IEnumerable Contracts { get; private set; }
14 | public IEnumerable Operations => Contracts.SelectMany(c => c.Operations);
15 |
16 | public ServiceDescription(Type serviceType)
17 | {
18 | ServiceType = serviceType;
19 |
20 | var contracts = new List();
21 |
22 | foreach (var contractType in ServiceType.GetInterfaces())
23 | {
24 | foreach (var serviceContract in contractType.GetTypeInfo().GetCustomAttributes())
25 | {
26 | contracts.Add(new ContractDescription(this, contractType, serviceContract));
27 | }
28 | }
29 |
30 | Contracts = contracts;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/SOAPService/src/CustomMiddleware/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 |
4 | "dependencies": {
5 | "NETStandard.Library": "1.6.0",
6 | "System.ServiceModel.Primitives": "4.1.0",
7 | "System.Reflection.TypeExtensions": "4.1.0",
8 | "System.ComponentModel": "4.0.1",
9 | "Microsoft.AspNetCore.Http.Abstractions": "1.0.0"
10 | },
11 |
12 | "frameworks": {
13 | "netstandard1.6": {
14 | "imports": "dnxcore50"
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPClient/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.ServiceModel.Channels;
6 | using System.Threading.Tasks;
7 |
8 | namespace SOAPClient
9 | {
10 | public class Program
11 | {
12 | public static void Main(string[] args)
13 | {
14 | Random numGen = new Random();
15 | double x = numGen.NextDouble() * 20;
16 | double y = numGen.NextDouble() * 20;
17 |
18 | var serviceAddress = "http://localhost:5000/CalculatorService.svc";
19 |
20 | var client = new CalculatorServiceClient(new BasicHttpBinding(), new EndpointAddress(serviceAddress));
21 | Console.WriteLine($"{x} + {y} == {client.Add(x, y)}");
22 | Console.WriteLine($"{x} - {y} == {client.Subtract(x, y)}");
23 | Console.WriteLine($"{x} * {y} == {client.Multiply(x, y)}");
24 | Console.WriteLine($"{x} / {y} == {client.Divide(x, y)}");
25 | client.Get("Client");
26 | }
27 | }
28 | class CalculatorServiceClient : ClientBase
29 | {
30 | public CalculatorServiceClient(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { }
31 | public double Add(double x, double y) => Channel.Add(x, y);
32 | public double Subtract(double x, double y) => Channel.Subtract(x, y);
33 | public double Multiply(double x, double y) => Channel.Multiply(x, y);
34 | public double Divide(double x, double y) => Channel.Divide(x, y);
35 |
36 | public void Get(string str)
37 | {
38 | Console.WriteLine(Channel.Get(str));
39 | }
40 | }
41 |
42 | [ServiceContract]
43 | public interface ICalculatorService
44 | {
45 | [OperationContract]
46 | double Add(double x, double y);
47 | [OperationContract]
48 | double Subtract(double x, double y);
49 | [OperationContract]
50 | double Multiply(double x, double y);
51 | [OperationContract]
52 | double Divide(double x, double y);
53 | [OperationContract]
54 | string Get(string str);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("SOAPClient")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("2b13196b-7529-4e79-aa72-9af00f71c459")]
20 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPClient/SOAPClient.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | 2b13196b-7529-4e79-aa72-9af00f71c459
11 | SOAPClient
12 | .\obj
13 | .\bin\
14 | v4.5.2
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPClient/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "buildOptions": {
4 | "emitEntryPoint": true
5 | },
6 |
7 | "dependencies": {
8 | "Microsoft.NETCore.App": {
9 | "type": "platform",
10 | "version": "1.0.0"
11 | },
12 | "System.Private.ServiceModel": "4.1.0",
13 | "System.ServiceModel.Http": "4.1.0",
14 | "System.ServiceModel.Primitives": "4.1.0"
15 | },
16 |
17 | "frameworks": {
18 | "netcoreapp1.0": {
19 | "imports": "dnxcore50"
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/CalculatorService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Threading.Tasks;
6 |
7 | namespace SOAPService
8 | {
9 | public class CalculatorService : ICalculatorService
10 | {
11 | public double Add(double x, double y) => x + y;
12 | public double Divide(double x, double y) => x / y;
13 | public double Multiply(double x, double y) => x * y;
14 | public double Subtract(double x, double y) => x - y;
15 | public string Get(string str) => $"{str} Hello World!";
16 | }
17 |
18 | [ServiceContract]
19 | public interface ICalculatorService
20 | {
21 | [OperationContract]
22 | double Add(double x, double y);
23 | [OperationContract]
24 | double Subtract(double x, double y);
25 | [OperationContract]
26 | double Multiply(double x, double y);
27 | [OperationContract]
28 | double Divide(double x, double y);
29 |
30 | [OperationContract]
31 | string Get(string str);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace SOAPService.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | public class ValuesController : Controller
11 | {
12 | // GET api/values
13 | [HttpGet]
14 | public IEnumerable Get()
15 | {
16 | return new string[] { "value1", "value2" };
17 | }
18 |
19 | // GET api/values/5
20 | [HttpGet("{id}")]
21 | public string Get(int id)
22 | {
23 | return "value";
24 | }
25 |
26 | // POST api/values
27 | [HttpPost]
28 | public void Post([FromBody]string value)
29 | {
30 | }
31 |
32 | // PUT api/values/5
33 | [HttpPut("{id}")]
34 | public void Put(int id, [FromBody]string value)
35 | {
36 | }
37 |
38 | // DELETE api/values/5
39 | [HttpDelete("{id}")]
40 | public void Delete(int id)
41 | {
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.AspNetCore.Builder;
8 |
9 | namespace SOAPService
10 | {
11 | public class Program
12 | {
13 | public static void Main(string[] args)
14 | {
15 | var host = new WebHostBuilder()
16 | .UseKestrel()
17 | .UseContentRoot(Directory.GetCurrentDirectory())
18 | .UseIISIntegration()
19 | .UseStartup()
20 | .Build();
21 |
22 | host.Run();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:4689/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "launchUrl": "api/values",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "SOAPService": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "launchUrl": "http://localhost:5000/api/values",
23 | "environmentVariables": {
24 | "ASPNETCORE_ENVIRONMENT": "Development"
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/SOAPService.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | 3ddf128c-8e5a-4222-8aa3-9808ba4ca880
10 | SOAPService
11 | .\obj
12 | .\bin\
13 | v4.5.2
14 |
15 |
16 | 2.0
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceModel;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Builder;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.DependencyInjection;
10 | using Microsoft.Extensions.Logging;
11 | using CustomMiddleware;
12 |
13 | namespace SOAPService
14 | {
15 | public class Startup
16 | {
17 | public Startup(IHostingEnvironment env)
18 | {
19 | var builder = new ConfigurationBuilder()
20 | .SetBasePath(env.ContentRootPath)
21 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
22 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
23 | .AddEnvironmentVariables();
24 | Configuration = builder.Build();
25 | }
26 |
27 | public IConfigurationRoot Configuration { get; }
28 |
29 | // This method gets called by the runtime. Use this method to add services to the container.
30 | public void ConfigureServices(IServiceCollection services)
31 | {
32 | // Add framework services.
33 | services.AddMvc();
34 | services.AddScoped();
35 | }
36 |
37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
39 | {
40 | loggerFactory.AddConsole(Configuration.GetSection("Logging"));
41 | loggerFactory.AddDebug();
42 | //加入一个/CalculatorService.svc 地址,绑定Http
43 | app.UseSOAPMiddleware("/CalculatorService.svc", new BasicHttpBinding());
44 |
45 | app.UseMvc();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "Microsoft.NETCore.App": {
4 | "version": "1.0.0",
5 | "type": "platform"
6 | },
7 | "Microsoft.AspNetCore.Mvc": "1.0.0",
8 | "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
9 | "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
10 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
11 | "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
12 | "Microsoft.Extensions.Configuration.Json": "1.0.0",
13 | "Microsoft.Extensions.Logging": "1.0.0",
14 | "Microsoft.Extensions.Logging.Console": "1.0.0",
15 | "Microsoft.Extensions.Logging.Debug": "1.0.0",
16 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
17 | "CustomMiddleware": "1.0.0-*",
18 | "System.ServiceModel.Http": "4.1.0"
19 | },
20 |
21 | "tools": {
22 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
23 | },
24 |
25 | "frameworks": {
26 | "netcoreapp1.0": {
27 | "imports": [
28 | "dotnet5.6",
29 | "portable-net45+win8"
30 | ]
31 | }
32 | },
33 |
34 | "buildOptions": {
35 | "emitEntryPoint": true,
36 | "preserveCompilationContext": true
37 | },
38 |
39 | "runtimeOptions": {
40 | "configProperties": {
41 | "System.GC.Server": true
42 | }
43 | },
44 |
45 | "publishOptions": {
46 | "include": [
47 | "wwwroot",
48 | "Views",
49 | "Areas/**/Views",
50 | "appsettings.json",
51 | "web.config"
52 | ]
53 | },
54 |
55 | "scripts": {
56 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/SOAPService/src/SOAPService/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/gRPCDemo/README.md:
--------------------------------------------------------------------------------
1 | #gRPCDemo
2 |
3 | [gRPC C#学习](http://www.cnblogs.com/linezero/p/grpc.html)
--------------------------------------------------------------------------------
/gRPCDemo/gRPCClient/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCClient/Program.cs:
--------------------------------------------------------------------------------
1 | using Grpc.Core;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using GRPCDemo;
8 |
9 | namespace gRPCClient
10 | {
11 | class Program
12 | {
13 | static void Main(string[] args)
14 | {
15 | Channel channel = new Channel("127.0.0.1:9007", ChannelCredentials.Insecure);
16 |
17 | var client = new gRPC.gRPCClient(channel);
18 | var reply= client.SayHello(new HelloRequest { Name = "LineZero" });
19 | Console.WriteLine("来自" + reply.Message);
20 |
21 | channel.ShutdownAsync().Wait();
22 | Console.WriteLine("任意键退出...");
23 | Console.ReadKey();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("gRPCClient")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("gRPCClient")]
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("2b0239a8-772f-486f-8aa6-113a561af934")]
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 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCClient/gRPCClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {2B0239A8-772F-486F-8AA6-113A561AF934}
8 | Exe
9 | Properties
10 | gRPCClient
11 | gRPCClient
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll
40 | True
41 |
42 |
43 | ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll
44 | True
45 |
46 |
47 |
48 |
49 | ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll
50 | True
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | {c391be7d-7209-4dd8-bc30-be70a460ec08}
70 | gRPCDemo
71 |
72 |
73 |
74 |
75 |
76 |
77 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
78 |
79 |
80 |
81 |
88 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCClient/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gRPCDemo", "gRPCDemo\gRPCDemo.csproj", "{C391BE7D-7209-4DD8-BC30-BE70A460EC08}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gRPCServer", "gRPCServer\gRPCServer.csproj", "{5302EDBC-7DE0-431B-A77F-5254C9E50F95}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gRPCClient", "gRPCClient\gRPCClient.csproj", "{2B0239A8-772F-486F-8AA6-113A561AF934}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {5302EDBC-7DE0-431B-A77F-5254C9E50F95}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {2B0239A8-772F-486F-8AA6-113A561AF934}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCDemo/HelloworldGrpc.cs:
--------------------------------------------------------------------------------
1 | // Generated by the protocol buffer compiler. DO NOT EDIT!
2 | // source: helloworld.proto
3 | #region Designer generated code
4 |
5 | using System;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using Grpc.Core;
9 |
10 | namespace GRPCDemo {
11 | public static class gRPC
12 | {
13 | static readonly string __ServiceName = "gRPCDemo.gRPC";
14 |
15 | static readonly Marshaller __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::GRPCDemo.HelloRequest.Parser.ParseFrom);
16 | static readonly Marshaller __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::GRPCDemo.HelloReply.Parser.ParseFrom);
17 |
18 | static readonly Method __Method_SayHello = new Method(
19 | MethodType.Unary,
20 | __ServiceName,
21 | "SayHello",
22 | __Marshaller_HelloRequest,
23 | __Marshaller_HelloReply);
24 |
25 | /// Service descriptor
26 | public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
27 | {
28 | get { return global::GRPCDemo.HelloworldReflection.Descriptor.Services[0]; }
29 | }
30 |
31 | /// Base class for server-side implementations of gRPC
32 | public abstract class gRPCBase
33 | {
34 | public virtual global::System.Threading.Tasks.Task SayHello(global::GRPCDemo.HelloRequest request, ServerCallContext context)
35 | {
36 | throw new RpcException(new Status(StatusCode.Unimplemented, ""));
37 | }
38 |
39 | }
40 |
41 | /// Client for gRPC
42 | public class gRPCClient : ClientBase
43 | {
44 | /// Creates a new client for gRPC
45 | /// The channel to use to make remote calls.
46 | public gRPCClient(Channel channel) : base(channel)
47 | {
48 | }
49 | /// Creates a new client for gRPC that uses a custom CallInvoker .
50 | /// The callInvoker to use to make remote calls.
51 | public gRPCClient(CallInvoker callInvoker) : base(callInvoker)
52 | {
53 | }
54 | /// Protected parameterless constructor to allow creation of test doubles.
55 | protected gRPCClient() : base()
56 | {
57 | }
58 | /// Protected constructor to allow creation of configured clients.
59 | /// The client configuration.
60 | protected gRPCClient(ClientBaseConfiguration configuration) : base(configuration)
61 | {
62 | }
63 |
64 | public virtual global::GRPCDemo.HelloReply SayHello(global::GRPCDemo.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
65 | {
66 | return SayHello(request, new CallOptions(headers, deadline, cancellationToken));
67 | }
68 | public virtual global::GRPCDemo.HelloReply SayHello(global::GRPCDemo.HelloRequest request, CallOptions options)
69 | {
70 | return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request);
71 | }
72 | public virtual AsyncUnaryCall SayHelloAsync(global::GRPCDemo.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
73 | {
74 | return SayHelloAsync(request, new CallOptions(headers, deadline, cancellationToken));
75 | }
76 | public virtual AsyncUnaryCall SayHelloAsync(global::GRPCDemo.HelloRequest request, CallOptions options)
77 | {
78 | return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request);
79 | }
80 | protected override gRPCClient NewInstance(ClientBaseConfiguration configuration)
81 | {
82 | return new gRPCClient(configuration);
83 | }
84 | }
85 |
86 | /// Creates service definition that can be registered with a server
87 | public static ServerServiceDefinition BindService(gRPCBase serviceImpl)
88 | {
89 | return ServerServiceDefinition.CreateBuilder()
90 | .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
91 | }
92 |
93 | }
94 | }
95 | #endregion
96 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCDemo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("gRPCDemo")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("gRPCDemo")]
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("c391be7d-7209-4dd8-bc30-be70a460ec08")]
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 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCDemo/gRPCDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C391BE7D-7209-4DD8-BC30-BE70A460EC08}
8 | Library
9 | Properties
10 | gRPCDemo
11 | gRPCDemo
12 | v4.5.2
13 | 512
14 |
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll
37 | True
38 |
39 |
40 | ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll
41 | True
42 |
43 |
44 |
45 |
46 | ..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll
47 | True
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
70 |
71 |
72 |
73 |
80 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCDemo/helloworld.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package gRPCDemo;
3 | service gRPC {
4 | rpc SayHello (HelloRequest) returns (HelloReply) {}
5 | }
6 |
7 | message HelloRequest {
8 | string name = 1;
9 | }
10 |
11 | message HelloReply {
12 | string message = 1;
13 | }
--------------------------------------------------------------------------------
/gRPCDemo/gRPCDemo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCServer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCServer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using GRPCDemo;
7 | using Grpc.Core;
8 |
9 | namespace gRPCServer
10 | {
11 | class gRPCImpl : gRPC.gRPCBase
12 | {
13 | // 实现SayHello方法
14 | public override Task SayHello(HelloRequest request, ServerCallContext context)
15 | {
16 | return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
17 | }
18 | }
19 |
20 | class Program
21 | {
22 | const int Port = 9007;
23 |
24 | public static void Main(string[] args)
25 | {
26 | Server server = new Server
27 | {
28 | Services = { gRPC.BindService(new gRPCImpl()) },
29 | Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
30 | };
31 | server.Start();
32 |
33 | Console.WriteLine("gRPC server listening on port " + Port);
34 | Console.WriteLine("任意键退出...");
35 | Console.ReadKey();
36 |
37 | server.ShutdownAsync().Wait();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("gRPCServer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("gRPCServer")]
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("5302edbc-7de0-431b-a77f-5254c9e50f95")]
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 |
--------------------------------------------------------------------------------
/gRPCDemo/gRPCServer/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gRPCDemo/generate.txt:
--------------------------------------------------------------------------------
1 | packages\Grpc.Tools.1.0.0\tools\windows_x86\protoc.exe -IgRPCDemo --csharp_out gRPCDemo gRPCDemo\helloworld.proto --grpc_out gRPCDemo --plugin=protoc-gen-grpc=packages\Grpc.Tools.1.0.0\tools\windows_x86\grpc_csharp_plugin.exe
2 |
3 |
--------------------------------------------------------------------------------