SierraLib.API.Views 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SierraLib.API.Views --version 1.0.1
NuGet\Install-Package SierraLib.API.Views -Version 1.0.1
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="SierraLib.API.Views" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SierraLib.API.Views --version 1.0.1
#r "nuget: SierraLib.API.Views, 1.0.1"
#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 SierraLib.API.Views as a Cake Addin
#addin nuget:?package=SierraLib.API.Views&version=1.0.1

// Install SierraLib.API.Views as a Cake Tool
#tool nuget:?package=SierraLib.API.Views&version=1.0.1

SierraLib.API.Views

A pattern for versioned views into your data model for APIs

This library provides a pair of interfaces and some extension methods which act as a framework on which you can build and maintain multiple, versioned, views into your core data models. It has been designed to work in concert with good API design patterns like versioned endpoints and semantic versioning to simplify the development of backwards compatible API surfaces as your services evolve.

Example

namespace Example
{
    using SierraLib.API.Views;

    public class UserProfile
    {
        public Guid Id { get; set; }

        public string Fullname { get; set; }

        public DateTime DateOfBirth { get; set; }

        public class Version1 : IView<UserProfile>
        {
            public string Id { get; set; }

            public string Fullname { get; set; }

            public DateTime DateOfBirth { get; set; }

            public class Representer : IRepresenter<UserProfile, Version1>
            {
                public UserProfile ToModel(Version1 view)
                {
                    return new UserProfile
                    {
                        Id = view.Id is null ? Guid.NewGuid() : Guid.ParseExact(view.Id, "N"),
                        Fullname = view.Fullname,
                        DateOfBirth = view.DateOfBirth,
                    };
                }

                public Version1 ToView(UserProfile model)
                {
                    return new Version1
                    {
                        Id = model.Id.ToString("N"),
                        Fullname = model.Fullname,
                        DateOfBirth = model.DateOfBirth,
                    };
                }
            }
        }
    }
}

Interfaces

IView<TModel>

The IView interface is used to mark classes which represent a view into a specific model.

IRepresenter<TModel, TView>

The IRepresenter interface provides the ToModel and ToView methods and is responsible for working to convert between the TModel and the TView.

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.

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.137 291 3/18/2024
1.0.8 1,615 8/19/2021
1.0.6 267 8/18/2021
1.0.5 267 8/18/2021
1.0.4 282 8/18/2021
1.0.4-alpha.0.12 170 7/14/2021
1.0.4-alpha.0.11 175 7/14/2021
1.0.4-alpha.0.10 178 7/14/2021
1.0.4-alpha.0.7 208 3/25/2021
1.0.4-alpha.0.6 221 3/15/2021
1.0.4-alpha.0.5 238 2/24/2021
1.0.4-alpha.0.4 196 2/1/2021
1.0.4-alpha.0.3 259 1/8/2021
1.0.4-alpha.0.2 219 12/23/2020
1.0.4-alpha.0.1 229 12/9/2020
1.0.3 639 12/4/2020
1.0.3-alpha.0.8 234 12/4/2020
1.0.3-alpha.0.7 233 12/4/2020
1.0.3-alpha.0.6 226 12/3/2020
1.0.3-alpha.0.5 265 11/9/2020
1.0.3-alpha.0.4 245 10/29/2020
1.0.3-alpha.0.3 256 10/14/2020
1.0.3-alpha.0.2 283 10/13/2020
1.0.3-alpha.0.1 246 9/28/2020
1.0.2 483 9/28/2020
1.0.2-alpha.0.9 273 9/28/2020
1.0.2-alpha.0.8 273 9/28/2020
1.0.2-alpha.0.7 276 9/28/2020
1.0.2-alpha.0.6 269 9/28/2020
1.0.2-alpha.0.5 277 9/28/2020
1.0.2-alpha.0.4 274 9/28/2020
1.0.2-alpha.0.3 322 6/14/2020
1.0.2-alpha.0.2 304 9/28/2019
1.0.1 719 9/28/2019