Skip to content

Commit 5bf70b0

Browse files
authored
Merge pull request #7 from dncuug/update-project
2 parents fc0a3d6 + d753b3b commit 5bf70b0

31 files changed

+1660
-1758
lines changed

src/X.Web.RSS/Enumerators/Day.cs

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
namespace X.Web.RSS.Enumerators
1+
using JetBrains.Annotations;
2+
3+
namespace X.Web.RSS.Enumerators;
4+
5+
[PublicAPI]
6+
public enum Day
27
{
3-
public enum Day
4-
{
5-
Monday,
6-
Tuesday,
7-
Wednesday,
8-
Thursday,
9-
Friday,
10-
Saturday,
11-
Sunday
12-
}
8+
Monday,
9+
Tuesday,
10+
Wednesday,
11+
Thursday,
12+
Friday,
13+
Saturday,
14+
Sunday
1315
}

src/X.Web.RSS/Enumerators/Hour.cs

+19-23
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
using X.Web.RSS.Exceptions;
22
using System.Xml.Serialization;
33

4-
namespace X.Web.RSS.Enumerators
4+
namespace X.Web.RSS.Enumerators;
5+
6+
public class Hour
57
{
6-
public class Hour
7-
{
8-
private byte _value;
8+
private byte _value;
99

10-
public Hour()
11-
{
12-
}
10+
public Hour()
11+
{
12+
}
1313

14-
public Hour(byte newValue)
15-
{
16-
_value = newValue;
17-
}
14+
public Hour(byte newValue)
15+
{
16+
_value = newValue;
17+
}
1818

19-
[XmlText]
20-
public byte Value
19+
[XmlText]
20+
public byte Value
21+
{
22+
get => _value;
23+
set
2124
{
22-
get
25+
if (value < 0 || value > 23)
2326
{
24-
return _value;
27+
throw new RSSParameterException("hour", value);
2528
}
26-
set
27-
{
28-
if (_value < 0 || _value > 23)
29-
{
30-
throw new RSSParameterException("hour", value);
31-
}
3229

33-
_value = value;
34-
}
30+
_value = value;
3531
}
3632
}
3733
}

src/X.Web.RSS/Enumerators/Protocol.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
namespace X.Web.RSS.Enumerators
1+
using JetBrains.Annotations;
2+
3+
namespace X.Web.RSS.Enumerators;
4+
5+
// ToDo: rename elements and check xml-rpc
6+
[PublicAPI]
7+
public enum Protocol
28
{
3-
// ToDo: rename elements and chect xml-rpc
4-
public enum Protocol
5-
{
6-
soap, // "soap",
7-
xmlrpc // "xml-rpc"
8-
}
9+
soap, // "soap",
10+
xmlrpc // "xml-rpc"
911
}

src/X.Web.RSS/Enumerators/Rel.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
namespace X.Web.RSS.Enumerators
1+
using JetBrains.Annotations;
2+
3+
namespace X.Web.RSS.Enumerators;
4+
5+
[PublicAPI]
6+
public enum Rel
27
{
3-
public enum Rel
4-
{
5-
self,
6-
alternate
7-
}
8+
self,
9+
alternate
810
}
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,37 @@
11
using System;
22
using System.Runtime.Serialization;
3+
using JetBrains.Annotations;
34

4-
namespace X.Web.RSS.Exceptions
5-
{
6-
public class RSSParameterException : Exception
7-
{
8-
private readonly string field;
9-
10-
private readonly object value;
5+
namespace X.Web.RSS.Exceptions;
116

12-
private const string MessageText = "RSSParameterException field '{0}', value '{1}'";
7+
public class RSSParameterException : Exception
8+
{
9+
private const string MessageText = "RSSParameterException field '{0}', value '{1}'";
1310

14-
public RSSParameterException(string field, object value)
15-
: base(string.Format(MessageText, field, value))
16-
{
17-
this.field = field;
18-
this.value = value;
19-
}
11+
public RSSParameterException(string field, object value)
12+
: base(string.Format(MessageText, field, value))
13+
{
14+
Field = field;
15+
Value = value;
16+
}
2017

21-
public RSSParameterException(string field, object value, Exception innerException)
22-
: base(string.Format(MessageText, field, value), innerException)
23-
{
24-
this.field = field;
25-
this.value = value;
26-
}
18+
public RSSParameterException(string field, object value, Exception innerException)
19+
: base(string.Format(MessageText, field, value), innerException)
20+
{
21+
Field = field;
22+
Value = value;
23+
}
2724

28-
protected RSSParameterException(SerializationInfo info, StreamingContext context, string field, object value)
29-
//: base(info, context)
30-
{
31-
this.field = field;
32-
this.value = value;
33-
}
25+
protected RSSParameterException(SerializationInfo info, StreamingContext context, string field, object value)
26+
: base(info, context)
27+
{
28+
Field = field;
29+
Value = value;
30+
}
3431

35-
public string Field
36-
{
37-
get { return this.field; }
38-
}
32+
[PublicAPI]
33+
public string Field { get; }
3934

40-
public object Value
41-
{
42-
get { return this.value; }
43-
}
44-
}
35+
[PublicAPI]
36+
public object Value { get; }
4537
}

src/X.Web.RSS/Exceptions/SerializationInfo.cs

-6
This file was deleted.

src/X.Web.RSS/Exceptions/StreamingContext.cs

-6
This file was deleted.
+25-27
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
using System;
22
using System.Globalization;
33

4-
namespace X.Web.RSS.Extensions
4+
namespace X.Web.RSS.Extensions;
5+
6+
public static class DateTimeExtensions
57
{
6-
public static class DateTimeExtensions
8+
///<summary>
9+
/// Converts a regular DateTime to a RFC822 date string.
10+
///</summary>
11+
///<returns>The specified date formatted as a RFC822 date string.</returns>
12+
public static string ToRFC822Date(this DateTime date)
713
{
8-
///<summary>
9-
/// Converts a regular DateTime to a RFC822 date string.
10-
///</summary>
11-
///<returns>The specified date formatted as a RFC822 date string.</returns>
12-
public static string ToRFC822Date(this DateTime date)
13-
{
14-
var timeZone = GetTimeZone();
14+
var timeZone = GetTimeZone();
1515

16-
var result = date.ToString("ddd, dd MMM yyyy HH:mm:ss " + timeZone.PadRight(5, '0'));
17-
return result;
18-
}
19-
20-
private static string GetTimeZone()
21-
{
22-
var utcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
23-
var offset = utcOffset.Hours;
24-
var timeZone = "+" + offset.ToString().PadLeft(2, '0');
16+
var result = date.ToString("ddd, dd MMM yyyy HH:mm:ss " + timeZone.PadRight(5, '0'));
17+
18+
return result;
19+
}
2520

26-
if (offset < 0)
27-
{
28-
int i = offset * -1;
29-
timeZone = "-" + i.ToString().PadLeft(2, '0');
30-
}
31-
return timeZone;
32-
}
21+
private static string GetTimeZone()
22+
{
23+
var utcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
24+
var offset = utcOffset.Hours;
25+
var timeZone = "+" + offset.ToString().PadLeft(2, '0');
3326

34-
public static DateTime FromRFC822Date(this string date)
27+
if (offset < 0)
3528
{
36-
return DateTime.Parse(date);
29+
var i = offset * -1;
30+
timeZone = "-" + i.ToString().PadLeft(2, '0');
3731
}
32+
33+
return timeZone;
3834
}
35+
36+
public static DateTime FromRFC822Date(this string date) => DateTime.Parse(date);
3937
}

0 commit comments

Comments
 (0)