Initial commit
commit
6a71ba43f6
|
@ -0,0 +1,5 @@
|
|||
bin/
|
||||
obj/
|
||||
/packages/
|
||||
riderModule.iml
|
||||
/_ReSharper.Caches/
|
|
@ -0,0 +1,13 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/modules.xml
|
||||
/.idea.ln.patterns.iml
|
||||
/projectSettingsUpdater.xml
|
||||
/contentModel.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.patterns", "ln.patterns\ln.patterns.csproj", "{BDF0FA7E-E280-4B0B-BCE8-9A3B8DF72BF0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BDF0FA7E-E280-4B0B-BCE8-9A3B8DF72BF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BDF0FA7E-E280-4B0B-BCE8-9A3B8DF72BF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDF0FA7E-E280-4B0B-BCE8-9A3B8DF72BF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDF0FA7E-E280-4B0B-BCE8-9A3B8DF72BF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,74 @@
|
|||
namespace ln.patterns;
|
||||
|
||||
public class Optional<T>
|
||||
{
|
||||
private readonly T _value;
|
||||
private readonly Exception? _exception;
|
||||
|
||||
public Optional(T value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
public Optional(Exception? exception)
|
||||
{
|
||||
_exception = exception;
|
||||
}
|
||||
|
||||
public bool TryGetValue(out T value)
|
||||
{
|
||||
value = _value;
|
||||
return _exception is null;
|
||||
}
|
||||
|
||||
public bool TryGetException(out Exception? exception)
|
||||
{
|
||||
exception = _exception;
|
||||
return _exception is not null;
|
||||
}
|
||||
|
||||
public Exception? Exception
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_exception is null)
|
||||
throw new NullReferenceException();
|
||||
return _exception;
|
||||
}
|
||||
}
|
||||
public T Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_exception is null)
|
||||
return _value;
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Is<ET>() where ET : Exception => _exception is ET;
|
||||
public bool Is<ET>(out ET? exception) where ET : Exception
|
||||
{
|
||||
if (_exception is ET)
|
||||
{
|
||||
exception = _exception as ET;
|
||||
return true;
|
||||
}
|
||||
|
||||
exception = null;
|
||||
return false;
|
||||
}
|
||||
public ET? As<ET>() where ET : Exception => _exception as ET;
|
||||
|
||||
public bool Valid => _exception is null;
|
||||
|
||||
public static implicit operator bool(Optional<T> o) => o._exception is null;
|
||||
public static implicit operator Optional<T>(Exception? e)
|
||||
{
|
||||
return new Optional<T>(e);
|
||||
}
|
||||
public static implicit operator Optional<T>(T value)
|
||||
{
|
||||
return new Optional<T>(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RepositoryUrl>https://nexus.l--n.de/repository/ln.net/</RepositoryUrl>
|
||||
<UserSecretsId>e910e63e-c2c5-4d40-a00b-bd7c6461757e</UserSecretsId>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>0.1.0-preview6</Version>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue