diff --git a/Docs/assets/images/shared.001.jpg b/Docs/assets/images/shared.001.jpg new file mode 100644 index 0000000..729a041 Binary files /dev/null and b/Docs/assets/images/shared.001.jpg differ diff --git a/Docs/多语言笔记.4.1.使用WebApi.ipynb b/Docs/多语言笔记.4.1.使用WebApi.ipynb index 5b2c352..d1a3c74 100644 --- a/Docs/多语言笔记.4.1.使用WebApi.ipynb +++ b/Docs/多语言笔记.4.1.使用WebApi.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -27,7 +27,26 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
Restore sources
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Loading extension script from `C:\\Users\\ruyu\\.nuget\\packages\\microsoft.dotnet.interactive.aspnetcore\\1.0.0-beta.24229.4\\interactive-extensions\\dotnet\\extension.dib`" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "// 可以先添加包源\n", "#i \"https://api.nuget.org/v3/index.json\"\n", @@ -46,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -55,7 +74,85 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "

Request


GET http://127.0.0.1:4230/ HTTP/1.1

Headers
NameValue
traceparent00-9f30dd383da7da9695452942910e5eeb-9074df5bcf652253-00
Body (0 bytes)

Response


HTTP/1.1 200 OK ( ms)

Headers
NameValue
DateSun, 05 May 2024 16:42:55 GMT
ServerKestrel
Transfer-Encodingchunked
Content-Length18
Body (18 bytes)Hello from MapGet!
" + ], + "text/plain": [ + "Request Method: GET\r\n", + "Request URI: http://127.0.0.1:4230/\r\n", + "Request Version: HTTP/1.1\r\n", + "\r\n", + "Status Code: 200 OK\r\n", + "Elapsed: ms\r\n", + "Version: HTTP/1.1\r\n", + "Content Type: \r\n", + "Content Length: 18 bytes\r\n", + "\r\n", + "Date: Sun, 05 May 2024 16:42:55 GMT\r\n", + "Server: Kestrel\r\n", + "Transfer-Encoding: chunked\r\n", + "Content-Length: 18\r\n", + "Body: Hello from MapGet!\r\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!aspnet\n", "\n", @@ -185,7 +282,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -194,7 +291,83 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "

Request


GET http://127.0.0.1:4230/ HTTP/1.1

Headers
NameValue
traceparent00-9f30dd383da7da9695452942910e5eeb-f3d20b96fdaaa199-00
Body (0 bytes)

Response


HTTP/1.1 500 Internal Server Error ( ms)

Headers
NameValue
DateSun, 05 May 2024 16:43:07 GMT
ServerKestrel
Content-Length0
Body (0 bytes)
" + ], + "text/plain": [ + "Request Method: GET\r\n", + "Request URI: http://127.0.0.1:4230/\r\n", + "Request Version: HTTP/1.1\r\n", + "\r\n", + "Status Code: 500 Internal Server Error\r\n", + "Elapsed: ms\r\n", + "Version: HTTP/1.1\r\n", + "Content Type: \r\n", + "Content Length: 0 bytes\r\n", + "\r\n", + "Date: Sun, 05 May 2024 16:43:07 GMT\r\n", + "Server: Kestrel\r\n", + "Content-Length: 0\r\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!aspnet\n", "\n", @@ -208,7 +381,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -217,7 +390,83 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "

Request


GET http://127.0.0.1:4230/ HTTP/1.1

Headers
NameValue
traceparent00-9f30dd383da7da9695452942910e5eeb-a79a9b38cdb6229a-00
Body (0 bytes)

Response


HTTP/1.1 500 Internal Server Error ( ms)

