ParseTo 1.0.2

dotnet add package ParseTo --version 1.0.2
NuGet\Install-Package ParseTo -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ParseTo" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ParseTo --version 1.0.2
#r "nuget: ParseTo, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ParseTo as a Cake Addin
#addin nuget:?package=ParseTo&version=1.0.2

// Install ParseTo as a Cake Tool
#tool nuget:?package=ParseTo&version=1.0.2

What is ParseTo

Parse To was a project first conceptualized as a way to commonly handle nulls but soon moved into a generic Parser to take an object variable and turn it into a generically passed type, a built in default for the type or a passed default for the type.

It does this by using an IParse<> interface that creates a handler for the type you wish to cast to or resturns an Exception if the type has not IParse<> impelmentation

Current Functionality

Custom parsable types

To build custom parsable type inherit a handler class or actual parsable object class from the IParse<[ObjectClassName]>(Must have a blank constructor) and implement the interface. Its as simple as that you class can now be parsed

For Example:

public TestObject : IParse<TestObject>
{
    public string Name { get; set; }
    
    public TestObject Parse(object i)
    {
        if(i is string)
            return new TestObject() { Name = i };
        return (TestObject)i;
    }

    public TestObject GetDefault()
    {
        return new TestObject();
    }
}    

build the class and inhrit from IParse<>(Must have a blank constructor)

public void TestMethod(string obj = "blank")
{
    var testObject = obj.ParseTo<TestObject>();
    

Now you can parse to your test object

Pre-built parsable types

int

Default return: 0

int?

Default return: null

string

Default return: ""

double

Default return: 0

long

Default return: 0

float

Default return: 0

decimal

Default return: 0

Guid

Default return: 00000000-0000-0000-0000-000000000000

bool

Default return: false

bool?

Default return: null

DateTime

Default return: 1/1/0001 12:00:00 AM (Equals Date.MinValue)

DateTime?

Default return: null

Contribute

Come conribute would love to hear you ideas Contribute

Issues

Got an issue here are my guidelines for reporting it.

License

This work is licensed under a MIT License

Code of Conduct

This repository contains the Open Source Code of Conduct

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 514 2/7/2020
1.0.1 457 1/2/2020
1.0.0 455 10/30/2019