Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
若汝棋茗
RRQMSocket
提交
2a4697b0
RRQMSocket
项目概览
若汝棋茗
/
RRQMSocket
10 个月 前同步成功
通知
20
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
RRQMSocket
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2a4697b0
编写于
6月 30, 2022
作者:
若汝棋茗
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化ConsoleAction
上级
bb83567a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
10 deletion
+30
-10
src/RRQMCore/Dependency/Attribute/DependencyInjectionAttribute.cs
...Core/Dependency/Attribute/DependencyInjectionAttribute.cs
+11
-0
src/RRQMCore/Dependency/Container.cs
src/RRQMCore/Dependency/Container.cs
+7
-6
src/RRQMCore/IO/ConsoleAction.cs
src/RRQMCore/IO/ConsoleAction.cs
+9
-1
src/RRQMCore/RRQMCore.csproj
src/RRQMCore/RRQMCore.csproj
+1
-1
src/RRQMSocket/RRQMSocket.csproj
src/RRQMSocket/RRQMSocket.csproj
+2
-2
未找到文件。
src/RRQMCore/Dependency/Attribute/DependencyInjectionAttribute.cs
浏览文件 @
2a4697b0
...
...
@@ -111,6 +111,17 @@ namespace RRQMCore.Dependency
this
.
Type
=
type
;
}
/// <summary>
/// 类型,参数,属性指定性注入。
/// </summary>
/// <param name="type"></param>
/// <param name="ps"></param>
public
DependencyParamterInjectAttribute
(
Type
type
,
params
object
[]
ps
)
:
base
(
ps
)
{
Key
=
string
.
Empty
;
this
.
Type
=
type
;
}
/// <summary>
/// 注入类型
/// </summary>
...
...
src/RRQMCore/Dependency/Container.cs
浏览文件 @
2a4697b0
...
...
@@ -13,6 +13,7 @@
using
RRQMCore.Extensions
;
using
System
;
using
System.Collections
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Reflection
;
...
...
@@ -25,7 +26,7 @@ namespace RRQMCore.Dependency
/// </summary>
public
class
Container
:
IContainer
{
private
readonly
Dictionary
<
string
,
DependencyDescriptor
>
registrations
=
new
Dictionary
<
string
,
DependencyDescriptor
>();
private
readonly
ConcurrentDictionary
<
string
,
DependencyDescriptor
>
registrations
=
new
Concurrent
Dictionary
<
string
,
DependencyDescriptor
>();
/// <summary>
/// <inheritdoc/>
...
...
@@ -35,7 +36,7 @@ namespace RRQMCore.Dependency
public
void
Register
(
DependencyDescriptor
descriptor
,
string
key
=
""
)
{
string
k
=
$"
{
descriptor
.
FromType
.
FullName
}{
key
}
"
;
registrations
.
AddOrUpdate
(
k
,
descriptor
);
registrations
.
AddOrUpdate
(
k
,
descriptor
,(
k
,
v
)=>
{
return
v
;
}
);
}
private
IScopedContainer
GetScopedContainer
()
...
...
@@ -45,11 +46,11 @@ namespace RRQMCore.Dependency
{
if
(
item
.
Value
.
Lifetime
==
Lifetime
.
Scoped
)
{
container
.
registrations
.
AddOrUpdate
(
item
.
Key
,
new
DependencyDescriptor
(
item
.
Value
.
FromType
,
item
.
Value
.
ToType
,
Lifetime
.
Singleton
));
container
.
registrations
.
AddOrUpdate
(
item
.
Key
,
new
DependencyDescriptor
(
item
.
Value
.
FromType
,
item
.
Value
.
ToType
,
Lifetime
.
Singleton
)
,
(
k
,
v
)
=>
{
return
v
;
}
);
}
else
{
container
.
registrations
.
AddOrUpdate
(
item
.
Key
,
item
.
Value
);
container
.
registrations
.
AddOrUpdate
(
item
.
Key
,
item
.
Value
,
(
k
,
v
)
=>
{
return
v
;
}
);
}
}
...
...
@@ -149,11 +150,11 @@ namespace RRQMCore.Dependency
if
(
ctor
is
null
)
{
//如果没有被特性标记,那就取构造函数参数最多的作为注入目标
ctor
=
toType
.
GetConstructors
().
OrderByDescending
(
x
=>
x
.
GetParameters
().
Length
).
First
();
if
(
ctor
is
null
)
if
(
toType
.
GetConstructors
().
Length
==
0
)
{
throw
new
RRQMException
(
$"没有找到类型
{
toType
.
FullName
}
的公共构造函数。"
);
}
ctor
=
toType
.
GetConstructors
().
OrderByDescending
(
x
=>
x
.
GetParameters
().
Length
).
First
();
}
else
{
...
...
src/RRQMCore/IO/ConsoleAction.cs
浏览文件 @
2a4697b0
...
...
@@ -12,6 +12,7 @@
//------------------------------------------------------------------------------
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
RRQMCore.IO
{
...
...
@@ -53,13 +54,20 @@ namespace RRQMCore.IO
/// </summary>
public
void
ShowAll
()
{
int
max
=
this
.
actions
.
Values
.
Max
(
a
=>
a
.
FullOrder
.
Length
)+
8
;
List
<
string
>
s
=
new
List
<
string
>();
foreach
(
var
item
in
this
.
actions
)
{
if
(!
s
.
Contains
(
item
.
Value
.
FullOrder
.
ToLower
()))
{
s
.
Add
(
item
.
Value
.
FullOrder
.
ToLower
());
Console
.
WriteLine
(
$"[
{
item
.
Value
.
FullOrder
}
]-------->
{
item
.
Value
.
Description
}
"
);
Console
.
Write
(
$"[
{
item
.
Value
.
FullOrder
}
]"
);
for
(
int
i
=
0
;
i
<
max
-
item
.
Value
.
FullOrder
.
Length
;
i
++)
{
Console
.
Write
(
"-"
);
}
Console
.
WriteLine
(
item
.
Value
.
Description
);
}
}
}
...
...
src/RRQMCore/RRQMCore.csproj
浏览文件 @
2a4697b0
...
...
@@ -5,7 +5,7 @@
<Authors>若汝棋茗</Authors>
<PackageIcon>RRQM.png</PackageIcon>
<Copyright>Copyright © 2022 若汝棋茗</Copyright>
<Version>8.2.
1
</Version>
<Version>8.2.
2
</Version>
<LangVersion>8.0</LangVersion>
<SignAssembly>true</SignAssembly>
<Description>此程序集是RRQM的核心开源库,其中包含了内存池、高性能序列化、日志接口在内的很多基本内容。
...
...
src/RRQMSocket/RRQMSocket.csproj
浏览文件 @
2a4697b0
...
...
@@ -4,7 +4,7 @@
<ApplicationIcon>RRQM.ico</ApplicationIcon>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>RRQM.pfx</AssemblyOriginatorKeyFile>
<Version>8.2.
1
</Version>
<Version>8.2.
2
</Version>
<LangVersion>8.0</LangVersion>
<Company>若汝棋茗</Company>
<Copyright>Copyright © 2022 若汝棋茗</Copyright>
...
...
@@ -78,7 +78,7 @@ API:https://www.yuque.com/eo2w71/rrqm</Description>
</ItemGroup>
<ItemGroup>
<PackageReference Include="RRQMCore" Version="8.2.
1
" />
<PackageReference Include="RRQMCore" Version="8.2.
2
" />
</ItemGroup>
</Project>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录