SkillAgentSearch skills...

Clay

Clay is a dynamic C# type that will enable you to sculpt objects of any shape just as easily as in JavaScript or other dynamic languages.

Install / Use

/learn @bleroy/Clay
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Clay

Clay is a dynamic C# type that will enable you to sculpt objects of any shape just as easily as in JavaScript or other dynamic languages.

Usage

First, you need to instantiate a Clay factory:

dynamic New = new ClayFactory();

Then you can create objects using a number of different syntaxes:

var person = New.Person();
person.FirstName = "Louis";
person.LastName = "Dejardin";
var person = New.Person();
person["FirstName"] = "Louis";
person["LastName"] = "Dejardin";
var person = New.Person()
    .FirstName("Louis")
    .LastName("Dejardin");
var person = New.Person(new {
    FirstName = "Louis",
    LastName = "Dejardin"
});
var person = New.Person(
    FirstName: "Louis",
    LastName: "Dejardin"
);

It is then possible to access members in three different, and equivalent ways:

person.FirstName
person["FirstName"]
person.FirstName()

One of the most powerful features of Clay is its dynamic casting ability, which enables you to cast a dynamic object to a known interface, without ever having to specify the interface on the object itself:

public interface IPerson {
    string FirstName { get; set; }
    string LastName { get; set; }
}

//...

IPerson typedPerson = person;
// Look! IntelliSense! Compile-time checks!
var fullName = $"{typedPerson.FirstName} {typedPerson.LastName}";

Blog posts about Clay

View on GitHub
GitHub Stars100
CategoryDevelopment
Updated6mo ago
Forks17

Languages

C#

Security Score

87/100

Audited on Sep 26, 2025

No findings