---
agentTools:
  projectIndex: https://objectfillernet.readme.io/llms.txt
---

# Getting Started

This page will help you get started with ObjectFiller.NET. You'll be up and running in a jiffy!

First you need to add the ObjectFiller.NET package to your project using [NuGet](https://www.nuget.org/packages/Tynamix.ObjectFiller).

* Do that by running the following command in the Package Manager Console:

[block:code]
{
  "codes": [
    {
      "code": "Install-Package Tynamix.ObjectFiller",
      "language": "shell"
    }
  ]
}
[/block]

Now you can start using ObjectFiller.NET in your application. With `Filler<Person>` you define which object you want to create/fill. With the method `.Create()` we **create** a new instance of `Person` and fill it with random values.

[block:code]
{
  "codes": [
    {
      "code": "public class Person\n{\n  public string Name { get; set; }\n  public string LastName { get; set; }\n  public int Age { get; set; }\n  public DateTime Birthday { get; set; }\n}\n\npublic class HelloFiller\n{\n  public void CreatePerson()\n  {\n    Filler<Person> pFiller = new Filler<Person>();\n    Person p = pFiller.Create();\n  }\n}",
      "language": "csharp",
      "name": "This code creates a class \"Person\" for you, filled with random data."
    }
  ]
}
[/block]

It is also possible to **fill** an **already existing instance** of an object. In the second example we first create a person and then call **Fill(...) instead of Create()**. This is great for stuff like DesignViewModels in WPF or whereever you need to fill the object in the constructor with `Fill(this)` for example.

[block:code]
{
  "codes": [
    {
      "code": "public class Person\n{\n  public string Name { get; set; }\n  public string LastName { get; set; }\n  public int Age { get; set; }\n  public DateTime Birthday { get; set; }\n}\n\npublic class HelloFiller\n{\n  public void FillPerson()\n  {\n    Person person = new Person();\n\n    Filler<Person> pFiller = new Filler<Person>();\n    Person p = pFiller.Fill(person);\n  }\n}",
      "language": "csharp",
      "name": "This code fills an already existing instance of an object with random data"
    }
  ]
}
[/block]

In VB.NET a simple example looks like this.

[block:code]
{
  "codes": [
    {
      "code": "Imports Tynamix.ObjectFiller\n\nClass Person\n    Property Name() As String\n\n    Property Age() As Integer\nEnd Class\n\nModule Module1\n    Sub Main()\n        Dim filler = New Filler(Of Person)()\n\n        filler.Setup() _\n            .OnType(Of String).Use(New MnemonicString(2)) _\n            .OnProperty(Function(x) x.Age).Use(New IntRange(18, 88))\n\n        Dim person As Person = filler.Create()\n        Console.WriteLine(person.Name)\n        Console.WriteLine(person.Age)\n\n        Console.ReadLine()\n    End Sub\n\nEnd Module",
      "language": "text",
      "name": "VB.NET Example"
    }
  ]
}
[/block]