All Projects → ababik → Remute

ababik / Remute

Licence: MIT License
C# library to create new immutable object applying lambda expressions to the existing immutable object

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Remute

Masuit.tools
ldqk.xyz/55
Stars: ✭ 2,539 (+4354.39%)
Mutual labels:  lambda, expression
aws lambda ftp function
AWS Lambda Function to connect to FTP, download files and save them to S3 bucket
Stars: ✭ 55 (-3.51%)
Mutual labels:  lambda
serverless-contact-form
Email contact form using the Serverless framework on AWS Lambda
Stars: ✭ 39 (-31.58%)
Mutual labels:  lambda
FMPN-FER
Official PyTorch Implementation of 'Facial Motion Prior Networks for Facial Expression Recognition', VCIP 2019, Oral
Stars: ✭ 76 (+33.33%)
Mutual labels:  expression
herman
Herman is a tool to simplify deployment of AWS Services using ECS and Lambda, and the provisioning of various AWS services.
Stars: ✭ 33 (-42.11%)
Mutual labels:  lambda
example-step-functions-integration-api-gateway
Example application using the new Step Functions integration with API Gateway. It developers to call API Gateway REST APIs and API Gateway from a Step Functions workflow.
Stars: ✭ 17 (-70.18%)
Mutual labels:  lambda
twitter
A serverless social network that's under development with some cool stuff, such as Serverless Framework, AppSync, GraphQL, Lambda, DynamoDB, Cognito, Kinesis Firehose, and Algolia ☁️
Stars: ✭ 29 (-49.12%)
Mutual labels:  lambda
aws-pipeline
Build a CI/CD for Microservices and Serverless Functions in AWS ☁️
Stars: ✭ 32 (-43.86%)
Mutual labels:  lambda
converter
Immutable PHP currency converter that's data-agnostic.
Stars: ✭ 77 (+35.09%)
Mutual labels:  immutable
formulize
🌘 formula ui generator
Stars: ✭ 82 (+43.86%)
Mutual labels:  expression
extract-css
Extract all CSS from a webpage, packaged as a Now V2 Lambda
Stars: ✭ 23 (-59.65%)
Mutual labels:  lambda
cerberus-serverless-components
A collection of AWS Serverless components for Cerberus
Stars: ✭ 12 (-78.95%)
Mutual labels:  lambda
s3-lambda-transcribe-audio-to-text-s3
Transcribe your audio to text with this serverless component
Stars: ✭ 84 (+47.37%)
Mutual labels:  lambda
fermor
Fast, powerful, general-purpose graph traversal and modelling tools plus a performant immutable in-memory graph database.
Stars: ✭ 22 (-61.4%)
Mutual labels:  immutable
rrbit-js
No description or website provided.
Stars: ✭ 11 (-80.7%)
Mutual labels:  immutable
cfn-encrypt
🔑🔐☁️ Cloudformation custom resource that enables creation of KMS encrypted strings and SSM secure parameters
Stars: ✭ 13 (-77.19%)
Mutual labels:  lambda
spring-boot-lambda
No description or website provided.
Stars: ✭ 44 (-22.81%)
Mutual labels:  lambda
serverless-plugin-lambda-dead-letter
serverless plugin that can configure a lambda with a dead letter queue or topic
Stars: ✭ 42 (-26.32%)
Mutual labels:  lambda
lambda-string
Lambda-string (LS) is a helping java agent that inject configurable toString method into lambdas with some useful meta-information.
Stars: ✭ 34 (-40.35%)
Mutual labels:  lambda
zappa-blog
A blog about Zappa, powered by Zappa. Zappa zappa zappa. Zappa.
Stars: ✭ 17 (-70.18%)
Mutual labels:  lambda

Remute

Remute C# library to create new immutable object applying lambda expressions to the existing immutable object.

Examples (flat and nested object structures)

For example define immutable class:

public class Employee
{
    public string FirstName { get; }

    public string LastName { get; }

    public Employee(string firstName, string lastName)
    {
        FirstName = firstName;
        LastName = lastName;
    }
}

Apply modification:

var remute = new Remute();
var expected = new Employee("John", "Doe");
var actual = remute.With(expected, x => x.FirstName, "Foo");

Generic method With returns new object where first name is updated:

Assert.AreNotSame(expected.FirstName, actual.FirstName);
Assert.AreSame(expected.LastName, actual.LastName);

Remute works with immutable nested object structures (including C# 9 records).

Define few more immutable classes:

public class Department
{
    public string Title { get; }

    public Employee Manager { get; }

    public Department(string title, Employee manager)
    {
        Title = title;
        Manager = manager;
    }
}

public class Organization
{
    public string Name { get; }

    public Department DevelopmentDepartment { get; }

    public Organization(string name, Department developmentDepartment)
    {
        Name = name;
        DevelopmentDepartment = developmentDepartment;
    }
}

Remute first name of the manager of the development department:

var expected = 
    new Organization("Organization", 
        new Department("Development Department", 
            new Employee("John", "Doe")));
            
var actual = remute.With(expected, x => x.DevelopmentDepartment.Manager.FirstName, "Foo");

Actual object has updated references for DevelopmentDepartment, Manager and FirstName. All other object references (like Organization.Name, Department.Title and Employee.LastName) remain the same.

Assert.AreNotSame(expected, actual);
Assert.AreNotSame(expected.DevelopmentDepartment, actual.DevelopmentDepartment);
Assert.AreNotSame(expected.DevelopmentDepartment.Manager, actual.DevelopmentDepartment.Manager);
Assert.AreSame(expected.Name, actual.Name);
Assert.AreSame(expected.DevelopmentDepartment.Title, expected.DevelopmentDepartment.Title);

Multiple constuctors and parameter names matching

By default Remute expects immutable type to have single constructor with parameters matching property names (case-insensetive). Use ActivationConfiguration to change this default behaviour. Check issue for more details.

var config = new ActivationConfiguration()
    .Configure<User>(x => new User(x.FirstName, x.LastName));

var remute = new Remute(config);

Syntax sugar

There is an extension method enabling chained modifications on any object.

using Remutable.Extensions;
...
var employee = new Employee(Guid.NewGuid(), "Joe", "Doe");

var actual = employee
    .Remute(x => x.FirstName, "Foo")
    .Remute(x => x.LastName, "Bar");

Assert.AreEqual("Foo", actual.FirstName);
Assert.AreEqual("Bar", actual.LastName);

Performance notes

Remute does not use reflection / Activator.CreateInstance for object creation. Instead cached lambda expressions are used that demonstrates great performance.

Get it

Remute is available as .Net Standard assembly via Nuget

dotnet add package Remute or Install-Package Remute

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].