<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vinicius Quaiato</title>
	<atom:link href="http://viniciusquaiato.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://viniciusquaiato.com/blog</link>
	<description>Tecnologia e algo mais...</description>
	<lastBuildDate>Tue, 09 Mar 2010 19:31:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Code Snippet para TestMethods no VisualStudio</title>
		<link>http://viniciusquaiato.com/blog/index.php/code-snippet-para-testmethods-no-visualstudio/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/code-snippet-para-testmethods-no-visualstudio/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 19:31:08 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Boas Práticas]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Dicas]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=681</guid>
		<description><![CDATA[Sempre achei um &#8220;pé&#8221; ter que ficar copiando métodos de teste, tudo pela preguiça de colocar o attribute [TestMethod] public void etc, etc.
Criei um CodeSnippet pra ser usado com C# que resolve alguns desses problemas. Abaixo segue o código do Snippet, à noite eu mostro como inserir o mesmo no VisualStudio, e coloco um link [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/tdd-na-net-magazine-69/' rel='bookmark' title='Permanent Link: TDD na .Net Magazine 69'>TDD na .Net Magazine 69</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Sempre achei um &#8220;pé&#8221; ter que ficar copiando métodos de teste, tudo pela preguiça de colocar o attribute [TestMethod] public void etc, etc.</p>
<p>Criei um CodeSnippet pra ser usado com C# que resolve alguns desses problemas. Abaixo segue o código do Snippet, à noite eu mostro como inserir o mesmo no VisualStudio, e coloco um link para download também:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CodeSnippets</span>  <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/VisualStudio/2010/CodeSnippet&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CodeSnippet</span> <span style="color: #000066;">Format</span>=<span style="color: #ff0000;">&quot;1.0.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Test Method<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Shortcut<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Code snippet to create a test method<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Vinicius Quaiato<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Expansion<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SnippetTypes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Header<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Snippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Literal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ID<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Test_Method_Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ID<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ToolTip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>The name of the method. Try using a name that indicates the purpose of the test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ToolTip<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Test_Method_Name<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Literal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Declarations<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Code</span> <span style="color: #000066;">Language</span>=<span style="color: #ff0000;">&quot;csharp&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #339933;">&lt;![CDATA[	[TestMethod]</span>
<span style="color: #339933;">	public void $Test_Method_Name$()</span>
<span style="color: #339933;">	{   </span>
&nbsp;
<span style="color: #339933;">	}]]&gt;</span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Code<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Snippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/CodeSnippet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/CodeSnippets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Espero que ajude um pouco. É mais rápido digitar &#8220;test + tab + tab&#8221; do que copiar, colar e alterar o nome do método anterior.</p>
<p>Abraços,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/tdd-na-net-magazine-69/' rel='bookmark' title='Permanent Link: TDD na .Net Magazine 69'>TDD na .Net Magazine 69</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/code-snippet-para-testmethods-no-visualstudio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamic Types na .Net Magazine #71</title>
		<link>http://viniciusquaiato.com/blog/index.php/dynamic-types-na-net-magazine-71/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/dynamic-types-na-net-magazine-71/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 13:37:17 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Publicações]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[.NET Magazine]]></category>
		<category><![CDATA[Artigos]]></category>
		<category><![CDATA[dynamic]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=668</guid>
		<description><![CDATA[Fala galera!
Foi publicado mais um artigo meu na .Net Magazine, edição 71.
O artigo fala sobre Dynamic Types e mostra alguns cenários de utilização das novas funcionalidades dinâmicas incorporadas ao .Net Framework 4.0.
Uma pequena amostra pode ser conferida aqui: http://www.devmedia.com.br/articles/viewcomp.asp?comp=16159
Esta edição está bem bacana, focando principalmente nas novidades do .Net 4.0 e do Visual Studio 2010. [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/tdd-na-net-magazine-69/' rel='bookmark' title='Permanent Link: TDD na .Net Magazine 69'>TDD na .Net Magazine 69</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/expandoobject-dinamismo-dotnet-4/' rel='bookmark' title='Permanent Link: ExpandoObject: dinamismo no .NET 4.0'>ExpandoObject: dinamismo no .NET 4.0</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><div class="wp-caption alignleft" style="width: 209px"><img alt="Capa .NET Magazine #71" src="http://www.devmedia.com.br/loja/img/capa_net71_G.jpg" title=".NET Magazine #71" width="199" height="271" /><p class="wp-caption-text">Capa .NET Magazine #71</p></div>Fala galera!</p>
<p>Foi publicado mais um artigo meu na <a href="http://www.devmedia.com.br/resumo/default.asp?ed=71&#038;site=1#2322" target="_blank">.Net Magazine, edição 71</a>.</p>
<p>O artigo fala sobre <a href="http://viniciusquaiato.com/blog/index.php/tag/dynamic/" target="_blank">Dynamic Types</a> e mostra alguns cenários de utilização das novas funcionalidades dinâmicas incorporadas ao .Net Framework 4.0.<br />
Uma pequena amostra pode ser conferida aqui: <a href="http://www.devmedia.com.br/articles/viewcomp.asp?comp=16159" target="_blank">http://www.devmedia.com.br/articles/viewcomp.asp?comp=16159</a></p>
<p>Esta edição está bem bacana, focando principalmente nas novidades do .Net 4.0 e do Visual Studio 2010. Vale conferir, temos também os seguintes artigos das feras:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<ul>
<li>.Net Brasil &#8211; Por: <a href="http://twitter.com/rodrigosendin" target="_blank">Rodrigo Sendin</a></li>
<li>Dynamic types &#8211; Por: <a href="http://twitter.com/vquaiato" target="_blank">Vinicius Quaiato</a></li>
<li>Dicas para otimizar o acesso ao SQL Server &#8211; Por: Danielle da Silva Monteiro</li>
<li>Visual Studio 2010 e .NET 4.0 &#8211; Por: <a href="http://twitter.com/leandronet" target="_blank">Leandro Daniel</a></li>
<li>Criando controles personalizados no ASP.NET &#8211; Por: <a href="http://twitter.com/tomalexsemple" target="_blank">Thomas Alexander</a></li>
<li>SharePoint &#8211; Por: Braian Takahira</li>
<li>Produtividade com T4 &#8211; Por: Rodrigo Sendin</li>
<li>Desenvolvimento Desktop no .NET &#8211; Por: Everton Coimbra de Araújo</li>
<li>ASP.NET e ADO.NET &#8211; Por: Erysson Batista Barros de Souz</li>
</ul>
<p>Deve chegar nas bancas nos próximos dias!</p>
<p>Por favor dêem seu feedback, é realmente muito importante!</p>
<p>Abraços,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/tdd-na-net-magazine-69/' rel='bookmark' title='Permanent Link: TDD na .Net Magazine 69'>TDD na .Net Magazine 69</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/expandoobject-dinamismo-dotnet-4/' rel='bookmark' title='Permanent Link: ExpandoObject: dinamismo no .NET 4.0'>ExpandoObject: dinamismo no .NET 4.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/dynamic-types-na-net-magazine-71/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework 4.0: Utilizando many-to-many com POCOs</title>
		<link>http://viniciusquaiato.com/blog/index.php/entity-framework-4-0-utilizando-many-to-many-com-pocos/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/entity-framework-4-0-utilizando-many-to-many-com-pocos/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 11:45:23 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Many-To-Many]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[POCO]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=493</guid>
		<description><![CDATA[Fala galera, recebi algumas dúvidas por e-mail e vamos resolver aqui.
Vamos trabalhar com relações many-to-many utilizando POCO e o Entity Framework 4.0.
Para ver como trabalhar com POCO no EF4 veja este post aqui.
Vamos fazer um exemplo bem simples, trabalhando com produtos e lojas. Cada produto poderá estar em muitas lojas, e uma loja poderá conter [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/entity-framework-4-model-first-com-pocos/' rel='bookmark' title='Permanent Link: Entity Framework 4 &#8211; Model First com POCOs'>Entity Framework 4 &#8211; Model First com POCOs</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Fala galera, recebi algumas dúvidas por e-mail e vamos resolver aqui.<br />
Vamos trabalhar com relações many-to-many utilizando POCO e o Entity Framework 4.0.<br />
Para ver como trabalhar com POCO no EF4 veja <a href="http://viniciusquaiato.com/blog/index.php/entity-framework-4-model-first-com-pocos/" target="_blank">este post aqui</a>.</p>
<p>Vamos fazer um exemplo bem simples, trabalhando com produtos e lojas. Cada produto poderá estar em muitas lojas, e uma loja poderá conter muitos produtos.<br />
Abaixo temos o desenho de nosso modelo inicial:<br />
<div id="attachment_634" class="wp-caption aligncenter" style="width: 310px"><a class="lightbox" href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Modelo.jpg"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Modelo-300x175.jpg" alt="Modelo de Classes Entity Framework 4.0" title="Modelo de Classes Entity Framework 4.0" width="300" height="175" class="size-full wp-image-634" /></a><p class="wp-caption-text">Modelo de Classes Entity Framework 4.0</p></div></p>
<p>Feito isso vamos criar uma associação entre nossas entidades, como pode ser visto abaixo:<br />
<div id="attachment_639" class="wp-caption aligncenter" style="width: 310px"><a class="lightbox" href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Criando-associacao-no-modelo.jpg"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Criando-associacao-no-modelo-300x194.jpg" alt="Criando associação no modelo do EF 4.0" title="Criando associação no modelo do EF 4.0" width="300" height="194" class="size-full wp-image-639" /></a><p class="wp-caption-text">Criando associação no modelo do EF 4.0</p></div></p>
<div id="attachment_642" class="wp-caption aligncenter" style="width: 278px"><a class="lightbox" href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Definindo-a-Associacao.jpg"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Definindo-a-Associacao-268x300.jpg" alt="Definindo a Associacao Many-To_Many no EF 4.0" title="Definindo a Associacao Many-To_Many no EF 4.0" width="268" height="300" class="size-full wp-image-642" /></a><p class="wp-caption-text">Definindo a Associacao Many-To_Many no EF 4.0</p></div>
<p>Feito isso basta salvarmos nosso modelo e gerar o banco de dados. Lembrando de desmarcar a opção de geração de código no modelo (<a href="http://viniciusquaiato.com/blog/index.php/entity-framework-4-model-first-com-pocos/" target="_blank">veja aqui como fazer isso</a>).</p>
<p>Nossas classes ficarão simples, como não poderia deixar de ser.<br />
Abaixo vemos a classe Produto, que como pode-se notar não possui nenhuma dependência do entity Framework e nem conhece nada relacionado com banco de dados:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Produto
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">int</span> Id <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> Nome <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">decimal</span> ValorSugerido <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">private</span> IList<span style="color: #008000;">&lt;</span>Loja<span style="color: #008000;">&gt;</span> lojasOndeVende <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>Loja<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> IList<span style="color: #008000;">&lt;</span>Loja<span style="color: #008000;">&gt;</span> LojasOndeVende
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">lojasOndeVende</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">lojasOndeVende</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Abaixo temos a classe Loja:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Loja
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">int</span> Id <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> Nome <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> <span style="color: #FF0000;">string</span> Cidade <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">private</span> IList<span style="color: #008000;">&lt;</span>Produto<span style="color: #008000;">&gt;</span> produtosQueVende <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>Produto<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">virtual</span> IList<span style="color: #008000;">&lt;</span>Produto<span style="color: #008000;">&gt;</span> ProdutosQueVende
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">produtosQueVende</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        set
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">produtosQueVende</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>E aqui temos nossa classe de contexto do Entity Framework, que também criamos, de forma bastante simples:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> EF4Context <span style="color: #008000;">:</span> ObjectContext
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> EF4Context<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #008000;">:</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;name=ModeloManyToManyContainer&quot;</span>, <span style="color: #666666;">&quot;ModeloManyToManyContainer&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> IObjectSet<span style="color: #008000;">&lt;</span>Produto<span style="color: #008000;">&gt;</span> produtos<span style="color: #008000;">;</span>
    <span style="color: #0600FF;">public</span> IObjectSet<span style="color: #008000;">&lt;</span>Produto<span style="color: #008000;">&gt;</span> Produtos
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>produtos <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                produtos <span style="color: #008000;">=</span> CreateObjectSet<span style="color: #008000;">&lt;</span>Produto<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> produtos<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">private</span> IObjectSet<span style="color: #008000;">&lt;</span>Loja<span style="color: #008000;">&gt;</span> lojas<span style="color: #008000;">;</span>
    <span style="color: #0600FF;">public</span> IObjectSet<span style="color: #008000;">&lt;</span>Loja<span style="color: #008000;">&gt;</span> Lojas
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>lojas <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                lojas <span style="color: #008000;">=</span> CreateObjectSet<span style="color: #008000;">&lt;</span>Loja<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> lojas<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>E isto é tudo que precisamos. Já podemos trabalhar com nossas entidades de forma a terem a relação Many-to-Many feita e funcionando.<br />
Criei uma aplicação console para demonstrar isso. O método abaixo faz algumas inserções no banco, e o resultado da consulta pode ser visto na imagem a seguir:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> InserirNovosProdutosELojas<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var contexto <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> EF4Context<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var produto <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Produto<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    produto.<span style="color: #0000FF;">Nome</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Produto de Soja&quot;</span><span style="color: #008000;">;</span>
    produto.<span style="color: #0000FF;">ValorSugerido</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">;</span>
&nbsp;
    var produto2 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Produto<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    produto2.<span style="color: #0000FF;">Nome</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Produto de tofu&quot;</span><span style="color: #008000;">;</span>
    produto2.<span style="color: #0000FF;">ValorSugerido</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">;</span>
&nbsp;
    var loja <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Loja<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    loja.<span style="color: #0000FF;">Nome</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Loja do Vinicius&quot;</span><span style="color: #008000;">;</span>
    loja.<span style="color: #0000FF;">Cidade</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;São Paulo&quot;</span><span style="color: #008000;">;</span>
    loja.<span style="color: #0000FF;">ProdutosQueVende</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>produto<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var loja2 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Loja<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    loja2.<span style="color: #0000FF;">Nome</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Loja Vegetariana&quot;</span><span style="color: #008000;">;</span>
    loja2.<span style="color: #0000FF;">Cidade</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;São Paulo&quot;</span><span style="color: #008000;">;</span>
    loja2.<span style="color: #0000FF;">ProdutosQueVende</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>produto<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    loja2.<span style="color: #0000FF;">ProdutosQueVende</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>produto2<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    contexto.<span style="color: #0000FF;">AddObject</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Produtos&quot;</span>, produto<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    contexto.<span style="color: #0000FF;">AddObject</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Produtos&quot;</span>, produto2<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    contexto.<span style="color: #0000FF;">AddObject</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Lojas&quot;</span>, loja<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    contexto.<span style="color: #0000FF;">AddObject</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Lojas&quot;</span>, loja2<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    contexto.<span style="color: #0000FF;">SaveChanges</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Console.<span style="color: #0000FF;">ReadKey</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Reparem que apenas adicionamos os produtos nas lojas, e não precisamos adicionar as lojas aos produtos também. O Entity Framework é esperto para fazer essa associação.</p>
<p>Aqui podemos ver uma saída gráfica das nossas relações:<br />
<div id="attachment_649" class="wp-caption aligncenter" style="width: 310px"><a class="lightbox" href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Resultado.jpg"><img  src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Resultado-300x151.jpg" alt="Resultado da relação Many-to-Many" title="Resultado da relação Many-to-Many" width="300" height="151" class="size-full wp-image-649" /></a><p class="wp-caption-text">Resultado da relação Many-to-Many</p></div></p>
<p>Bom pessoal, éisso aê. A relação Many-to-Many com POCOs no Entity Framework 4.0 é bastante simples e natural. Não requer passos adicionais e nem complicados.</p>
<p>Qualquer dúvida, crítica ou sugestão, deixem seus comentários ou podem escrever email.</p>
<p>Att,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/entity-framework-4-model-first-com-pocos/' rel='bookmark' title='Permanent Link: Entity Framework 4 &#8211; Model First com POCOs'>Entity Framework 4 &#8211; Model First com POCOs</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/entity-framework-4-0-utilizando-many-to-many-com-pocos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dojo .Net Architects: Vídeo e Apresentação</title>
		<link>http://viniciusquaiato.com/blog/index.php/dojo-net-architects-video-e-apresentacao/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/dojo-net-architects-video-e-apresentacao/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 12:29:36 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Boas Práticas]]></category>
		<category><![CDATA[Dojos]]></category>
		<category><![CDATA[Publicações]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[.Net Architects]]></category>
		<category><![CDATA[Coding Dojo]]></category>
		<category><![CDATA[DNA]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=630</guid>
		<description><![CDATA[Fala galera. Abaixo está o vídeo e apresentação do Coding Dojo do .Net Architects.
Apresentação:
Coding Dojo .Net Architects &#8211; 30.01.2010
View more presentations from Vinicius Quaiato.

Vídeo do Dojo:

Mais detalhes podem ser vistos aqui:
http://dojo.dotnetarchitects.net/index.php/2010/02/27/resultado-1-coding-dojo-net-architects/
Abraços,
Vinicius Quaiato.


Related posts:Coding Dojo .NET Architects &#8211; 30/01/2010 &#8211; São Paulo
Podcast Princípios SOLID &#8211; .NET Architects
TDD na .Net Magazine 69



Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/coding-dojo-net-architects-30-01-2010-sao-paulo/' rel='bookmark' title='Permanent Link: Coding Dojo .NET Architects &#8211; 30/01/2010 &#8211; São Paulo'>Coding Dojo .NET Architects &#8211; 30/01/2010 &#8211; São Paulo</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/podcast-principios-solid-net-architects/' rel='bookmark' title='Permanent Link: Podcast Princípios SOLID &#8211; .NET Architects'>Podcast Princípios SOLID &#8211; .NET Architects</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/tdd-na-net-magazine-69/' rel='bookmark' title='Permanent Link: TDD na .Net Magazine 69'>TDD na .Net Magazine 69</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Fala galera. Abaixo está o vídeo e apresentação do Coding Dojo do .Net Architects.</p>
<p>Apresentação:</p>
<div style="width:425px" id="__ss_3288565"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/viniciusquaiato/coding-dojo-net-architects-30012010" title="Coding Dojo .Net Architects - 30.01.2010">Coding Dojo .Net Architects &#8211; 30.01.2010</a></strong><object width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=codingdojo-30-01-2010-100226184406-phpapp01&#038;stripped_title=coding-dojo-net-architects-30012010" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=codingdojo-30-01-2010-100226184406-phpapp01&#038;stripped_title=coding-dojo-net-architects-30012010" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/viniciusquaiato">Vinicius Quaiato</a>.</div>
</div>
<p>Vídeo do Dojo:<br />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="288" id="viddler_98af9aa3"><param name="movie" value="http://www.viddler.com/player/98af9aa3/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/98af9aa3/" width="437" height="288" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_98af9aa3"></embed></object></p>
<p>Mais detalhes podem ser vistos aqui:<br />
<a href="http://dojo.dotnetarchitects.net/index.php/2010/02/27/resultado-1-coding-dojo-net-architects/" target="_blank">http://dojo.dotnetarchitects.net/index.php/2010/02/27/resultado-1-coding-dojo-net-architects/</a></p>
<p>Abraços,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/coding-dojo-net-architects-30-01-2010-sao-paulo/' rel='bookmark' title='Permanent Link: Coding Dojo .NET Architects &#8211; 30/01/2010 &#8211; São Paulo'>Coding Dojo .NET Architects &#8211; 30/01/2010 &#8211; São Paulo</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/podcast-principios-solid-net-architects/' rel='bookmark' title='Permanent Link: Podcast Princípios SOLID &#8211; .NET Architects'>Podcast Princípios SOLID &#8211; .NET Architects</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/tdd-na-net-magazine-69/' rel='bookmark' title='Permanent Link: TDD na .Net Magazine 69'>TDD na .Net Magazine 69</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/dojo-net-architects-video-e-apresentacao/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Asp.Net Ajax Library: Nova biblioteca do Asp.Net 4.0</title>
		<link>http://viniciusquaiato.com/blog/index.php/asp-net-ajax-library-nova-biblioteca-do-asp-net-4-0/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/asp-net-ajax-library-nova-biblioteca-do-asp-net-4-0/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 10:30:53 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Ajax Library]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Novidades]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=511</guid>
		<description><![CDATA[Asp.Net Ajax Library é uma nova biblioteca JavaScript que nos permite criar aplicações orientadas a dados de forma simples e prática.
Ela difere do Ajax Control Toolkit no sentido de que todos os seus controles e funcionalidades rodam inteiramente no client, ou seja, é possível utilizar o Ajax Library em páginas 100% html, nenhum code behind, [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/asp-net-mvc-jquery/' rel='bookmark' title='Permanent Link: ASP.NET MVC + JQuery'>ASP.NET MVC + JQuery</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/dynamicobject-dinamismo-no-net-4-0/' rel='bookmark' title='Permanent Link: DynamicObject: dinamismo no .NET 4.0'>DynamicObject: dinamismo no .NET 4.0</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.asp.net/ajaxlibrary/MainPage.ashx" target="_blank">Asp.Net Ajax Library</a> é uma nova biblioteca JavaScript que nos permite criar aplicações orientadas a dados de forma simples e prática.</p>
<p>Ela difere do Ajax Control Toolkit no sentido de que todos os seus controles e funcionalidades rodam inteiramente no client, ou seja, é possível utilizar o Ajax Library em páginas 100% html, nenhum code behind, nenhum arquivo .aspx e nenhum arquivo .cs (é possível trabalhar com .aspx e codebehind, só não é obrigatório).</p>
<p>Para realizarmos este exemplo vamos fazer o download da biblioteca no CodePlex neste link: <a href="http://ajax.codeplex.com/" target="_blank">http://ajax.codeplex.com/</a></p>
<p>Neste exemplo veremos como gerar uma tabela de dados contendo o nome de algumas bandas e suas respectivas fotos.<br />
Não utilizaremos ainda acesso a webservices, trabalharemos com dados locais.</p>
<p>Para isso criaremos um projeto Asp.Net WebSite vazio, e adicionaremos um arquivo html, chamado Default.htm (Sim, nossa aplicação toda executará em um arquivo .htm).<br />
Vamos adicionar ao projeto os arquivos .js que fazem parte da biblioteca, como mostra a imagem abaixo:<br />
<a class="lightbox" href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Adicionando-arquivos-js1.jpg"><div id="attachment_590" class="wp-caption aligncenter" style="width: 310px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Adicionando-arquivos-js1-300x229.jpg" alt="Adicionando arquivos js Asp.Net Ajax Library 4.0" title="Adicionando arquivos js Asp.Net Ajax Library 4.0" width="300" height="229" class="size-medium wp-image-590" /><p class="wp-caption-text">Adicionando arquivos js Asp.Net Ajax Library 4.0</p></div></a></p>
<p>Feito isso adicionarei os trechos de código abaixo na página Default.html. Separei em dois blocos para mostrar primeiro o código JavaScript e depois o código HTML, no final colocarei o código completo da página.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;Scripts/Start.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
    Sys.<span style="color: #660066;">require</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>Sys.<span style="color: #660066;">components</span>.<span style="color: #660066;">dataView</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> bandas <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
                <span style="color: #009900;">&#123;</span> Nome<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Metallica'</span><span style="color: #339933;">,</span> Foto<span style="color: #339933;">:</span> <span style="color: #3366CC;">'metallica.jpg'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span> Nome<span style="color: #339933;">:</span> <span style="color: #3366CC;">'The Smiths'</span><span style="color: #339933;">,</span> Foto<span style="color: #339933;">:</span> <span style="color: #3366CC;">'smiths.jpg'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span> Nome<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Depeche Mode'</span><span style="color: #339933;">,</span> Foto<span style="color: #339933;">:</span> <span style="color: #3366CC;">'depeche.jpg'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span> Nome<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Los hermanos'</span><span style="color: #339933;">,</span> Foto<span style="color: #339933;">:</span> <span style="color: #3366CC;">'hermanos.jpg'</span> <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            Sys.<span style="color: #660066;">create</span>.<span style="color: #660066;">dataView</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#corpo&quot;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>data<span style="color: #339933;">:</span> bandas<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Como pode ser visto na <strong><em>linha 1</em></strong> estou adicionando uma referência para o arquivo Start.js, que faz parte do Asp.Net Ajax Library, e adicionamos no nosso projeto.<br />
Na <strong><em>linha 3</em></strong> começa a acontecer a &#8220;mágica&#8221;. Chamamos o método require que recebe neste caso dois parâmetros. O primeiro é uma biblioteca a ser carregada, neste caso o <em>Sys.components.dataView</em>. o segundo parâmetro é uma função a ser executada depois que a biblioteca foi carregada, ou seja, seus recursos já estão disponíveis.<br />
Um dos principais recursos para a exibição de dados é o DataView. DataView é basicamente um template, criamos marcações HTML e então pedimos para o Ajax Library transformar em um dataview.<br />
Da <strong><em>linha 5</em></strong> até <strong><em>linha 10</em></strong> eu crio um objeto utilizando notação <a href="http://www.json.org/" target="_blank">JSON</a>, contendo o nome de uma banda, e o nome de um arquivo com a imagem da banda, bastante simples. Este objeto será nossa fonte de dados.<br />
Na <strong><em>linha 11</em></strong> ocorre o bind dos dados. Utilizando o <em>Sys.create.dataView</em> passamos como primeiro parâmetro o id de um elemento HTML onde deve ser criado o dataview. E como segundo parâmetro dizemos que o objeto bandas deve ser usado como fonte de dados.<br />
Bastante simples.</p>
<p>Abaixo está o código HTML, onde definimos o elemento que será o dataView:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;thead<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Banda<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Foto<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/thead<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tbody</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;corpo&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;sys-template&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{{Nome}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">sys:src</span>=<span style="color: #ff0000;">&quot;{{Foto}}&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Apenas criamos uma table, simples. Na <strong><em>linha 8</em></strong> está um detalhe importante pois utilizamos uma class chamada <em>sys-template</em>. Esta class é necessária para que o Ajax Library reconheça este elemento como um template com o qual ele poderá trabalhar.<br />
Na <strong><em>linha 11</em></strong> criamos um span e como valor do span utilizamos a marcação {{Nome}} que diz para o Ajax Library que ali deve ser colocado o campo Nome da fonte de dados que passamos para ele.<br />
Na <strong><em>linha 14</em></strong> fazemos quase a mesma coisa, a diferença é que ao invés de utilizarmos o atributo src do elemento img, utilizamos sys-src, pois o valor deste atributo {{Foto}} está entre as aspas, e é com o <em>sys-src</em> que o Ajax Library consegue fazer o bind corretamente.</p>
<p>Pronto! Agora temos nossa aplicação funcionando, realizando o bind da nossa fonte de dados, e exibindo tudo da maneira desejada. Como mostra a figura abaixo:<br />
<a class="lightbox" href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Pagina-usando-Asp.Net-Ajax-Library.jpg"><div id="attachment_600" class="wp-caption aligncenter" style="width: 257px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Pagina-usando-Asp.Net-Ajax-Library-247x300.jpg" alt="Página usando Asp.Net Ajax Library" title="Página usando Asp.Net Ajax Library" width="247" height="300" class="size-full wp-image-600" /></a><p class="wp-caption-text">Página usando Asp.Net Ajax Library</p></div></p>
<p>O código completo da página Default.html está aqui:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;Scripts/Start.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            Sys.require([Sys.components.dataView],
                function () {
                    var bandas = [
                        { Nome: 'Metallica', Foto: 'metallica.jpg' },
                        { Nome: 'The Smiths', Foto: 'smiths.jpg' },
                        { Nome: 'Depeche Mode', Foto: 'depeche.jpg' },
                        { Nome: 'Los hermanos', Foto: 'hermanos.jpg' }
                    ];
                    Sys.create.dataView(&quot;#corpo&quot;,
                     {
                         data: bandas
                     });
                });  
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;thead<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Banda<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Foto<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/thead<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tbody</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;corpo&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;sys-template&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>{{Nome}}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">sys:src</span>=<span style="color: #ff0000;">&quot;{{Foto}}&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tbody<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Bom pessoal, por hoje é isso. O Asp.Net Ajax Library possui uma série de recursos e controles incríveis. São 3 tipos diferentes de bindings, e os bindings podem ser feitos de maneiras variadas.<br />
Pretendo ir dando mais detalhes e informações por aqui, na medida do possível.<br />
Alguns How To podem ser vistos <a href="http://www.asp.net/ajaxlibrary/learn.ashx" target="_blank">aqui</a>.</p>
<p>Comentário, críticas e sugestões são bem vindos.</p>
<p>Att,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/asp-net-mvc-jquery/' rel='bookmark' title='Permanent Link: ASP.NET MVC + JQuery'>ASP.NET MVC + JQuery</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/dynamicobject-dinamismo-no-net-4-0/' rel='bookmark' title='Permanent Link: DynamicObject: dinamismo no .NET 4.0'>DynamicObject: dinamismo no .NET 4.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/asp-net-ajax-library-nova-biblioteca-do-asp-net-4-0/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PLINQ: Paralelismo no .Net 4 com Parallel LINQ</title>
		<link>http://viniciusquaiato.com/blog/index.php/plinq-paralelismo-no-net-4-com-parallel-linq/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/plinq-paralelismo-no-net-4-com-parallel-linq/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 10:25:14 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Novidades]]></category>
		<category><![CDATA[Paralelismo]]></category>
		<category><![CDATA[PLINQ]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=516</guid>
		<description><![CDATA[Fala galera. Vou abordar um pouco do PLINQ neste post.
Parallel LINQ, ou PLINQ, é uma implementação do padrão LINQ que trabalha de forma paralela sobre qualquer fonte de dados em memória que implemente IEnumerable ou IEnumerable&#60;T&#62;, possuindo ainda a execução adiada até o momento em que a query é enumerada, ou seja, de fato utilizada.
Umas [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-parallel-for/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For'>Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Fala galera. Vou abordar um pouco do PLINQ neste post.</p>
<p>Parallel LINQ, ou <a href="http://msdn.microsoft.com/en-us/magazine/cc163329.aspx" target="_blank">PLINQ</a>, é uma implementação do padrão <a href="http://msdn.microsoft.com/en-us/netframework/aa904594.aspx" target="_blank">LINQ</a> que trabalha de forma paralela sobre qualquer fonte de dados em memória que implemente <a href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx" target="_blank">IEnumerable</a> ou <a href="http://msdn.microsoft.com/en-us/library/9eekhta0.aspx" target="_blank">IEnumerable&lt;T&gt;</a>, possuindo ainda a execução adiada até o momento em que a query é enumerada, ou seja, de fato utilizada.</p>
<p>Umas das novidades é o extension <a href="http://msdn.microsoft.com/en-us/library/system.linq.parallelenumerable.asparallel%28VS.100%29.aspx" target="_blank">AsParallel</a> que está disponível em IEnumerable e IEnumerable&lt;T&gt;. AsParallel diz que à partir daquele momento as operações realizadas sobre aquela fonte de dados serão executas de forma paralela, é bem simples. O código abaixo demonstra isso:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var numeros <span style="color: #008000;">=</span> Enumerable.<span style="color: #0000FF;">Range</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var dobrados <span style="color: #008000;">=</span> from n <span style="color: #0600FF;">in</span> numeros.<span style="color: #0000FF;">AsParallel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                   select Dobro<span style="color: #000000;">&#40;</span>n<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var dobro <span style="color: #0600FF;">in</span> dobrados<span style="color: #000000;">&#41;</span>
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>dobro<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Console.<span style="color: #0000FF;">ReadKey</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">int</span> Dobro<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> numero<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Thread.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">500</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> numero <span style="color: #008000;">*</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Como vemos na <strong><em>linha 5</em></strong> estamos chamando o método AsParallel na nossa coleção de números. Então apenas chamamos um método passando o número como parâmetro. Este método apenas congela a thread por meio segundo para que possamos notar como os valores são executados de forma paralela. Na imagem abaixo temos o resultado:<br />
<div id="attachment_543" class="wp-caption aligncenter" style="width: 215px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Enumerando-com-AsParallel.jpg" alt="Enumerando com AsParallel do PLINQ" title="Enumerando com AsParallel do PLINQ" width="205" height="203" class="size-full wp-image-543" /><p class="wp-caption-text">Enumerando com AsParallel do PLINQ</p></div></p>
<p>O PLINQ também permite de forma simples e fácil especificar quantos processadores queremos utilizar para executar as operações paralelas. É possível especificar até um máximo de 64 processadores (ô loco meu!).<br />
Abaixo segue a alteraçãono código anterior especificando 2 processadores a serem utilizados (só tenho 2):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>5
6
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">    var dobrados <span style="color: #008000;">=</span> from n <span style="color: #0600FF;">in</span> numeros.<span style="color: #0000FF;">AsParallel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">WithDegreeOfParallelism</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
                   select Dobro<span style="color: #000000;">&#40;</span>n<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Na <strong><em>linha 5</em></strong> do nosso código adicionamos uma chamada para a extensão <a href="http://msdn.microsoft.com/en-us/library/dd383719%28VS.100%29.aspx" target="_blank">WithDegreeOfParallelism</a> e passamos como parâmetro o total de processadores a ser utilizado. No mais o código permanece exatamente igual.</p>
<p>Outro recurso bastante interessante é realizar o processamento paralelo e conseguir que o resultado seja ordenado. Isso é possível utilizando a extension <a href="http://msdn.microsoft.com/en-us/library/dd642142%28VS.100%29.aspx" target="_blank">AsOrdered</a>.<br />
No código anterior poderíamos utilziar AsParallel e continuar realizando o processamento de forma paralela mas mantendo a saída ordenada, como pode ser visto abaixo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>5
6
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">    var dobrados <span style="color: #008000;">=</span> from n <span style="color: #0600FF;">in</span> numeros.<span style="color: #0000FF;">AsParallel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">AsOrdered</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                   select Dobro<span style="color: #000000;">&#40;</span>n<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>A saída pode ser vista na imagem abaixo:<br />
<div id="attachment_546" class="wp-caption aligncenter" style="width: 255px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/AsParallel-com-AsOrdered.jpg" alt="PLINQ usando AsParallel com AsOrdered" title="PLINQ usando AsParallel com AsOrdered" width="245" height="215" class="size-full wp-image-546" /><p class="wp-caption-text">PLINQ usando AsParallel com AsOrdered</p></div></p>
<p>Existem ainda diversos recursos no PLINQ. Em breve abordarei mais sobre eles aqui.<br />
Uma boa documentação está disponível no MSDN <a href="http://msdn.microsoft.com/en-us/library/dd997425%28VS.100%29.aspx" target="_blank">aqui</a>, <a href="http://msdn.microsoft.com/en-us/library/dd537608%28VS.100%29.aspx" target="_blank">aqui</a> e <a href="http://msdn.microsoft.com/pt-br/vstudio/dd441784%28en-us%29.aspx#Parallel" target="_blank">aqui</a>.</p>
<p>Comentários, críticas e sugestões, basta escrever.</p>
<p>Att,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-parallel-for/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For'>Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/plinq-paralelismo-no-net-4-com-parallel-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Postando no Twitter com TweetSharp em C#</title>
		<link>http://viniciusquaiato.com/blog/index.php/postando-no-twitter-com-tweetsharp-em-c/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/postando-no-twitter-com-tweetsharp-em-c/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 10:25:43 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Mídias Sociais]]></category>
		<category><![CDATA[TweetSharp]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=559</guid>
		<description><![CDATA[Continuando a falar da API TweetSharp, neste post mostrarei como enviar tweets e retweetar mensagens.
Novamente estamos utilizando as interfaces fluentes do TweetSharp, o que torna o trabalho bem simples e fácil, pois com a ajuda do intellisense podemos realizar todo trabalho simplesmente navegando através dos métodos, que possuem nomes bem definidos e claros.
Bom vamos lá, [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/' rel='bookmark' title='Permanent Link: TweetSharp: Acessando o Twitter com C#'>TweetSharp: Acessando o Twitter com C#</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/twitter_512x512.png"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/twitter_512x512-150x150.png" alt="" title="twitter c#" width="150" height="150" class="alignleft size-thumbnail wp-image-570" /></a>Continuando a falar da API TweetSharp, neste post mostrarei como enviar tweets e retweetar mensagens.</p>
<p>Novamente estamos utilizando as interfaces fluentes do TweetSharp, o que torna o trabalho bem simples e fácil, pois com a ajuda do intellisense podemos realizar todo trabalho simplesmente navegando através dos métodos, que possuem nomes bem definidos e claros.</p>
<p>Bom vamos lá, continuaremos utilizando o código apresentado neste post <a href="http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/" target="_blank">aqui</a>.</p>
<p>Abaixo estou criando o método que envia uma nova mensagem para o Twitter:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> PostarMensagemTwitter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> mensagem<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var request <span style="color: #008000;">=</span> FluentTwitter
                   .<span style="color: #0000FF;">CreateRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                   .<span style="color: #0000FF;">AuthenticateAs</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;seuLogin&quot;</span>, <span style="color: #666666;">&quot;suaSenha&quot;</span><span style="color: #000000;">&#41;</span>
                   .<span style="color: #0000FF;">Statuses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                   .<span style="color: #0000FF;">Update</span><span style="color: #000000;">&#40;</span>mensagem<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var result <span style="color: #008000;">=</span> request.<span style="color: #0000FF;">Request</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Este método é bem simples e a única novidade é a <strong><em>linha 7</em></strong>, onde chamamos o método Update, passando uma string, que é a mensagem que será enviada para o Twitter. Para entender mais sobre os outros métodos, veja a explicação <a href="http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/" target="_blank">aqui</a>.</p>
<p>Agora vou alterar o método Main para enviar uma nova mensagem e depois fazer a consulta das últimas 10 mensagens para verificar se realmente conseguimos enviar o tweet:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    PostarMensagemTwitter<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Enviando tweet através do post do blog!!!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var tweets <span style="color: #008000;">=</span> Obter10ultimosTweets<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var tweet <span style="color: #0600FF;">in</span> tweets<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;@{0} {1}<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span>, tweet.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">ScreenName</span>, tweet.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Console.<span style="color: #0000FF;">ReadKey</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>O resultado pode ser visto na imagem abaixo:<br />
<div id="attachment_565" class="wp-caption aligncenter" style="width: 687px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Postando-mensagem-twitter.jpg" alt="Postando mensagem Twitter com C# e Tweetsharp" title="Postando mensagem Twitter com C# e Tweetsharp" width="677" height="450" class="size-full wp-image-565" /><p class="wp-caption-text">Postando mensagem Twitter com C# e Tweetsharp</p></div></p>
<p>Para fazer um retweet, ou seja, repassar uma mensagem que alguém enviou, utilizaremos o método abaixo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Retweetar<span style="color: #000000;">&#40;</span>TwitterStatus tweet<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var request <span style="color: #008000;">=</span> FluentTwitter
       .<span style="color: #0000FF;">CreateRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
       .<span style="color: #0000FF;">AuthenticateAs</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;seuLogin&quot;</span>, <span style="color: #666666;">&quot;suaSenha&quot;</span><span style="color: #000000;">&#41;</span>
       .<span style="color: #0000FF;">Statuses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
       .<span style="color: #0000FF;">Retweet</span><span style="color: #000000;">&#40;</span>tweet, RetweetMode.<span style="color: #0000FF;">Prefix</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var result <span style="color: #008000;">=</span> request.<span style="color: #0000FF;">Request</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Na <strong><em>linha 1</em></strong> podemos notar que recebemos como parâmetro um TwitterStatus, que é a mensagem que queremos retweetar. Veremos depois como obter este objeto. Na <strong><em>linha 7</em></strong> estamos chamando o método Retweet e passando como primeiro parâmetro o tweet que queremos retweetar, e passamos também um valor do enum RetweetMode, neste caso o valor Prefix, indiicando que o prefixo &#8216;RT&#8217; deve ser adicionado ao nosso retweet.</p>
<p>Alterei o método Main para selecionar um tweet específico, retweetar, e então listar os últimos 10 para vermos o nosso retweet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var tweets <span style="color: #008000;">=</span> Obter10ultimosTweets<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    var paraRetweetar <span style="color: #008000;">=</span> tweets.<span style="color: #0000FF;">Where</span><span style="color: #000000;">&#40;</span>t <span style="color: #008000;">=&gt;</span> t.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">ScreenName</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;vquaiato&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">First</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Retweetar<span style="color: #000000;">&#40;</span>paraRetweetar<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    tweets <span style="color: #008000;">=</span> Obter10ultimosTweets<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var tweet <span style="color: #0600FF;">in</span> tweets<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;@{0} {1}<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span>, tweet.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">ScreenName</span>, tweet.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Console.<span style="color: #0000FF;">ReadKey</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>A única novidade aqui é que estou selecionando um tweet específico na <strong><em>linha 4</em></strong>, no caso um tweet que tenha sido enviado por mim.</p>
<p>O resultado pode ser conferido na imagem abaixo (e se você me segue no twitter, deve ter visto estas mensagens também @vquaiato):<br />
<div id="attachment_574" class="wp-caption aligncenter" style="width: 687px"><a href="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Retweetando-com-TweetSharp.jpg"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Retweetando-com-TweetSharp.jpg" alt="Retweet com TweetSharp em C#" title="Retweet com TweetSharp em C#" width="677" height="474" class="size-full wp-image-574" /></a><p class="wp-caption-text">Retweet com TweetSharp em C#</p></div></p>
<p>É isso aê! Deste jeito teremos um cliente para twitter pronto de forma bem simples e objetiva.</p>
<p>Recebi algumas dicas de outras bibliotecas para acessar o Twitter também, e em breve postarei algo aqui.<br />
O <a href="http://twitter.com/juloliveira" target="_blank">@juloliveira</a> indicou o <a href="http://www.codeplex.com/LinqToTwitter" target="_blank">Linq2Twitter</a>.<br />
O <a href="http://twitter.com/brunokenj" target="_blank">@brunokenj</a> indicou o <a href="http://code.google.com/p/twitterizer/" target="_blank">Twitterizer</a>.<br />
Logo mais falo sobre estas bibliotecas aqui.</p>
<p>Abraços, e lembrando que os comentários e dúvidas, críticas, etc, são sempre bem vindos.<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/' rel='bookmark' title='Permanent Link: TweetSharp: Acessando o Twitter com C#'>TweetSharp: Acessando o Twitter com C#</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/postando-no-twitter-com-tweetsharp-em-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TweetSharp: Acessando o Twitter com C#</title>
		<link>http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 10:15:42 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Mídias Sociais]]></category>
		<category><![CDATA[TweetSharp]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=510</guid>
		<description><![CDATA[
Fala galera, vou demonstrar como é simples acessar o Twitter utilizando a biblioteca TweetSharp e suas interfaces fluentes.
Primeiramente baixe as dlls do Tweetsharp aqui.
O TweetSharp é uma api que fornece acesso de forma simplificada à API do Twitter.
Vamos então criar um projeto utilizando o Visual Studio 2010 beta 2 porém estou utilizando a versão 3.5 [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/postando-no-twitter-com-tweetsharp-em-c/' rel='bookmark' title='Permanent Link: Postando no Twitter com TweetSharp em C#'>Postando no Twitter com TweetSharp em C#</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/twitter_bird.jpg" alt="twitter_bird" title="twitter_bird" width="300" height="249" class="alignleft size-full wp-image-556" /></p>
<p>Fala galera, vou demonstrar como é simples acessar o Twitter utilizando a biblioteca TweetSharp e suas interfaces fluentes.</p>
<p>Primeiramente baixe as dlls do Tweetsharp <a href="http://code.google.com/p/tweetsharp/" target="_blank">aqui</a>.</p>
<p>O <a href="http://tweetsharp.com/" target="_blank">TweetSharp</a> é uma api que fornece acesso de forma simplificada à API do Twitter.</p>
<p>Vamos então criar um projeto utilizando o Visual Studio 2010 beta 2 porém estou utilizando a versão 3.5 para o projeto, pois existem alguns conflitos com o framework 4.<br />
Estou criando uma Console Application, para que possamos ver uma saída gráfica do nosso código.</p>
<p>Vamos adicionar a referência para o TweetSharp em nosso projeto, como mostra a figura abaixo:<br />
<div id="attachment_514" class="wp-caption aligncenter" style="width: 661px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/Referencias-TweetSharp.jpg" alt="Adicionando Referencias TweetSharp" title="Adicionando Referencias TweetSharp" width="651" height="446" class="size-full wp-image-514" /><p class="wp-caption-text">Adicionando Referencias TweetSharp</p></div></p>
<p>Feito isso vou criar 2 métodos. Um para para buscar os 10 últimos tweets da minha lista e o outro para exibir a lista de amigos.</p>
<p>Primeiramente inclua estes 3 statements using:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">Dimebrain.TweetSharp.Model</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Dimebrain.TweetSharp.Fluent</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Dimebrain.TweetSharp.Extensions</span><span style="color: #008000;">;</span></pre></div></div>

<p>No código acima estamos adicionando as referências para usarmos os métodos de extensão e as interfaces fluentes do TweetSharp e também as classes do mesmo.</p>
<p>Abaixo temos o método que busca os 10 últimos tweets:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> IEnumerable<span style="color: #008000;">&lt;</span>TwitterStatus<span style="color: #008000;">&gt;</span> Obter10UltimosTweets<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var search <span style="color: #008000;">=</span> FluentTwitter
                    .<span style="color: #0000FF;">CreateRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">AuthenticateAs</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;seuLogin&quot;</span>, <span style="color: #666666;">&quot;suaSenha&quot;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">Statuses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">OnHomeTimeline</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">Take</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">AsJson</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var result <span style="color: #008000;">=</span> search.<span style="color: #0000FF;">Request</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> result.<span style="color: #0000FF;">AsStatuses</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Por utilizar <a href="http://en.wikipedia.org/wiki/Fluent_interface" target="_blank">interfaces fluentes</a> O código fica bem simples e legível. Na <strong><em>linha 4</em></strong> criamos um request utilizando a api do TweetSharp. Na <strong><em>linha 5</em></strong> dizemos quais credenciais devem ser utilizadas. Na <strong><em>linha 6</em></strong> informamos que queremos trabalhar com os &#8220;statuses&#8221; ou seja, os tweets. Na <strong><em>linha 7</em></strong> dizemos que queremos os tweets que aparecem na nossa home, ou seja, de quem seguimos e os nossos também. Já na <strong><em>linha 8</em></strong> pegamos apenas 10 destes tweets e os formatamos em Json na <strong><em>linha 9</em></strong>.<br />
O código em si é realmente bastante legível.</p>
<p>E o nosso método main fica assim:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var tweets <span style="color: #008000;">=</span> Obter10ultimosTweets<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var tweet <span style="color: #0600FF;">in</span> tweets<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;@{0} {1}<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span>, tweet.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">ScreenName</span>, tweet.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Console.<span style="color: #0000FF;">ReadKey</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Este método é bem simples, apenas itera os elementos retornados pelo método anterior. As propriedades do objeto TwitterStatus podem ser conferidas com ajuda do intellisense ou então pressionado F12 sobre a classe.<br />
O resultado pode ser visto na imagem abaixo:<br />
<div id="attachment_536" class="wp-caption aligncenter" style="width: 687px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/10UltimosTweets.jpg" alt="10 Últimos Tweets com TweetSharp" title="10 Últimos Tweets com TweetSharp" width="677" height="462" class="size-full wp-image-536" /><p class="wp-caption-text">10 Últimos Tweets com TweetSharp</p></div></p>
<p>Para exibir a lista de amigos vou utilizar o método abaixo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> IEnumerable<span style="color: #008000;">&lt;</span>TwitterUser<span style="color: #008000;">&gt;</span> ObterListaDeAmigos<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var search <span style="color: #008000;">=</span> FluentTwitter
                    .<span style="color: #0000FF;">CreateRequest</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">AuthenticateAs</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;seuLogin&quot;</span>, <span style="color: #666666;">&quot;suaSenha&quot;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">Users</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">GetFriends</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                    .<span style="color: #0000FF;">AsJson</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var result <span style="color: #008000;">=</span> search.<span style="color: #0000FF;">Request</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">return</span> result.<span style="color: #0000FF;">AsUsers</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>A diferença neste código para o anterior está na <strong><em>linha 6</em></strong> onde informamos que queremos trabalhar com os usuários, e na <strong><em>linha 7</em></strong> onde dizemos que queremos obter os friends, ou seja, as pessoas que estamos seguindo.</p>
<p>E alteramos o código do método main de forma que fique assim;</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var tweets <span style="color: #008000;">=</span> Obter10ultimosTweets<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var tweet <span style="color: #0600FF;">in</span> tweets<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;@{0} {1}<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span>, tweet.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">ScreenName</span>, tweet.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\n</span>LISTA DE AMIGOS<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    var amigos <span style="color: #008000;">=</span> ObterListaDeAmigos<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var amigo <span style="color: #0600FF;">in</span> amigos<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Console.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;@{0}&quot;</span>, amigo.<span style="color: #0000FF;">ScreenName</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    Console.<span style="color: #0000FF;">ReadKey</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>O resultado pode ser conferido na imagem abaixo:<br />
<div id="attachment_535" class="wp-caption aligncenter" style="width: 687px"><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/lista-de-amigos.jpg" alt="Lista de amigos com TweetSharp" title="Lista de amigos com TweetSharp" width="677" height="342" class="size-full wp-image-535" /><p class="wp-caption-text">Lista de amigos com TweetSharp</p></div></p>
<p>Bom pessoal, é basicamente isso. A biblioteca TweetSharp oferece ainda diversos outros recursos, tudo que é necessário para se fazer um bom trabalho com o twitter.</p>
<p>Dúvidas, sugestões, reclamações: os comentários estão aí pra isso.</p>
<p>Att,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/postando-no-twitter-com-tweetsharp-em-c/' rel='bookmark' title='Permanent Link: Postando no Twitter com TweetSharp em C#'>Postando no Twitter com TweetSharp em C#</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/tweetsharp-acessando-o-twitter-com-c/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 RC lançado</title>
		<link>http://viniciusquaiato.com/blog/index.php/visual-studio-2010-rc-lancado/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/visual-studio-2010-rc-lancado/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 18:39:27 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Novidades]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=519</guid>
		<description><![CDATA[Fala galera!
Dia 10 de fevereiro, se não me engano, tivemos a liberação da versão RC (Release Candidate) do Visual Studio 2010 para download.
O link para download é este: http://www.microsoft.com/downloads/details.aspx?FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a&#038;displaylang=en
Você pode obter mais informações sobre esta versão aqui: http://msdn.microsoft.com/pt-br/vstudio/dd582936.aspx
Algumas informações (comentários, bugs e melhorias) podem ser vistas aqui no blog do Scott Guthrie.
Estou preparando mais alguns [...]


Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-parallel-for/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For'>Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-generate-from-usage/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Generate from usage'>Visual Studio 2010 &#8211; Novas Features &#8211; Generate from usage</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-docking-janelas/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Docking Janelas'>Visual Studio 2010 &#8211; Novas Features &#8211; Docking Janelas</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/vs2010_logo.png" alt="vs2010 logo" title="vs2010 logo" width="233" height="178" class="alignleft size-full wp-image-525" />Fala galera!<br />
Dia 10 de fevereiro, se não me engano, tivemos a liberação da versão RC (Release Candidate) do Visual Studio 2010 para download.</p>
<p>O link para download é este: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a&#038;displaylang=en" target="_blank">http://www.microsoft.com/downloads/details.aspx?FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a&#038;displaylang=en</a></p>
<p>Você pode obter mais informações sobre esta versão aqui: <a href="http://msdn.microsoft.com/pt-br/vstudio/dd582936.aspx" target="_blank">http://msdn.microsoft.com/pt-br/vstudio/dd582936.aspx</a></p>
<p>Algumas informações (comentários, bugs e melhorias) podem ser vistas <a href="http://weblogs.asp.net/scottgu/archive/2010/02/08/vs-2010-net-4-release-candidate.aspx" target="_blank">aqui no blog do Scott Guthrie.</a></p>
<p>Estou preparando mais alguns posts sobre funcionalidades do VS2010, e logo mais estarão por aqui.</p>
<p>É isso, espero que utilizem, dêem seu feedback, e se divirtam!</p>
<p>Att,<br />
Vinicius Quaiato.</p>


<p>Related posts:<ol><li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-parallel-for/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For'>Visual Studio 2010 &#8211; Novas Features &#8211; Parallel For</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-generate-from-usage/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Generate from usage'>Visual Studio 2010 &#8211; Novas Features &#8211; Generate from usage</a></li>
<li><a href='http://viniciusquaiato.com/blog/index.php/visual-studio-2010-novas-features-docking-janelas/' rel='bookmark' title='Permanent Link: Visual Studio 2010 &#8211; Novas Features &#8211; Docking Janelas'>Visual Studio 2010 &#8211; Novas Features &#8211; Docking Janelas</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/visual-studio-2010-rc-lancado/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Off-Topic] Motivação importa</title>
		<link>http://viniciusquaiato.com/blog/index.php/off-topic-motivacao-importa/</link>
		<comments>http://viniciusquaiato.com/blog/index.php/off-topic-motivacao-importa/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 11:57:23 +0000</pubDate>
		<dc:creator>Vinicius Quaiato</dc:creator>
				<category><![CDATA[[Off - Topic]]]></category>
		<category><![CDATA[Carreira]]></category>
		<category><![CDATA[Motivação]]></category>
		<category><![CDATA[Profissionais]]></category>
		<category><![CDATA[Talentos]]></category>

		<guid isPermaLink="false">http://viniciusquaiato.com/blog/?p=496</guid>
		<description><![CDATA[Acredito que as empresas querem ter os melhores funcionários (colaboradores, parceiros, times, equipes, etc). Esta é minha crença.
E o que mostra que um profissional é o melhor profissional? Conhecimento técnico? Comprometimento? Disponibilidade? Olhar crítico? Tudo isso. Porém acredito em algo mais: Motivação.
Não basta contratar o profissional com o maior conhecimento técnico disponível no mercado. Este [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><img src="http://viniciusquaiato.com/blog/wp-content/uploads/2010/02/diamantess.jpg" alt="diamantes" title="diamantes" width="300" height="264" class="alignleft size-full wp-image-503" />Acredito que as empresas querem ter os melhores funcionários (colaboradores, parceiros, times, equipes, etc). Esta é minha crença.<br />
E o que mostra que um profissional é o melhor profissional? Conhecimento técnico? Comprometimento? Disponibilidade? Olhar crítico? Tudo isso. Porém acredito em algo mais: Motivação.</p>
<p>Não basta contratar o profissional com o maior conhecimento técnico disponível no mercado. Este conhecimento técnico pode ser, e acredite que é, suprimido pela falta de motivação. E se você quer que sua empresa, time, equipe, etc, esteja entre os melhores:</p>
<p>&nbsp;</p>
<ul>
<li>Conheça os anseios e desejos deste profissional &#8211; Entenda o que ele almeja, e ajude-o a conquistar</li>
<li>Dê a ele a chance de participar &#8211; Faça-o parte de um time</li>
<li>Invista nele, além do salário &#8211; Apagar incêndio é importante, mas permita-o crescer</li>
<li>Preocupe-se com a qualidade técnica do trabalho executado &#8211; Mostre que o que ele faz tem valor</li>
<li>Fuja dos modelos organizacionais batidos e ultrapassados &#8211; Se quer mentes brilhantes, inove!</li>
<li>Crie um ambiente colaborativo &#8211; É muito melhor trabalhar em grupo</li>
<li>Mostre a ele que perder a batalha não é perder a guerra &#8211; Participe com ele das derrotas e construam vitórias juntos</li>
<li>Desafie-o constantemente &#8211; Os melhores aguentam a pressão e criam soluções inesperadas</li>
<li>Deseje tê-lo em sua equipe &#8211; Mostre o quão importante é sua participação</li>
</ul>
<p>O mercado está cheio de profissionais medíocres, que se contentam em receber um contra-cheque no final do mês, porém, o mercado é construído por aqueles que se importam com os itens mencionados acima. </p>
<p>Um profissional brilhante pode tornar-se medíocre em razão do ambiente desfavorável, e quando isso acontecer, esteja certo, ele vai abandonar este time.<br />
Não se pode apagar mentes brilhantes, então se você realmente deseja tê-las em sua equipe, faça por merecer. Cultive os talentos que você possui na sua empresa.<br />
Cultive os seus diamantes!</p>
<p>Mantenha seus profissionais motivados, e eles terão os melhores resultados. Eles farão a diferença. Eles se importarão com o que fazem. Eles se importarão com o que entregam. Farão com qualidade. Participarão das decisões, evitarão cometer erros. Assumirão os erros.</p>
<p>Se você deseja resultados medíocres, se deseja apenas pagar incêndios, e receber de seus clientes, não se importe com nada do que foi dito. Agora, se você deseja que sua empresa se destaque, se deseja os melhores profissionais, se quer fazer diferente e tornar-se referência, não atue da mesma maneira que os medíocres, faça de sua empresa uma empresa brilhante.</p>
<p>Motivação matters.</p>
<p>Att,<br />
Vinicius Quaiato.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://viniciusquaiato.com/blog/index.php/off-topic-motivacao-importa/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