Headers
NameValue
DateSun, 05 May 2024 16:43:27 GMT
ServerKestrel
Content-Length0
Body (0 bytes)
" + ], + "text/plain": [ + "Request Method: GET\r\n", + "Request URI: http://127.0.0.1:4230/\r\n", + "Request Version: HTTP/1.1\r\n", + "\r\n", + "Status Code: 500 Internal Server Error\r\n", + "Elapsed: ms\r\n", + "Version: HTTP/1.1\r\n", + "Content Type: \r\n", + "Content Length: 0 bytes\r\n", + "\r\n", + "Date: Sun, 05 May 2024 16:43:27 GMT\r\n", + "Server: Kestrel\r\n", + "Content-Length: 0\r\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!aspnet\n", "Endpoints.MapGet(\"/\", async context =>\n", @@ -230,7 +479,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -239,7 +488,48 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
http://127.0.0.1:4230/
AbsolutePath
/
AbsoluteUri
http://127.0.0.1:4230/
LocalPath
/
Authority
127.0.0.1:4230
HostNameTypeIPv4
IsDefaultPort
False
IsFile
False
IsLoopback
True
PathAndQuery
/
Segments
[ / ]
IsUnc
False
Host
127.0.0.1
Port
4230
Query
Fragment
Scheme
http
OriginalString
http://127.0.0.1:4230
DnsSafeHost
127.0.0.1
IdnHost
127.0.0.1
IsAbsoluteUri
True
UserEscaped
False
UserInfo
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!aspnet\n", "\n", @@ -248,7 +538,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -257,7 +547,53 @@ "kernelName": "csharp" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
Microsoft.AspNetCore.Builder.ApplicationBuilder
ApplicationServices
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScopeTrue
ServiceProviderMicrosoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
ServerFeatures
[ [Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature] ]
Revision
1
IsReadOnly
False
(values)
indexvalue
0
[Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature]
KeyMicrosoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature
Value
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature
InternalCollection
[ http://127.0.0.1:4230 ]
PublicCollection
[ http://127.0.0.1:4230 ]
IsReadOnly
False
Count
1
(values)
[ http://127.0.0.1:4230 ]
PreferHostingUrls
False
Properties
keytypevalue
application.Services
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScopeTrue
ServiceProviderMicrosoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
server.Features
Microsoft.AspNetCore.Http.Features.FeatureCollection
[ [Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature] ]
Revision
1
IsReadOnly
False
(values)
indexvalue
0
[Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature]
KeyMicrosoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature
Value
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature
InternalCollection
[ http://127.0.0.1:4230 ]
PublicCollection[ http://127.0.0.1:4230 ]
IsReadOnlyFalse
Count1
(values)
[ http://127.0.0.1:4230 ]
PreferHostingUrls
False
__EndpointRouteBuilder
Microsoft.AspNetCore.Routing.DefaultEndpointRouteBuilder
Microsoft.AspNetCore.Routing.DefaultEndpointRouteBuilder
ApplicationBuilder
Microsoft.AspNetCore.Builder.ApplicationBuilder
ApplicationServices
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScopeTrue
ServiceProviderMicrosoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
ServerFeatures
[ [Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature] ]
Revision
1
IsReadOnly
False
(values)
indexvalue
0
[Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature]
KeyMicrosoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature
ValueMicrosoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature
Properties
keytypevalue
application.Services
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScopeTrue
ServiceProviderMicrosoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
server.Features
Microsoft.AspNetCore.Http.Features.FeatureCollection
[ [Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature] ]
Revision1
IsReadOnlyFalse
(values)
indexvalue
0[Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.ServerAddressesFeature]
__EndpointRouteBuilder
Microsoft.AspNetCore.Routing.DefaultEndpointRouteBuilder
Microsoft.AspNetCore.Routing.DefaultEndpointRouteBuilder
ApplicationBuilderMicrosoft.AspNetCore.Builder.ApplicationBuilder
DataSources[ Microsoft.AspNetCore.Routing.RouteEndpointDataSource ]
ServiceProviderMicrosoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
__UseRouting
System.Func<Microsoft.AspNetCore.Builder.IApplicationBuilder,Microsoft.AspNetCore.Builder.IApplicationBuilder>
System.Func`2[Microsoft.AspNetCore.Builder.IApplicationBuilder,Microsoft.AspNetCore.Builder.IApplicationBuilder]
Target
<null>
MethodMicrosoft.AspNetCore.Builder.IApplicationBuilder UseRouting(Microsoft.AspNetCore.Builder.IApplicationBuilder)
DataSources
indexvalue
0
Microsoft.AspNetCore.Routing.RouteEndpointDataSource
Endpoints
Microsoft.AspNetCore.Routing.RouteEndpointDataSource
Endpoints
Microsoft.AspNetCore.Routing.RouteEndpointDataSource
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScope
True
ServiceProvider
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
IsRootScopeTrue
ServiceProviderMicrosoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
__UseRouting
System.Func<Microsoft.AspNetCore.Builder.IApplicationBuilder,Microsoft.AspNetCore.Builder.IApplicationBuilder>
System.Func`2[Microsoft.AspNetCore.Builder.IApplicationBuilder,Microsoft.AspNetCore.Builder.IApplicationBuilder]
Target
<null>
Method
Microsoft.AspNetCore.Builder.IApplicationBuilder UseRouting(Microsoft.AspNetCore.Builder.IApplicationBuilder)
Name
UseRouting
DeclaringTypeMicrosoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions
ReflectedTypeMicrosoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions
MemberTypeMethod
MetadataToken
100663382
Module
Microsoft.AspNetCore.Routing.dll
MDStreamVersion
131072
FullyQualifiedName
C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\8.0.4\\Microsoft.AspNetCore.Routing.dll
ModuleVersionId
6c078444-7365-4d36-a723-507bbed36e5f
MetadataToken
1
ScopeName
Microsoft.AspNetCore.Routing.dll
Name
Microsoft.AspNetCore.Routing.dll
Assembly
Microsoft.AspNetCore.Routing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
CodeBasefile:///C:/Program Files/dotnet/shared/Microsoft.AspNetCore.App/8.0.4/Microsoft.AspNetCore.Routing.dll
FullNameMicrosoft.AspNetCore.Routing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
EntryPoint
<null>
DefinedTypes[ HttpExtensions, System.Text.RegularExpressions.Generated.F74B1AE921BCEFE4BA601AA541C7A23B1CA9711EA81E8FE504B5B6446748E035A__GetAlphaRouteRegex_0, System.Text.RegularExpressions.Generated.F74B1AE921BCEFE4BA601AA541C7A23B1CA9711EA81E8FE504B5B6446748E035A__Utilities, System.Runtime.CompilerServices.TypeHelper, Microsoft.Net.Http.Headers.HttpRuleParser, Microsoft.Net.Http.Headers.HttpParseResult, Microsoft.Extensions.Internal.PropertyHelper, Microsoft.Extensions.DependencyInjection.ConfigureRouteOptions, Microsoft.Extensions.DependencyInjection.RoutingServiceCollectionExtensions, Microsoft.Extensions.DependencyInjection.RegexInlineRouteConstraintSetup, Microsoft.AspNetCore.Shared.DebuggerHelpers, Microsoft.AspNetCore.Internal.ExecuteHandlerHelper, Microsoft.AspNetCore.Internal.RouteValueDictionaryTrimmerWarning, Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions, Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions, Microsoft.AspNetCore.Builder.FallbackEndpointRouteBuilderExtensions, Microsoft.AspNetCore.Builder.RouteHandlerBuilder, Microsoft.AspNetCore.Builder.RoutingBuilderExtensions, Microsoft.AspNetCore.Builder.RoutingEndpointConventionBuilderExtensions, Microsoft.AspNetCore.Builder.MapRouteRouteBuilderExtensions ... (341 more) ]
IsCollectibleFalse
ManifestModuleMicrosoft.AspNetCore.Routing.dll
ReflectionOnlyFalse
LocationC:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\8.0.4\\Microsoft.AspNetCore.Routing.dll
ImageRuntimeVersionv4.0.30319
GlobalAssemblyCacheFalse
HostContext0
IsDynamicFalse
ExportedTypes[ Microsoft.Extensions.DependencyInjection.RoutingServiceCollectionExtensions, Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions, Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions, Microsoft.AspNetCore.Builder.FallbackEndpointRouteBuilderExtensions, Microsoft.AspNetCore.Builder.RouteHandlerBuilder, Microsoft.AspNetCore.Builder.RoutingBuilderExtensions, Microsoft.AspNetCore.Builder.RoutingEndpointConventionBuilderExtensions, Microsoft.AspNetCore.Builder.MapRouteRouteBuilderExtensions, Microsoft.AspNetCore.Builder.RouterMiddleware, Microsoft.AspNetCore.Builder.RouteShortCircuitEndpointConventionBuilderExtensions, Microsoft.AspNetCore.Http.EndpointFilterExtensions, Microsoft.AspNetCore.Http.OpenApiRouteHandlerBuilderExtensions, Microsoft.AspNetCore.Routing.RouteHandlerServices, Microsoft.AspNetCore.Routing.CompositeEndpointDataSource, Microsoft.AspNetCore.Routing.DataTokensMetadata, Microsoft.AspNetCore.Routing.DefaultEndpointDataSource, Microsoft.AspNetCore.Routing.DefaultInlineConstraintResolver, Microsoft.AspNetCore.Routing.EndpointDataSource, Microsoft.AspNetCore.Routing.EndpointGroupNameAttribute, Microsoft.AspNetCore.Routing.EndpointNameAttribute ... (118 more) ]
IsFullyTrustedTrue
CustomAttributes[ [System.Runtime.CompilerServices.ExtensionAttribute()], [System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)], [System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)], [System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute+DebuggingModes)2)], [System.Reflection.Metadata.MetadataUpdateHandlerAttribute(typeof(Microsoft.Extensions.Internal.PropertyHelper+MetadataUpdateHandler))], [System.Runtime.Versioning.TargetFrameworkAttribute(\".NETCoreApp,Version=v8.0\", FrameworkDisplayName = \".NET 8.0\")], [System.Runtime.CompilerServices.InternalsVisibleToAttribute(\"Microsoft.AspNetCore.OpenApi.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb\")], [System.Runtime.CompilerServices.InternalsVisibleToAttribute(\"Microsoft.AspNetCore.Routing.Microbenchmarks, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb\")], [System.Runtime.CompilerServices.InternalsVisibleToAttribute(\"Microsoft.AspNetCore.Routing.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb\")], [System.Runtime.CompilerServices.InternalsVisibleToAttribute(\"Microsoft.AspNetCore.Mvc.ApiExplorer.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb\")], [System.Runtime.CompilerServices.InternalsVisibleToAttribute(\"DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7\")], [System.Runtime.CompilerServices.InternalsVisibleToAttribute(\"Microsoft.AspNetCore.Mvc.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb\")], [System.Reflection.AssemblyMetadataAttribute(\"IsTrimmable\", \"True\")], [System.Reflection.AssemblyMetadataAttribute(\"CommitHash\", \"8486d31e24f30e3fa1809a95699a0adc16f448d7\")], [System.Reflection.AssemblyMetadataAttribute(\"SourceCommitUrl\", \"https://github.com/dotnet/aspnetcore/tree/8486d31e24f30e3fa1809a95699a0adc16f448d7\")], [System.Reflection.AssemblyMetadataAttribute(\"Serviceable\", \"True\")], [System.Reflection.AssemblyCompanyAttribute(\"Microsoft Corporation\")], [System.Reflection.AssemblyConfigurationAttribute(\"Release\")], [System.Reflection.AssemblyCopyrightAttribute(\"© Microsoft Corporation. All rights reserved.\")], [System.Reflection.AssemblyDescriptionAttribute(\"\r\n", + " ASP.NET Core middleware for routing requests to application logic and for generating links.\r\n", + " Commonly used types:\r\n", + " Microsoft.AspNetCore.Routing.Route\r\n", + " Microsoft.AspNetCore.Routing.RouteCollection\r\n", + " \")] ... (6 more) ]
EscapedCodeBasefile:///C:/Program%20Files/dotnet/shared/Microsoft.AspNetCore.App/8.0.4/Microsoft.AspNetCore.Routing.dll
Modules[ Microsoft.AspNetCore.Routing.dll ]
SecurityRuleSetNone
ModuleHandle
System.ModuleHandle
MDStreamVersion131072
CustomAttributes
indexvalue
0[System.Security.UnverifiableCodeAttribute()]
1[System.Runtime.CompilerServices.RefSafetyRulesAttribute((Int32)11)]
2[System.Runtime.CompilerServices.NullablePublicOnlyAttribute((Boolean)True)]
IsSecurityCritical
True
IsSecuritySafeCritical
False
IsSecurityTransparent
False
MethodHandle
System.RuntimeMethodHandle
Value
140713067293856
AttributesPublic, Static, HideBySig
CallingConventionStandard
ReturnTypeMicrosoft.AspNetCore.Builder.IApplicationBuilder
ReturnTypeCustomAttributes
Microsoft.AspNetCore.Builder.IApplicationBuilder
ParameterTypeMicrosoft.AspNetCore.Builder.IApplicationBuilder
Name
<null>
HasDefaultValue
False
DefaultValue
RawDefaultValue
MetadataToken
134217728
AttributesNone
Member
Microsoft.AspNetCore.Builder.IApplicationBuilder UseRouting(Microsoft.AspNetCore.Builder.IApplicationBuilder)
NameUseRouting
DeclaringTypeMicrosoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions
ReflectedTypeMicrosoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions
MemberTypeMethod
MetadataToken100663382
ModuleMicrosoft.AspNetCore.Routing.dll
IsSecurityCriticalTrue
IsSecuritySafeCriticalFalse
IsSecurityTransparentFalse
MethodHandleSystem.RuntimeMethodHandle
AttributesPublic, Static, HideBySig
CallingConventionStandard
ReturnTypeMicrosoft.AspNetCore.Builder.IApplicationBuilder
ReturnTypeCustomAttributesMicrosoft.AspNetCore.Builder.IApplicationBuilder
ReturnParameterMicrosoft.AspNetCore.Builder.IApplicationBuilder
IsCollectibleFalse
IsGenericMethodFalse
IsGenericMethodDefinitionFalse
ContainsGenericParametersFalse
MethodImplementationFlagsIL
IsAbstractFalse
IsConstructorFalse
IsFinalFalse
IsHideBySigTrue
IsSpecialNameFalse
IsStaticTrue
IsVirtualFalse
IsAssemblyFalse
IsFamilyFalse
IsFamilyAndAssemblyFalse
IsFamilyOrAssemblyFalse
IsPrivateFalse
IsPublicTrue
IsConstructedGenericMethodFalse
CustomAttributes[ [System.Runtime.CompilerServices.ExtensionAttribute()] ]
Position
-1
IsIn
False
IsLcid
False
IsOptional
False
IsOut
False
IsRetval
False
CustomAttributes(empty)
ReturnParameter
Microsoft.AspNetCore.Builder.IApplicationBuilder
ParameterTypeMicrosoft.AspNetCore.Builder.IApplicationBuilder
Name
<null>
HasDefaultValue
False
DefaultValue
RawDefaultValue
MetadataToken
134217728
AttributesNone
Member
Microsoft.AspNetCore.Builder.IApplicationBuilder UseRouting(Microsoft.AspNetCore.Builder.IApplicationBuilder)
NameUseRouting
DeclaringTypeMicrosoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions
ReflectedTypeMicrosoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions
MemberTypeMethod
MetadataToken100663382
ModuleMicrosoft.AspNetCore.Routing.dll
IsSecurityCriticalTrue
IsSecuritySafeCriticalFalse
IsSecurityTransparentFalse
MethodHandleSystem.RuntimeMethodHandle
AttributesPublic, Static, HideBySig
CallingConventionStandard
ReturnTypeMicrosoft.AspNetCore.Builder.IApplicationBuilder
ReturnTypeCustomAttributesMicrosoft.AspNetCore.Builder.IApplicationBuilder
ReturnParameterMicrosoft.AspNetCore.Builder.IApplicationBuilder
IsCollectibleFalse
IsGenericMethodFalse
IsGenericMethodDefinitionFalse
ContainsGenericParametersFalse
MethodImplementationFlagsIL
IsAbstractFalse
IsConstructorFalse
IsFinalFalse
IsHideBySigTrue
IsSpecialNameFalse
IsStaticTrue
IsVirtualFalse
IsAssemblyFalse
IsFamilyFalse
IsFamilyAndAssemblyFalse
IsFamilyOrAssemblyFalse
IsPrivateFalse
IsPublicTrue
IsConstructedGenericMethodFalse
CustomAttributes[ [System.Runtime.CompilerServices.ExtensionAttribute()] ]
Position
-1
IsIn
False
IsLcid
False
IsOptional
False
IsOut
False
IsRetval
False
CustomAttributes(empty)
IsCollectible
False
IsGenericMethod
False
IsGenericMethodDefinition
False
ContainsGenericParameters
False
MethodImplementationFlagsIL
IsAbstract
False
IsConstructor
False
IsFinal
False
IsHideBySig
True
IsSpecialName
False
IsStatic
True
IsVirtual
False
IsAssembly
False
IsFamily
False
IsFamilyAndAssembly
False
IsFamilyOrAssembly
False
IsPrivate
False
IsPublic
True
IsConstructedGenericMethod
False
CustomAttributes
indexvalue
0
[System.Runtime.CompilerServices.ExtensionAttribute()]
ConstructorVoid .ctor()
ConstructorArguments[ ]
NamedArguments[ ]
AttributeTypeSystem.Runtime.CompilerServices.ExtensionAttribute
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "#!aspnet\n", "\n", diff --git a/Docs/多语言笔记.6.1.共享变量.ipynb b/Docs/多语言笔记.6.1.共享变量.ipynb index 245a83f..e0a7c70 100644 --- a/Docs/多语言笔记.6.1.共享变量.ipynb +++ b/Docs/多语言笔记.6.1.共享变量.ipynb @@ -5,15 +5,78 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 共享变量的使用" + "# 变量共享" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "使用 .NET 交互式内核,可以在单个笔记本中以多种语言编写代码。为了利用每种语言的不同优势,您会发现在它们之间共享数据很有用。即一种语言的变量,可以在其它语言中使用。\n", + "默认情况下,.NET Interactive 支持多种不同的语言,其中大多数语言都允许使用magic 命令`#!set` 和 `#!shared` 进行共享。" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 各语言对变量共享的支持" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "| 语言 | 变量共享 |\n", + "| ---- | ---- |\n", + "| C# | 支持 |\n", + "| F# | 支持 |\n", + "| PowerShell | 支持 |\n", + "| JavaScript | 支持 |\n", + "| SQL | 支持 |\n", + "| KQL | 支持 |\n", + "| Python | 支持 |\n", + "| R | 支持 |\n", + "| HTML | 不支持 |\n", + "| Mermaid | 不支持 |" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 查看、管理全部变量方法" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![变量共享](./assets/images/shared.001.jpg)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 简单示例:C# 运行中的变量,被其它语言共享。" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "//定义变量:存储网关\n", + "string getway = \"192.168.1.1\";" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "## 全局设置" + "## PowerShell 中使用" ] }, { @@ -21,21 +84,69 @@ "execution_count": null, "metadata": { "dotnet_interactive": { - "language": "csharp" + "language": "pwsh" }, "polyglot_notebook": { - "kernelName": "csharp" + "kernelName": "pwsh" } }, "outputs": [], "source": [ - "// 默认包源\n", - "#i \"https://api.nuget.org/v3/index.json\"\n", + "# Poweshell中使用 前面C#单元中定义的变量\n", + "# 特别注意:因为PS中变量名必须以$开头,所以在命令中 name 参数名,在PS中使用时必须加$前辍\n", "\n", - "//Nuget 包引用\n", - "#r \"nuget: Microsoft.DotNet.Interactive.ExtensionLab,*-*\"\n", + "#!set --value @csharp:getway --name gw\n", + "\n", + "Write-Host $gw\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## F# 中使用" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "fsharp" + }, + "polyglot_notebook": { + "kernelName": "fsharp" + } + }, + "outputs": [], + "source": [ + "#!set --value @csharp:getway --name getway\n", "\n", - "//全局变量" + "Console.WriteLine(getway)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 在javascrip中使用" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "dotnet_interactive": { + "language": "javascript" + }, + "polyglot_notebook": { + "kernelName": "javascript" + } + }, + "outputs": [], + "source": [ + "#!set --value @csharp:getway --name getway\n", + "console.log(getway);\n" ] } ],