Skip to content

Commit d8d3f7f

Browse files
committed
refactor: 更改类命名空间
1 parent 88ac65e commit d8d3f7f

48 files changed

Lines changed: 166 additions & 155 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/extensions/BootstrapBlazor.Socket/BootstrapBlazor.Socket.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@
99
<Description>BootstrapBlazor extensions of Socket</Description>
1010
</PropertyGroup>
1111

12+
<ItemGroup>
13+
<Using Include="BootstrapBlazor.DataAdapters" />
14+
<Using Include="BootstrapBlazor.DataHandlers" />
15+
<Using Include="BootstrapBlazor.DataConverters" />
16+
</ItemGroup>
17+
1218
</Project>

src/extensions/BootstrapBlazor.Socket/DataPackageAdapter/DataPackageAdapter.cs renamed to src/extensions/BootstrapBlazor.Socket/DataAdapter/DataPackageAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5-
namespace BootstrapBlazor.Components;
5+
namespace BootstrapBlazor.DataAdapters;
66

77
/// <summary>
88
/// Provides a base implementation for adapting data packages between different systems or formats.
@@ -50,7 +50,7 @@ public virtual async ValueTask HandlerAsync(ReadOnlyMemory<byte> data, Cancellat
5050
/// <param name="socketDataConverter"></param>
5151
/// <param name="entity"></param>
5252
/// <returns></returns>
53-
public virtual bool TryConvertTo<TEntity>(ReadOnlyMemory<byte> data, ISocketDataConverter<TEntity> socketDataConverter, out TEntity? entity)
53+
public virtual bool TryConvertTo<TEntity>(ReadOnlyMemory<byte> data, IDataConverter<TEntity> socketDataConverter, out TEntity? entity)
5454
{
5555
entity = default;
5656
var ret = socketDataConverter.TryConvertTo(data, out var v);

src/extensions/BootstrapBlazor.Socket/DataPackageAdapter/IDataPackageAdapter.cs renamed to src/extensions/BootstrapBlazor.Socket/DataAdapter/IDataPackageAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5-
namespace BootstrapBlazor.Components;
5+
namespace BootstrapBlazor.DataAdapters;
66

77
/// <summary>
88
/// Defines an adapter for handling and transmitting data packages to a target destination.
@@ -50,5 +50,5 @@ public interface IDataPackageAdapter
5050
/// <param name="entity">When this method returns, contains the converted entity if the conversion was successful; otherwise, the default
5151
/// value for the type of the entity.</param>
5252
/// <returns><see langword="true"/> if the conversion was successful; otherwise, <see langword="false"/>.</returns>
53-
bool TryConvertTo<TEntity>(ReadOnlyMemory<byte> data, ISocketDataConverter<TEntity> socketDataConverter, out TEntity? entity);
53+
bool TryConvertTo<TEntity>(ReadOnlyMemory<byte> data, IDataConverter<TEntity> socketDataConverter, out TEntity? entity);
5454
}

src/extensions/BootstrapBlazor.Socket/DataConverter/SocketDataConverter.cs renamed to src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
using System.Reflection;
66

7-
namespace BootstrapBlazor.Components;
7+
namespace BootstrapBlazor.DataConverters;
88

99
/// <summary>
1010
/// Provides a base class for converting socket data into a specified entity type.
1111
/// </summary>
1212
/// <typeparam name="TEntity">The type of entity to convert the socket data into.</typeparam>
13-
public class SocketDataConverter<TEntity>(SocketDataConverterCollections converters) : ISocketDataConverter<TEntity>
13+
public class DataConverter<TEntity>(DataConverterCollections converters) : IDataConverter<TEntity>
1414
{
1515
/// <summary>
1616
/// 构造函数
1717
/// </summary>
18-
public SocketDataConverter() : this(new())
18+
public DataConverter() : this(new())
1919
{
2020

2121
}
@@ -57,7 +57,7 @@ protected virtual bool Parse(ReadOnlyMemory<byte> data, TEntity entity)
5757
var properties = entity.GetType().GetProperties().Where(p => p.CanWrite).ToList();
5858
foreach (var p in properties)
5959
{
60-
var attr = p.GetCustomAttribute<SocketDataPropertyConverterAttribute>(false)
60+
var attr = p.GetCustomAttribute<DataPropertyConverterAttribute>(false)
6161
?? GetPropertyConverterAttribute(p);
6262
if (attr != null)
6363
{
@@ -69,9 +69,9 @@ protected virtual bool Parse(ReadOnlyMemory<byte> data, TEntity entity)
6969
return ret;
7070
}
7171

72-
private SocketDataPropertyConverterAttribute? GetPropertyConverterAttribute(PropertyInfo propertyInfo)
72+
private DataPropertyConverterAttribute? GetPropertyConverterAttribute(PropertyInfo propertyInfo)
7373
{
74-
SocketDataPropertyConverterAttribute? attr = null;
74+
DataPropertyConverterAttribute? attr = null;
7575
if (converters.TryGetPropertyConverter<TEntity>(propertyInfo, out var v))
7676
{
7777
attr = v;

src/extensions/BootstrapBlazor.Socket/DataConverter/SocketDataConverterCollections.cs renamed to src/extensions/BootstrapBlazor.Socket/DataConverter/DataConverterCollections.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@
66
using System.Linq.Expressions;
77
using System.Reflection;
88

9-
namespace BootstrapBlazor.Components;
9+
namespace BootstrapBlazor.DataConverters;
1010

1111
/// <summary>
1212
/// 数据转换器集合类
1313
/// </summary>
14-
public sealed class SocketDataConverterCollections
14+
public sealed class DataConverterCollections
1515
{
16-
readonly ConcurrentDictionary<Type, ISocketDataConverter> _converters = new();
17-
readonly ConcurrentDictionary<MemberInfo, SocketDataPropertyConverterAttribute> _propertyConverters = new();
16+
readonly ConcurrentDictionary<Type, IDataConverter> _converters = new();
17+
readonly ConcurrentDictionary<MemberInfo, DataPropertyConverterAttribute> _propertyConverters = new();
1818

1919
/// <summary>
20-
/// 增加指定 <see cref="ISocketDataConverter{TEntity}"/> 数据类型转换器方法
20+
/// 增加指定 <see cref="IDataConverter{TEntity}"/> 数据类型转换器方法
2121
/// </summary>
2222
/// <typeparam name="TEntity"></typeparam>
2323
/// <param name="converter"></param>
24-
public void AddTypeConverter<TEntity>(ISocketDataConverter<TEntity> converter)
24+
public void AddTypeConverter<TEntity>(IDataConverter<TEntity> converter)
2525
{
2626
var type = typeof(TEntity);
2727
_converters.AddOrUpdate(type, t => converter, (t, v) => converter);
2828
}
2929

3030
/// <summary>
31-
/// 增加默认数据类型转换器方法 转换器使用 <see cref="SocketDataConverter{TEntity}"/>
31+
/// 增加默认数据类型转换器方法 转换器使用 <see cref="DataConverter{TEntity}"/>
3232
/// </summary>
3333
/// <typeparam name="TEntity"></typeparam>
34-
public void AddTypeConverter<TEntity>() => AddTypeConverter(new SocketDataConverter<TEntity>(this));
34+
public void AddTypeConverter<TEntity>() => AddTypeConverter(new DataConverter<TEntity>(this));
3535

3636
/// <summary>
3737
/// 添加属性类型转化器方法
3838
/// </summary>
3939
/// <typeparam name="TEntity"></typeparam>
4040
/// <param name="propertyExpression"></param>
4141
/// <param name="attribute"></param>
42-
public void AddPropertyConverter<TEntity>(Expression<Func<TEntity, object?>> propertyExpression, SocketDataPropertyConverterAttribute attribute)
42+
public void AddPropertyConverter<TEntity>(Expression<Func<TEntity, object?>> propertyExpression, DataPropertyConverterAttribute attribute)
4343
{
4444
if (propertyExpression.Body is MemberExpression memberExpression)
4545
{
@@ -55,11 +55,11 @@ public void AddPropertyConverter<TEntity>(Expression<Func<TEntity, object?>> pro
5555
/// 获得指定数据类型转换器方法
5656
/// </summary>
5757
/// <typeparam name="TEntity"></typeparam>
58-
public bool TryGetTypeConverter<TEntity>([NotNullWhen(true)] out ISocketDataConverter<TEntity>? converter)
58+
public bool TryGetTypeConverter<TEntity>([NotNullWhen(true)] out IDataConverter<TEntity>? converter)
5959
{
6060
converter = null;
6161
var ret = false;
62-
if (_converters.TryGetValue(typeof(TEntity), out var v) && v is ISocketDataConverter<TEntity> c)
62+
if (_converters.TryGetValue(typeof(TEntity), out var v) && v is IDataConverter<TEntity> c)
6363
{
6464
converter = c;
6565
ret = true;
@@ -71,7 +71,7 @@ public bool TryGetTypeConverter<TEntity>([NotNullWhen(true)] out ISocketDataConv
7171
/// 获得指定数据类型属性转换器方法
7272
/// </summary>
7373
/// <typeparam name="TEntity"></typeparam>
74-
public bool TryGetPropertyConverter<TEntity>(Expression<Func<TEntity, object?>> propertyExpression, [NotNullWhen(true)] out SocketDataPropertyConverterAttribute? converterAttribute)
74+
public bool TryGetPropertyConverter<TEntity>(Expression<Func<TEntity, object?>> propertyExpression, [NotNullWhen(true)] out DataPropertyConverterAttribute? converterAttribute)
7575
{
7676
converterAttribute = null;
7777
var ret = false;
@@ -87,7 +87,7 @@ public bool TryGetPropertyConverter<TEntity>(Expression<Func<TEntity, object?>>
8787
/// 获得指定数据类型属性转换器方法
8888
/// </summary>
8989
/// <typeparam name="TEntity"></typeparam>
90-
public bool TryGetPropertyConverter<TEntity>(MemberInfo memberInfo, [NotNullWhen(true)] out SocketDataPropertyConverterAttribute? converterAttribute)
90+
public bool TryGetPropertyConverter<TEntity>(MemberInfo memberInfo, [NotNullWhen(true)] out DataPropertyConverterAttribute? converterAttribute)
9191
{
9292
converterAttribute = null;
9393
var ret = false;

src/extensions/BootstrapBlazor.Socket/DataConverter/SocketDataPropertyConverterAttribute.cs renamed to src/extensions/BootstrapBlazor.Socket/DataConverter/DataPropertyConverterAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5-
namespace BootstrapBlazor.Components;
5+
namespace BootstrapBlazor.DataConverters;
66

77
/// <summary>
88
/// Represents an attribute used to mark a field as a socket data field.
@@ -11,7 +11,7 @@ namespace BootstrapBlazor.Components;
1111
/// socket connection. It is intended for use in scenarios where socket communication requires specific fields to be
1212
/// identified for processing.</remarks>
1313
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
14-
public class SocketDataPropertyConverterAttribute : Attribute
14+
public class DataPropertyConverterAttribute : Attribute
1515
{
1616
/// <summary>
1717
/// 获得/设置 数据类型

src/extensions/BootstrapBlazor.Socket/DataConverter/SocketDataTypeConverterAttribute.cs renamed to src/extensions/BootstrapBlazor.Socket/DataConverter/DataTypeConverterAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5-
namespace BootstrapBlazor.Components;
5+
namespace BootstrapBlazor.DataConverters;
66

77
/// <summary>
88
///
99
/// </summary>
1010
[AttributeUsage(AttributeTargets.Class)]
11-
public class SocketDataTypeConverterAttribute : Attribute
11+
public class DataTypeConverterAttribute : Attribute
1212
{
1313
/// <summary>
14-
/// Gets or sets the type of the <see cref="ISocketDataConverter{TEntity}"/>.
14+
/// Gets or sets the type of the <see cref="IDataConverter{TEntity}"/>.
1515
/// </summary>
1616
public Type? Type { get; set; }
1717
}

src/extensions/BootstrapBlazor.Socket/DataConverter/ISocketDataConverter.cs renamed to src/extensions/BootstrapBlazor.Socket/DataConverter/IDataConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5-
namespace BootstrapBlazor.Components;
5+
namespace BootstrapBlazor.DataConverters;
66

77
/// <summary>
88
/// Socket 数据转换器接口
99
/// </summary>
10-
public interface ISocketDataConverter
10+
public interface IDataConverter
1111
{
1212

1313
}
@@ -16,7 +16,7 @@ public interface ISocketDataConverter
1616
/// Defines a method to convert raw socket data into a specified entity type.
1717
/// </summary>
1818
/// <typeparam name="TEntity">The type of entity to convert the data into.</typeparam>
19-
public interface ISocketDataConverter<TEntity> : ISocketDataConverter
19+
public interface IDataConverter<TEntity> : IDataConverter
2020
{
2121
/// <summary>
2222
/// Attempts to convert the specified data to an instance of <typeparamref name="TEntity"/>.

src/extensions/BootstrapBlazor.Socket/DataPackageHandler/DataPackageHandlerBase.cs renamed to src/extensions/BootstrapBlazor.Socket/DataHandler/DataPackageHandlerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5-
namespace BootstrapBlazor.Components;
5+
namespace BootstrapBlazor.DataHandlers;
66

77
/// <summary>
88
/// Provides a base implementation for handling data packages in a communication system.

src/extensions/BootstrapBlazor.Socket/DataPackageHandler/DelimiterDataPackageHandler.cs renamed to src/extensions/BootstrapBlazor.Socket/DataHandler/DelimiterDataPackageHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Buffers;
66
using System.Text;
77

8-
namespace BootstrapBlazor.Components;
8+
namespace BootstrapBlazor.DataHandlers;
99

1010
/// <summary>
1111
/// Handles data packages that are delimited by a specific sequence of bytes or characters.

0 commit comments

Comments
 (0)