<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kleber Silva on Medium]]></title>
        <description><![CDATA[Stories by Kleber Silva on Medium]]></description>
        <link>https://medium.com/@kleberapsilva?source=rss-d8c1b5c62152------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YAUzQFd8f1yOVhf7n-o3NA.jpeg</url>
            <title>Stories by Kleber Silva on Medium</title>
            <link>https://medium.com/@kleberapsilva?source=rss-d8c1b5c62152------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:55:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kleberapsilva/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Humanizer, a biblioteca definitiva para manipular strings em .Net]]></title>
            <link>https://medium.com/@kleberapsilva/humanizer-a-biblioteca-definitiva-para-manipular-strings-em-net-3400be808f17?source=rss-d8c1b5c62152------2</link>
            <guid isPermaLink="false">https://medium.com/p/3400be808f17</guid>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[biblioteca]]></category>
            <category><![CDATA[humanizer]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[visual-studio]]></category>
            <dc:creator><![CDATA[Kleber Silva]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 22:34:00 GMT</pubDate>
            <atom:updated>2019-03-20T23:42:57.204Z</atom:updated>
            <content:encoded><![CDATA[<h3>Humanizer, a biblioteca definitiva para manipular strings em .Net</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*J5eLNsD6REcMmehDuHmYcg.png" /></figure><p>Fala galera, quem nunca precisou manipular vários tipos de dados para strings? Pois é, hoje vou apresentar para vocês a biblioteca <a href="https://github.com/Humanizr/Humanizer">Humanizer</a>.</p><p><a href="https://github.com/Humanizr/Humanizer"><strong>Humanizer</strong></a> é uma ótima biblioteca para obter representações legíveis por nós, meros seres humanos para strings, números e datas em .Net. Cortar strings até um certo tamanho ou transformar um TimeSpan em “uma hora” não é mágica. No entanto, tentar fazer todo o trabalho por conta própria levará um tempo que o maravilhoso <a href="http://( http://humanizr.net)">Humanizer</a> já gastou. Vamos ver alguns casos de uso em que essa biblioteca provou ser de grande ajuda.</p><h3>Instalação</h3><p>Abra seu projeto no Solution Explorer no Visual Studio, clique com o botão direito do mouse em References e selecione “Manage NuGet Packages…” para procurar os pacotes do NuGet. Procure por <strong>Humanizer</strong> e instale este pacote:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*iulpQBYG-2pwvJG9TlG8Cw.png" /><figcaption>Instalação da versão em português</figcaption></figure><p>Após incluir a biblioteca em sua referência de projeto, é hora de colocar a mão na massa e ver do que o Humanizer é capaz de fazer por nós… Show me the code :-)</p><h3><strong>Trabalhando com DateTime e TimeSpan</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*tIJoPLjGmORwl1t_xM4jkQ.png" /><figcaption>Algumas implementações e suas saídas!</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9241aa6fdb3a68fdf1622d50cf7aabbd/href">https://medium.com/media/9241aa6fdb3a68fdf1622d50cf7aabbd/href</a></iframe><h3><strong>Unidades de Medida Computacionais</strong></h3><p>Pode ser útil saber o tamanho de um arquivo antes de tentar baixá-lo em uma conexão móvel. No entanto, apenas mostrar o tamanho em bytes pode não ajudar seus usuários. O Humanizer oferece sua própria classe para representar tamanhos de arquivo que podem ser convertidos conforme necessário ou mostrados novamente em um formato legível.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*bqkokHs-VmnWNoRrUrcwgQ.png" /><figcaption>Medidas Computacionais</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/972603b462e7e25f57d1aa83d3fbf2af/href">https://medium.com/media/972603b462e7e25f57d1aa83d3fbf2af/href</a></iframe><h3><strong>Truncando Strings</strong></h3><p>Muitas vezes precisamos trabalhar com strings longas e adicionar aqueles 3 pontinhos (…) no final para dar a entender que o texto é longo, o método Truncate do Humanizer faz esse trabalho para nós. S2 :-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oSPIu5r_RbRgNKQjNBLgFg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca3c6539c81c1bf1112a721d54140cf8/href">https://medium.com/media/ca3c6539c81c1bf1112a721d54140cf8/href</a></iframe><h4><strong>Adicionando novas palavras</strong></h4><p>As vezes, você pode precisar adicionar uma regra do vocabulário de singularização/pluralização.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*tP2CuToVsXieAcAhKgk1DA.png" /><figcaption>Incluindo a palavra Homem no Plural e Singular</figcaption></figure><h3>Quantidades com Humanizer</h3><p>Como podemos observar temos muitas formas de utilizar essa fantástica biblioteca, abaixo deixo mais alguns exemplos de uso com quantidades.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*qIba15xPEWGso-ahJHRRIw.png" /><figcaption>Trabalhando com quantidades</figcaption></figure><h3>Strings e Enum</h3><p>E claro que temos o bom e velho trabalho com String e Enum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIMg9dKxZxwc4T2Dk7_9vQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/73465d06c520754fee2796d7135a57aa/href">https://medium.com/media/73465d06c520754fee2796d7135a57aa/href</a></iframe><h3>Conclusão</h3><p>O Humanizer é uma ótima ajuda quando você precisa formatar a saída em um formato legível por humanos. Não parece muito, mas é muito seguro quando você usa essa biblioteca, em vez de escrever o código por conta própria. Eu estou apenas arranhando a superfície do Humanizer, passando por algumas tarefas corriqueiras. Há também exemplos de uso no ASP.NET MVC em suas Views.</p><p>Espero ter ajudado, aproveita e da uma olhada no <a href="http://humanizr.net/">Humanizer</a> e <a href="https://twitter.com/MehdiKhalili">agradeça ao autor no Twitter</a> enquanto você está por aqui! Valeu Dev!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3400be808f17" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>