Skip to content

Commit bde437d

Browse files
committed
代码清理
1 parent 6de1efb commit bde437d

26 files changed

+259
-257
lines changed

src/Cosmos.Core/Cosmos/ByteExtensions.cs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ namespace Cosmos;
66
/// </summary>
77
public static class ByteExtensions
88
{
9-
#region Min & Max
10-
119
/// <summary>
1210
/// Gets max one. <br />
1311
/// 获取大值。
@@ -26,37 +24,16 @@ public static class ByteExtensions
2624
/// <returns></returns>
2725
public static byte Min(this byte val1, byte val2) => Math.Min(val1, val2);
2826

29-
#endregion
30-
31-
#region Resize
32-
3327
/// <summary>
3428
/// Resize <br />
3529
/// 重新设置尺寸
3630
/// </summary>
37-
/// <param name="this"></param>
31+
/// <param name="buff"></param>
3832
/// <param name="newSize"></param>
3933
/// <returns></returns>
40-
public static byte[] Resize(this byte[] @this, int newSize)
41-
{
42-
Array.Resize(ref @this, newSize);
43-
return @this;
44-
}
45-
46-
#endregion
47-
48-
#region To MemoryStream
49-
50-
/// <summary>
51-
/// Convert byte[] to <see cref="MemoryStream"/> <br />
52-
/// 转换类型,将 <see cref="byte"/>[] 转换为 <see cref="MemoryStream"/>
53-
/// </summary>
54-
/// <param name="this"></param>
55-
/// <returns></returns>
56-
public static MemoryStream ToMemoryStream(this byte[] @this)
34+
public static byte[] Resize(this byte[] buff, int newSize)
5735
{
58-
return new MemoryStream(@this);
36+
Array.Resize(ref buff, newSize);
37+
return buff;
5938
}
60-
61-
#endregion
6239
}

src/Cosmos.Core/Cosmos/Date/DateTime.cs renamed to src/Cosmos.Core/Cosmos/Date/DateTimeOutputExtensions.cs

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,9 @@
11
namespace Cosmos.Date;
22

