AdjustStringProperties is a .NET library which find all String Properties in an Object (Model,Dto,Entity) that have Setter and Adjust them. this packge Built in .NetStandard 2.0
- Install-Package AdjustStringProperties
First Let's Create Person Class:
public class Person
{
public string Name { get; set; }
public string LastName { get; set; }
public string FullName => $"{Name} {LastName}";
public string Description { get; set; }
}
Then Create Person Object:
var person = new Person()
{
Name = "John",
LastName = "Smith",
Description = "John Smith Description"
};
Now We Can Use Package Like This:
person.AdjustString();
1-Trim String Peoperties
if User Input Data Is Like Bellow
var person = new Person()
{
Name = " John ",
LastName = " Smith ",
Description = "John Smith Description"
};
As you Can See Bellow:
After Use of Package It Will Be Like Bellow:
2-Replace Multiple Spaces With Single
if User Input Contains More Than 1 Space Between Words together ,Spaces Will Replace Will 1 Space . look at "Description" property Bellow:
var person = new Person()
{
Name = "John",
LastName = "Smith",
Description = "John Smith Description"
};
After Use of Package It Will Be Like Bellow:
more features are in Progress and will be add to Package