Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,45 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplePost", "src\SimplePost.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplePost.Tests", "tests\SimplePost.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimplePost", "src\SimplePost.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,127 +3,30 @@

// <auto-generated/>

#nullable disable
#nullable enable

using System;
using System.Collections;
using System.Collections.Generic;

namespace SimplePost
namespace SimplePost;

internal static class Argument
{
internal static class Argument
public static void AssertNotNull<T>(T value, string name)
{
public static void AssertNotNull<T>(T value, string name)
{
if (value is null)
{
throw new ArgumentNullException(name);
}
}

public static void AssertNotNull<T>(T? value, string name)
where T : struct
if (value is null)
{
if (!value.HasValue)
{
throw new ArgumentNullException(name);
}
throw new ArgumentNullException(name);
}

public static void AssertNotNullOrEmpty<T>(IEnumerable<T> value, string name)
{
if (value is null)
{
throw new ArgumentNullException(name);
}
if (value is ICollection<T> collectionOfT && collectionOfT.Count == 0)
{
throw new ArgumentException("Value cannot be an empty collection.", name);
}
if (value is ICollection collection && collection.Count == 0)
{
throw new ArgumentException("Value cannot be an empty collection.", name);
}
using IEnumerator<T> e = value.GetEnumerator();
if (!e.MoveNext())
{
throw new ArgumentException("Value cannot be an empty collection.", name);
}
}

public static void AssertNotNullOrEmpty(string value, string name)
{
if (value is null)
{
throw new ArgumentNullException(name);
}
if (value.Length == 0)
{
throw new ArgumentException("Value cannot be an empty string.", name);
}
}

public static void AssertNotNullOrWhiteSpace(string value, string name)
{
if (value is null)
{
throw new ArgumentNullException(name);
}
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name);
}
}

public static void AssertNotDefault<T>(ref T value, string name)
where T : struct, IEquatable<T>
{
if (value.Equals(default))
{
throw new ArgumentException("Value cannot be empty.", name);
}
}

public static void AssertInRange<T>(T value, T minimum, T maximum, string name)
where T : notnull, IComparable<T>
{
if (minimum.CompareTo(value) > 0)
{
throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed.");
}
if (maximum.CompareTo(value) < 0)
{
throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed.");
}
}

public static void AssertEnumDefined(Type enumType, object value, string name)
{
if (!Enum.IsDefined(enumType, value))
{
throw new ArgumentException($"Value not defined for {enumType.FullName}.", name);
}
}

public static T CheckNotNull<T>(T value, string name)
where T : class
{
AssertNotNull(value, name);
return value;
}

public static string CheckNotNullOrEmpty(string value, string name)
}
public static void AssertNotNullOrEmpty(string value, string name)
{
if (value is null)
{
AssertNotNullOrEmpty(value, name);
return value;
throw new ArgumentNullException(name);
}

public static void AssertNull<T>(T value, string name, string message = null)
if (value.Length == 0)
{
if (value != null)
{
throw new ArgumentException(message ?? "Value must be null.", name);
}
throw new ArgumentException("Value cannot be an empty string.", name);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <auto-generated/>

#nullable enable

using System.Threading;
using Azure;

namespace SimplePost;

internal static class CancellationTokenExtensions
{
public static RequestContext ToRequestContext(this CancellationToken cancellationToken)
{
if (cancellationToken == default)
{
return DefaultRequestContext;
}

return new RequestContext()
{
CancellationToken = cancellationToken
};
}

private static RequestContext DefaultRequestContext => _defaultRequestContext ??= new();
private static RequestContext? _defaultRequestContext;
}
Loading