Skip to content

Commit

Permalink
Merge pull request #7 from dncuug/update-project
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado-x authored Sep 3, 2022
2 parents fc0a3d6 + d753b3b commit 5bf70b0
Show file tree
Hide file tree
Showing 31 changed files with 1,660 additions and 1,758 deletions.
24 changes: 13 additions & 11 deletions src/X.Web.RSS/Enumerators/Day.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
namespace X.Web.RSS.Enumerators
using JetBrains.Annotations;

namespace X.Web.RSS.Enumerators;

[PublicAPI]
public enum Day
{
public enum Day
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
42 changes: 19 additions & 23 deletions src/X.Web.RSS/Enumerators/Hour.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
using X.Web.RSS.Exceptions;
using System.Xml.Serialization;

namespace X.Web.RSS.Enumerators
namespace X.Web.RSS.Enumerators;

public class Hour
{
public class Hour
{
private byte _value;
private byte _value;

public Hour()
{
}
public Hour()
{
}

public Hour(byte newValue)
{
_value = newValue;
}
public Hour(byte newValue)
{
_value = newValue;
}

[XmlText]
public byte Value
[XmlText]
public byte Value
{
get => _value;
set
{
get
if (value < 0 || value > 23)
{
return _value;
throw new RSSParameterException("hour", value);
}
set
{
if (_value < 0 || _value > 23)
{
throw new RSSParameterException("hour", value);
}

_value = value;
}
_value = value;
}
}
}
16 changes: 9 additions & 7 deletions src/X.Web.RSS/Enumerators/Protocol.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace X.Web.RSS.Enumerators
using JetBrains.Annotations;

namespace X.Web.RSS.Enumerators;

// ToDo: rename elements and check xml-rpc
[PublicAPI]
public enum Protocol
{
// ToDo: rename elements and chect xml-rpc
public enum Protocol
{
soap, // "soap",
xmlrpc // "xml-rpc"
}
soap, // "soap",
xmlrpc // "xml-rpc"
}
14 changes: 8 additions & 6 deletions src/X.Web.RSS/Enumerators/Rel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace X.Web.RSS.Enumerators
using JetBrains.Annotations;

namespace X.Web.RSS.Enumerators;

[PublicAPI]
public enum Rel
{
public enum Rel
{
self,
alternate
}
self,
alternate
}
62 changes: 27 additions & 35 deletions src/X.Web.RSS/Exceptions/RSSParameterException.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
using System;
using System.Runtime.Serialization;
using JetBrains.Annotations;

namespace X.Web.RSS.Exceptions
{
public class RSSParameterException : Exception
{
private readonly string field;

private readonly object value;
namespace X.Web.RSS.Exceptions;

private const string MessageText = "RSSParameterException field '{0}', value '{1}'";
public class RSSParameterException : Exception
{
private const string MessageText = "RSSParameterException field '{0}', value '{1}'";

public RSSParameterException(string field, object value)
: base(string.Format(MessageText, field, value))
{
this.field = field;
this.value = value;
}
public RSSParameterException(string field, object value)
: base(string.Format(MessageText, field, value))
{
Field = field;
Value = value;
}

public RSSParameterException(string field, object value, Exception innerException)
: base(string.Format(MessageText, field, value), innerException)
{
this.field = field;
this.value = value;
}
public RSSParameterException(string field, object value, Exception innerException)
: base(string.Format(MessageText, field, value), innerException)
{
Field = field;
Value = value;
}

protected RSSParameterException(SerializationInfo info, StreamingContext context, string field, object value)
//: base(info, context)
{
this.field = field;
this.value = value;
}
protected RSSParameterException(SerializationInfo info, StreamingContext context, string field, object value)
: base(info, context)
{
Field = field;
Value = value;
}

public string Field
{
get { return this.field; }
}
[PublicAPI]
public string Field { get; }

public object Value
{
get { return this.value; }
}
}
[PublicAPI]
public object Value { get; }
}
6 changes: 0 additions & 6 deletions src/X.Web.RSS/Exceptions/SerializationInfo.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/X.Web.RSS/Exceptions/StreamingContext.cs

This file was deleted.

52 changes: 25 additions & 27 deletions src/X.Web.RSS/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
using System;
using System.Globalization;

namespace X.Web.RSS.Extensions
namespace X.Web.RSS.Extensions;

public static class DateTimeExtensions
{
public static class DateTimeExtensions
///<summary>
/// Converts a regular DateTime to a RFC822 date string.
///</summary>
///<returns>The specified date formatted as a RFC822 date string.</returns>
public static string ToRFC822Date(this DateTime date)
{
///<summary>
/// Converts a regular DateTime to a RFC822 date string.
///</summary>
///<returns>The specified date formatted as a RFC822 date string.</returns>
public static string ToRFC822Date(this DateTime date)
{
var timeZone = GetTimeZone();
var timeZone = GetTimeZone();

var result = date.ToString("ddd, dd MMM yyyy HH:mm:ss " + timeZone.PadRight(5, '0'));
return result;
}

private static string GetTimeZone()
{
var utcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
var offset = utcOffset.Hours;
var timeZone = "+" + offset.ToString().PadLeft(2, '0');
var result = date.ToString("ddd, dd MMM yyyy HH:mm:ss " + timeZone.PadRight(5, '0'));

return result;
}

if (offset < 0)
{
int i = offset * -1;
timeZone = "-" + i.ToString().PadLeft(2, '0');
}
return timeZone;
}
private static string GetTimeZone()
{
var utcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
var offset = utcOffset.Hours;
var timeZone = "+" + offset.ToString().PadLeft(2, '0');

public static DateTime FromRFC822Date(this string date)
if (offset < 0)
{
return DateTime.Parse(date);
var i = offset * -1;
timeZone = "-" + i.ToString().PadLeft(2, '0');
}

return timeZone;
}

public static DateTime FromRFC822Date(this string date) => DateTime.Parse(date);
}
Loading

0 comments on commit 5bf70b0

Please sign in to comment.