├── logo.png
├── UnitAspExample
├── Views
│ ├── _ViewStart.cshtml
│ ├── _ViewImports.cshtml
│ ├── Home
│ │ ├── Privacy.cshtml
│ │ └── Index.cshtml
│ └── Shared
│ │ ├── _ValidationScriptsPartial.cshtml
│ │ ├── Error.cshtml
│ │ └── _Layout.cshtml
├── Startup.cs
├── wwwroot
│ ├── favicon.ico
│ ├── js
│ │ └── site.js
│ ├── lib
│ │ ├── jquery-validation-unobtrusive
│ │ │ └── LICENSE.txt
│ │ ├── jquery-validation
│ │ │ └── LICENSE.md
│ │ ├── bootstrap
│ │ │ └── LICENSE
│ │ └── jquery
│ │ │ └── LICENSE.txt
│ └── css
│ │ └── site.css
├── appsettings.Development.json
├── appsettings.json
├── Models
│ ├── ErrorViewModel.cs
│ └── Test.cs
├── UnitAspExample.csproj
├── Program.cs
├── Properties
│ └── launchSettings.json
└── Controllers
│ ├── HomeController.cs
│ ├── TestController.cs
│ └── UserController.cs
├── .gitignore
├── NUnitBigCookieKit
├── UnitKit.cs
├── Resources
│ ├── test.xlsx
│ ├── test2.xlsx
│ ├── testEmpty.xlsx
│ └── BoyerMooreUnit.txt
├── UnitReflect.cs
├── UnitBigExport.cs
└── NUnitBigCookieKit.csproj
├── UnitBenchmark
├── Resources
│ ├── test.xlsx
│ ├── test2.xlsx
│ ├── testEmpty.xlsx
│ └── BoyerMooreUnit.txt
├── Program.cs
├── UnitBenchmark.csproj
├── ExcelReadBenchmark.cs
└── BoyerMooreBenchmark.cs
├── BigCookie.Document
├── wwwroot
│ ├── JDialog
│ │ └── css
│ │ │ ├── gb_tips.png
│ │ │ ├── loader.gif
│ │ │ ├── loader1.gif
│ │ │ ├── bg-default.png
│ │ │ ├── gb_tip_loading.gif
│ │ │ └── jdialog_confirm_icon_espresso.png
│ └── document-ui.css
├── UriInfo.cs
├── DocumentConfigureOptions.cs
├── DocumentExtension.cs
└── BigCookie.Document.csproj
├── BigCookieKit
├── Resources
│ ├── xlsx
│ │ ├── workbook.xml.rels
│ │ ├── .rels
│ │ ├── workbook.xml
│ │ ├── sharedStrings.xml
│ │ ├── [Content_Types].xml
│ │ └── styles.xml
│ └── Common.cs
├── XML
│ ├── PacketState.cs
│ ├── XmlAttribute.cs
│ ├── XmlInfo.cs
│ ├── XmlPacket.cs
│ └── CookieTable.cs
├── Algorithm
│ ├── BTree.cs
│ ├── AVLTree.cs
│ ├── BStarTree.cs
│ ├── BinaryTree.cs
│ ├── BPlusTree
│ │ ├── IPromotionListener.cs
│ │ ├── NullBTreeNodeElement.cs
│ │ ├── BTree.cs
│ │ ├── BTreeNodeElementInterstice.cs
│ │ └── BTreeNodeElement.cs
│ ├── BinarySearchTree.cs
│ └── LZW.cs
├── FTP
│ ├── SftpClient.cs
│ └── FtpClient.cs
├── Kit.Template.cs
├── Kit.SIMD.cs
├── Serialization
│ ├── ISerializer.cs
│ └── BasicSerializer.cs
├── Attributes
│ ├── RequiredRuleAttribute.cs
│ ├── DisplayAttribute.cs
│ ├── DecimalRuleAttribute.cs
│ ├── BasicAttribute.cs
│ ├── StringRuleAttribute.cs
│ └── NumericRuleAttribute.cs
├── DbValueFormat.cs
├── Kit.Double.cs
├── Kit.Compress.cs
└── Kit.Enum.cs
├── UnitConsole
├── Properties
│ └── launchSettings.json
├── BytesIndexOf.cs
├── UnitConsole.csproj
├── BenchmarkExcelRead.cs
├── BPlusTreeTest.cs
└── Program.cs
├── BigCookieKit.Distributed
└── BigCookieKit.Distributed.csproj
├── BigCookieKit.Serialization
├── BigCookieKit.Serialization.csproj
└── Binary
│ ├── FormatterBase.cs
│ ├── DateTimeFormatter.cs
│ ├── GeneralFormatter.cs
│ └── Binary.cs
├── BigCookieKit.Reflect
├── FieldByte.cs
├── FieldFloat.cs
├── FieldInt16.cs
├── FieldInt32.cs
├── FieldInt64.cs
├── FieldDouble.cs
├── FieldDecimal.cs
├── TabManager.cs
├── VariableManager.cs
├── MethodManager.cs
├── CacheManager.cs
├── TryCatchManager.cs
├── OperatorCode.cs
├── CtorStroke.cs
├── FastDynamic.cs
├── GenericParameterStroke.cs
├── GenericStroke.cs
├── FieldDateTime.cs
├── ListManager.cs
├── PropertyStroke.cs
├── MethodStroke.cs
├── ClassStroke.cs
├── FieldNullable.cs
├── AssertManager.cs
├── FieldString.cs
├── FastExtend.cs
└── FieldBoolean.cs
├── BigCookieKit.Network
├── IPipe.cs
├── ApplyMode.cs
├── NetworkProtocol.cs
├── HttpHandle.cs
├── MessageMode.cs
├── NoneHandle.cs
├── Pipeline.cs
├── XSocketAsyncEventArgs.cs
├── XSocket.cs
├── Handle.cs
├── ICilent.cs
├── HandleTools.cs
├── BigCookieKit.Network.csproj
├── IServer.cs
├── Buffer.cs
└── Network.cs
├── BigCookieKit.AspCore
├── RouteSelector
│ ├── EndpointSelector.cs
│ ├── JumpTable.cs
│ ├── Matcher.cs
│ ├── IEndpointSelectorPolicy.cs
│ ├── NullRouter.cs
│ ├── CandidateState.cs
│ ├── ZeroEntryJumpTable.cs
│ ├── DfaState.cs
│ ├── PathSegment.cs
│ ├── FastPathTokenizerHelpers.cs
│ ├── SingleEntryAsciiJumpTable.cs
│ ├── SingleEntryJumpTable.cs
│ ├── Ascii.cs
│ ├── DictionaryJumpTable.cs
│ ├── LinearSearchJumpTable.cs
│ ├── JumpTableBuilder.cs
│ └── DefaultParameterPolicyFactory.cs
├── DependencyInjection
│ ├── AutoInjectionAttribute.cs
│ └── AutoDependencyInjection.cs
├── Standard
│ ├── ApiPager.cs
│ ├── ApiPermission.cs
│ └── ApiPermissionPager.cs
├── EntityFramework
│ ├── UpdateModel.cs
│ ├── QueryFunc.cs
│ ├── DbModel.cs
│ ├── QueryMeta.cs
│ ├── JoinSelect.cs
│ └── EntityFrameworkKit.cs
├── ConcurrencyLimiter
│ ├── ConcurrencyLimiterOption.cs
│ └── ActionLimter.cs
├── Apm
│ ├── ApmEntityFrameworkLoggerProvider.cs
│ ├── ApmDbContext.cs
│ ├── ApmLoggerFilter.cs
│ └── ApmEntityFrameworkLogger.cs
└── BigCookieKit.AspCore.csproj
├── TcpClientExmaple
├── TcpClientExmaple.csproj
└── Program.cs
├── TcpServerExmaple
├── TcpServerExmaple.csproj
└── Program.cs
├── BigCookieKit.Office
├── Xlsx
│ ├── WorkBook.cs
│ ├── XlsxRowConfigException.cs
│ ├── MapRow.cs
│ ├── ColumnNormal.cs
│ ├── ColumnConfig.cs
│ ├── ExcelHelper.cs
│ └── ExcelConfig.cs
└── BigCookieKit.Office.csproj
├── BigCookieKit.Rpc
└── BigCookieKit.Rpc.csproj
├── BigCookieSequelize
└── BigCookieSequelize.csproj
└── LICENSE
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/logo.png
--------------------------------------------------------------------------------
/UnitAspExample/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "_Layout";
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | */bin/*
2 | */obj/*
3 |
4 | .vs/*
5 |
6 | */*.user
7 |
8 | Nuget/*.nupkg
--------------------------------------------------------------------------------
/UnitAspExample/Startup.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/UnitAspExample/Startup.cs
--------------------------------------------------------------------------------
/NUnitBigCookieKit/UnitKit.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/NUnitBigCookieKit/UnitKit.cs
--------------------------------------------------------------------------------
/UnitBenchmark/Resources/test.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/UnitBenchmark/Resources/test.xlsx
--------------------------------------------------------------------------------
/UnitAspExample/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/UnitAspExample/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/UnitBenchmark/Resources/test2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/UnitBenchmark/Resources/test2.xlsx
--------------------------------------------------------------------------------
/NUnitBigCookieKit/Resources/test.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/NUnitBigCookieKit/Resources/test.xlsx
--------------------------------------------------------------------------------
/NUnitBigCookieKit/Resources/test2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/NUnitBigCookieKit/Resources/test2.xlsx
--------------------------------------------------------------------------------
/UnitBenchmark/Resources/testEmpty.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/UnitBenchmark/Resources/testEmpty.xlsx
--------------------------------------------------------------------------------
/NUnitBigCookieKit/Resources/testEmpty.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/NUnitBigCookieKit/Resources/testEmpty.xlsx
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/JDialog/css/gb_tips.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/BigCookie.Document/wwwroot/JDialog/css/gb_tips.png
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/JDialog/css/loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/BigCookie.Document/wwwroot/JDialog/css/loader.gif
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/JDialog/css/loader1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/BigCookie.Document/wwwroot/JDialog/css/loader1.gif
--------------------------------------------------------------------------------
/UnitAspExample/Views/_ViewImports.cshtml:
--------------------------------------------------------------------------------
1 | @using UnitAspExample
2 | @using UnitAspExample.Models
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/JDialog/css/bg-default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/BigCookie.Document/wwwroot/JDialog/css/bg-default.png
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/JDialog/css/gb_tip_loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/BigCookie.Document/wwwroot/JDialog/css/gb_tip_loading.gif
--------------------------------------------------------------------------------
/BigCookieKit/Resources/xlsx/workbook.xml.rels:
--------------------------------------------------------------------------------
1 | {0}
--------------------------------------------------------------------------------
/UnitConsole/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "UnitConsole": {
4 | "commandName": "Project",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/BigCookieKit/XML/PacketState.cs:
--------------------------------------------------------------------------------
1 | namespace BigCookieKit.XML
2 | {
3 | public enum PacketState
4 | {
5 | None,
6 | Start,
7 | End
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/JDialog/css/jdialog_confirm_icon_espresso.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BigBigZBBing/BigCookieKit/HEAD/BigCookie.Document/wwwroot/JDialog/css/jdialog_confirm_icon_espresso.png
--------------------------------------------------------------------------------
/UnitAspExample/Views/Home/Privacy.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Privacy Policy";
3 | }
4 |
@ViewData["Title"]
5 |
6 | Use this page to detail your site's privacy policy.
7 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Algorithm
6 | {
7 | class BTree
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/AVLTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Algorithm
6 | {
7 | class AVLTree
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BStarTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Algorithm
6 | {
7 | class BStarTree
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/BigCookieKit/FTP/SftpClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.FTP
6 | {
7 | public class SftpClient
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/BigCookieKit/Kit.Template.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit
6 | {
7 | public static partial class Kit
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/BigCookieKit.Distributed/BigCookieKit.Distributed.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1;net5
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BinaryTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Algorithm
6 | {
7 | class BinaryTree
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/BigCookieKit.Serialization/BigCookieKit.Serialization.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net2;netstandard2.0
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/UnitAspExample/Views/Shared/_ValidationScriptsPartial.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BPlusTree/IPromotionListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BPlusTree
4 | {
5 | public interface IPromotionListener where T : class, IComparable
6 | {
7 | void RootIs(BTreeNode node);
8 | }
9 | }
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BinarySearchTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Algorithm
6 | {
7 | class BinarySearchTree
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/UnitAspExample/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/UnitAspExample/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/UnitAspExample/wwwroot/js/site.js:
--------------------------------------------------------------------------------
1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | // for details on configuring this project to bundle and minify static web assets.
3 |
4 | // Write your JavaScript code.
5 |
--------------------------------------------------------------------------------
/UnitAspExample/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Home Page";
3 | }
4 |
5 |
9 |
--------------------------------------------------------------------------------
/BigCookieKit/Kit.SIMD.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Linq;
5 | using System.Numerics;
6 | using System.IO;
7 |
8 | namespace BigCookieKit
9 | {
10 | public static partial class Kit
11 | {
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/BigCookieKit/Resources/xlsx/.rels:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/BigCookieKit/Resources/xlsx/workbook.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {0}
5 |
6 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BPlusTree/NullBTreeNodeElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BPlusTree
4 | {
5 | public class NullBTreeNodeElement : BTreeNodeElement where T : class, IComparable
6 | {
7 | public NullBTreeNodeElement() : base(null)
8 | {
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/BigCookieKit/Resources/xlsx/sharedStrings.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | 测试模板
6 |
7 |
8 |
--------------------------------------------------------------------------------
/UnitAspExample/Models/ErrorViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace UnitAspExample.Models
4 | {
5 | public class ErrorViewModel
6 | {
7 | public string RequestId { get; set; }
8 |
9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldByte.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldByte : CanCompute
7 | {
8 | internal FieldByte(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.Network/IPipe.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | public interface IPipe
10 | {
11 | Task InvokeAsync(Session session,Action context);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldFloat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldFloat : CanCompute
7 | {
8 | internal FieldFloat(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldInt16.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldInt16 : CanCompute
7 | {
8 | internal FieldInt16(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldInt32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldInt32 : CanCompute
7 | {
8 | internal FieldInt32(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldInt64.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldInt64 : CanCompute
7 | {
8 | internal FieldInt64(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldDouble.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldDouble : CanCompute
7 | {
8 | internal FieldDouble(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldDecimal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldDecimal : CanCompute
7 | {
8 | internal FieldDecimal(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/EndpointSelector.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 |
3 | using System.Threading.Tasks;
4 |
5 | namespace BigCookieKit.AspCore.RouteSelector
6 | {
7 | internal abstract class EndpointSelector
8 | {
9 | public abstract Task SelectAsync(HttpContext httpContext, CandidateSet candidates);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/UnitAspExample/Models/Test.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 |
7 | namespace UnitAspExample.Models
8 | {
9 | public class Test
10 | {
11 | [Required]
12 | public string Name { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/JumpTable.cs:
--------------------------------------------------------------------------------
1 | namespace BigCookieKit.AspCore.RouteSelector
2 | {
3 | internal abstract class JumpTable
4 | {
5 | public abstract int GetDestination(string path, PathSegment segment);
6 |
7 | public virtual string DebuggerToString()
8 | {
9 | return GetType().Name;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/TcpClientExmaple/TcpClientExmaple.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/TcpServerExmaple/TcpServerExmaple.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp5.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/ApplyMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | ///
10 | /// 应用方式
11 | ///
12 | public enum ApplyMode
13 | {
14 | Client,
15 | Server,
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/NetworkProtocol.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | public enum NetworkProtocol
10 | {
11 | None,
12 | Tcp,
13 | Udp,
14 | Http1,
15 | Http2
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/WorkBook.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Office.Xlsx
8 | {
9 | public class WorkBook
10 | {
11 | public int? SheetId { get; set; }
12 |
13 | public string SheetName { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/DependencyInjection/AutoInjectionAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.DependencyInjection
8 | {
9 | [AttributeUsage(AttributeTargets.Class)]
10 | public class AutoInjectionAttribute : Attribute
11 | {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Standard/ApiPager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.Standard
8 | {
9 | public abstract class ApiPager
10 | {
11 | public int PageIndex { get; set; }
12 |
13 | public int PageCount { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/Matcher.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 |
3 | using System.Threading.Tasks;
4 |
5 | namespace BigCookieKit.AspCore.RouteSelector
6 | {
7 | internal abstract class Matcher
8 | {
9 | public abstract Task MatchAsync(HttpContext httpContext);
10 |
11 | public abstract Task SelectorAsync(string path, string httpMethod = "GET");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/BigCookieKit/FTP/FtpClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net;
4 | using System.Text;
5 |
6 | namespace BigCookieKit.FTP
7 | {
8 | public class FtpClient
9 | {
10 | ///
11 | /// 是否开启SSL
12 | ///
13 | public bool Ssl = false;
14 |
15 | public FtpClient()
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BigCookieKit.Serialization/Binary/FormatterBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Serialization.Binary
6 | {
7 | public interface FormatterBase
8 | {
9 | Binary Host { get; set; }
10 |
11 | int Priority { get; set; }
12 |
13 | bool Write(object value);
14 |
15 | object Read(Type type);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/BigCookieKit/XML/XmlAttribute.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace BigCookieKit.XML
4 | {
5 | ///
6 | /// XML标签的属性
7 | ///
8 | /// **用结构体来降低堆的利用
9 | ///
10 | ///
11 | [StructLayout(LayoutKind.Auto)]
12 | public struct XmlAttribute
13 | {
14 | public string Name;
15 |
16 | public string Text;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/BigCookieKit.Rpc/BigCookieKit.Rpc.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1;net5
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/XlsxRowConfigException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Office.Xlsx
6 | {
7 | class XlsxRowConfigException : Exception
8 | {
9 | public XlsxRowConfigException()
10 | {
11 | }
12 |
13 | public XlsxRowConfigException(string message) : base(message)
14 | {
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/BigCookieKit/Serialization/ISerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Serialization
9 | {
10 | public class ISerializer
11 | {
12 | public Stream stream { get; set; }
13 |
14 | public void WriteLength(int length)
15 | {
16 |
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/IEndpointSelectorPolicy.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 |
3 | using System.Collections.Generic;
4 | using System.Threading.Tasks;
5 |
6 | namespace BigCookieKit.AspCore.RouteSelector
7 | {
8 | internal interface IEndpointSelectorPolicy
9 | {
10 | bool AppliesToEndpoints(IReadOnlyList endpoints);
11 |
12 | Task ApplyAsync(HttpContext httpContext, CandidateSet candidates);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/HttpHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | public class HttpHandle : Handle
10 | {
11 | public override void Decode(Action packet)
12 | {
13 | }
14 |
15 | public override void Encode(byte[] bytes)
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/EntityFramework/UpdateModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace BigCookieKit.AspCore.EntityFramework
5 | {
6 | public class UpdateModel
7 | {
8 | [Key]
9 | public long Id { get; set; }
10 |
11 | public long? UpdateUserId { get; set; }
12 |
13 | public string UpdateUserName { get; set; }
14 |
15 | public DateTime? UpdateTime { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/MessageMode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | ///
10 | /// 封包消息类型
11 | ///
12 | public enum MessageMode
13 | {
14 | None = 0,
15 | MessageShort = 1,
16 | MessageInt = 2,
17 | Disconect = 0xFF,
18 | Reconnect = 0xFE,
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BigCookieKit/XML/XmlInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace BigCookieKit.XML
4 | {
5 | ///
6 | /// Xml的信息数据
7 | ///
8 | /// **用结构体来降低堆的利用
9 | ///
10 | ///
11 | [StructLayout(LayoutKind.Auto)]
12 | public struct XmlInfo
13 | {
14 | public bool HasValue;
15 | public string Name;
16 | public string Text;
17 | public XmlAttribute[] Attributes;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/BigCookie.Document/wwwroot/document-ui.css:
--------------------------------------------------------------------------------
1 | * {
2 | padding: 0;
3 | margin: 0;
4 | }
5 |
6 | html, body {
7 | width: 100%;
8 | height: 100%;
9 | }
10 |
11 | .container {
12 | max-width: 1200px;
13 | min-width: 1200px;
14 | }
15 |
16 | .description {
17 | display: block;
18 | width: 100%;
19 | padding: 20px 20px 20px 20px;
20 | color: #217dbb;
21 | background-color: #fafafa;
22 | border: 1px solid #ddd;
23 | margin: 0 0 5px 0;
24 | }
25 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/TabManager.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection.Emit;
2 |
3 | namespace BigCookieKit.Reflect
4 | {
5 | public class TabManager : EmitBasic
6 | {
7 | private Label pointer { get; set; }
8 |
9 | internal TabManager(ILGenerator generator, Label pointer) : base(generator)
10 | {
11 | this.pointer = pointer;
12 | }
13 |
14 | public void Break()
15 | {
16 | Emit(OpCodes.Br, pointer);
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/EntityFramework/QueryFunc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.EntityFramework
8 | {
9 | public enum QueryFunc
10 | {
11 | Equal,
12 | NoEqual,
13 | Like,
14 | NotLike,
15 | In,
16 | NotIn,
17 | GrThen,
18 | GrThenOrEqual,
19 | LeThen,
20 | LeThenOrEqual,
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/BigCookieKit/Serialization/BasicSerializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Serialization
9 | {
10 | ///
11 | /// 基础序列化器
12 | ///
13 | public class BasicSerializer : ISerializer
14 | {
15 | public void StringEncode(string source)
16 | {
17 | byte[] bits = Kit.GetBytes(source.ToCharArray());
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/UnitConsole/BytesIndexOf.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Attributes;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace UnitConsole
9 | {
10 | public class BytesIndexOf
11 | {
12 |
13 | [Benchmark(Description = "IndexOf")]
14 | public void IndexOf()
15 | {
16 |
17 | }
18 |
19 | [Benchmark(Description = "FastIndexOf")]
20 | public void FastIndexOf()
21 | {
22 |
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookieKit/Attributes/RequiredRuleAttribute.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Attributes;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace BigCookieKit
7 | {
8 | [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
9 | public class RequiredRuleAttribute
10 | : BasicAttribute
11 | {
12 | public RequiredRuleAttribute(string Name = "") : base(Name)
13 | {
14 | this.Name = Name;
15 | base.Required = true;
16 | }
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/NoneHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | public class NoneHandle : Handle
10 | {
11 | public override void Encode(byte[] bytes)
12 | {
13 | BigCookieKit.Network.Buffer.SetBuffer(this, bytes);
14 | }
15 |
16 | public override void Decode(Action packet)
17 | {
18 | packet(MemoryBuffer.ToArray());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/BigCookieKit/Attributes/DisplayAttribute.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Attributes;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Reflection;
5 | using System.Text;
6 |
7 | namespace BigCookieKit
8 | {
9 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
10 | public class DisplayAttribute
11 | : Attribute
12 | {
13 | public string Value { get; set; }
14 |
15 | public DisplayAttribute(string value)
16 | {
17 | this.Value = value;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/MapRow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Office.Xlsx
6 | {
7 | public class WorkBookMap
8 | {
9 |
10 | public WorkBookMap()
11 | {
12 | }
13 |
14 | public SheetMap GetSheet(int index)
15 | {
16 | return null;
17 | }
18 | }
19 |
20 | public class SheetMap
21 | {
22 |
23 | }
24 |
25 | public class RowMap
26 | {
27 |
28 | }
29 |
30 | public class CellMap
31 | {
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/BigCookieKit/DbValueFormat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit
6 | {
7 | ///
8 | /// DataTable取值格式化
9 | ///
10 | [Flags]
11 | public enum DbValueFormat
12 | {
13 | None = 0,
14 | ///
15 | /// 去除头尾空格
16 | ///
17 | DisTrim = 1,
18 | ///
19 | /// 去除换行符
20 | ///
21 | DisBreak = 2,
22 | ///
23 | /// 去除制表符
24 | ///
25 | DisTabs = 4,
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/UnitAspExample/UnitAspExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 |
7 |
8 | C:\Users\zbb58\source\repos\github\BigCookieKit\UnitAspExample\UnitAspExample.xml
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/VariableManager.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection.Emit;
2 |
3 | namespace BigCookieKit.Reflect
4 | {
5 | public class VariableManager : EmitBasic
6 | {
7 | internal LocalBuilder instance;
8 |
9 | internal VariableManager(LocalBuilder stack, ILGenerator generator) : base(generator)
10 | {
11 | this.instance = stack;
12 | }
13 |
14 | public void Output()
15 | {
16 | base.Emit(OpCodes.Ldloc_S, this.instance);
17 | }
18 |
19 | public void Input()
20 | {
21 | base.Emit(OpCodes.Stloc_S, this.instance);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/BigCookieKit/Attributes/DecimalRuleAttribute.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Attributes;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit
9 | {
10 | ///
11 | /// 浮点数规则
12 | ///
13 | public class DecimalRuleAttribute
14 | : NumericRuleAttribute
15 | {
16 | public DecimalRuleAttribute(string Name = "") : base(Name)
17 | {
18 | }
19 |
20 | ///
21 | /// 精度
22 | ///
23 | public object Precision { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/MethodManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class MethodManager : EmitBasic
7 | {
8 | internal Type ReturnType { get; set; }
9 |
10 | public MethodManager(ILGenerator generator, Type returnType) : base(generator)
11 | {
12 | ReturnType = returnType;
13 | }
14 |
15 | public LocalBuilder ReturnRef()
16 | {
17 | tiggerPop = false;
18 | LocalBuilder ret = DeclareLocal(ReturnType);
19 | Emit(OpCodes.Stloc_S, ret);
20 | return ret;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/UnitAspExample/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/NullRouter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Routing;
2 |
3 | using System.Threading.Tasks;
4 |
5 | namespace BigCookieKit.AspCore.RouteSelector
6 | {
7 | internal class NullRouter : IRouter
8 | {
9 | public static readonly NullRouter Instance = new NullRouter();
10 |
11 | private NullRouter()
12 | {
13 | }
14 |
15 | public VirtualPathData? GetVirtualPath(VirtualPathContext context)
16 | {
17 | return null;
18 | }
19 |
20 | public Task RouteAsync(RouteContext context)
21 | {
22 | return Task.CompletedTask;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookie.Document/UriInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookie.Document
8 | {
9 | public class UriInfo
10 | {
11 | public string Uri { get; set; }
12 |
13 | public string Comment { get; set; }
14 |
15 | public string Method { get; set; }
16 |
17 | }
18 |
19 | public class BodyTable
20 | {
21 | public string FieldName { get; set; }
22 |
23 | public string TypeName { get; set; }
24 |
25 | public bool IsRequire { get; set; }
26 |
27 | public string Comment { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/UnitConsole/UnitConsole.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/ColumnNormal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Office.Xlsx
8 | {
9 | ///
10 | /// 列的默认类型
11 | ///
12 | public enum ColumnNormal
13 | {
14 | ///
15 | /// 默认
16 | ///
17 | Default,
18 | ///
19 | /// Guid
20 | ///
21 | Guid,
22 | ///
23 | /// 当前时间
24 | ///
25 | NowDate,
26 | ///
27 | /// 自增
28 | ///
29 | Increment,
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/ConcurrencyLimiter/ConcurrencyLimiterOption.cs:
--------------------------------------------------------------------------------
1 | namespace BigCookieKit.AspCore.ConcurrencyLimiter
2 | {
3 | public class ConcurrencyLimiterOption
4 | {
5 | ///
6 | /// 限流地址
7 | ///
8 | public string RequestPath { get; set; }
9 |
10 | ///
11 | /// 队列最大等待数量
12 | ///
13 | public int RequestQueueLimit { get; set; }
14 |
15 | ///
16 | /// 最大并行数量
17 | ///
18 | public int MaxConcurrentRequests { get; set; }
19 |
20 | ///
21 | /// 队列满返回消息
22 | ///
23 | public string QueueFullMessage { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/EntityFramework/DbModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.AspCore.EntityFramework
9 | {
10 | public class DbModel
11 | {
12 | [Key]
13 | public long Id { get; set; }
14 |
15 | public long? CreateUserId { get; set; }
16 |
17 | public string CreateUserName { get; set; }
18 |
19 | public DateTime? CreateTime { get; set; }
20 |
21 | public long? UpdateUserId { get; set; }
22 |
23 | public string UpdateUserName { get; set; }
24 |
25 | public DateTime? UpdateTime { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/EntityFramework/QueryMeta.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.EntityFramework
8 | {
9 | [AttributeUsage(AttributeTargets.Property, Inherited = true)]
10 | public class QueryMeta : Attribute
11 | {
12 | public QueryFunc Where { get; set; }
13 |
14 | public string Name { get; set; }
15 |
16 | public QueryMeta(QueryFunc where)
17 | {
18 | this.Where = where;
19 | }
20 |
21 | public QueryMeta(QueryFunc Where, string Name)
22 | {
23 | this.Where = Where;
24 | this.Name = Name;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BigCookieKit/Attributes/BasicAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Attributes
6 | {
7 | public abstract class BasicAttribute
8 | : Attribute
9 | {
10 | internal BasicAttribute(string Name)
11 | {
12 | this.Name = Name;
13 | }
14 |
15 | ///
16 | /// 属性名称
17 | ///
18 | public string Name { get; set; }
19 |
20 | ///
21 | /// 验证失败消息
22 | ///
23 | public string Message { get; set; }
24 |
25 | ///
26 | /// 必填
27 | ///
28 | public bool Required { get; set; }
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/BigCookieKit/Resources/xlsx/[Content_Types].xml:
--------------------------------------------------------------------------------
1 | {0}
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Apm/ApmEntityFrameworkLoggerProvider.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 |
3 | using System;
4 |
5 | namespace BigCookieKit.AspCore.Apm
6 | {
7 | public class ApmEntityFrameworkLoggerProvider : ILoggerProvider
8 | {
9 | private readonly Func _filter;
10 | private readonly IServiceProvider _provider;
11 |
12 | public ApmEntityFrameworkLoggerProvider(Func filter, IServiceProvider provider)
13 | {
14 | _filter = filter;
15 | _provider = provider;
16 | }
17 |
18 | public ILogger CreateLogger(string categoryName) => new ApmEntityFrameworkLogger(categoryName, _filter, _provider);
19 | public void Dispose() { }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/BigCookie.Document/DocumentConfigureOptions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.Extensions.FileProviders;
3 | using Microsoft.Extensions.Options;
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Reflection;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace BigCookie.Document
13 | {
14 | public class DocumentConfigureOptions : IPostConfigureOptions
15 | {
16 | public void PostConfigure(string name, StaticFileOptions options)
17 | {
18 | var embeddedProvider = new EmbeddedFileProvider(Assembly.GetExecutingAssembly(), "BigCookie.Document.wwwroot");
19 | options.FileProvider = embeddedProvider;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/UnitBenchmark/Program.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Running;
2 |
3 | using BigCookieKit.Algorithm;
4 |
5 | using System;
6 |
7 | namespace UnitBenchmark
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | //string s1 = "HERE IS A SIMPLE EXAMPLE";
14 | //string s2 = "EXAMPLE";
15 | //BoyerMoore.BoyerMooreFirstMatch(s1.ToCharArray(), s2.ToCharArray());
16 |
17 | BoyerMooreBenchmark boyerMooreBenchmark = new BoyerMooreBenchmark();
18 | boyerMooreBenchmark.BoyerMooreChar();
19 |
20 | //BenchmarkRunner.Run(typeof(BoyerMooreBenchmark));
21 | //BenchmarkRunner.Run(typeof(MapToBenchmark));
22 | //BenchmarkRunner.Run(typeof(ExcelReadBenchmark));
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Apm/ApmDbContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 |
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace BigCookieKit.AspCore.Apm
7 | {
8 | public abstract class ApmDbContext : DbContext
9 | {
10 | public ApmDbContext() { }
11 |
12 | public ApmDbContext(DbContextOptions options)
13 | : base(options)
14 | {
15 | }
16 |
17 | public static Dictionary> _OnConfiguring = new Dictionary>();
18 |
19 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
20 | {
21 | _OnConfiguring[GetType()]?.Invoke(optionsBuilder);
22 | base.OnConfiguring(optionsBuilder);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Standard/ApiPermission.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.Standard
8 | {
9 | public abstract class ApiPermission
10 | {
11 | ///
12 | /// 用户Id
13 | ///
14 | public string UserId { get; set; }
15 |
16 | ///
17 | /// 用户名
18 | ///
19 | public string UserName { get; set; }
20 |
21 | ///
22 | /// 所属租户
23 | ///
24 | public string[] Tenement { get; set; }
25 |
26 | ///
27 | /// 权限码
28 | ///
29 | public string[] PermissionCode { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/UnitAspExample/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.Hosting;
4 | using Microsoft.Extensions.Logging;
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Threading.Tasks;
10 |
11 | namespace UnitAspExample
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | CreateHostBuilder(args).Build().Run();
18 | }
19 |
20 | public static IHostBuilder CreateHostBuilder(string[] args) =>
21 | Host.CreateDefaultBuilder(args)
22 | .ConfigureWebHostDefaults(webBuilder =>
23 | {
24 | webBuilder.UseStartup();
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/UnitAspExample/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:60898",
7 | "sslPort": 44391
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "UnitAspExample": {
19 | "commandName": "Project",
20 | "dotnetRunMessages": "true",
21 | "launchBrowser": true,
22 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
23 | "environmentVariables": {
24 | "ASPNETCORE_ENVIRONMENT": "Development"
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/CandidateState.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.AspNetCore.Routing;
3 |
4 | namespace BigCookieKit.AspCore.RouteSelector
5 | {
6 | internal struct CandidateState
7 | {
8 | internal CandidateState(Endpoint endpoint, int score)
9 | {
10 | Endpoint = endpoint;
11 | Score = score;
12 | Values = null;
13 | }
14 |
15 | internal CandidateState(Endpoint endpoint, RouteValueDictionary? values, int score)
16 | {
17 | Endpoint = endpoint;
18 | Values = values;
19 | Score = score;
20 | }
21 |
22 | public Endpoint Endpoint { get; }
23 |
24 | public int Score { get; }
25 |
26 | public RouteValueDictionary? Values { get; internal set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Standard/ApiPermissionPager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.Standard
8 | {
9 | public abstract class ApiPermissionPager : ApiPager
10 | {
11 | ///
12 | /// 用户Id
13 | ///
14 | public string UserId { get; set; }
15 |
16 | ///
17 | /// 用户名
18 | ///
19 | public string UserName { get; set; }
20 |
21 | ///
22 | /// 所属租户
23 | ///
24 | public string[] Tenement { get; set; }
25 |
26 | ///
27 | /// 权限码
28 | ///
29 | public string[] PermissionCode { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/EntityFramework/JoinSelect.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.AspCore.EntityFramework
8 | {
9 | public class JoinSelect
10 | where T1 : class
11 | where T2 : class
12 | {
13 | private readonly T1 arg1;
14 | private readonly T2 arg2;
15 | private object _value;
16 |
17 | public JoinSelect(T1 arg1, T2 arg2)
18 | {
19 | this.arg1 = arg1;
20 | this.arg2 = arg2;
21 | }
22 |
23 | public T As(Func selector)
24 | where T : class
25 | {
26 | this._value = selector.Invoke(arg1, arg2);
27 | return this._value as T;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/BigCookieKit/Attributes/StringRuleAttribute.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Attributes;
2 | using System;
3 |
4 | namespace BigCookieKit
5 | {
6 | ///
7 | /// 字符串规则
8 | ///
9 | [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = true)]
10 | public class StringRuleAttribute
11 | : BasicAttribute
12 | {
13 | public StringRuleAttribute(string Name = "") : base(Name)
14 | {
15 | }
16 |
17 | ///
18 | /// 最大长度
19 | ///
20 | public object MaxLength { get; set; }
21 |
22 | ///
23 | /// 最小长度
24 | ///
25 | public object MinLength { get; set; }
26 |
27 | ///
28 | /// 正则表达式
29 | ///
30 | public string RegExp { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/ZeroEntryJumpTable.cs:
--------------------------------------------------------------------------------
1 | namespace BigCookieKit.AspCore.RouteSelector
2 | {
3 | internal class ZeroEntryJumpTable : JumpTable
4 | {
5 | private readonly int _defaultDestination;
6 | private readonly int _exitDestination;
7 |
8 | public ZeroEntryJumpTable(int defaultDestination, int exitDestination)
9 | {
10 | _defaultDestination = defaultDestination;
11 | _exitDestination = exitDestination;
12 | }
13 |
14 | public override int GetDestination(string path, PathSegment segment)
15 | {
16 | return segment.Length == 0 ? _exitDestination : _defaultDestination;
17 | }
18 |
19 | public override string DebuggerToString()
20 | {
21 | return $"{{ $+: {_defaultDestination}, $0: {_exitDestination} }}";
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/DfaState.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Routing.Matching;
2 |
3 | namespace BigCookieKit.AspCore.RouteSelector
4 | {
5 | internal readonly struct DfaState
6 | {
7 | public readonly Candidate[] Candidates;
8 | public readonly IEndpointSelectorPolicy[] Policies;
9 | public readonly JumpTable PathTransitions;
10 | public readonly PolicyJumpTable PolicyTransitions;
11 |
12 | public DfaState(
13 | Candidate[] candidates,
14 | IEndpointSelectorPolicy[] policies,
15 | JumpTable pathTransitions,
16 | PolicyJumpTable policyTransitions)
17 | {
18 | Candidates = candidates;
19 | Policies = policies;
20 | PathTransitions = pathTransitions;
21 | PolicyTransitions = policyTransitions;
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/BigCookie.Document/DocumentExtension.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.Extensions.FileProviders;
3 |
4 | using System;
5 | using System.Reflection;
6 |
7 | namespace BigCookie.Document
8 | {
9 | public static class DocumentExtension
10 | {
11 | internal static IApplicationBuilder _application;
12 | internal static string _description = "";
13 |
14 | public static void UseDocumentUI(this IApplicationBuilder app, string description = "")
15 | {
16 | _application = app;
17 | _description = description;
18 |
19 | var options = new StaticFileOptions();
20 | {
21 | var embeddedProvider = new ManifestEmbeddedFileProvider(Assembly.GetExecutingAssembly(), "wwwroot");
22 | options.FileProvider = embeddedProvider;
23 | }
24 | app.UseStaticFiles(options);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/CacheManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace BigCookieKit.Reflect
6 | {
7 | internal static class CacheManager
8 | {
9 | internal static Dictionary EntityCache => new Dictionary();
10 |
11 | internal static FastProperty[] CachePropsManager(this Type type)
12 | {
13 | if (!EntityCache.ContainsKey(type.FullName))
14 | {
15 | EntityCache.Add(type.FullName, EnumerableProp(type).ToArray());
16 | }
17 | return EntityCache[type.FullName];
18 | }
19 |
20 | private static IEnumerable EnumerableProp(Type type)
21 | {
22 | foreach (var prop in type.GetProperties())
23 | {
24 | yield return new FastProperty(prop);
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/BigCookieKit/Resources/Common.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Reflection;
5 | using System.Text;
6 |
7 | namespace BigCookieKit.Resources
8 | {
9 | public static class Common
10 | {
11 | private const string ResourcePath = "BigCookieKit.Resources.";
12 |
13 | public static Stream GetXlsxResource(string fileName)
14 | {
15 | Assembly Asmb = Assembly.GetExecutingAssembly();
16 | return Asmb.GetManifestResourceStream(ResourcePath + "xlsx." + fileName);
17 | }
18 |
19 | public static string GetXlsxResourceString(string fileName)
20 | {
21 | Assembly Asmb = Assembly.GetExecutingAssembly();
22 | using Stream stream = Asmb.GetManifestResourceStream(ResourcePath + "xlsx." + fileName);
23 | StreamReader sr = new StreamReader(stream);
24 | return sr.ReadToEnd();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BigCookieSequelize/BigCookieSequelize.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5
5 | 1.0.2021.0407
6 | ©2021-2021 Big.Cookie
7 | 仿nodejs的Sequelize框架
8 | logo.png
9 | https://github.com/BigBigZBBing/BigCookieKit
10 | git
11 | 仿nodejs的Sequelize框架
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | True
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BPlusTree/BTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace BPlusTree
5 | {
6 | public class BTree : IPromotionListener where T : class, IComparable
7 | {
8 | private BTreeNode root;
9 |
10 | public BTree(int order)
11 | {
12 | root = new BTreeNode(order, this);
13 | }
14 |
15 | #region IPromotionListener Members
16 |
17 | public void RootIs(BTreeNode node)
18 | {
19 | root = node;
20 | }
21 |
22 | #endregion
23 |
24 | public void Insert(T value)
25 | {
26 | var node = root.Find(value);
27 | node.Insert(value);
28 | }
29 |
30 | public override string ToString()
31 | {
32 | return root.ToString();
33 | }
34 |
35 | public BTreeNodeElement Search(T searchKey)
36 | {
37 | return root.Search(searchKey);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/UnitAspExample/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 | @model ErrorViewModel
2 | @{
3 | ViewData["Title"] = "Error";
4 | }
5 |
6 | Error.
7 | An error occurred while processing your request.
8 |
9 | @if (Model.ShowRequestId)
10 | {
11 |
12 | Request ID: @Model.RequestId
13 |
14 | }
15 |
16 | Development Mode
17 |
18 | Swapping to Development environment will display more detailed information about the error that occurred.
19 |
20 |
21 | The Development environment shouldn't be enabled for deployed applications.
22 | It can result in displaying sensitive information from exceptions to end users.
23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
24 | and restarting the app.
25 |
26 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/BigCookieKit.AspCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 | 10.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/PathSegment.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace BigCookieKit.AspCore.RouteSelector
5 | {
6 | internal readonly struct PathSegment : IEquatable
7 | {
8 | public readonly int Start;
9 | public readonly int Length;
10 |
11 | public PathSegment(int start, int length)
12 | {
13 | Start = start;
14 | Length = length;
15 | }
16 |
17 | public override bool Equals(object? obj)
18 | {
19 | return obj is PathSegment segment ? Equals(segment) : false;
20 | }
21 |
22 | public bool Equals(PathSegment other)
23 | {
24 | return Start == other.Start && Length == other.Length;
25 | }
26 |
27 | public override int GetHashCode()
28 | {
29 | return Start;
30 | }
31 |
32 | public override string ToString()
33 | {
34 | return $"Segment({Start}:{Length})";
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/Pipeline.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Network
8 | {
9 | public class Pipeline
10 | {
11 | internal List pipes = new List();
12 |
13 | internal int _poistion;
14 |
15 | internal void Add(IPipe pipe)
16 | {
17 | pipes.Add(pipe);
18 | }
19 |
20 | internal void Start(Session session, Action callback)
21 | {
22 | _poistion = 0;
23 | if (pipes.Count == 0)
24 | callback?.Invoke();
25 | else Spin(session, callback);
26 | }
27 |
28 | internal void Spin(Session session, Action callback)
29 | {
30 | pipes[_poistion++].InvokeAsync(session,
31 | pipes.Count > _poistion
32 | ? delegate { Spin(session, callback); }
33 | : callback);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/TryCatchManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class TryCatchManager
7 | {
8 | private ILGenerator generator;
9 |
10 | internal TryCatchManager(ILGenerator generator)
11 | {
12 | this.generator = generator;
13 | }
14 |
15 | public TryCatchManager Catch(Action builder)
16 | {
17 | generator.BeginCatchBlock(typeof(Exception));
18 | var ex = generator.DeclareLocal(typeof(Exception));
19 | generator.Emit(OpCodes.Stloc_S, ex);
20 | builder(ex);
21 | return this;
22 | }
23 |
24 | public TryCatchManager Finally(Action builder)
25 | {
26 | generator.BeginFinallyBlock();
27 | builder();
28 | return this;
29 | }
30 |
31 | public void TryEnd()
32 | {
33 | generator.EndExceptionBlock();
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/FastPathTokenizerHelpers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BigCookieKit.AspCore.RouteSelector
4 | {
5 | internal static class FastPathTokenizerHelpers
6 | {
7 | public static int Tokenize(string path, Span segments)
8 | {
9 | if (string.IsNullOrEmpty(path))
10 | {
11 | return 0;
12 | }
13 |
14 | int count = 0;
15 | int start = 1;
16 | int end;
17 | var span = path.AsSpan(start);
18 | while ((end = span.IndexOf('/')) >= 0 && count < segments.Length)
19 | {
20 | segments[count++] = new PathSegment(start, end);
21 | start += end + 1;
22 | span = path.AsSpan(start);
23 | }
24 |
25 | var length = span.Length;
26 | if (length > 0 && count < segments.Length)
27 | {
28 | segments[count++] = new PathSegment(start, length);
29 | }
30 |
31 | return count;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/OperatorCode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Reflect
8 | {
9 | public enum OperatorCode
10 | {
11 | ///
12 | /// +
13 | ///
14 | Add,
15 | ///
16 | /// -
17 | ///
18 | Sub,
19 | ///
20 | /// *
21 | ///
22 | Mul,
23 | ///
24 | /// /
25 | ///
26 | Div,
27 | ///
28 | /// %
29 | ///
30 | Rem,
31 | ///
32 | /// <<
33 | ///
34 | Shl,
35 | ///
36 | /// >>
37 | ///
38 | Shr,
39 | ///
40 | /// ^
41 | ///
42 | Xor,
43 | ///
44 | /// &
45 | ///
46 | And,
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 大饼嘴强
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 all
13 | 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 THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/BigCookieKit/Attributes/NumericRuleAttribute.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Attributes;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit
9 | {
10 | ///
11 | /// 整数规则
12 | ///
13 | [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
14 | public class NumericRuleAttribute
15 | : BasicAttribute
16 | {
17 | public NumericRuleAttribute(string Name = "") : base(Name)
18 | {
19 | }
20 |
21 | ///
22 | /// 大于
23 | ///
24 | public object Greater { get; set; }
25 |
26 | ///
27 | /// 小于
28 | ///
29 | public object Less { get; set; }
30 |
31 | ///
32 | /// 等于
33 | ///
34 | public object Equal { get; set; }
35 |
36 | ///
37 | /// 不等于
38 | ///
39 | public object NoEqual { get; set; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/ConcurrencyLimiter/ActionLimter.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Threading;
4 |
5 | namespace BigCookieKit.AspCore.ConcurrencyLimiter
6 | {
7 | public class ActionLimter
8 | {
9 | public ActionLimter(int maxCount, int maxWait)
10 | {
11 | Semaphore = new SemaphoreSlim(maxCount, maxCount);
12 | this.maxWait = maxWait;
13 | }
14 |
15 | ///
16 | /// 信号灯
17 | ///
18 | public SemaphoreSlim Semaphore { get; set; }
19 |
20 | private int waitCount = 0;
21 | private readonly int maxWait;
22 | private readonly object _lock = new object();
23 |
24 | public bool Doing(Action action)
25 | {
26 | if (Volatile.Read(ref waitCount) >= maxWait)
27 | return false;
28 | Interlocked.Increment(ref waitCount);
29 | Semaphore.Wait();
30 | action?.Invoke();
31 | Semaphore.Release();
32 | Interlocked.Decrement(ref waitCount);
33 | return true;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/BigCookieKit/XML/XmlPacket.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace BigCookieKit.XML
9 | {
10 | ///
11 | /// 解析的XML的实体
12 | ///
13 | public class XmlPacket
14 | {
15 | #region 内部参数
16 |
17 | internal XmlPacket Parent { get; set; }
18 |
19 | internal PacketState State { get; set; }
20 |
21 | #endregion
22 |
23 | public XmlInfo Info;
24 |
25 | public IList Node { get; set; }
26 |
27 | public XmlAttribute GetAttr(string key)
28 | {
29 | var attrs = Info.Attributes;
30 | if (attrs.NotExist()) return default;
31 | for (int i = 0; i < attrs.Length; i++)
32 | {
33 | var attr = attrs[i];
34 | if (attr.Name.Equals(key, StringComparison.OrdinalIgnoreCase))
35 | return attr;
36 | }
37 | return default;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/XSocketAsyncEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Network
9 | {
10 | public class XSocketAsyncEventArgs : SocketAsyncEventArgs
11 | {
12 | #if NET452
13 | public Memory MemoryBuffer { get { return this.Buffer; } }
14 | #endif
15 | internal ApplyMode Mode { get; set; }
16 |
17 | public Socket Client
18 | {
19 | get => Mode switch
20 | {
21 | ApplyMode.Client => ConnectSocket,
22 | ApplyMode.Server => AcceptSocket,
23 | _ => null
24 | };
25 | internal set
26 | {
27 | switch (Mode)
28 | {
29 | case ApplyMode.Client:
30 | break;
31 | case ApplyMode.Server:
32 | AcceptSocket = value;
33 | break;
34 | }
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/NUnitBigCookieKit/UnitReflect.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit;
2 | using BigCookieKit.Reflect;
3 |
4 | using NUnit.Framework;
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace NUnitBigCookieKit
13 | {
14 | public class UnitReflect
15 | {
16 |
17 | [SetUp]
18 | public void Setup()
19 | {
20 |
21 | }
22 |
23 | ///
24 | /// 高性能动态扩展对象
25 | ///
26 | [Test]
27 | public void ExtendObject()
28 | {
29 | FastExtend canExtend = new FastExtend();
30 | canExtend.AddMember("Name1", typeof(string));
31 | canExtend.AddMember("Name2", typeof(string));
32 | canExtend.AddMember("Name3", typeof(string));
33 | canExtend["Name1"] = "123";
34 | for (int i = 4; i < 20; i++)
35 | {
36 | var name = $"Name" + i;
37 | canExtend.AddMember(name, typeof(string));
38 | canExtend[name] = "123";
39 | }
40 | canExtend.RemoveMember("Name2");
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/UnitAspExample/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 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/XSocket.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Network
9 | {
10 | public class XSocket : Socket
11 | {
12 | public XSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) : base(addressFamily, socketType, protocolType)
13 | {
14 | }
15 |
16 | public ApplyMode Mode { get; set; }
17 |
18 | internal static XSocket Create(Socket socket)
19 | {
20 | return new XSocket(socket.AddressFamily, socket.SocketType, socket.ProtocolType);
21 | }
22 |
23 | public bool Start(SocketAsyncEventArgs e)
24 | {
25 | var xe = e as XSocketAsyncEventArgs;
26 | xe.Mode = Mode;
27 | switch (Mode)
28 | {
29 | case ApplyMode.Server:
30 | return AcceptAsync(xe);
31 | case ApplyMode.Client:
32 | return ConnectAsync(xe);
33 | default: throw new SocketException();
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/UnitAspExample/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2018 Twitter, Inc.
4 | Copyright (c) 2011-2018 The Bootstrap Authors
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 |
--------------------------------------------------------------------------------
/UnitBenchmark/UnitBenchmark.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net5.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | Always
22 |
23 |
24 | Always
25 |
26 |
27 | Always
28 |
29 |
30 | Always
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/UnitConsole/BenchmarkExcelRead.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Attributes;
2 | using BigCookieKit.Office;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Data;
6 | using System.Text;
7 |
8 | namespace UnitConsole
9 | {
10 | public class BenchmarkExcelRead
11 | {
12 |
13 | [Benchmark(Description = "NpoiRead")]
14 | public void NpoiRead()
15 | {
16 | NpoiKit npoiKit = new NpoiKit(@"C:\Users\zbb58\Desktop\test.xlsx");
17 | npoiKit.CreateConfig(config =>
18 | {
19 | config.ColumnNameRow = 1;
20 | config.StartRow = 2;
21 | });
22 | DataTable dt = npoiKit.ToDataTable(npoiKit.GetSheet("Sheet1"));
23 | }
24 |
25 | [Benchmark(Description = "OpenXmlRead")]
26 | public void OpenXmlRead()
27 | {
28 | ReadExcelKit excelKit = new ReadExcelKit(@"C:\Users\zbb58\Desktop\test.xlsx");
29 | excelKit.AddConfig(config =>
30 | {
31 | config.SheetIndex = 1;
32 | config.ColumnNameRow = 1;
33 | config.StartRow = 2;
34 | });
35 | DataTable dt = excelKit.ReadDataTable();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/BigCookie.Document/BigCookie.Document.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 | true
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/UnitBenchmark/Resources/BoyerMooreUnit.txt:
--------------------------------------------------------------------------------
1 | Configuration
2 | Overview
3 | RabbitMQ comes with default built-in settings. Those can be entirely sufficient in some environment (e.g. development and QA). For all other cases, as well as production deployment tuning, there is a way to configure many things in the broker as well as plugins.
4 |
5 | This guide covers a number of topics related to configuration:
6 |
7 | Different ways in which various settings of the server and plugins are configured
8 | Configuration file(s): primary rabbitmq.conf and optional advanced.config
9 | Default configuration file location(s) on various platforms
10 | Configuration troubleshooting: how to find config file location and inspect and verify effective configuration
11 | Environment variables
12 | Operating system (kernel) limits
13 | Available core server settings
14 | Available environment variables
15 | How to encrypt sensitive configuration values
16 | and more.
17 |
18 | Since configuration affects many areas of the system, including plugins, individual documentation guides dive deeper into what can be configured. Runtime Tuning is a companion to this guide that focuses on the configurable parameters in the runtime. Production Checklist is a related guide that outlines what settings will likely need tuning in most production environments.
--------------------------------------------------------------------------------
/NUnitBigCookieKit/Resources/BoyerMooreUnit.txt:
--------------------------------------------------------------------------------
1 | Configuration
2 | Overview
3 | RabbitMQ comes with default built-in settings. Those can be entirely sufficient in some environment (e.g. development and QA). For all other cases, as well as production deployment tuning, there is a way to configure many things in the broker as well as plugins.
4 |
5 | This guide covers a number of topics related to configuration:
6 |
7 | Different ways in which various settings of the server and plugins are configured
8 | Configuration file(s): primary rabbitmq.conf and optional advanced.config
9 | Default configuration file location(s) on various platforms
10 | Configuration troubleshooting: how to find config file location and inspect and verify effective configuration
11 | Environment variables
12 | Operating system (kernel) limits
13 | Available core server settings
14 | Available environment variables
15 | How to encrypt sensitive configuration values
16 | and more.
17 |
18 | Since configuration affects many areas of the system, including plugins, individual documentation guides dive deeper into what can be configured. Runtime Tuning is a companion to this guide that focuses on the configurable parameters in the runtime. Production Checklist is a related guide that outlines what settings will likely need tuning in most production environments.
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/CtorStroke.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Reflection.Emit;
4 |
5 | namespace BigCookieKit.Reflect
6 | {
7 | public sealed class CtorStroke
8 | {
9 | private ConstructorBuilder constructorBuilder;
10 | private FuncGenerator generator;
11 |
12 | internal CtorStroke(ConstructorBuilder constructorBuilder)
13 | {
14 | this.constructorBuilder = constructorBuilder;
15 | generator = new FuncGenerator(constructorBuilder.GetILGenerator());
16 | }
17 |
18 | public CtorStroke Builder(Action builder)
19 | {
20 | builder(generator);
21 | return this;
22 | }
23 |
24 | public CtorStroke CustomAttr(ConstructorInfo ctor, params object[] args)
25 | {
26 | constructorBuilder.SetCustomAttribute(new CustomAttributeBuilder(ctor, args));
27 | return this;
28 | }
29 |
30 | public CtorStroke CustomAttr(ConstructorInfo ctor, params byte[] binary)
31 | {
32 | constructorBuilder.SetCustomAttribute(ctor, binary);
33 | return this;
34 | }
35 |
36 | public void End()
37 | {
38 | generator.Return();
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/BigCookieKit.Network/Handle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net.Sockets;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BigCookieKit.Network
10 | {
11 | public abstract class Handle : XSocketAsyncEventArgs
12 | {
13 | public Handle()
14 | {
15 | }
16 |
17 | private byte[] _buffer;
18 |
19 | private EventHandler _callback;
20 |
21 | internal byte[] buffer { get { return _buffer; } set { BigCookieKit.Network.Buffer.SetBuffer(this, value); } }
22 |
23 | internal EventHandler callback { get { return _callback; } set { Completed += value; } }
24 |
25 | internal Pipeline pipeline = new Pipeline();
26 |
27 | internal Handle New()
28 | {
29 | Handle handle = (Handle)Activator.CreateInstance(GetType());
30 | handle.pipeline = pipeline;
31 | return handle;
32 | }
33 |
34 | public void PipeStart(Session session, Action callback)
35 | {
36 | pipeline.Start(session, callback);
37 | }
38 |
39 | public abstract void Encode(byte[] bytes);
40 |
41 | public abstract void Decode(Action packet);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FastDynamic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Concurrent;
4 | using System.Collections.Generic;
5 |
6 | namespace BigCookieKit.Reflect
7 | {
8 | public sealed class FastDynamic : IEnumerable
9 | {
10 | private FastDynamic()
11 | {
12 | }
13 |
14 | public object this[string Name]
15 | {
16 | get
17 | {
18 | return this.Properties[Name].Get();
19 | }
20 | set
21 | {
22 | this.Properties[Name].Set(value);
23 | }
24 | }
25 |
26 | public IDictionary Properties { get; internal set; }
27 |
28 | internal object Instance { get; set; }
29 |
30 | public static FastDynamic GetFastDynamic(T entity) where T : class, new()
31 | {
32 | return new FastDynamic()
33 | {
34 | Properties = new ConcurrentDictionary(ManagerGX.GetProps(entity.GetType().GetProperties(), entity)),
35 | Instance = entity
36 | };
37 | }
38 |
39 | IEnumerator IEnumerable.GetEnumerator()
40 | {
41 | foreach (var item in Properties)
42 | {
43 | yield return item;
44 | }
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/BigCookieKit/Resources/xlsx/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/ICilent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Network
9 | {
10 | public interface ICilent
11 | {
12 | ///
13 | /// 开启服务
14 | ///
15 | void Start();
16 |
17 | ///
18 | /// 开始
19 | ///
20 | void Open();
21 |
22 | ///
23 | /// 连接过程
24 | ///
25 | void ProcessConnect(SocketAsyncEventArgs e);
26 |
27 | ///
28 | /// 发送过程
29 | ///
30 | void ProcessSend(SocketAsyncEventArgs e);
31 |
32 | ///
33 | /// 接收过程
34 | ///
35 | void ProcessReceive(SocketAsyncEventArgs e);
36 |
37 | ///
38 | /// 调度中心
39 | ///
40 | ///
41 | ///
42 | void DispatchCenter(object sender, SocketAsyncEventArgs e);
43 |
44 | ///
45 | /// 接收结果回调
46 | ///
47 | Action OnCallBack { get; set; }
48 |
49 | ///
50 | /// 连接成功回调
51 | ///
52 | Action OnConnect { get; set; }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/HandleTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Network
9 | {
10 | public static class HandleTools
11 | {
12 | internal static Handle Define(this Handle handle, EventHandler _event)
13 | {
14 | if (handle != null)
15 | {
16 | handle.callback = _event;
17 | }
18 | return handle;
19 | }
20 |
21 | internal static Handle Define(this Handle handle, byte[] buffer, EventHandler _event)
22 | {
23 | if (handle != null)
24 | {
25 | handle.buffer = buffer;
26 | handle.callback = _event;
27 | }
28 | return handle;
29 | }
30 |
31 | public static void AddPipe(this Handle handle) where T : IPipe
32 | {
33 | var midType = typeof(T);
34 | handle.pipeline.Add((IPipe)Activator.CreateInstance(midType));
35 | }
36 |
37 | public static void AddPipe(this Handle handle, Type midType)
38 | {
39 | if (!(midType.BaseType is IPipe)) throw new ArrayTypeMismatchException();
40 | handle.pipeline.Add((IPipe)Activator.CreateInstance(midType));
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/BigCookieKit/Kit.Double.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.CompilerServices;
4 | using System.Text;
5 |
6 | namespace BigCookieKit
7 | {
8 | public static partial class Kit
9 | {
10 | ///
11 | /// 获取浮点数的精度
12 | ///
13 | ///
14 | ///
15 | public static int GetPrecision(this float m_float)
16 | {
17 | return GetPrecision((decimal)m_float);
18 | }
19 |
20 | ///
21 | /// 获取浮点数的精度
22 | ///
23 | ///
24 | ///
25 | public static int GetPrecision(this double m_float)
26 | {
27 | return GetPrecision((decimal)m_float);
28 | }
29 |
30 | ///
31 | /// 获取浮点数的精度
32 | ///
33 | ///
34 | ///
35 | public static int GetPrecision(this decimal m_float)
36 | {
37 | var str = m_float.ToString();
38 | var index = str.IndexOf(".", StringComparison.OrdinalIgnoreCase);
39 | if (index > -1)
40 | {
41 | return str.Substring(index + 1).TrimEnd('0').Length;
42 | }
43 | else
44 | return 0;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/BigCookieKit.Network.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | False
5 | netcoreapp3.1;net5
6 | BigCookieKit.Network
7 | BigCookieKit.Network
8 | BigCookieKit.Network
9 | BigCookieKit.Network
10 | BigCookieKit.Network
11 | 高性能网络通信库
12 | 特点:高性能,包含(*TCP,*UDP,HTTP,HTTPS,HTTP,MQTT)
13 | 使用详解关注CSDN Big.Cookie博客
14 | 技术讨论群 QQ群:1600800
15 | ©2021-2021 BigCookieKit.Network
16 | MIT
17 | logo.png
18 | https://github.com/BigBigZBBing/BigCookieKit
19 | git
20 | 1.2021.9.5
21 | 1.2021.9.5
22 | 1.2021.9.5
23 | ../Nuget
24 | Library
25 |
26 |
27 |
28 |
29 |
30 |
31 | True
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/ColumnConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Office.Xlsx
8 | {
9 | public class ColumnConfig
10 | {
11 | private string _Column;
12 |
13 | ///
14 | /// 列的序号
15 | ///
16 | public string Column
17 | {
18 | get
19 | {
20 | return _Column;
21 | }
22 | set
23 | {
24 | ColumnIndex = ExcelHelper.ColumnToIndex(value);
25 | _Column = value;
26 | }
27 | }
28 |
29 | ///
30 | /// 列的索引 由1开始
31 | ///
32 | public int? ColumnIndex { get; set; }
33 |
34 | ///
35 | /// 列的类型
36 | ///
37 | public Type ColumnType { get; set; }
38 |
39 | ///
40 | /// 列的名称
41 | ///
42 | public string ColumnName { get; set; }
43 |
44 | ///
45 | /// 默认值
46 | ///
47 | public ColumnNormal NormalType { get; set; }
48 |
49 | ///
50 | /// 默认值
51 | ///
52 | public object DefaultValue { get; set; }
53 |
54 | ///
55 | /// 是否可空
56 | ///
57 | public bool IsAllowNull { get; set; } = true;
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/IServer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Network
9 | {
10 | public interface IServer
11 | {
12 | ///
13 | /// 开启服务
14 | ///
15 | void Start();
16 |
17 | ///
18 | /// 开始
19 | ///
20 | void Open();
21 |
22 | ///
23 | /// 连接过程
24 | ///
25 | void ProcessAccept(SocketAsyncEventArgs e);
26 |
27 | ///
28 | /// 发送过程
29 | ///
30 | void ProcessSend(SocketAsyncEventArgs e);
31 |
32 | ///
33 | /// 接收过程
34 | ///
35 | void ProcessReceive(SocketAsyncEventArgs e);
36 |
37 | ///
38 | /// 调度中心
39 | ///
40 | ///
41 | ///
42 | void DispatchCenter(object sender, SocketAsyncEventArgs e);
43 |
44 | ///
45 | /// 用户连接成功回调
46 | ///
47 | Action OnConnect { get; set; }
48 |
49 | ///
50 | /// 接收到数据回调
51 | ///
52 | Action OnReceive { get; set; }
53 |
54 | ///
55 | /// 用户断开连接回调
56 | ///
57 | Action OnExit { get; set; }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/ExcelHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Office.Xlsx
8 | {
9 | ///
10 | /// Excel帮助类
11 | ///
12 | public static class ExcelHelper
13 | {
14 | ///
15 | /// 获取Excal 列坐标的对应的索引
16 | ///
17 | ///
18 | ///
19 | public static int? ColumnToIndex(string column)
20 | {
21 | if (string.IsNullOrEmpty(column)) return null;
22 | int index = 0, pos = 0;
23 | for (int i = column.Length - 1; i >= 0; i--, pos++)
24 | {
25 | index += ((column[i] - 64) * (int)(Math.Pow(26, pos)));
26 | }
27 | return index - 1;
28 | }
29 |
30 | ///
31 | /// 根据索引获取Excal 列坐标
32 | ///
33 | ///
34 | ///
35 | public static string IndexToColumn(int index)
36 | {
37 | if (index < 0) return null;
38 | string column = "";
39 | do
40 | {
41 | if (column.Length > 0)
42 | index--;
43 | column = ((char)(index % 26 + (int)'A')).ToString() + column;
44 | index = (int)((index - index % 26) / 26);
45 | } while (index > 0);
46 | return column;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/BigCookieKit.Office.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | False
5 | netcoreapp3.1;net5
6 | BigCookieKit.Office
7 | BigCookieKit.Office
8 | BigCookieKit.Office
9 | BigCookieKit.Office
10 | BigCookieKit.Office
11 | 高性能Office操作库
12 | 特点:超高性能,包含(*XLSX,XLS,WORD,PDF)
13 | 使用详解关注CSDN Big.Cookie博客
14 | 技术讨论群 QQ群:1600800
15 | ©2021-2021 BigCookieKit.Office
16 | MIT
17 | logo.png
18 | https://github.com/BigBigZBBing/BigCookieKit
19 | git
20 | 1.2021.9.5
21 | 1.2021.9.5
22 | 1.2021.9.5
23 | ../Nuget
24 | Library
25 | True
26 |
27 |
28 |
29 |
30 |
31 | True
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/UnitConsole/BPlusTreeTest.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Algorithm;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace UnitConsole
9 | {
10 | public static class BPlusTreeTest
11 | {
12 | public static void Example()
13 | {
14 | Console.WriteLine("程序初始占用内存:{0}MB", (GC.GetTotalMemory(true) / 1024));
15 |
16 | var tree = new BPlusTree(5);
17 |
18 | Console.WriteLine("创建BPlusTree完成!");
19 | Console.WriteLine("程序占用内存:{0}MB", (GC.GetTotalMemory(true) / 1024));
20 |
21 | //tree.Insert(0, 0);
22 | //tree.Insert(1, 1);
23 | //tree.Insert(2, 2);
24 | //tree.Insert(3, 3);
25 | //tree.Insert(4, 4);
26 | //tree.Insert(5, 5);
27 | //tree.Insert(6, 6);
28 | //tree.Insert(7, 7);
29 | //tree.Insert(11, 11);
30 | //tree.Insert(12, 12);
31 | //tree.Insert(13, 13);
32 | //tree.Insert(14, 14);
33 | //tree.Insert(15, 15);
34 |
35 | //tree.Insert(8, 8);
36 | //tree.Insert(9, 9);
37 | //tree.Insert(10, 10);
38 |
39 | for (int i = 0; i < 500; i++)
40 | {
41 | tree.Insert(i, i);
42 | Console.WriteLine("BPlusTree添加索引:{0}内容:{1}", i, i);
43 | Console.WriteLine("程序占用内存:{0}MB", (GC.GetTotalMemory(true) / 1024));
44 | Console.ReadKey();
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/NUnitBigCookieKit/UnitBigExport.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Office;
2 | using BigCookieKit.Office.Xlsx;
3 | using NUnit.Framework;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Data;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace NUnitBigCookieKit
13 | {
14 | public class UnitBigExport
15 | {
16 | DataSet bigData { get; set; }
17 |
18 | [SetUp]
19 | public void Setup()
20 | {
21 | bigData = new DataSet();
22 |
23 | DataTable dt = new DataTable();
24 |
25 | dt.Columns.Add("Field1");
26 | dt.Columns.Add("Field2");
27 | dt.Columns.Add("Field3");
28 | dt.Columns.Add("Field4");
29 | dt.Columns.Add("Field5");
30 | dt.Columns.Add("Field6");
31 | dt.Columns.Add("Field7");
32 | dt.Columns.Add("Field8");
33 |
34 | for (int i = 0; i < 1000000; i++)
35 | {
36 | dt.Rows.Add(new object[] { "value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8" });
37 | }
38 |
39 | bigData.Tables.Add(dt);
40 | }
41 |
42 |
43 | [Test]
44 | public void WriteExcelBigUnit()
45 | {
46 | string path1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WriteExcelBigUnit.xlsx");
47 | using (WriteExcelKit writeExcel = new WriteExcelKit(path1))
48 | {
49 | writeExcel.Save(bigData);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/GenericParameterStroke.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Reflection.Emit;
5 |
6 | namespace BigCookieKit.Reflect
7 | {
8 | public sealed class GenericParameterStroke
9 | {
10 | internal List> builders = new List>();
11 |
12 | internal GenericParameterStroke() { }
13 |
14 | public GenericParameterStroke ConstraintClass()
15 | {
16 | return ConstraintClass(typeof(T));
17 | }
18 |
19 | public GenericParameterStroke ConstraintClass(Type type)
20 | {
21 | builders.Add(x => x.SetBaseTypeConstraint(type));
22 | return this;
23 | }
24 |
25 | public GenericParameterStroke ConstraintInterface()
26 | {
27 | return ConstraintInterface(typeof(T));
28 | }
29 |
30 | public GenericParameterStroke ConstraintInterface(params Type[] type)
31 | {
32 | builders.Add(x => x.SetInterfaceConstraints(type));
33 | return this;
34 | }
35 |
36 | public GenericParameterStroke ConstraintQualifier(GenericQualifier GenericType)
37 | {
38 | builders.Add(x => x.SetGenericParameterAttributes((GenericParameterAttributes)GenericType));
39 | return this;
40 | }
41 |
42 | internal void Builder(GenericTypeParameterBuilder genericTypeParameter)
43 | {
44 | builders.ForEach(x => x.Invoke(genericTypeParameter));
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/GenericStroke.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Reflection.Emit;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BigCookieKit.Reflect
10 | {
11 | public sealed class GenericStroke
12 | {
13 | internal TypeBuilder typeBuilder;
14 |
15 | internal MethodBuilder methodBuilder;
16 |
17 | internal Dictionary parameterNames = new Dictionary();
18 |
19 | internal GenericStroke() { }
20 |
21 | internal GenericStroke(TypeBuilder typeBuilder)
22 | {
23 | this.typeBuilder = typeBuilder;
24 | }
25 |
26 | internal GenericStroke(MethodBuilder methodBuilder)
27 | {
28 | this.methodBuilder = methodBuilder;
29 | }
30 |
31 | public GenericParameterStroke AddGenericParameter(string name)
32 | {
33 | var stroke = new GenericParameterStroke();
34 | parameterNames.Add(name, stroke);
35 | return stroke;
36 | }
37 |
38 | internal void Builder()
39 | {
40 | GenericTypeParameterBuilder[] builders = null;
41 | builders ??= typeBuilder?.DefineGenericParameters(parameterNames.Select(x => x.Key).ToArray());
42 | builders ??= methodBuilder?.DefineGenericParameters(parameterNames.Select(x => x.Key).ToArray());
43 | foreach (var item in builders)
44 | parameterNames[item.Name].Builder(item);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/SingleEntryAsciiJumpTable.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace BigCookieKit.AspCore.RouteSelector
5 | {
6 | internal class SingleEntryAsciiJumpTable : JumpTable
7 | {
8 | private readonly int _defaultDestination;
9 | private readonly int _exitDestination;
10 | private readonly string _text;
11 | private readonly int _destination;
12 |
13 | public SingleEntryAsciiJumpTable(
14 | int defaultDestination,
15 | int exitDestination,
16 | string text,
17 | int destination)
18 | {
19 | _defaultDestination = defaultDestination;
20 | _exitDestination = exitDestination;
21 | _text = text;
22 | _destination = destination;
23 | }
24 |
25 | public override int GetDestination(string path, PathSegment segment)
26 | {
27 | var length = segment.Length;
28 | if (length == 0)
29 | {
30 | return _exitDestination;
31 | }
32 |
33 | var text = _text;
34 | if (length != text.Length)
35 | {
36 | return _defaultDestination;
37 | }
38 |
39 | var a = path.AsSpan(segment.Start, length);
40 | var b = text.AsSpan();
41 |
42 | return Ascii.AsciiIgnoreCaseEquals(a, b, length) ? _destination : _defaultDestination;
43 | }
44 |
45 | public override string DebuggerToString()
46 | {
47 | return $"{{ {_text}: {_destination}, $+: {_defaultDestination}, $0: {_exitDestination} }}";
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/SingleEntryJumpTable.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 |
4 | namespace BigCookieKit.AspCore.RouteSelector
5 | {
6 | internal class SingleEntryJumpTable : JumpTable
7 | {
8 | private readonly int _defaultDestination;
9 | private readonly int _exitDestination;
10 | private readonly string _text;
11 | private readonly int _destination;
12 |
13 | public SingleEntryJumpTable(
14 | int defaultDestination,
15 | int exitDestination,
16 | string text,
17 | int destination)
18 | {
19 | _defaultDestination = defaultDestination;
20 | _exitDestination = exitDestination;
21 | _text = text;
22 | _destination = destination;
23 | }
24 |
25 | public override int GetDestination(string path, PathSegment segment)
26 | {
27 | if (segment.Length == 0)
28 | {
29 | return _exitDestination;
30 | }
31 |
32 | if (segment.Length == _text.Length &&
33 | string.Compare(
34 | path,
35 | segment.Start,
36 | _text,
37 | 0,
38 | segment.Length,
39 | StringComparison.OrdinalIgnoreCase) == 0)
40 | {
41 | return _destination;
42 | }
43 |
44 | return _defaultDestination;
45 | }
46 |
47 | public override string DebuggerToString()
48 | {
49 | return $"{{ {_text}: {_destination}, $+: {_defaultDestination}, $0: {_exitDestination} }}";
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UnitAspExample/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | /* Provide sufficient contrast against white background */
11 | a {
12 | color: #0366d6;
13 | }
14 |
15 | .btn-primary {
16 | color: #fff;
17 | background-color: #1b6ec2;
18 | border-color: #1861ac;
19 | }
20 |
21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
22 | color: #fff;
23 | background-color: #1b6ec2;
24 | border-color: #1861ac;
25 | }
26 |
27 | /* Sticky footer styles
28 | -------------------------------------------------- */
29 | html {
30 | font-size: 14px;
31 | }
32 | @media (min-width: 768px) {
33 | html {
34 | font-size: 16px;
35 | }
36 | }
37 |
38 | .border-top {
39 | border-top: 1px solid #e5e5e5;
40 | }
41 | .border-bottom {
42 | border-bottom: 1px solid #e5e5e5;
43 | }
44 |
45 | .box-shadow {
46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
47 | }
48 |
49 | button.accept-policy {
50 | font-size: 1rem;
51 | line-height: inherit;
52 | }
53 |
54 | /* Sticky footer styles
55 | -------------------------------------------------- */
56 | html {
57 | position: relative;
58 | min-height: 100%;
59 | }
60 |
61 | body {
62 | /* Margin bottom by footer height */
63 | margin-bottom: 60px;
64 | }
65 | .footer {
66 | position: absolute;
67 | bottom: 0;
68 | width: 100%;
69 | white-space: nowrap;
70 | line-height: 60px; /* Vertically center the text there */
71 | }
72 |
--------------------------------------------------------------------------------
/BigCookieKit.Serialization/Binary/DateTimeFormatter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Serialization.Binary
6 | {
7 | public class DateTimeFormatter : FormatterBase
8 | {
9 | public Binary Host { get; set; }
10 |
11 | public int Priority { get; set; } = 2;
12 |
13 | public object Read(Type type)
14 | {
15 | if (type == typeof(DateTime))
16 | {
17 | var handle = Host.GetHandle();
18 | var obj = handle.Read(typeof(long));
19 | return DateTime.FromBinary((long)obj);
20 | }
21 | else if (type == typeof(TimeSpan))
22 | {
23 | var handle = Host.GetHandle();
24 | var obj = handle.Read(typeof(long));
25 | return TimeSpan.FromTicks((long)obj);
26 | }
27 |
28 | return Activator.CreateInstance(type);
29 | }
30 |
31 | public bool Write(object value)
32 | {
33 | var type = value.GetType();
34 |
35 | if (type == typeof(DateTime))
36 | {
37 | var tick = ((DateTime)value).Ticks;
38 | var handle = Host.GetHandle();
39 | return handle.Write(tick);
40 | }
41 | else if (type == typeof(TimeSpan))
42 | {
43 | var tick = ((TimeSpan)value).Ticks;
44 | var handle = Host.GetHandle();
45 | return handle.Write(tick);
46 | }
47 |
48 | return false;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/UnitAspExample/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright JS Foundation and other contributors, https://js.foundation/
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 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldDateTime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldDateTime : FieldManager
7 | {
8 | internal FieldDateTime(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 |
12 | public static FieldBoolean operator ==(FieldDateTime field, DateTime value)
13 | {
14 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
15 | }
16 |
17 | public static FieldBoolean operator ==(FieldDateTime field, LocalBuilder value)
18 | {
19 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
20 | }
21 |
22 | public static FieldBoolean operator ==(FieldDateTime field, FieldDateTime value)
23 | {
24 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
25 | }
26 |
27 | public static FieldBoolean operator !=(FieldDateTime field, DateTime value)
28 | {
29 | return ManagerGX.Comparer(
30 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
31 | field.NewInt32(), OpCodes.Ceq);
32 | }
33 |
34 | public static FieldBoolean operator !=(FieldDateTime field, LocalBuilder value)
35 | {
36 | return ManagerGX.Comparer(
37 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
38 | field.NewInt32(), OpCodes.Ceq);
39 | }
40 |
41 | public static FieldBoolean operator !=(FieldDateTime field, FieldDateTime value)
42 | {
43 | return ManagerGX.Comparer(
44 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
45 | field.NewInt32(), OpCodes.Ceq);
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/ListManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection.Emit;
4 |
5 | namespace BigCookieKit.Reflect
6 | {
7 | public class FieldList : FieldManager>
8 | {
9 | public FieldList(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
10 | {
11 | }
12 |
13 | public void Add(LocalBuilder value)
14 | {
15 | Call("Add", value);
16 | }
17 |
18 | public FieldBoolean Contains(LocalBuilder value)
19 | {
20 | return new FieldBoolean(Call("Contains", value).ReturnRef(), generator);
21 | }
22 |
23 | public void RemoveAt(LocalBuilder value)
24 | {
25 | Call("RemoveAt", value);
26 | }
27 |
28 | public CanCompute GetCount()
29 | {
30 | return new CanCompute(Call("get_Count").ReturnRef(), generator);
31 | }
32 | }
33 |
34 | public class FieldList : FieldManager
35 | {
36 | public FieldList(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
37 | {
38 | }
39 |
40 | public void Add(LocalBuilder value)
41 | {
42 | Call("Add", value);
43 | }
44 |
45 | public FieldBoolean Contains(LocalBuilder value)
46 | {
47 | return new FieldBoolean(Call("Contains", value).ReturnRef(), generator);
48 | }
49 |
50 | public void RemoveAt(LocalBuilder value)
51 | {
52 | Call("RemoveAt", value);
53 | }
54 |
55 | public CanCompute GetCount()
56 | {
57 | return new CanCompute(Call("get_Count").ReturnRef(), generator);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/UnitAspExample/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using BigCookie.Document;
2 |
3 | using BigCookieKit.AspCore.RouteSelector;
4 |
5 | using Microsoft.AspNetCore.Http;
6 | using Microsoft.AspNetCore.Mvc;
7 | using Microsoft.AspNetCore.Mvc.Abstractions;
8 | using Microsoft.AspNetCore.Mvc.Controllers;
9 | using Microsoft.AspNetCore.Mvc.Infrastructure;
10 | using Microsoft.AspNetCore.Routing;
11 | using Microsoft.AspNetCore.Routing.Patterns;
12 | using Microsoft.Extensions.DependencyInjection;
13 | using Microsoft.Extensions.Logging;
14 |
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Diagnostics;
18 | using System.Linq;
19 | using System.Reflection;
20 | using System.Threading.Tasks;
21 |
22 | using UnitAspExample.Models;
23 |
24 | namespace UnitAspExample.Controllers
25 | {
26 | ///
27 | /// 主页
28 | ///
29 | public class HomeController : Controller
30 | {
31 | private readonly ILogger _logger;
32 |
33 | public HomeController(ILogger logger)
34 | {
35 | _logger = logger;
36 | }
37 |
38 | ///
39 | /// 默认API
40 | ///
41 | ///
42 | public IActionResult Index()
43 | {
44 | return View();
45 | }
46 |
47 | [Route("Privacy")]
48 | public IActionResult Privacy()
49 | {
50 | return View();
51 | }
52 |
53 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
54 | public IActionResult Error()
55 | {
56 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/PropertyStroke.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System;
3 | using System.Reflection;
4 | using System.Reflection.Emit;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace BigCookieKit.Reflect
8 | {
9 | public sealed class PropertyStroke
10 | {
11 | internal PropertyBuilder propertyBuilder;
12 |
13 | internal FieldStroke fieldStroke;
14 |
15 | internal PropertyStroke() { }
16 |
17 | internal PropertyStroke(PropertyBuilder propertyBuilder, FieldStroke fieldStroke)
18 | {
19 | this.propertyBuilder = propertyBuilder;
20 | this.fieldStroke = fieldStroke;
21 | }
22 |
23 | public void Constant(T constant)
24 | {
25 | fieldStroke.Constant(constant);
26 | }
27 |
28 | public void Constant(MethodInfo method, params LocalBuilder[] parameters)
29 | {
30 | fieldStroke.Constant(method, parameters);
31 | }
32 |
33 | public LocalBuilder GetValue(FuncGenerator generator)
34 | {
35 | return fieldStroke.GetValue(generator);
36 | }
37 |
38 | public void SetValue(FuncGenerator generator, LocalBuilder constant)
39 | {
40 | fieldStroke.SetValue(generator, constant);
41 | }
42 |
43 | public PropertyStroke AddAttribute(Type type, params object[] args)
44 | {
45 | propertyBuilder.SetCustomAttribute(new CustomAttributeBuilder(type.GetConstructor(args.Select(x => x.GetType()).ToArray()), args));
46 | return this;
47 | }
48 |
49 | public PropertyStroke AddAttribute(ConstructorInfo ctor, params byte[] binary)
50 | {
51 | propertyBuilder.SetCustomAttribute(ctor, binary);
52 | return this;
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/DependencyInjection/AutoDependencyInjection.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace BigCookieKit.AspCore.DependencyInjection
11 | {
12 | ///
13 | /// 自动依赖注入类
14 | ///
15 | public static class DependencyInjectionImplementation
16 | {
17 | ///
18 | /// 自动注入方法
19 | ///
20 | /// 规则:
21 | /// 1.接口类为实现类名称前面增加I标识
22 | /// 2.实现类标注[AutoInjection]属性
23 | ///
24 | ///
25 | ///
26 | public static void AutoDependencyInjection(this IServiceCollection services)
27 | {
28 | var path = AppDomain.CurrentDomain.BaseDirectory;
29 | var dir = new System.IO.DirectoryInfo(path);
30 | var dlls = dir.GetFiles("*.dll");
31 | foreach (var dll in dlls)
32 | {
33 | var assembly = Assembly.LoadFrom(dll.FullName);
34 | if (assembly.ExportedTypes.Count() > 0)
35 | {
36 | var autoInjectionService = assembly.ExportedTypes.Where(x => x.GetCustomAttribute() != null);
37 | if (autoInjectionService.Count() > 0)
38 | {
39 | foreach (var service in autoInjectionService)
40 | {
41 | var Interface = service.GetInterface("I" + service.Name);
42 | services.AddScoped(Interface, service);
43 | }
44 | }
45 | }
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/NUnitBigCookieKit/NUnitBigCookieKit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | Always
31 |
32 |
33 | Always
34 |
35 |
36 | Always
37 |
38 |
39 | Always
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/TcpServerExmaple/Program.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Network;
2 |
3 | using System;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 |
9 | namespace TcpServerExmaple
10 | {
11 | class Program
12 | {
13 | static int connection = 0;
14 |
15 | static void Main(string[] args)
16 | {
17 | Console.Title = $"连接数:{connection}";
18 | NetworkServer tcpServer = new NetworkServer(7447);
19 | tcpServer.BufferSize = 4096;
20 | tcpServer.OnConnect = user =>
21 | {
22 | Console.WriteLine($"{user.UserHost}:{user.UserPort}接入~");
23 | Interlocked.Increment(ref connection);
24 | Console.Title = $"连接数:{connection}";
25 | };
26 |
27 | tcpServer.OnReceive = (user, packet) =>
28 | {
29 | string res = Encoding.UTF8.GetString(packet);
30 | Console.WriteLine($"[{user.UserHost}:{user.UserPort}]:{res}");
31 | //user.SendMessage("收到~");
32 | };
33 |
34 | tcpServer.OnExit = user =>
35 | {
36 | Console.WriteLine($"{user.UserHost}:{user.UserPort}离开~");
37 | Interlocked.Decrement(ref connection);
38 | Console.Title = $"连接数:{connection}";
39 | };
40 |
41 | //tcpServer.Handle = new EasyHandle();
42 | //tcpServer.Handle.AddPipe();
43 |
44 | tcpServer.Start();
45 |
46 | Thread.Sleep(-1);
47 | }
48 | }
49 |
50 | class TestPipe : IPipe
51 | {
52 | public async Task InvokeAsync(Session session, Action context)
53 | {
54 | Console.WriteLine("接收前1");
55 | context?.Invoke();
56 | Console.WriteLine("接收后1");
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/MethodStroke.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using System.Reflection.Emit;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace BigCookieKit.Reflect
8 | {
9 | public sealed class MethodStroke
10 | {
11 | internal MethodBuilder methodBuilder;
12 |
13 | internal FuncGenerator generator;
14 |
15 | internal MethodStroke() { }
16 |
17 | internal MethodStroke(MethodBuilder methodBuilder)
18 | {
19 | this.methodBuilder = methodBuilder;
20 | generator = new FuncGenerator(methodBuilder.GetILGenerator());
21 | }
22 |
23 | public MethodStroke Builder(Action builder)
24 | {
25 | builder(generator);
26 | return this;
27 | }
28 |
29 | public MethodStroke AddAttribute(Type type, params object[] args)
30 | {
31 | methodBuilder.SetCustomAttribute(new CustomAttributeBuilder(type.GetConstructor(args.Select(x => x.GetType()).ToArray()), args));
32 | return this;
33 | }
34 |
35 | public MethodStroke AddAttribute(ConstructorInfo ctor, params byte[] binary)
36 | {
37 | methodBuilder.SetCustomAttribute(ctor, binary);
38 | return this;
39 | }
40 |
41 | public MethodStroke AddGeneric(params string[] typeNames)
42 | {
43 | methodBuilder.DefineGenericParameters(typeNames);
44 | return this;
45 | }
46 |
47 | public MethodStroke AddGeneric(Action stroke)
48 | {
49 | var generic = new GenericStroke(methodBuilder);
50 | stroke.Invoke(generic);
51 | generic.Builder();
52 | return this;
53 | }
54 |
55 | public void End()
56 | {
57 | generator.Return();
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/UnitAspExample/Controllers/TestController.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.AspCore.RouteSelector;
2 |
3 | using Microsoft.AspNetCore.Mvc;
4 | using Microsoft.AspNetCore.Mvc.Controllers;
5 | using Microsoft.AspNetCore.Routing;
6 |
7 | using System;
8 | using System.Collections.Generic;
9 | using System.Linq;
10 | using System.Threading.Tasks;
11 |
12 | namespace UnitAspExample.Controllers
13 | {
14 | ///
15 | /// 测试控制器
16 | ///
17 | [Route("BigTest/[controller]")]
18 | public class TestController : Controller
19 | {
20 | ///
21 | /// 测试接口
22 | ///
23 | ///
24 | [HttpGet]
25 | [Route("Index")]
26 | public IActionResult Index()
27 | {
28 | ViewBag.Data = "测试";
29 | return Ok("成功");
30 | }
31 |
32 | ///
33 | /// 测试路由选择器
34 | ///
35 | ///
36 | [HttpGet]
37 | [Route("TestSelector")]
38 | public IActionResult TestSelector()
39 | {
40 | var dendpoint = HttpContext.RequestServices.MathEndpoint("/Home").Result;
41 | var selectorResult = dendpoint.InvokeAsync(HttpContext)?.Result;
42 | var data = selectorResult.ViewBag.Data;
43 | return Ok("测试成功!");
44 | }
45 |
46 | ///
47 | /// 测试路由描述符
48 | ///
49 | ///
50 | [HttpGet]
51 | [Route("Test2Selector")]
52 | public IActionResult Test2Selector([FromServices] EndpointDataSource dataSource)
53 | {
54 | var endpoint = dataSource.Endpoints.FirstOrDefault(x => x.GetRoutePath() == "/Home");
55 | var selectorResult = endpoint.InvokeAsync(HttpContext)?.Result;
56 | var data = selectorResult.ViewBag.Data;
57 | return Ok("测试成功!");
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/Ascii.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace BigCookieKit.AspCore.RouteSelector
7 | {
8 | internal static class Ascii
9 | {
10 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
11 | public static bool AsciiIgnoreCaseEquals(ReadOnlySpan a, ReadOnlySpan b, int length)
12 | {
13 | if (a.Length < length || b.Length < length)
14 | {
15 | ThrowArgumentExceptionForLength();
16 | }
17 |
18 | ref var charA = ref MemoryMarshal.GetReference(a);
19 | ref var charB = ref MemoryMarshal.GetReference(b);
20 |
21 | while (length > 0 && AsciiIgnoreCaseEquals(charA, charB))
22 | {
23 | charA = ref Unsafe.Add(ref charA, 1);
24 | charB = ref Unsafe.Add(ref charB, 1);
25 | length--;
26 | }
27 |
28 | return length == 0;
29 | }
30 |
31 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
32 | public static bool AsciiIgnoreCaseEquals(char charA, char charB)
33 | {
34 | const uint AsciiToLower = 0x20;
35 | return
36 | charA == charB ||
37 |
38 | ((charA | AsciiToLower) == (charB | AsciiToLower) && (uint)((charA | AsciiToLower) - 'a') <= (uint)('z' - 'a'));
39 | }
40 |
41 | public static bool IsAscii(string text)
42 | {
43 | for (var i = 0; i < text.Length; i++)
44 | {
45 | if (text[i] > (char)0x7F)
46 | {
47 | return false;
48 | }
49 | }
50 |
51 | return true;
52 | }
53 |
54 | private static void ThrowArgumentExceptionForLength()
55 | {
56 | throw new ArgumentException("length");
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BPlusTree/BTreeNodeElementInterstice.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BPlusTree
4 | {
5 | public class BTreeNodeElementInterstice where T : class, IComparable
6 | {
7 | private BTreeNode container;
8 | private BTreeNode nodePointer;
9 |
10 | public BTreeNodeElementInterstice(BTreeNode pointer, BTreeNodeElement smaller, BTreeNodeElement larger)
11 | {
12 | Smaller = smaller;
13 | Larger = larger;
14 | NodePointer = pointer;
15 | }
16 |
17 | public BTreeNodeElementInterstice(BTreeNodeElement smaller, BTreeNodeElement larger)
18 | : this(new NullBTreeNode(), smaller, larger)
19 | {
20 | }
21 |
22 | public BTreeNode NodePointer
23 | {
24 | get { return nodePointer; }
25 | set
26 | {
27 | nodePointer = value;
28 | if (nodePointer == null) return;
29 | nodePointer.Parent = container;
30 | }
31 | }
32 |
33 | public BTreeNodeElement Smaller { get; set; }
34 |
35 | public BTreeNodeElement Larger { get; set; }
36 |
37 | public BTreeNodeElementInterstice Next
38 | {
39 | get
40 | {
41 | if (Larger == null) return null;
42 | return Larger.NextInterval;
43 | }
44 | }
45 |
46 | public BTreeNode Container
47 | {
48 | set
49 | {
50 | container = value;
51 | if (nodePointer == null) return;
52 | nodePointer.Parent = container;
53 | }
54 | }
55 | }
56 |
57 | public class NullBTreeNode : BTreeNode where T : class, IComparable
58 | {
59 | public NullBTreeNode() : base(0, null)
60 | {
61 | }
62 |
63 | public override string ToString()
64 | {
65 | return string.Empty;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/TcpClientExmaple/Program.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Network;
2 |
3 | using System;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | namespace TcpClientExmaple
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | NetworkClient client = new NetworkClient("127.0.0.1", 7447);
15 |
16 | client.OnConnect = user =>
17 | {
18 | Random random = new Random();
19 | while (true)
20 | {
21 | var message = Console.ReadLine();
22 | user.SendMessage(message);
23 |
24 | //user.SendMessage(RamdomString());
25 | //string str = Console.ReadLine();
26 | //switch (str)
27 | //{
28 | // case "close":
29 | // user.Disconnect();
30 | // break;
31 | // default:
32 | // user.SendMessage(str);
33 | // break;
34 | //}
35 | }
36 | };
37 |
38 | client.OnCallBack = (user, packet) =>
39 | {
40 | Console.WriteLine(Encoding.UTF8.GetString(packet));
41 | };
42 |
43 | //client.Handle = new EasyHandle();
44 | client.Start();
45 |
46 | Thread.Sleep(-1);
47 | }
48 |
49 | public static byte[] RamdomString(int length = 1024)
50 | {
51 | var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
52 | var stringChars = new char[length];
53 | var random = new Random();
54 | for (int i = 0; i < length; i++)
55 | {
56 | stringChars[i] = chars[random.Next(chars.Length - 1)];
57 | }
58 | return System.Text.Encoding.UTF8.GetBytes(stringChars);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BigCookieKit/XML/CookieTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Text;
5 |
6 | namespace BigCookieKit.XML
7 | {
8 | ///
9 | /// 重构DataTable适应于BigCookie的框架数据调度
10 | ///
11 | public class CookieTable
12 | {
13 | public List Columns { get; set; }
14 |
15 | public List Rows { get; set; }
16 |
17 | public CookieTable()
18 | {
19 | Columns = new List();
20 | Rows = new List();
21 | }
22 |
23 | public void AddColumn(string ColumnName, Type ColumnType, string Formula = null)
24 | {
25 | Columns.Add(new CookieColumn()
26 | {
27 | ColumnName = ColumnName,
28 | ColumnType = ColumnType,
29 | Formula = Formula,
30 | });
31 | }
32 |
33 | public void AddRow(params object[] value)
34 | {
35 | if (value.Length > Columns.Count)
36 | throw new IndexOutOfRangeException();
37 |
38 | CookieRow ncr = new CookieRow();
39 | ncr.Cells = new CookieCell[Columns.Count];
40 | for (int i = 0; i < value.Length; i++)
41 | {
42 | ncr.Cells[i].Column = Columns[i];
43 | ncr.Cells[i].Value = value[i];
44 | }
45 | Rows.Add(ncr);
46 | }
47 | }
48 |
49 | public class CookieColumn
50 | {
51 | public string Formula { get; set; }
52 |
53 | public Type ColumnType { get; set; }
54 |
55 | public string ColumnName { get; set; }
56 | }
57 |
58 | public class CookieRow
59 | {
60 | public CookieCell[] Cells { get; set; }
61 | }
62 |
63 | public struct CookieCell
64 | {
65 | public CookieColumn Column { get; set; }
66 |
67 | public string Formula { get; set; }
68 |
69 | public object Value { get; set; }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/UnitConsole/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BenchmarkDotNet.Running;
3 | using BenchmarkDotNet.Configs;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Net.Http;
7 | using System.Threading.Tasks.Dataflow;
8 | using System.Threading.Tasks;
9 | using System.Threading;
10 | using BigCookieKit.Reflect;
11 | using System.Linq.Expressions;
12 | using System.Text;
13 | using System.Text.Json.Serialization;
14 | using System.Net.Sockets;
15 | using System.Reflection;
16 | using BigCookieKit.IO;
17 | using System.Collections.Generic;
18 | using BigCookieKit.Algorithm;
19 | using System.Security.Cryptography;
20 | using BigCookieKit;
21 | using BigCookieKit.Rpc;
22 | using System.Security.Claims;
23 | using BigCookieKit.Serialization.Binary;
24 |
25 | namespace UnitConsole
26 | {
27 | class Program
28 | {
29 | public class ActorModel
30 | {
31 | public Actor Actor { get; set; }
32 |
33 | public object Packet { get; set; }
34 | }
35 |
36 | static void Main(string[] args)
37 | {
38 | //BenchmarkRunner.Run();
39 |
40 | //RpcClient api = new RpcClient("127.0.0.1", 8888);
41 | //IApiContact api1 = api.GetInstance();
42 | //api1.Test("name");
43 |
44 | GeneralFormatter general = new GeneralFormatter();
45 |
46 | //Actor actor = new Actor((items) =>
47 | //{
48 | // foreach (var item in items)
49 | // {
50 | // Console.WriteLine("收到:" + item);
51 | // }
52 | //}, 10, int.MaxValue, 1);
53 |
54 | //for (int i = 0; i < 5; i++)
55 | //{
56 | // actor.Post(i.ToString());
57 | //}
58 | //actor.Complete();
59 |
60 | Console.ReadKey();
61 | }
62 | }
63 |
64 | public interface IApiContact
65 | {
66 | public void Ok();
67 |
68 | public void Test(string name);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/ClassStroke.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using System.Reflection.Emit;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace BigCookieKit.Reflect
8 | {
9 | public sealed class ClassStroke
10 | {
11 | internal TypeBuilder typeBuilder;
12 |
13 | internal ConstructorBuilder publicBuilder;
14 |
15 | internal ConstructorBuilder staticBuilder;
16 |
17 | internal ClassStroke() { }
18 |
19 | internal ClassStroke(TypeBuilder typeBuilder, ConstructorBuilder publicBuilder, ConstructorBuilder staticBuilder)
20 | {
21 | this.typeBuilder = typeBuilder;
22 | this.publicBuilder = publicBuilder;
23 | this.staticBuilder = staticBuilder;
24 | }
25 |
26 | public ClassStroke AddAttribute(Type type, params object[] args)
27 | {
28 | typeBuilder.SetCustomAttribute(new CustomAttributeBuilder(type.GetConstructor(args.Select(x => x.GetType()).ToArray()), args));
29 | return this;
30 | }
31 |
32 | public ClassStroke AddAttribute(ConstructorInfo ctor, params byte[] binary)
33 | {
34 | typeBuilder.SetCustomAttribute(ctor, binary);
35 | return this;
36 | }
37 |
38 | public ClassStroke AddGeneric(params string[] typeNames)
39 | {
40 | typeBuilder.DefineGenericParameters(typeNames);
41 | return this;
42 | }
43 |
44 | public ClassStroke AddGeneric(Action stroke)
45 | {
46 | var generic = new GenericStroke(typeBuilder);
47 | stroke.Invoke(generic);
48 | generic.Builder();
49 | return this;
50 | }
51 |
52 | public ClassStroke InheritClass(Type type)
53 | {
54 | typeBuilder.SetParent(type);
55 | return this;
56 | }
57 |
58 | public ClassStroke InheritInterface(Type type)
59 | {
60 | typeBuilder.AddInterfaceImplementation(type);
61 | return this;
62 | }
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Apm/ApmLoggerFilter.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit;
2 | using BigCookieKit.Algorithm;
3 |
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 |
8 | using System;
9 | using System.Diagnostics;
10 | using System.IO;
11 | using System.Threading.Tasks;
12 |
13 | namespace BigCookieKit.AspCore.Apm
14 | {
15 | public class ApmLoggerFilter
16 | {
17 | private readonly RequestDelegate _next;
18 |
19 | public int Count { get; set; }
20 |
21 | public ApmLoggerFilter(RequestDelegate next)
22 | {
23 | _next = next;
24 | }
25 |
26 | public async Task Invoke(HttpContext context)
27 | {
28 | Stopwatch stopwatch = Stopwatch.StartNew();
29 | if (string.IsNullOrEmpty(context.Request.Headers["TraceId"]))
30 | {
31 | context.Request.Headers.Add("TraceId", Snowflake.NextId().ToString());
32 | }
33 | string message = string.Empty;
34 |
35 | var orginstream = context.Response.Body;
36 | using var stream = new MemoryStream();
37 | context.Response.Body = stream;
38 |
39 | try
40 | {
41 | await _next?.Invoke(context);
42 | }
43 | catch (Exception ex)
44 | {
45 | message = ex.Message;
46 | }
47 | stopwatch.Stop();
48 |
49 | var configuration = context.RequestServices.GetService();
50 | switch (configuration.GetSection("ApmLogger:LoggerType")?.Value)
51 | {
52 | case "Console":
53 | ApmLoggerCore.ConsoleApiLogger(context, stopwatch, message);
54 | break;
55 | case "SQLite":
56 | ApmLoggerCore.SQLiteApiLogger(context, stopwatch, message);
57 | break;
58 | }
59 |
60 | await stream.CopyToAsync(orginstream);
61 | context.Response.Body = orginstream;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/UnitBenchmark/ExcelReadBenchmark.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Attributes;
2 | using BigCookieKit.Office.Xlsx;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Data;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace UnitBenchmark
12 | {
13 | public class ExcelReadBenchmark
14 | {
15 | public readonly string resource = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources");
16 |
17 | [Benchmark]
18 | public void MiniRead()
19 | {
20 | string path = Path.Combine(resource, "test.xlsx");
21 | var rows = MiniExcelLibs.MiniExcel.Query(path);
22 |
23 | //自行转换成DataTable
24 | DataTable dt = new DataTable();
25 | foreach (var item in rows)
26 | {
27 | if (dt.Columns.Count == 0)
28 | {
29 | foreach (var item1 in (IDictionary)item)
30 | dt.Columns.Add(item1.Key);
31 | }
32 | else
33 | {
34 | DataRow ndr = dt.NewRow();
35 | foreach (var item1 in (IDictionary)item)
36 | {
37 | if (dt.Columns[item1.Key].DataType != item1.Value.GetType())
38 | dt.Columns[item1.Key].DataType = item1.Value.GetType();
39 | ndr[item1.Key] = item1.Value;
40 | }
41 | dt.Rows.Add(ndr);
42 | }
43 | }
44 |
45 | }
46 |
47 | [Benchmark]
48 | public void XmlRead()
49 | {
50 | string path = Path.Combine(resource, "test.xlsx");
51 | ReadExcelKit excelKit = new ReadExcelKit(path);
52 | excelKit.AddConfig(config =>
53 | {
54 | config.SheetIndex = 1;
55 | config.ColumnNameRow = 1;
56 | config.StartRow = 2;
57 | });
58 | DataTable dt = excelKit.XmlReadDataTable();
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/EntityFramework/EntityFrameworkKit.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore.Infrastructure;
3 | using Microsoft.EntityFrameworkCore.Storage;
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Data;
8 | using System.Data.Common;
9 | using System.Runtime.CompilerServices;
10 | using System.Text;
11 |
12 | namespace BigCookieKit.EntityFramework
13 | {
14 | public static class EntityFrameworkKit
15 | {
16 | ///
17 | /// 根据SQL获取DataTable
18 | ///
19 | public static DataTable ReadDataTable(this DbContext context, string sql, params DbParameter[] parameters)
20 | {
21 | return SqlToDataSet(context.Database, sql, parameters).Tables[0];
22 | }
23 |
24 | ///
25 | /// 根据SQL获取DataSet
26 | ///
27 | public static DataSet ReadDataSet(this DbContext context, string sql, params DbParameter[] parameters)
28 | {
29 | return SqlToDataSet(context.Database, sql, parameters);
30 | }
31 |
32 | ///
33 | /// 获取自定义sql的结果集
34 | ///
35 | private static DataSet SqlToDataSet(DatabaseFacade facade, string sql, params DbParameter[] parameters)
36 | {
37 | var ds = new DataSet();
38 | var con = facade.GetDbConnection();
39 |
40 | if (con.State != ConnectionState.Open) con.Open();
41 | using (var cmd = con.CreateCommand())
42 | {
43 | cmd.CommandText = sql;
44 | cmd.Parameters.AddRange(parameters);
45 | cmd.Transaction = facade.CurrentTransaction?.GetDbTransaction();
46 |
47 | using (var reader = cmd.ExecuteReader())
48 | {
49 | while (!reader.IsClosed)
50 | {
51 | var dt = new DataTable();
52 | dt.Load(reader);
53 | ds.Tables.Add(dt);
54 | }
55 | }
56 | }
57 | return ds;
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/DictionaryJumpTable.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace BigCookieKit.AspCore.RouteSelector
9 | {
10 | internal class DictionaryJumpTable : JumpTable
11 | {
12 | private readonly int _defaultDestination;
13 | private readonly int _exitDestination;
14 | private readonly Dictionary _dictionary;
15 |
16 | public DictionaryJumpTable(
17 | int defaultDestination,
18 | int exitDestination,
19 | (string text, int destination)[] entries)
20 | {
21 | _defaultDestination = defaultDestination;
22 | _exitDestination = exitDestination;
23 |
24 | _dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
25 | for (var i = 0; i < entries.Length; i++)
26 | {
27 | _dictionary.Add(entries[i].text, entries[i].destination);
28 | }
29 | }
30 |
31 | public override int GetDestination(string path, PathSegment segment)
32 | {
33 | if (segment.Length == 0)
34 | {
35 | return _exitDestination;
36 | }
37 |
38 | var text = path.Substring(segment.Start, segment.Length);
39 | if (_dictionary.TryGetValue(text, out var destination))
40 | {
41 | return destination;
42 | }
43 |
44 | return _defaultDestination;
45 | }
46 |
47 | public override string DebuggerToString()
48 | {
49 | var builder = new StringBuilder();
50 | builder.Append("{ ");
51 |
52 | builder.AppendJoin(", ", _dictionary.Select(kvp => $"{kvp.Key}: {kvp.Value}"));
53 |
54 | builder.Append("$+: ");
55 | builder.Append(_defaultDestination);
56 | builder.Append(", ");
57 |
58 | builder.Append("$0: ");
59 | builder.Append(_defaultDestination);
60 |
61 | builder.Append(" }");
62 |
63 | return builder.ToString();
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/BigCookieKit.Office/Xlsx/ExcelConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BigCookieKit.Office.Xlsx
8 | {
9 | public class ExcelConfig
10 | {
11 | ///
12 | /// 工作簿索引
13 | ///
14 | public int SheetIndex { get; set; }
15 |
16 | ///
17 | /// 列名索引行 不设置则自动列名 例:Colume1 Colume2
18 | ///
19 | public int? ColumnNameRow { get; set; }
20 |
21 | ///
22 | /// 开始的行 跟Excal左边对应
23 | ///
24 | public int? StartRow { get; set; } = 1;
25 |
26 | ///
27 | /// 结束的行
28 | ///
29 | public int? EndRow { get; set; }
30 |
31 | ///
32 | /// 开始的列 跟Excal上边对应
33 | ///
34 | public string StartColumn
35 | {
36 | get
37 | {
38 | return _StartColumn;
39 | }
40 | set
41 | {
42 | StartColumnIndex = ExcelHelper.ColumnToIndex(value);
43 | _StartColumn = value;
44 | }
45 | }
46 |
47 | ///
48 | /// 开始的列索引
49 | ///
50 | public int? StartColumnIndex { get; set; }
51 |
52 | ///
53 | /// 结束的列
54 | ///
55 | public string EndColumn
56 | {
57 | get
58 | {
59 | return _EndColumn;
60 | }
61 | set
62 | {
63 | EndColumnIndex = ExcelHelper.ColumnToIndex(value).GetValueOrDefault();
64 | _EndColumn = value;
65 | }
66 | }
67 |
68 | ///
69 | /// 结束的列索引
70 | ///
71 | public int? EndColumnIndex { get; set; }
72 |
73 | ///
74 | /// 列的配置
75 | ///
76 | public ColumnConfig[] ColumnSetting { get; set; }
77 |
78 | private string _StartColumn;
79 | private string _EndColumn;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/BigCookieKit/Kit.Compress.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.IO.Compression;
5 | using System.Text;
6 | using System.Linq;
7 | using System.Runtime.CompilerServices;
8 |
9 | namespace BigCookieKit
10 | {
11 | public static partial class Kit
12 | {
13 | ///
14 | /// 全局压缩方式
15 | ///
16 | public static CompressionLevel compressionLevel { get; set; } = CompressionLevel.NoCompression;
17 |
18 | ///
19 | /// 文件夹所有文件压缩到Zip
20 | ///
21 | /// Zip文件目标路径
22 | /// 文件夹路径
23 | public static bool DirToFormZipPacket(string zipFilePath, string dirPath)
24 | {
25 | FileInfo zipFile = new FileInfo(zipFilePath);
26 | if (!zipFile.Exists)
27 | {
28 | DirectoryInfo dir = new DirectoryInfo(dirPath);
29 | if (!dir.Exists)
30 | return false;
31 | ZipFile.CreateFromDirectory(dir.FullName, zipFile.FullName, compressionLevel, true);
32 | return true;
33 | }
34 | return false;
35 | }
36 |
37 | ///
38 | /// 文件压缩到Zip
39 | ///
40 | /// Zip文件目标路径
41 | /// 所有的文件路径
42 | ///
43 | public static bool FileToFormZipPacket(string zipFilePath, params string[] filesPath)
44 | {
45 | FileInfo zipFile = new FileInfo(zipFilePath);
46 | if (zipFile.Exists)
47 | {
48 | using (var archive = ZipFile.Open(zipFile.FullName, ZipArchiveMode.Update))
49 | {
50 | foreach (var item in filesPath)
51 | {
52 | FileInfo file = new FileInfo(item);
53 | archive.CreateEntryFromFile(file.FullName, file.Name);
54 | }
55 | }
56 | return true;
57 | }
58 | return false;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BigCookieKit.Serialization/Binary/GeneralFormatter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Reflection;
5 | using System.Text;
6 |
7 | namespace BigCookieKit.Serialization.Binary
8 | {
9 | public class GeneralFormatter : FormatterBase
10 | {
11 | private Dictionary ReadCache { get; set; }
12 |
13 | private Dictionary WriteCache { get; set; }
14 |
15 | public Binary Host { get; set; }
16 |
17 | public int Priority { get; set; } = 1;
18 |
19 | public GeneralFormatter()
20 | {
21 | WriteCache = new Dictionary();
22 | foreach (var item in typeof(BinaryWriter).GetMethods())
23 | {
24 | if (item.Name == "Write")
25 | {
26 | var parameters = item.GetParameters();
27 | if (parameters.Length == 1)
28 | {
29 | WriteCache.Add(parameters[0].ParameterType, item);
30 | }
31 | }
32 | }
33 |
34 | ReadCache = new Dictionary();
35 | foreach (var type in WriteCache.Keys)
36 | {
37 | var read = typeof(BinaryReader).GetMethod($"Read{type.Name.Replace("[]", "s")}");
38 | if (read != null)
39 | {
40 | ReadCache.Add(type, read);
41 | }
42 | }
43 | }
44 |
45 | public object Read(Type type)
46 | {
47 | if (ReadCache.ContainsKey(type))
48 | {
49 | BinaryReader read = new BinaryReader(Host.Stream);
50 | return ReadCache[type].Invoke(read, null);
51 | }
52 |
53 | return Activator.CreateInstance(type);
54 | }
55 |
56 | public bool Write(object value)
57 | {
58 | var type = value.GetType();
59 |
60 | if (WriteCache.ContainsKey(type))
61 | {
62 | BinaryWriter writer = new BinaryWriter(Host.Stream);
63 | WriteCache[type].Invoke(writer, new object[] { value });
64 | }
65 |
66 | return false;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/LinearSearchJumpTable.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Data;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace BigCookieKit.AspCore.RouteSelector
8 | {
9 | internal class LinearSearchJumpTable : JumpTable
10 | {
11 | private readonly int _defaultDestination;
12 | private readonly int _exitDestination;
13 | private readonly (string text, int destination)[] _entries;
14 |
15 | public LinearSearchJumpTable(
16 | int defaultDestination,
17 | int exitDestination,
18 | (string text, int destination)[] entries)
19 | {
20 | _defaultDestination = defaultDestination;
21 | _exitDestination = exitDestination;
22 | _entries = entries;
23 | }
24 |
25 | public override int GetDestination(string path, PathSegment segment)
26 | {
27 | if (segment.Length == 0)
28 | {
29 | return _exitDestination;
30 | }
31 |
32 | var entries = _entries;
33 | for (var i = 0; i < entries.Length; i++)
34 | {
35 | var text = entries[i].text;
36 | if (segment.Length == text.Length &&
37 | string.Compare(
38 | path,
39 | segment.Start,
40 | text,
41 | 0,
42 | segment.Length,
43 | StringComparison.OrdinalIgnoreCase) == 0)
44 | {
45 | return entries[i].destination;
46 | }
47 | }
48 |
49 | return _defaultDestination;
50 | }
51 |
52 | public override string DebuggerToString()
53 | {
54 | var builder = new StringBuilder();
55 | builder.Append("{ ");
56 |
57 | builder.AppendJoin(", ", _entries.Select(e => $"{e.text}: {e.destination}"));
58 |
59 | builder.Append("$+: ");
60 | builder.Append(_defaultDestination);
61 | builder.Append(", ");
62 |
63 | builder.Append("$0: ");
64 | builder.Append(_defaultDestination);
65 |
66 | builder.Append(" }");
67 |
68 | return builder.ToString();
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/UnitAspExample/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @ViewData["Title"] - UnitAspExample
7 |
8 |
9 |
10 |
11 |
32 |
33 |
34 | @RenderBody()
35 |
36 |
37 |
38 |
43 |
44 |
45 |
46 | @await RenderSectionAsync("Scripts", required: false)
47 |
48 |
49 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldNullable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Reflection.Emit;
4 |
5 | namespace BigCookieKit.Reflect
6 | {
7 | public class FieldNullable : FieldManager where T : struct
8 | {
9 | internal MethodInfo ValueInfo { get; set; }
10 |
11 | internal MethodInfo HasValueInfo { get; set; }
12 |
13 | internal MethodInfo GetValueOrDefaultInfo { get; set; }
14 |
15 | internal FieldNullable(LocalBuilder stack, ILGenerator generator) : base(ToNullable(stack, generator), generator)
16 | {
17 | ValueInfo = typeof(Nullable).GetProperty("Value").GetGetMethod();
18 | HasValueInfo = typeof(Nullable).GetProperty("HasValue").GetGetMethod();
19 | GetValueOrDefaultInfo = typeof(Nullable).GetMethod("GetValueOrDefault", Type.EmptyTypes);
20 | }
21 |
22 | internal static LocalBuilder ToNullable(LocalBuilder stack, ILGenerator generator)
23 | {
24 | LocalBuilder NullValue = generator.DeclareLocal(typeof(Nullable));
25 | generator.Emit(OpCodes.Ldloca_S, NullValue);
26 | generator.Emit(OpCodes.Ldloc_S, stack);
27 | generator.Emit(OpCodes.Call, typeof(Nullable).GetConstructor(new Type[] { typeof(T) }));
28 | return NullValue;
29 | }
30 |
31 | public FieldBoolean HasValue()
32 | {
33 | LocalBuilder Has = DeclareLocal(typeof(bool));
34 | generator.Emit(OpCodes.Ldloca_S, instance);
35 | Emit(OpCodes.Call, HasValueInfo);
36 | generator.Emit(OpCodes.Stloc_S, Has);
37 | return new FieldBoolean(Has, generator);
38 | }
39 |
40 | public LocalBuilder Value()
41 | {
42 | LocalBuilder Original = generator.DeclareLocal(typeof(T));
43 | generator.Emit(OpCodes.Ldloca_S, instance);
44 | Emit(OpCodes.Call, ValueInfo);
45 | generator.Emit(OpCodes.Stloc_S, Original);
46 | return Original;
47 | }
48 |
49 | public LocalBuilder GetValueOrDefault()
50 | {
51 | LocalBuilder Default = generator.DeclareLocal(typeof(T));
52 | generator.Emit(OpCodes.Ldloca_S, instance);
53 | Emit(OpCodes.Call, GetValueOrDefaultInfo);
54 | generator.Emit(OpCodes.Stloc_S, Default);
55 | return Default;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/BPlusTree/BTreeNodeElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BPlusTree
4 | {
5 | public class BTreeNodeElement where T:class, IComparable
6 | {
7 | private readonly T value;
8 | private Guid identifier;
9 |
10 | public override string ToString()
11 | {
12 | return value.ToString();
13 | // return value.ToString() + "[" + identifier + "]";
14 | }
15 |
16 | public BTreeNodeElement Next
17 | {
18 | get
19 | {
20 | return NextInterval.Larger;
21 | }
22 | }
23 |
24 | public BTreeNodeElement Previous
25 | {
26 | get
27 | {
28 | return PreviousInterval.Smaller;
29 | }
30 | }
31 |
32 | public BTreeNodeElement(T value)
33 | {
34 | this.value = value;
35 | NextInterval = new BTreeNodeElementInterstice(this, null);
36 | PreviousInterval = new BTreeNodeElementInterstice(null, this);
37 | identifier = Guid.NewGuid();
38 | }
39 |
40 | public BTreeNodeElementInterstice PreviousInterval { get; set; }
41 |
42 | public BTreeNodeElementInterstice NextInterval { get; set; }
43 |
44 | private bool Equals(BTreeNodeElement other)
45 | {
46 | if (ReferenceEquals(null, other)) return false;
47 | if (ReferenceEquals(this, other)) return true;
48 | return Equals(other.value, value);
49 | }
50 |
51 | public override bool Equals(object obj)
52 | {
53 | if (ReferenceEquals(null, obj)) return false;
54 | if (ReferenceEquals(this, obj)) return true;
55 | if (obj.GetType() != typeof (BTreeNodeElement)) return false;
56 | return Equals((BTreeNodeElement) obj);
57 | }
58 |
59 | public override int GetHashCode()
60 | {
61 | return (value != null ? value.GetHashCode() : 0);
62 | }
63 |
64 | public virtual T Value
65 | {
66 | get { return value; }
67 | }
68 |
69 | public void BreakForwardLink()
70 | {
71 | // NextInterval = new BTreeNodeElementInterstice(NextInterval.NodePointer, this, null);
72 | NextInterval.Larger = null;
73 | }
74 |
75 | public void TerminateForwardLink()
76 | {
77 | NextInterval = new BTreeNodeElementInterstice(this, null);
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/Apm/ApmEntityFrameworkLogger.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.Extensions.Logging;
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Diagnostics;
9 |
10 | namespace BigCookieKit.AspCore.Apm
11 | {
12 | public class ApmEntityFrameworkLogger : ILogger
13 | {
14 | private readonly string categoryName;
15 | private readonly Func filter;
16 | private readonly IServiceProvider provider;
17 |
18 | public ApmEntityFrameworkLogger(string categoryName, Func filter, IServiceProvider provider)
19 | {
20 | this.categoryName = categoryName;
21 | this.filter = filter;
22 | this.provider = provider;
23 | }
24 |
25 | public bool IsEnabled(LogLevel logLevel)
26 | {
27 | return true;
28 | }
29 |
30 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter)
31 | {
32 | if (logLevel == LogLevel.Information
33 | && eventId.Name == "Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted")
34 | {
35 | var accessor = provider.GetService();
36 | IReadOnlyList> values = state as IReadOnlyList>;
37 |
38 | if (accessor.HttpContext != null)
39 | {
40 | var configuration = accessor.HttpContext.RequestServices.GetService();
41 | switch (configuration.GetSection("ApmLogger:LoggerType")?.Value)
42 | {
43 | case "Console":
44 | ApmLoggerCore.ConsoleEFLogger(accessor.HttpContext, new Dictionary(values), exception);
45 | break;
46 | case "SQLite":
47 | ApmLoggerCore.SQLiteEFLogger(accessor.HttpContext, new Dictionary(values), exception);
48 | break;
49 | }
50 | }
51 | }
52 | }
53 |
54 | public IDisposable BeginScope(TState state)
55 | {
56 | return null;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/UnitAspExample/Controllers/UserController.cs:
--------------------------------------------------------------------------------
1 | using BigCookieKit.Standard;
2 |
3 | using Microsoft.AspNetCore.Mvc;
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel.DataAnnotations;
8 | using System.Linq;
9 | using System.Threading.Tasks;
10 |
11 | namespace UnitAspExample.Controllers
12 | {
13 | public class UserAddDto
14 | {
15 | ///
16 | /// 测试注释
17 | ///
18 | public string String1 { get; set; }
19 |
20 | [Required]
21 | public DateTime DateTime1 { get; set; }
22 |
23 | public DateTime? DateTime2 { get; set; }
24 |
25 | public int Int1 { get; set; }
26 |
27 | public int? Int2 { get; set; }
28 |
29 | ///
30 | /// 所属的公司
31 | ///
32 | public List Companys { get; set; }
33 | }
34 |
35 | public class UserCompany
36 | {
37 | ///
38 | /// 公司名称
39 | ///
40 | public string Name { get; set; }
41 | }
42 |
43 | ///
44 | /// 用户响应模型
45 | ///
46 | public class UserResponse
47 | {
48 | ///
49 | /// 返回的用户名
50 | ///
51 | public string UserName { get; set; } = "ZHANGBINGBIN";
52 |
53 | ///
54 | /// 是否为超级管理员
55 | ///
56 | public bool IsSuper { get; set; } = true;
57 | }
58 |
59 | ///
60 | /// 用户管理
61 | ///
62 | [Route("Management/[controller]")]
63 | public class UserController : Controller
64 | {
65 | ///
66 | /// 用户列表
67 | ///
68 | ///
69 | [HttpGet]
70 | [Route("Index")]
71 | public IActionResult Index()
72 | {
73 | return View();
74 | }
75 |
76 | ///
77 | /// 新增用户
78 | ///
79 | ///
80 | [HttpPost]
81 | [Route("Add")]
82 | public ApiResponse Add(UserAddDto dto)
83 | {
84 | return new ApiResponseSuccess();
85 | }
86 |
87 | ///
88 | /// 更新用户
89 | ///
90 | ///
91 | [HttpPost]
92 | [Route("Update")]
93 | public ApiResponse Update(long? Id, UserAddDto dto)
94 | {
95 | return new ApiResponseSuccess(new UserResponse());
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/AssertManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection.Emit;
4 |
5 | namespace BigCookieKit.Reflect
6 | {
7 | public class AssertManager
8 | {
9 | private FuncGenerator generator;
10 | private List> context = new List>();
11 |
12 | internal AssertManager(FuncGenerator generator, Tuple context)
13 | {
14 | this.generator = generator;
15 | this.context.Add(context);
16 | }
17 |
18 | public AssertManager ElseIF(LocalBuilder assert, Action builder)
19 | {
20 | context.Add(new Tuple(assert, builder));
21 | return this;
22 | }
23 |
24 | public AssertManager ElseIF(FieldManager assert, Action builder)
25 | {
26 | context.Add(new Tuple(assert, builder));
27 | return this;
28 | }
29 |
30 | public void Else(Action builder)
31 | {
32 | Label end = generator.DefineLabel();
33 | Label lab = generator.DefineLabel();
34 | bool first = true;
35 | foreach (var item in context)
36 | {
37 | if (!first) generator.MarkLabel(lab);
38 | lab = generator.DefineLabel();
39 | generator.Emit(OpCodes.Ldloc_S, item.Item1);
40 | generator.Emit(OpCodes.Brfalse, lab);
41 | item.Item2?.Invoke();
42 | generator.Emit(OpCodes.Br, end);
43 | first = false;
44 | }
45 | generator.MarkLabel(lab);
46 | builder?.Invoke(generator);
47 | generator.Emit(OpCodes.Br, end);
48 | generator.MarkLabel(end);
49 | }
50 |
51 | public void IFEnd()
52 | {
53 | Label end = generator.DefineLabel();
54 | Label lab = generator.DefineLabel();
55 | bool first = true;
56 | foreach (var item in context)
57 | {
58 | if (!first) generator.MarkLabel(lab);
59 | lab = generator.DefineLabel();
60 | generator.Emit(OpCodes.Ldloc_S, item.Item1);
61 | generator.Emit(OpCodes.Brfalse, lab);
62 | item.Item2?.Invoke();
63 | generator.Emit(OpCodes.Br, end);
64 | first = false;
65 | }
66 | generator.MarkLabel(lab);
67 | generator.MarkLabel(end);
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldString.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldString : FieldManager
7 | {
8 | internal FieldString(LocalBuilder stack, ILGenerator generator) : base(stack, generator)
9 | {
10 | }
11 |
12 | public FieldBoolean IsNull()
13 | {
14 | return this.IsNull(this);
15 | }
16 |
17 | public FieldBoolean IsNullOrEmpty()
18 | {
19 | Output();
20 | return new FieldBoolean(this.ReflectStaticMethod("IsNullOrEmpty", typeof(string)).ReturnRef(), this);
21 | }
22 |
23 | public static FieldBoolean operator ==(FieldString field, string value)
24 | {
25 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
26 | }
27 |
28 | public static FieldBoolean operator ==(FieldString field, LocalBuilder value)
29 | {
30 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
31 | }
32 |
33 | public static FieldBoolean operator ==(FieldString field, FieldString value)
34 | {
35 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
36 | }
37 |
38 | public static FieldBoolean operator !=(FieldString field, string value)
39 | {
40 | return ManagerGX.Comparer(
41 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
42 | field.NewInt32(), OpCodes.Ceq);
43 | }
44 |
45 | public static FieldBoolean operator !=(FieldString field, LocalBuilder value)
46 | {
47 | return ManagerGX.Comparer(
48 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
49 | field.NewInt32(), OpCodes.Ceq);
50 | }
51 |
52 | public static FieldBoolean operator !=(FieldString field, FieldString value)
53 | {
54 | return ManagerGX.Comparer(
55 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
56 | field.NewInt32(), OpCodes.Ceq);
57 | }
58 |
59 | public static FieldString operator +(FieldString field, string value)
60 | {
61 | return ManagerGX.Compute(field, value, OpCodes.Add);
62 | }
63 |
64 | public static VariableManager operator +(FieldString field, LocalBuilder value)
65 | {
66 | return ManagerGX.Compute(field, value, OpCodes.Add);
67 | }
68 |
69 | public static FieldString operator +(FieldString field, FieldString value)
70 | {
71 | return ManagerGX.Compute(field, value, OpCodes.Add);
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/BigCookieKit/Algorithm/LZW.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigCookieKit.Algorithm
6 | {
7 | ///
8 | /// LZW压缩算法
9 | ///
10 | public static class LZW
11 | {
12 | ///
13 | /// 压缩
14 | ///
15 | /// 字符串
16 | /// 字节流
17 | public static List Compress(string uncompressed)
18 | {
19 | //初始化ASCII码表
20 | Dictionary dictionary = new Dictionary();
21 | for (int i = 0; i < 256; i++)
22 | dictionary.Add(((char)i).ToString(), i);
23 |
24 | string w = string.Empty;
25 | List compressed = new List();
26 |
27 | foreach (char c in uncompressed)
28 | {
29 | string wc = w + c;
30 | if (dictionary.ContainsKey(wc))
31 | {
32 | w = wc;
33 | }
34 | else
35 | {
36 | compressed.Add(dictionary[w]);
37 | dictionary.Add(wc, dictionary.Count);
38 | w = c.ToString();
39 | }
40 | }
41 |
42 | if (!string.IsNullOrEmpty(w))
43 | compressed.Add(dictionary[w]);
44 |
45 | return compressed;
46 | }
47 |
48 | ///
49 | /// 解压缩
50 | ///
51 | /// 字节流
52 | /// 字符串
53 | public static string Decompress(List compressed)
54 | {
55 | //初始化ASCII码表
56 | Dictionary dictionary = new Dictionary();
57 | for (int i = 0; i < 256; i++)
58 | dictionary.Add(i, ((char)i).ToString());
59 |
60 | string w = dictionary[compressed[0]];
61 | compressed.RemoveAt(0);
62 | StringBuilder decompressed = new StringBuilder(w);
63 |
64 | foreach (int k in compressed)
65 | {
66 | string entry = null;
67 | if (dictionary.ContainsKey(k))
68 | entry = dictionary[k];
69 | else if (k == dictionary.Count)
70 | entry = w + w[0];
71 |
72 | decompressed.Append(entry);
73 |
74 | dictionary.Add(dictionary.Count, w + entry[0]);
75 |
76 | w = entry;
77 | }
78 |
79 | return decompressed.ToString();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/JumpTableBuilder.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Routing;
2 |
3 | using System;
4 |
5 | namespace BigCookieKit.AspCore.RouteSelector
6 | {
7 | internal static class JumpTableBuilder
8 | {
9 | public const int InvalidDestination = -1;
10 |
11 | public static JumpTable Build(int defaultDestination, int exitDestination, (string text, int destination)[] pathEntries)
12 | {
13 | if (defaultDestination == InvalidDestination)
14 | {
15 | var message = $"{nameof(defaultDestination)} is not set. Please report this as a bug.";
16 | throw new InvalidOperationException(message);
17 | }
18 |
19 | if (exitDestination == InvalidDestination)
20 | {
21 | var message = $"{nameof(exitDestination)} is not set. Please report this as a bug.";
22 | throw new InvalidOperationException(message);
23 | }
24 |
25 | if (pathEntries == null || pathEntries.Length == 0)
26 | {
27 | return new ZeroEntryJumpTable(defaultDestination, exitDestination);
28 | }
29 |
30 | if (pathEntries.Length == 1 && Ascii.IsAscii(pathEntries[0].text))
31 | {
32 | var entry = pathEntries[0];
33 | return new SingleEntryAsciiJumpTable(defaultDestination, exitDestination, entry.text, entry.destination);
34 | }
35 |
36 | // We have a fallback that works for non-ASCII
37 | if (pathEntries.Length == 1)
38 | {
39 | var entry = pathEntries[0];
40 | return new SingleEntryJumpTable(defaultDestination, exitDestination, entry.text, entry.destination);
41 | }
42 |
43 | var threshold = IntPtr.Size == 8 ? 100 : 50;
44 | if (pathEntries.Length >= threshold)
45 | {
46 | return new DictionaryJumpTable(defaultDestination, exitDestination, pathEntries);
47 | }
48 |
49 | JumpTable fallback;
50 |
51 | if (pathEntries.Length <= 10)
52 | {
53 | fallback = new LinearSearchJumpTable(defaultDestination, exitDestination, pathEntries);
54 | }
55 | else
56 | {
57 | fallback = new DictionaryJumpTable(defaultDestination, exitDestination, pathEntries);
58 | }
59 |
60 | return fallback;
61 | }
62 |
63 | public interface IParameterLiteralNodeMatchingPolicy : IParameterPolicy
64 | {
65 | bool MatchesLiteral(string parameterName, string literal);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/BigCookieKit.AspCore/RouteSelector/DefaultParameterPolicyFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Routing;
2 | using Microsoft.AspNetCore.Routing.Constraints;
3 | using Microsoft.AspNetCore.Routing.Patterns;
4 | using Microsoft.Extensions.Options;
5 |
6 | using System;
7 |
8 | namespace BigCookieKit.AspCore.RouteSelector
9 | {
10 | internal class DefaultParameterPolicyFactory : ParameterPolicyFactory
11 | {
12 | private readonly RouteOptions _options;
13 | private readonly IServiceProvider _serviceProvider;
14 |
15 | public DefaultParameterPolicyFactory(
16 | IOptions options,
17 | IServiceProvider serviceProvider)
18 | {
19 | _options = options.Value;
20 | _serviceProvider = serviceProvider;
21 | }
22 |
23 | public override IParameterPolicy Create(RoutePatternParameterPart? parameter, IParameterPolicy parameterPolicy)
24 | {
25 | if (parameterPolicy == null)
26 | {
27 | throw new ArgumentNullException(nameof(parameterPolicy));
28 | }
29 |
30 | if (parameterPolicy is IRouteConstraint routeConstraint)
31 | {
32 | return InitializeRouteConstraint(parameter?.IsOptional ?? false, routeConstraint);
33 | }
34 |
35 | return parameterPolicy;
36 | }
37 |
38 | public override IParameterPolicy Create(RoutePatternParameterPart? parameter, string inlineText)
39 | {
40 | if (inlineText == null)
41 | {
42 | throw new ArgumentNullException(nameof(inlineText));
43 | }
44 |
45 | var parameterPolicy = ParameterPolicyActivator.ResolveParameterPolicy(
46 | _options.ConstraintMap,
47 | _serviceProvider,
48 | inlineText,
49 | out var parameterPolicyKey);
50 |
51 | if (parameterPolicy == null)
52 | {
53 | throw new InvalidOperationException("");
54 | }
55 |
56 | if (parameterPolicy is IRouteConstraint constraint)
57 | {
58 | return InitializeRouteConstraint(parameter?.IsOptional ?? false, constraint);
59 | }
60 |
61 | return parameterPolicy;
62 | }
63 |
64 | private static IParameterPolicy InitializeRouteConstraint(
65 | bool optional,
66 | IRouteConstraint routeConstraint)
67 | {
68 | if (optional)
69 | {
70 | routeConstraint = new OptionalRouteConstraint(routeConstraint);
71 | }
72 |
73 | return routeConstraint;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/UnitBenchmark/BoyerMooreBenchmark.cs:
--------------------------------------------------------------------------------
1 | using BenchmarkDotNet.Attributes;
2 |
3 | using BigCookieKit;
4 | using BigCookieKit.Algorithm;
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace UnitBenchmark
13 | {
14 | public class BoyerMooreBenchmark
15 | {
16 | byte[] content_byte;
17 | byte[] pettern_byte;
18 | char[] content_char;
19 | char[] pettern_char;
20 | string content;
21 |
22 | public BoyerMooreBenchmark()
23 | {
24 | content = @"Configuration
25 | Overview
26 | RabbitMQ comes with default built-in settings. Those can be entirely sufficient in some environment (e.g. development and QA). For all other cases, as well as production deployment tuning, there is a way to configure many things in the broker as well as plugins.
27 |
28 | This guide covers a number of topics related to configuration:
29 |
30 | Different ways in which various settings of the server and plugins are configured
31 | Configuration file(s): primary rabbitmq.conf and optional advanced.config
32 | Default configuration file location(s) on various platforms
33 | Configuration troubleshooting: how to find config file location and inspect and verify effective configuration
34 | Environment variables
35 | Operating system (kernel) limits
36 | Available core server settings
37 | Available environment variables
38 | How to encrypt sensitive configuration values
39 | and more.
40 |
41 | Since configuration affects many areas of the system, including plugins, individual documentation guides dive deeper into what can be configured. Runtime Tuning is a companion to this guide that focuses on the configurable parameters in the runtime. Production Checklist is a related guide that outlines what settings will likely need tuning in most production environments.";
42 | //string pettern = "effective config";
43 | //string pettern = "configuration";
44 | string pettern = "config";
45 |
46 | content_byte = Encoding.Default.GetBytes(content);
47 | pettern_byte = Encoding.Default.GetBytes(pettern);
48 |
49 | content_char = content.ToCharArray();
50 | pettern_char = pettern.ToCharArray();
51 | }
52 |
53 | [Benchmark]
54 | public void BoyerMooreByte()
55 | {
56 | BoyerMoore.BoyerMooreFirstMatch(content_byte, pettern_byte);
57 | }
58 |
59 | [Benchmark]
60 | public void BoyerMooreChar()
61 | {
62 | var s1 = BoyerMoore.BoyerMooreFirstMatch(content_char, pettern_char);
63 | var arr = BoyerMoore.BoyerMooreMatchAll(content_char, pettern_char);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/Buffer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net.Sockets;
4 | using System.Text;
5 |
6 | namespace BigCookieKit.Network
7 | {
8 | ///
9 | /// 缓冲位
10 | ///
11 | public class Buffer
12 | {
13 | ///
14 | /// 初始化
15 | ///
16 | /// 缓冲区
17 | /// 偏移量
18 | /// 位长度
19 | ///
20 | public static Buffer New(ref byte[] Bytes, int Offset, int Length)
21 | {
22 | return new Buffer(ref Bytes, Offset, Length);
23 | }
24 |
25 | ///
26 | /// 缓冲区字节流
27 | ///
28 | private byte[] Bytes { get; set; }
29 |
30 | ///
31 | /// 缓冲位字节流
32 | ///
33 | private Memory Data { get { return Bytes.AsMemory().Slice(Offset, Length); } }
34 |
35 | ///
36 | /// 缓冲区偏移量
37 | ///
38 | private int Offset { get; set; }
39 |
40 | ///
41 | /// 缓冲位长度
42 | ///
43 | private int Length { get; set; }
44 |
45 | ///
46 | /// 构造函数
47 | ///
48 | /// 缓冲区
49 | /// 偏移量
50 | /// 位长度
51 | public Buffer(ref byte[] Bytes, int Offset, int Length)
52 | {
53 | this.Bytes = Bytes;
54 | this.Offset = Offset;
55 | this.Length = Length;
56 | }
57 |
58 | ///
59 | /// 清扫缓冲位
60 | ///
61 | public void Free()
62 | {
63 | for (int i = 0; i < Length; i++)
64 | {
65 | this[i] = 0;
66 | }
67 | }
68 |
69 | public byte this[int index]
70 | {
71 | get
72 | {
73 | return Bytes[index + Offset];
74 | }
75 | set
76 | {
77 | Bytes[index + Offset] = value;
78 | }
79 | }
80 |
81 | public static implicit operator Memory(Buffer buffer) => buffer.Data;
82 | #if NET452
83 | public static implicit operator byte[](Buffer buffer) => buffer.Data.ToArray();
84 | #endif
85 |
86 | public static void SetBuffer(SocketAsyncEventArgs saea, Memory buffer)
87 | {
88 | #if NET452
89 | saea.SetBuffer(buffer.ToArray(), 0, buffer.Length);
90 | #else
91 | saea.SetBuffer(buffer);
92 | #endif
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/BigCookieKit.Network/Network.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Buffers;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Net.Security;
7 | using System.Net.Sockets;
8 | using System.Runtime.CompilerServices;
9 | using System.Security.Authentication;
10 | using System.Security.Cryptography.X509Certificates;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 |
14 | namespace BigCookieKit.Network
15 | {
16 | ///
17 | /// 基础网络
18 | ///
19 | public class Network
20 | {
21 | ///
22 | /// 网络地址
23 | ///
24 | public string Host { get; set; }
25 |
26 | ///
27 | /// 端口
28 | ///
29 | public int Port { get; set; }
30 |
31 | ///
32 | /// 网络协议
33 | ///
34 | public virtual NetworkProtocol Protocol { get; set; }
35 |
36 | ///
37 | /// 应用模式
38 | ///
39 | public virtual ApplyMode Mode { get; set; }
40 |
41 | ///
42 | /// 地址方案
43 | /// 默认为IPV4
44 | ///
45 | public AddressFamily AddressFamily { get; set; } = AddressFamily.InterNetwork;
46 |
47 | ///
48 | /// 通信方式
49 | ///
50 | public SocketType SocketType { get; set; } = SocketType.Stream;
51 |
52 | ///
53 | /// 编码方式
54 | ///
55 | public Encoding Encoder { get; set; } = Encoding.UTF8;
56 |
57 | ///
58 | /// 数据处理器
59 | ///
60 | public Handle Handle { get; set; }
61 |
62 | ///
63 | /// 缓存片大小 默认4K
64 | ///
65 | public int BufferSize { get; set; } = 4096;
66 |
67 | ///
68 | /// SSL协议
69 | ///
70 | public SslProtocols SslProtocols { get; set; } = SslProtocols.None;
71 |
72 | ///
73 | /// 当前套接字
74 | ///
75 | internal XSocket CurrSocket { get; set; }
76 | ///
77 | /// 安全证书
78 | ///
79 | public X509Certificate Certificate { get; set; }
80 |
81 | ///
82 | /// 缓存池
83 | ///
84 | internal ArrayPool BufferPool = ArrayPool.Create();
85 |
86 | public Network(string Host, int Port)
87 | {
88 | this.Host = Host;
89 | this.Port = Port;
90 | }
91 |
92 | ///
93 | /// 解析地址
94 | ///
95 | ///
96 | public IPEndPoint GetAddress() => new IPEndPoint(Dns.GetHostAddresses(Host).FirstOrDefault(), Port);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FastExtend.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BigCookieKit.Reflect
9 | {
10 | public class FastExtend
11 | {
12 | private ConcurrentDictionary allMember;
13 |
14 | private bool isGenerate = false;
15 |
16 | private SmartBuilder globalBuilder;
17 |
18 | private int version = 1;
19 |
20 | private object instance;
21 |
22 | private FastDynamic _dynamic;
23 |
24 | public object Instance
25 | {
26 | get
27 | {
28 | CheckGenerate();
29 | return instance;
30 | }
31 | }
32 |
33 | public FastExtend()
34 | {
35 | allMember = new ConcurrentDictionary();
36 | }
37 |
38 | public object this[string name]
39 | {
40 | get
41 | {
42 | CheckGenerate();
43 | if (_dynamic != null)
44 | {
45 | return _dynamic[name];
46 | }
47 | throw new NullReferenceException();
48 | }
49 | set
50 | {
51 | CheckGenerate();
52 | _dynamic[name] = value;
53 | }
54 | }
55 |
56 | private void CheckGenerate()
57 | {
58 | if (isGenerate)
59 | {
60 | globalBuilder = new SmartBuilder();
61 | globalBuilder.Class("anonymity" + version);
62 | foreach (var item in allMember)
63 | {
64 | var prop = globalBuilder.Property(item.Key, item.Value);
65 | if (_dynamic != null && _dynamic.Properties.ContainsKey(item.Key))
66 | prop.Constant(_dynamic[item.Key]);
67 | }
68 | instance = globalBuilder.Generation();
69 | _dynamic = FastDynamic.GetFastDynamic(instance);
70 | version++;
71 | isGenerate = false;
72 | }
73 | }
74 |
75 | public void AddMember(string name, Type type)
76 | {
77 | if (!allMember.ContainsKey(name))
78 | {
79 | if (allMember.TryAdd(name, type))
80 | {
81 | isGenerate = true;
82 | }
83 | }
84 | }
85 |
86 | public void RemoveMember(string name)
87 | {
88 | if (allMember.ContainsKey(name))
89 | {
90 | if (allMember.TryRemove(name, out _))
91 | {
92 | isGenerate = true;
93 | }
94 | }
95 | }
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/BigCookieKit.Reflect/FieldBoolean.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection.Emit;
3 |
4 | namespace BigCookieKit.Reflect
5 | {
6 | public class FieldBoolean : FieldManager
7 | {
8 | internal FieldBoolean(LocalBuilder stack, ILGenerator il) : base(stack, il)
9 | {
10 | }
11 |
12 | public static FieldBoolean operator ==(FieldBoolean field, bool value)
13 | {
14 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
15 | }
16 |
17 | public static FieldBoolean operator ==(FieldBoolean field, LocalBuilder value)
18 | {
19 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
20 | }
21 |
22 | public static FieldBoolean operator ==(FieldBoolean field, FieldBoolean value)
23 | {
24 | return ManagerGX.Comparer(field, value, OpCodes.Ceq);
25 | }
26 |
27 | public static FieldBoolean operator !=(FieldBoolean field, bool value)
28 | {
29 | return ManagerGX.Comparer(
30 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
31 | field.NewInt32(), OpCodes.Ceq);
32 | }
33 |
34 | public static FieldBoolean operator !=(FieldBoolean field, LocalBuilder value)
35 | {
36 | return ManagerGX.Comparer(
37 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
38 | field.NewInt32(), OpCodes.Ceq);
39 | }
40 |
41 | public static FieldBoolean operator !=(FieldBoolean field, FieldBoolean value)
42 | {
43 | return ManagerGX.Comparer(
44 | ManagerGX.Comparer(field, value, OpCodes.Ceq),
45 | field.NewInt32(), OpCodes.Ceq);
46 | }
47 |
48 | public static FieldBoolean operator |(FieldBoolean field, FieldBoolean value)
49 | {
50 | var assert = field.NewBoolean();
51 | var _true = field.DefineLabel();
52 | field.Output();
53 | field.Emit(OpCodes.Ldc_I4_1);
54 | field.Emit(OpCodes.Beq_S, _true);
55 | field.Emit(OpCodes.Ldc_I4_0);
56 | assert.Input();
57 | value.Output();
58 | field.Emit(OpCodes.Ldc_I4_1);
59 | field.Emit(OpCodes.Beq_S, _true);
60 | field.MarkLabel(_true);
61 | return assert;
62 | }
63 |
64 | public static FieldBoolean operator &(FieldBoolean field, FieldBoolean value)
65 | {
66 | var assert = field.NewBoolean();
67 | var _false = field.DefineLabel();
68 | field.Output();
69 | field.Emit(OpCodes.Ldc_I4_0);
70 | field.Emit(OpCodes.Beq_S, _false);
71 | value.Output();
72 | field.Emit(OpCodes.Ldc_I4_0);
73 | field.Emit(OpCodes.Beq_S, _false);
74 | field.Emit(OpCodes.Ldc_I4_1);
75 | assert.Input();
76 | field.MarkLabel(_false);
77 | return assert;
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/BigCookieKit/Kit.Enum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Text;
5 |
6 | namespace BigCookieKit
7 | {
8 | public static partial class Kit
9 | {
10 | ///
11 | /// 根据key对应Value转字典
12 | ///
13 | /// 枚举类型
14 | ///
15 | public static IDictionary ToEnumKeyValue(Type type)
16 | {
17 | if (!type.IsEnum) throw new TypeAccessException();
18 | string[] Names = Enum.GetNames(type);
19 | Array Values = Enum.GetValues(type);
20 | IDictionary dic = new Dictionary();
21 | for (int i = 0; i < Values.Length; i++)
22 | {
23 | dic.Add((int)Values.GetValue(i), Names[i].ToString());
24 | }
25 | return dic;
26 | }
27 |
28 | ///
29 | /// 根据key对应Value转字典
30 | ///
31 | /// 枚举类型
32 | ///
33 | public static IDictionary ToEnumKeyValue() where TEnum : Enum
34 | {
35 | return ToEnumKeyValue(typeof(TEnum));
36 | }
37 |
38 | ///
39 | /// 根据key对应Display转字典
40 | ///
41 | /// 枚举类型
42 | ///
43 | public static IDictionary ToEnumKeyDisplay(Type type)
44 | {
45 | if (!type.IsEnum) throw new TypeAccessException();
46 | string[] Names = Enum.GetNames(type);
47 | Array Values = Enum.GetValues(type);
48 | IDictionary dic = new Dictionary();
49 | string desc = string.Empty;
50 | for (int i = 0; i < Values.Length; i++)
51 | {
52 | object t = Enum.Parse(type, Values.GetValue(i).ToString());
53 | MemberInfo[] memInfo = type.GetMember(t.ToString());
54 | if (memInfo != null && memInfo.Length > 0)
55 | {
56 | object[] attrs = memInfo[0].GetCustomAttributes(typeof(DisplayAttribute), false);
57 | if (attrs != null && attrs.Length > 0)
58 | {
59 | desc = ((DisplayAttribute)attrs[0]).Value;
60 | }
61 | }
62 | dic.Add((int)Values.GetValue(i), string.IsNullOrEmpty(desc) ? Names[i].ToString() : desc);
63 | }
64 | return dic;
65 | }
66 |
67 | ///
68 | /// 根据key对应Display转字典
69 | ///
70 | /// 枚举类型
71 | ///
72 | public static IDictionary ToEnumKeyDisplay() where TEnum : Enum
73 | {
74 | return ToEnumKeyDisplay(typeof(TEnum));
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/BigCookieKit.Serialization/Binary/Binary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace BigCookieKit.Serialization.Binary
7 | {
8 | ///
9 | /// 二进制序列化
10 | ///
11 | public class Binary : IDisposable
12 | {
13 | ///
14 | /// 处理器
15 | ///
16 | private ICollection Handles { get; set; }
17 |
18 | ///
19 | /// 压缩流
20 | ///
21 | internal Stream Stream { get; set; }
22 |
23 | ///
24 | /// 二进制核心
25 | ///
26 | public Binary Host { get; set; }
27 |
28 | ///
29 | /// 优先级
30 | ///
31 | public int Priority { get; set; }
32 |
33 | public Binary()
34 | {
35 | Handles = new List();
36 | Stream = new MemoryStream();
37 | FormatterSort();
38 | }
39 |
40 | public T Read(Type type)
41 | {
42 | foreach (var handle in Handles)
43 | {
44 | var obj = handle.Read(type);
45 | if (obj != null)
46 | {
47 | return (T)obj;
48 | }
49 | }
50 |
51 | return default(T);
52 | }
53 |
54 | public bool Write(object value)
55 | {
56 | foreach (var handle in Handles)
57 | {
58 | if (!handle.Write(value)) return true;
59 | }
60 |
61 | return false;
62 | }
63 |
64 | public FormatterBase GetHandle() where T : FormatterBase
65 | {
66 | foreach (var handle in Handles)
67 | {
68 | if (handle.GetType() == typeof(T))
69 | {
70 | return handle;
71 | }
72 | }
73 |
74 | return null;
75 | }
76 |
77 | private void FormatterSort()
78 | {
79 | var tmp = new List();
80 | tmp.Add(new GeneralFormatter() { Host = this });
81 |
82 | foreach (var handle in Handles)
83 | {
84 | bool isInsert = false;
85 | for (int i = 0; i < tmp.Count; i++)
86 | {
87 | var item = tmp[i];
88 | if (handle.Priority < item.Priority)
89 | {
90 | tmp.Insert(i, handle);
91 | isInsert = true;
92 | break;
93 | }
94 | }
95 |
96 | if (!isInsert) tmp.Add(handle);
97 | }
98 |
99 | Handles = tmp;
100 | }
101 |
102 | public void Dispose()
103 | {
104 | ((IDisposable)Stream).Dispose();
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------