3-
/// <summary>
4-
/// Datetime Output Styles <br />
5-
/// 时间输出风格
6-
/// </summary>
7-
public enum DateTimeOutputStyles
8-
{
9-
/// <summary>
10-
/// DateTime
11-
/// </summary>
12-
DateTime,
13-
14-
/// <summary>
15-
/// Date
16-
/// </summary>
17-
Date,
18-
19-
/// <summary>
20-
/// Time
21-
/// </summary>
22-
Time,
23-
24-
/// <summary>
25-
/// LongDate
26-
/// </summary>
27-
LongDate,
28-
29-
/// <summary>
30-
/// LongTime
31-
/// </summary>
32-
LongTime,
33-
34-
/// <summary>
35-
/// ShortDate
36-
/// </summary>
37-
ShortDate,
38-
39-
/// <summary>
40-
/// ShortTime
41-
/// </summary>
42-
ShortTime,
43-
44-
/// <summary>
45-
/// Millisecond
46-
/// </summary>
47-
Millisecond,
48-
}
49-
503
/// <summary>
514
/// DateTime Helper (internal)
525
/// </summary>
53-
internal static class DateTimeHelper
6+
internal static class DateTimeOutputHelper
547
{
558
/// <summary>
569
/// If this then that...
@@ -70,7 +23,7 @@ public static string Ifttt(bool condition, string format1, string format2)
7023
/// DateTime to String extensions <br />
7124
/// DateTime 转换为 String 的扩展
7225
/// </summary>
73-
public static class DateTimeToStringExtensions
26+
public static class DateTimeOutputExtensions
7427
{
7528
/// <summary>
7629
/// Convert DateTime value to String. <br />
@@ -84,9 +37,9 @@ public static string ToString(this DateTime dt, DateTimeOutputStyles styles, boo
8437
{
8538
return styles switch
8639
{
87-
DateTimeOutputStyles.DateTime => dt.ToString(DateTimeHelper.Ifttt(isRemoveSecond, "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH:mm:ss")),
40+
DateTimeOutputStyles.DateTime => dt.ToString(DateTimeOutputHelper.Ifttt(isRemoveSecond, "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH:mm:ss")),
8841
DateTimeOutputStyles.Date => dt.ToString("yyyy-MM-dd"),
89-
DateTimeOutputStyles.Time => dt.ToString(DateTimeHelper.Ifttt(isRemoveSecond, "HH:mm", "HH:mm:ss")),
42+
DateTimeOutputStyles.Time => dt.ToString(DateTimeOutputHelper.Ifttt(isRemoveSecond, "HH:mm", "HH:mm:ss")),
9043
DateTimeOutputStyles.LongDate => dt.ToLongDateString(),
9144
DateTimeOutputStyles.LongTime => dt.ToLongTimeString(),
9245
DateTimeOutputStyles.ShortDate => dt.ToShortDateString(),
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace Cosmos.Date;
2+
3+
/// <summary>
4+
/// Datetime Output Styles <br />
5+
/// 时间输出风格
6+
/// </summary>
7+
public enum DateTimeOutputStyles
8+
{
9+
/// <summary>
10+
/// DateTime
11+
/// </summary>
12+
DateTime,
13+
14+
/// <summary>
15+
/// Date
16+
/// </summary>
17+
Date,
18+
19+
/// <summary>
20+
/// Time
21+
/// </summary>
22+
Time,
23+
24+
/// <summary>
25+
/// LongDate
26+
/// </summary>
27+
LongDate,
28+
29+
/// <summary>
30+
/// LongTime
31+
/// </summary>
32+
LongTime,
33+
34+
/// <summary>
35+
/// ShortDate
36+
/// </summary>
37+
ShortDate,
38+
39+
/// <summary>
40+
/// ShortTime
41+
/// </summary>
42+
ShortTime,
43+
44+
/// <summary>
45+
/// Millisecond
46+
/// </summary>
47+
Millisecond,
48+
}

src/Cosmos.Core/Cosmos/Date/TimeStamp.UnixTimeStamp.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ private UnixTimeStamp(DateTime dt, long timestamp)
4545
(time.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
4646

4747
private static readonly Func<long, DateTime> FromUnixTimestampFunc = timestamp =>
48-
(TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local))
49-
.Add(new TimeSpan(long.Parse(timestamp + "0000000")));
48+
TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local)
49+
.Add(new TimeSpan(long.Parse(timestamp + "0000000")));
5050

5151
/// <summary>
5252
/// Gets a func for unix now.

src/Cosmos.Core/Cosmos/Exceptions/Try.Create.Future.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public static partial class Try
3838
/// <typeparam name="T2"></typeparam>
3939
/// <typeparam name="T"></typeparam>
4040
/// <returns></returns>
41-
public static FutureCreatingBuilder<T1, T2, T> CreateFuture<T1, T2, T>(Func<T1, T2, T> createFunction) => new(createFunction);
41+
public static FutureCreatingBuilder<T1, T2, T> CreateFuture<T1, T2, T>(
42+
Func<T1, T2, T> createFunction) => new(createFunction);
4243

4344
/// <summary>
4445
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -50,7 +51,8 @@ public static partial class Try
5051
/// <typeparam name="T3"></typeparam>
5152
/// <typeparam name="T"></typeparam>
5253
/// <returns></returns>
53-
public static FutureCreatingBuilder<T1, T2, T3, T> CreateFuture<T1, T2, T3, T>(Func<T1, T2, T3, T> createFunction) => new(createFunction);
54+
public static FutureCreatingBuilder<T1, T2, T3, T> CreateFuture<T1, T2, T3, T>(
55+
Func<T1, T2, T3, T> createFunction) => new(createFunction);
5456

5557
/// <summary>
5658
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -63,7 +65,8 @@ public static partial class Try
6365
/// <typeparam name="T4"></typeparam>
6466
/// <typeparam name="T"></typeparam>
6567
/// <returns></returns>
66-
public static FutureCreatingBuilder<T1, T2, T3, T4, T> CreateFuture<T1, T2, T3, T4, T>(Func<T1, T2, T3, T4, T> createFunction) => new(createFunction);
68+
public static FutureCreatingBuilder<T1, T2, T3, T4, T> CreateFuture<T1, T2, T3, T4, T>(
69+
Func<T1, T2, T3, T4, T> createFunction) => new(createFunction);
6770

6871
/// <summary>
6972
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -77,7 +80,8 @@ public static partial class Try
7780
/// <typeparam name="T5"></typeparam>
7881
/// <typeparam name="T"></typeparam>
7982
/// <returns></returns>
80-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T> CreateFuture<T1, T2, T3, T4, T5, T>(Func<T1, T2, T3, T4, T5, T> createFunction) => new(createFunction);
83+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T> CreateFuture<T1, T2, T3, T4, T5, T>(
84+
Func<T1, T2, T3, T4, T5, T> createFunction) => new(createFunction);
8185

8286
/// <summary>
8387
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -92,7 +96,8 @@ public static partial class Try
9296
/// <typeparam name="T6"></typeparam>
9397
/// <typeparam name="T"></typeparam>
9498
/// <returns></returns>
95-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T> CreateFuture<T1, T2, T3, T4, T5, T6, T>(Func<T1, T2, T3, T4, T5, T6, T> createFunction) => new(createFunction);
99+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T> CreateFuture<T1, T2, T3, T4, T5, T6, T>(
100+
Func<T1, T2, T3, T4, T5, T6, T> createFunction) => new(createFunction);
96101

97102
/// <summary>
98103
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -108,7 +113,8 @@ public static partial class Try
108113
/// <typeparam name="T7"></typeparam>
109114
/// <typeparam name="T"></typeparam>
110115
/// <returns></returns>
111-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T>(Func<T1, T2, T3, T4, T5, T6, T7, T> createFunction) => new(createFunction);
116+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T>(
117+
Func<T1, T2, T3, T4, T5, T6, T7, T> createFunction) => new(createFunction);
112118

113119
/// <summary>
114120
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -125,7 +131,8 @@ public static partial class Try
125131
/// <typeparam name="T8"></typeparam>
126132
/// <typeparam name="T"></typeparam>
127133
/// <returns></returns>
128-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T> createFunction) => new(createFunction);
134+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T>(
135+
Func<T1, T2, T3, T4, T5, T6, T7, T8, T> createFunction) => new(createFunction);
129136

130137
/// <summary>
131138
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -143,7 +150,8 @@ public static partial class Try
143150
/// <typeparam name="T9"></typeparam>
144151
/// <typeparam name="T"></typeparam>
145152
/// <returns></returns>
146-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T> createFunction) => new(createFunction);
153+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T>(
154+
Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T> createFunction) => new(createFunction);
147155

148156
/// <summary>
149157
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -162,7 +170,8 @@ public static partial class Try
162170
/// <typeparam name="T10"></typeparam>
163171
/// <typeparam name="T"></typeparam>
164172
/// <returns></returns>
165-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T> createFunction) => new(createFunction);
173+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T>(
174+
Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T> createFunction) => new(createFunction);
166175

167176
/// <summary>
168177
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -182,7 +191,8 @@ public static partial class Try
182191
/// <typeparam name="T11"></typeparam>
183192
/// <typeparam name="T"></typeparam>
184193
/// <returns></returns>
185-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T> createFunction) => new(createFunction);
194+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T>(
195+
Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T> createFunction) => new(createFunction);
186196

187197
/// <summary>
188198
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />
@@ -203,8 +213,8 @@ public static partial class Try
203213
/// <typeparam name="T12"></typeparam>
204214
/// <typeparam name="T"></typeparam>
205215
/// <returns></returns>
206-
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T> createFunction) =>
207-
new(createFunction);
216+
public static FutureCreatingBuilder<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T> CreateFuture<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T>(
217+
Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T> createFunction) => new(createFunction);
208218

209219
/// <summary>
210220
/// Create a new instance of <see cref="Try{TResult}"/> in the future. <br />

0 commit comments

Comments
 (0)