file scoped namespaces (#565)

This commit is contained in:
Aleh Khantsevich
2025-02-16 11:54:23 +01:00
committed by GitHub
parent cf9869b71e
commit 3ddc1a6229
617 changed files with 32107 additions and 32721 deletions

View File

@@ -1,33 +1,32 @@
using System;
using Wino.Core.Domain.Models.Calendar;
namespace Wino.Core.Domain.Extensions
namespace Wino.Core.Domain.Extensions;
public static class DateTimeExtensions
{
public static class DateTimeExtensions
/// <summary>
/// Returns a date range for the month of the given date.
/// </summary>
/// <param name="date">Date to get range for.</param>
public static DateRange GetMonthDateRangeStartingWeekday(this DateTime date, DayOfWeek WeekStartDay)
{
/// <summary>
/// Returns a date range for the month of the given date.
/// </summary>
/// <param name="date">Date to get range for.</param>
public static DateRange GetMonthDateRangeStartingWeekday(this DateTime date, DayOfWeek WeekStartDay)
{
DateTime firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
DateTime firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
int daysToSubtract = (7 + (firstDayOfMonth.DayOfWeek - WeekStartDay)) % 7;
DateTime rangeStart = firstDayOfMonth.AddDays(-daysToSubtract);
int daysToSubtract = (7 + (firstDayOfMonth.DayOfWeek - WeekStartDay)) % 7;
DateTime rangeStart = firstDayOfMonth.AddDays(-daysToSubtract);
DateTime rangeEnd = rangeStart.AddDays(34);
DateTime rangeEnd = rangeStart.AddDays(34);
return new DateRange(rangeStart, rangeEnd);
}
return new DateRange(rangeStart, rangeEnd);
}
public static DateTime GetWeekStartDateForDate(this DateTime date, DayOfWeek firstDayOfWeek)
{
// Detect the first day of the week that contains the selected date.
int diff = (7 + (date.DayOfWeek - firstDayOfWeek)) % 7;
public static DateTime GetWeekStartDateForDate(this DateTime date, DayOfWeek firstDayOfWeek)
{
// Detect the first day of the week that contains the selected date.
int diff = (7 + (date.DayOfWeek - firstDayOfWeek)) % 7;
// Start loading from this date instead of visible date.
return date.AddDays(-diff).Date;
}
// Start loading from this date instead of visible date.
return date.AddDays(-diff).Date;
}
}

View File

@@ -1,24 +1,23 @@
using System;
using System.Collections.Generic;
namespace Wino.Core.Domain.Extensions
{
public static class ExceptionExtensions
{
public static IEnumerable<Exception> GetInnerExceptions(this Exception ex)
{
if (ex == null)
{
throw new ArgumentNullException("ex");
}
namespace Wino.Core.Domain.Extensions;
var innerException = ex;
do
{
yield return innerException;
innerException = innerException.InnerException;
}
while (innerException != null);
public static class ExceptionExtensions
{
public static IEnumerable<Exception> GetInnerExceptions(this Exception ex)
{
if (ex == null)
{
throw new ArgumentNullException("ex");
}
var innerException = ex;
do
{
yield return innerException;
innerException = innerException.InnerException;
}
while (innerException != null);
}
}

View File

@@ -1,20 +1,19 @@
using System;
using System.IO;
namespace Wino.Core.Domain.Extensions
namespace Wino.Core.Domain.Extensions;
public static class MimeExtensions
{
public static class MimeExtensions
public static string GetBase64MimeMessage(this MimeKit.MimeMessage message)
{
public static string GetBase64MimeMessage(this MimeKit.MimeMessage message)
{
using MemoryStream memoryStream = new();
using MemoryStream memoryStream = new();
message.WriteTo(memoryStream);
message.WriteTo(memoryStream);
return Convert.ToBase64String(memoryStream.ToArray());
}
public static MimeKit.MimeMessage GetMimeMessageFromBase64(this string base64)
=> MimeKit.MimeMessage.Load(new System.IO.MemoryStream(Convert.FromBase64String(base64)));
return Convert.ToBase64String(memoryStream.ToArray());
}
public static MimeKit.MimeMessage GetMimeMessageFromBase64(this string base64)
=> MimeKit.MimeMessage.Load(new System.IO.MemoryStream(Convert.FromBase64String(base64)));
}