Trafonesoft 1.0.0

TrafoneSoft package will help in working with objects. Like cloning/ copying one instance values to another instance.
Many more features to come.

Install-Package Trafonesoft -Version 1.0.0
dotnet add package Trafonesoft --version 1.0.0
paket add Trafonesoft --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TrafoneSoft package will help in working with objects. Like cloning/ copying one instance values to another instance. Many more features to come.

  1. CopyProperties method

    If need to copy only properties values from an instance to another one.

    ObjectUtil<T>.CopyProperties(object1, ref object2);

  2. CopyFields method

    If need to copy only fields values from an instance to another one.

    ObjectUtil<T>.CopyFields(object1, ref object2);

  3. Clone method

    If need to copy all properties and fields values from an instance to another one.

    ObjectUtil<T>.Clone(object1, ref object2);

Suppose we have a User (super) class and a SubUser( Child) class .
public class User {
public String Id {get; set;}
public String Name {get; set;}
}

public class SubUser : User{
public String Role {get;set;}
}

var user = GetUserDataFromDb(); // An methodd to fetch data from db . It can be replaced according to your requirement.

Now if we want to return SubUser type with Role assigned.

var subUser = new SubUser();
var temp = subUser as User; // Typecasting .
ObjectUtil<User>.CopyProperties(user, ref temp);

return subUser;

TrafoneSoft package will help in working with objects. Like cloning/ copying one instance values to another instance. Many more features to come.

  1. CopyProperties method

    If need to copy only properties values from an instance to another one.

    ObjectUtil<T>.CopyProperties(object1, ref object2);

  2. CopyFields method

    If need to copy only fields values from an instance to another one.

    ObjectUtil<T>.CopyFields(object1, ref object2);

  3. Clone method

    If need to copy all properties and fields values from an instance to another one.

    ObjectUtil<T>.Clone(object1, ref object2);

Suppose we have a User (super) class and a SubUser( Child) class .
public class User {
public String Id {get; set;}
public String Name {get; set;}
}

public class SubUser : User{
public String Role {get;set;}
}

var user = GetUserDataFromDb(); // An methodd to fetch data from db . It can be replaced according to your requirement.

Now if we want to return SubUser type with Role assigned.

var subUser = new SubUser();
var temp = subUser as User; // Typecasting .
ObjectUtil<User>.CopyProperties(user, ref temp);

return subUser;

Release Notes

Added CopyProperties , CopyFields and Copy(All) methods.

  • .NETStandard 2.0

    • No dependencies.

Version History

Version Downloads Last updated
1.0.0 182 6/27/2018