Revert "File scoped namespaces"

This reverts commit d31d8f574e.
This commit is contained in:
Burak Kaan Köse
2025-02-16 11:43:30 +01:00
parent d31d8f574e
commit cf9869b71e
617 changed files with 32097 additions and 31478 deletions

View File

@@ -1,32 +1,33 @@
using System;
using Wino.Core.Domain.Models.Calendar;
namespace Wino.Core.Domain.Extensions;
public static class DateTimeExtensions
namespace Wino.Core.Domain.Extensions
{
/// <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)
public static class DateTimeExtensions
{
DateTime firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
/// <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);
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,23 +1,24 @@
using System;
using System.Collections.Generic;
namespace Wino.Core.Domain.Extensions;
public static class ExceptionExtensions
namespace Wino.Core.Domain.Extensions
{
public static IEnumerable<Exception> GetInnerExceptions(this Exception ex)
public static class ExceptionExtensions
{
if (ex == null)
public static IEnumerable<Exception> GetInnerExceptions(this Exception ex)
{
throw new ArgumentNullException("ex");
}
if (ex == null)
{
throw new ArgumentNullException("ex");
}
var innerException = ex;
do
{
yield return innerException;
innerException = innerException.InnerException;
var innerException = ex;
do
{
yield return innerException;
innerException = innerException.InnerException;
}
while (innerException != null);
}
while (innerException != null);
}
}

View File

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