Skip to content

pesalexmapper/Helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PELEXMapper

Features

PELEXMapper is a NuGet library that you can have a framework to functionality improvements.

The following platforms are supported:

  • .NET

Getting started

The easiest way to get started is by installing the available NuGet packages and if you're not a NuGet fan then follow these steps:

Download the latest runtime library from: https://www.nuget.org/api/v2/package/PELEXMapper; Or install the latest package: PM> Install-Package PESALEXMapper

A Quick Example

Mapping classes and properties

Take advantage of the mapping capabilities through the static class MapperUtil.

Ignore dependencies in mapping different ways:

MapperUtil.IgnoreDependences(foo, fooDTO);
var barDTO = MapperUtil.IgnoreDependences<BarDTO>(bar);
bar = MapperUtil.IgnoreDependences<BarDTO, Bar>(barDTO);

Keep dependencies in mapping different ways:

MapperUtil.KeepDependencies(foo, fooDTO);
var barDTO = MapperUtil.KeepDependencies<BarDTO>(bar);
bar = MapperUtil.KeepDependencies<BarDTO, Bar>(barDTO);

Get value on property:

var id = MapperUtil.GetValue(foo, "Id");
// id => 0;

Enter value on property:

MapperUtil.SetValue(foo, "Id", 1);
// foo.Id => 1

Concatenate Parameters with Comma Separation:

var result = MapperUtil.ConcatCSV(foo.Id, foo.Name);
// result => "1-bar"

Obtain the distinct properties dynamically (concatenated):

dynamic dynamicBar = { Id = 1, Name = "Second", PID = "10"};
var result = MapperUtil.ConcatCSV(dynamicBar);
// result => "1-Second-10"

Implementation helper

Take advantage of the mapping capabilities through the static class ImplementationUtil

Verify that the interface is being implemented:

var result = ImplementationUtil.ContainsInterface(typeof(Foo), "IBar");
// result => false

Checks if the property exists:

var result = ImplementationUtil.ContainsProperty(typeof(Foo), "IBar");
// result => false

Gadget of string (this is a extension)

Take advantage of the mapping capabilities through the static class StringUtil

Returns null or text without side spaces:

using PESALEXMapper.Helper;
...
var result = " ".TrimNull();
var result2 = " any ".TrimNull();
// result => null
// result2 => "any"

Remove spaces within the text and return in tiny:

var result = ImplementationUtil.Tyne("Foo Bar TEST");
// result => "foobartest"

Removes parentheses from text: [Obsolete] use RemoveSpecialChars

var result = ImplementationUtil.WithoutParentheses("Foo (bar)");
// result => "Foo bar"

Remove special char from text:

var arrange = "Foo (bar)";
var result = arrange.RemoveSpecialChars("(", ")");
// result => "Foo bar"

Remove all special characters of string:

var result = ImplementationUtil.Alphanumeric("#@$a123$% 4567890A@#$@#$");
// result => "a1234567890A"

Return only letters:

var result = ImplementationUtil.Alphabetic("34a097A2424 ");
// result => "aA"

Returns only numerics:

var result = ImplementationUtil.Numerics("1A2s3#4%5¨6¨&7*8(9@0T");
// result => "1234567890"

Capitalize sentence:

var result = ImplementationUtil.Capitalize("capitalize sentence");
// result => "Capitalize Sentence"

Capitalize first letter in text:

var result = ImplementationUtil.CapitalizeFirst("capitalize first letter");
// result => "Capitalize first letter"

Gadget of Enum

Take advantage of the mapping capabilities through the static class EnumUtil

Example of Enum

    [Description("Values")]
    public enum EnumValue
    {
        [Description("1ª name")]
        Foo,
        [Description("2ª name")]
        Bar,
        [Description("3ª name")]
        FooBar,
        [Description("4ª name")]
        BarFoo
    }

Obtain the description of the member of an enum:

var result = EnumUtil.DescriptionArray<EnumValue>();
// result[0] => "1ª name"
// result[3] => "4ª name"
// result.Count => 4

Obtain the description of an enum:

var result = EnumUtil.GetDescriptionOfType<EnumValue>();
// result => "Values"

Obtain the enum value by description:

var result = EnumUtil.GetValue<EnumValue>("4ª name");
// result => 3

Obtain the description of an enum:

var result = EnumUtil.GetByName<EnumValue>("Bar");
// result => EnumValue.Bar

Obtain the description list of all members:

var resultA = EnumUtil.GetDescription<EnumValue>(EnumValue.FooBar.ToString());
var resultB = EnumUtil.GetDescription<EnumValue>("FooBar");
// resultA => "3ª name"
// resultB => resultA

Report Support

To report errors, questions and suggestions go to the link

About

Funcionalidades para auxiliar na codificação em C#

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages