Nina 1.0.0
dotnet add package Nina --version 1.0.0
NuGet\Install-Package Nina -Version 1.0.0
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="Nina" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nina --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nina, 1.0.0"
#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 Nina as a Cake Addin #addin nuget:?package=Nina&version=1.0.0 // Install Nina as a Cake Tool #tool nuget:?package=Nina&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Nina
Nina is a library for fluent generic construction of objects of any type.
Implementation Example(s):
//Defining the class:
public class Person
{
public string Name { get; set; }
public bool Married { get; set; }
public Person Partner { get; set; }
public ICollection<Person> Friends { get; set; }
public ICollection<ICollection<Person>> FriendsOfFriends { get; set; }
public Gender Gender { get; set; }
public DateTime BirthDate { get; set; }
public int Age { get { return DateTime.Now.Year - BirthDate.Year; } }
private string Secret { get; set; }
}
public enum Gender
{
Male,
Female
}
/*---------------------------------------------------------------------------- */
//Starting using the SetBuilder<T> class:
var person = new SetBuilder<Person>()
.WithProperty(p => p.Name, s => "Edu") //Can handle with any type
.WithProperty(p => p.Married, m => true)
.WithProperty(p => p.BirthDate, b => new DateTime(2005, 9, 22))
.WithProperty(p => p.Partner, p =>
{
return new SetBuilder<Person>()
.WithProperty(p => p.Name, n => "Livia")
.WithProperty(p => p.Married, m => true)
.WithProperty(p => p.Gender, Gender.Female) //Can pass a value directly
.Build();
})
.WithProperty(p => p.Friends, bf => //Can handle with Collections
{
bf.Add(f =>
{
return new SetBuilder<Person>()
.WithProperty(p => p.Name, n => "Guilherme")
.Build();
});
bf.Add(f =>
{
return new SetBuilder<Person>()
.WithProperty(p => p.Name, n => "Alan")
.WithProperty(p => p.Married, m => true)
.Build();
});
})
.WithProperty(p => p.FriendsOfFriends, bfof => //Can handle with nested Collections
{
bfof.Add(bf =>
{
return
[
new SetBuilder<Person>()
.WithProperty(p => p.Name, n => "João")
.Build(),
new SetBuilder<Person>()
.WithProperty(p => p.Name, n => "Paulo")
.Build()
];
});
bfof.Add(bf =>
{
return
[
new SetBuilder<Person>()
.WithProperty(p => p.Name, n => "Pedro")
.WithProperty(p => p.Married, m => true)
.Build()
];
});
})
.Build();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.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.0 | 59 | 10/22/2024 |
The first release with SetBuilder<T> class and WithProperty(...) methods.