<?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>I&#039;m Kiraya</title>
	<atom:link href="http://www.metalide.com/kiraya/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.metalide.com/kiraya</link>
	<description>Blog personale di Andrea &#34;Kiraya&#34; Magini</description>
	<lastBuildDate>Wed, 11 Apr 2012 20:37:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Kingdom:Undead Control Handlers</title>
		<link>http://www.metalide.com/kiraya/?p=1018</link>
		<comments>http://www.metalide.com/kiraya/?p=1018#comments</comments>
		<pubDate>Wed, 11 Apr 2012 20:37:29 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Kingdom:Undead Prototype]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CCLayer]]></category>
		<category><![CDATA[CCNode]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[Delegate]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Handler]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Keyboard]]></category>
		<category><![CDATA[Mouse]]></category>
		<category><![CDATA[NSEvent]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Protocol]]></category>
		<category><![CDATA[Touch]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=1018</guid>
		<description><![CDATA[Nel disegno del codice, mi sono accorto di una cosa che a tendere rendeva illeggibile e poco gestibile il codice, la gestione degli eventi mouse, touch e keyboard da parte dei CCLayer di cocos2d. Dovendo mostrare diversi CCNode contenenti UI &#8230; <a href="http://www.metalide.com/kiraya/?p=1018">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Nel disegno del codice, mi sono accorto di una cosa che a tendere rendeva illeggibile e poco gestibile il codice, la gestione degli eventi mouse, touch e keyboard da parte dei CCLayer di cocos2d.</p>
<p>Dovendo mostrare diversi CCNode contenenti UI realizzate con cocos, come ad esempio la scheda del giocatore, piuttosto che un menu di scelta, una popup modale magari realizzata con texture fatte adhoc, la gestione degli eventi rimaneva tutta comunque nell&#8217;implementazione del cclayer contenente tutta la parte principale del gioco.</p>
<p>Così ho deciso di estendere il cclayer, aggiungendo la possibilità di fornire gli eventi a dei delegati. Questo mi permette di &#8220;responsabilizzare&#8221; il codice al meglio, lasciando ad esempio la gestione del click su un certo pulsante solo nel ccnode che lo contiene.</p>
<p>Questo e&#8217; un esempio di come estendere il CCLayer:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// CCLayerControlServer.h</span><br />
<span style="color: #11740a; font-style: italic;">// KingdomUndead</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// Created by Andrea Magini on 04/04/12.</span><br />
<span style="color: #11740a; font-style: italic;">// Copyright (c) 2012 metalide. All rights reserved.</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<br />
<span style="color: #6e371a;">#import</span><br />
<span style="color: #6e371a;">#import &quot;cocos2d.h&quot;</span><br />
<span style="color: #6e371a;">#import &quot;KeyboardControlHandler.h&quot;</span><br />
<span style="color: #6e371a;">#import &quot;MouseControlHandler.h&quot;</span><br />
<br />
<span style="color: #a61390;">@interface</span> CCLayerControlServer <span style="color: #002200;">:</span> CCLayer<span style="color: #002200;">&#123;</span><br />
<span style="color: #a61390;">@private</span><br />
<br />
idkeyboardDelegate;<br />
<span style="color: #a61390;">id</span> mouseDelegate;<br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic,retain<span style="color: #002200;">&#41;</span><span style="color: #a61390;">id</span> keyboardDelegate;<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic,retain<span style="color: #002200;">&#41;</span><span style="color: #a61390;">id</span> mouseDelegate;<br />
<br />
<span style="color: #a61390;">@end</span></div></div>
<p>E questa la sua implementazione:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// CCLayerControlServer.m</span><br />
<span style="color: #11740a; font-style: italic;">// KingdomUndead</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// Created by Andrea Magini on 04/04/12.</span><br />
<span style="color: #11740a; font-style: italic;">// Copyright (c) 2012 metalide. All rights reserved.</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<br />
<span style="color: #6e371a;">#import &quot;CCLayerControlServer.h&quot;</span><br />
<br />
<span style="color: #a61390;">@implementation</span> CCLayerControlServer<br />
<span style="color: #a61390;">@synthesize</span> keyboardDelegate;<br />
<span style="color: #a61390;">@synthesize</span> mouseDelegate;<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> init<br />
<span style="color: #002200;">&#123;</span><br />
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span>self<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
self.isMouseEnabled <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
self.isKeyboardEnabled <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> ccKeyUp<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSEvent</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<br />
<span style="color: #002200;">&#123;</span><br />
<br />
<span style="color: #002200;">&#91;</span>keyboardDelegate handleKeyUp<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> ccMouseUp<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSEvent</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<span style="color: #002200;">&#123;</span><br />
<span style="color: #002200;">&#91;</span>mouseDelegate handleMouseUp<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> ccMouseDragged<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSEvent</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<span style="color: #002200;">&#123;</span><br />
<span style="color: #002200;">&#91;</span>mouseDelegate handleMouseDragged<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>dealloc<span style="color: #002200;">&#123;</span><br />
<span style="color: #002200;">&#91;</span>keyboardDelegate release<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>mouseDelegate release<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #a61390;">@end</span></div></div>
<p>In questo modo tutti gli eventi intercettati dal layer vengono passati di volta in volta ai delegati registrati.<br />
In ogni momento posso ad esempio deregistrare il layer come delegato per gli eventi e registrare un particolare CCNODE che gestisce una popup che si e&#8217; appena mostrata a video.</p>
<p>I delegati devono avere un particolare Protocol per rispondere agli eventi mouse, o tastiera (o touch su iOS)</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;KeyboardControlHandler.h</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;KingdomUndead</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;Created by Andrea Magini on 04/04/12.</span><br />
<span style="color: #11740a; font-style: italic;">// &nbsp;Copyright (c) 2012 metalide. All rights reserved.</span><br />
<span style="color: #11740a; font-style: italic;">//</span><br />
<br />
<span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span><br />
<span style="color: #6e371a;">#import &lt;Carbon/Carbon.h&gt;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">//per gestire il controllo sui vari ccnode e layers in modo da abilitare e disabilitare il controller</span><br />
<br />
<span style="color: #a61390;">@protocol</span> KeyboardControlHandler &lt;NSObject&gt;<br />
@required<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> handleKeyUp<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSEvent</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event;<br />
<span style="color: #a61390;">@end</span></div></div>
<p>Questo permette di snellire il codice del CCLayer evitando di mettere tonnellate di if nei vari mousebuttonup, down, keyup etc e andando invece a gestire gli eventi<br />
in maniera opportuna nei vari ccnode contenuti nella scena principale. Un esempio pratico è quello per la gestione degli eventi sull&#8217;HUD , lasciandoli gestire direttamente al CCNODE in questione, separandolo dagli eventi di gioco. </p>
<p>Come registrare un delegato:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">@interface</span> HudNode <span style="color: #002200;">:</span> CCNode&lt;KeyboardControlHandler&gt;<span style="color: #002200;">&#123;</span><br />
<br />
<span style="color: #002200;">&#125;</span></div></div>
<p>Nel codice del CCLayer principale, durante l&#8217;init registro il CCNode dell&#8217;hud, e poi lo imposto come delegato per la gestione degli eventi tastiera</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self addChild<span style="color: #002200;">:</span>hudNode<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp;<span style="color: #002200;">&#91;</span>self setKeyboardDelegate<span style="color: #002200;">:</span>hudNode<span style="color: #002200;">&#93;</span>;</div></div>
<p>e poi nel CCNode che implementa l&#8217;hud, implemento il metodo del Protocol KeyboardControlHandler</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> handleKeyUp<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSEvent</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; CCLOG<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;key up: %@&quot;</span>, <span style="color: #002200;">&#91;</span>event characters<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; UInt16 keyCode <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>event keyCode<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>keyCode <span style="color: #002200;">==</span> kVK_Space<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #11740a; font-style: italic;">//fai qualcosa :)</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span></div></div>
<p>Spero sia chiaro <img src='http://www.metalide.com/kiraya/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=1018</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kingdom:Undead sketch e idee</title>
		<link>http://www.metalide.com/kiraya/?p=985</link>
		<comments>http://www.metalide.com/kiraya/?p=985#comments</comments>
		<pubDate>Fri, 06 Apr 2012 18:31:44 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Kingdom:Undead Prototype]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Cocos2d]]></category>
		<category><![CDATA[CoreData]]></category>
		<category><![CDATA[IPad]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Kingdom:Undead]]></category>
		<category><![CDATA[Kiraya]]></category>
		<category><![CDATA[Notification Center]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Osx]]></category>
		<category><![CDATA[Protocol]]></category>
		<category><![CDATA[Rosae Crucis]]></category>
		<category><![CDATA[Undead]]></category>
		<category><![CDATA[Zombi]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=985</guid>
		<description><![CDATA[Iniziamo oggi una serie di articoli/appunti/idee sullo sviluppo di un prototipo di gioco per mac osx, iphone e ipad. Il gioco è un incrocio tra un tower defence e un rpg, in cui si deve gestire il Kingdom, il &#8220;regno&#8221; &#8230; <a href="http://www.metalide.com/kiraya/?p=985">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Iniziamo oggi una serie di articoli/appunti/idee sullo sviluppo di un prototipo di gioco per mac osx, iphone e ipad.</p>
<p>Il gioco è un incrocio tra un tower defence e un rpg, in cui si deve gestire il Kingdom, il &#8220;regno&#8221; di un manipolo di sopravvissuti all&#8217;infezione zombie.</p>
<p>Il tutto sarà incentrato nella gestione e nella crescita di questo Kingdom, un insieme di bunker e container che vengono assemblati man mano che si acquisiscono le materie prime.</p>
<p>Lo sviluppo per ora è su XCode 4.2 utilizzando obiective-c e la libreria Cocos2d .</p>
<p>Per semplificare il disegno, sto iniziando a definire tutti i modelli grafici abbozzandoli a matita, e poi scannerizzandoli e scontornandoli a mano.<br />
Consiglio l&#8217;uso di <a title="PixelMator" href="http://www.pixelmator.com/" target="_blank">PixelMator</a> per questo tipo di attività. E&#8217; un software dal costo moderato e dalle grandi potenzialità. Quando il gioco si troverà ad uno stadio abbastanza maturo, e avrò finito di definire con esattezza la dimensione di ogni singolo asset di gioco, allora passerò il lavoro a uno o più grafici 2d per ridisegnare il tutto.</p>
<p>Non conoscendo bene objective-c e <a title="Cocos2d" href="http://www.cocos2d-iphone.org/" target="_blank">cocos2d</a>, inizio per gradi facendo direttamente training on the job, molte cose quindi magari ovvie a chi conosce meglio questo linguaggio, a primo acchitto potrebbero sfuggirmi. Già nella situazione attuale, iniziata oramai da 2 settimane, mi sono accorto di carenze nel disegno delle classi e ho iniziato a utilizzare funzionalità non previste inizialmente, come CoreData, il NotificationCenter , i Protocolli, e tante altre cose.</p>
<p>Alcuni ignobili schizzi da me eseguiti:</p>

<a href='http://www.metalide.com/kiraya/?attachment_id=992' title='kuScan1'><img width="150" height="150" src="http://www.metalide.com/kiraya/wp-content/uploads/2012/04/kuScan1-150x150.jpg" class="attachment-thumbnail" alt="kuScan1" title="kuScan1" /></a>
<a href='http://www.metalide.com/kiraya/?attachment_id=993' title='kuScan2'><img width="150" height="150" src="http://www.metalide.com/kiraya/wp-content/uploads/2012/04/kuScan2-150x150.jpg" class="attachment-thumbnail" alt="kuScan2" title="kuScan2" /></a>
<a href='http://www.metalide.com/kiraya/?attachment_id=995' title='actor1'><img width="150" height="150" src="http://www.metalide.com/kiraya/wp-content/uploads/2012/04/actor1-150x150.png" class="attachment-thumbnail" alt="actor1" title="actor1" /></a>
<a href='http://www.metalide.com/kiraya/?attachment_id=996' title='zombi1'><img width="150" height="150" src="http://www.metalide.com/kiraya/wp-content/uploads/2012/04/zombi1-150x150.png" class="attachment-thumbnail" alt="zombi1" title="zombi1" /></a>
<a href='http://www.metalide.com/kiraya/?attachment_id=998' title='kuScan3'><img width="150" height="150" src="http://www.metalide.com/kiraya/wp-content/uploads/2012/04/kuScan3-150x150.jpg" class="attachment-thumbnail" alt="kuScan3" title="kuScan3" /></a>
<a href='http://www.metalide.com/kiraya/?attachment_id=999' title='newScan4'><img width="150" height="150" src="http://www.metalide.com/kiraya/wp-content/uploads/2012/04/newScan4-150x150.jpg" class="attachment-thumbnail" alt="newScan4" title="newScan4" /></a>

<p>&nbsp;</p>
<p>Che trasformati, diventeranno la base dei nostri spritesheet dove mettere tutte le animazioni per i sopravvissuti e per gli zombie, e i tileset per la nostra mappa.</p>
<p>Per la creazione del Kingdom invece sto utilizzando una CCTMXTiledMap composta da due righe, una per il piano base e una per il piano superiore, composta da 3 strati di layer, il primo che contiene lo sfondo di ogni cella, il secondo che contiene il centro della cella, con i mobili e soprammobili, il terzo strato che contiene le immagini frontali, le cornici dei bunker. i personaggi si troveranno tra lo sfondo e il layer centrale. Questo permetterà di avere una mappa modulare in cui andare a mischiare diversi background, foreground e middle per ottenere un numero maggiore di personalizzazioni della mappa.</p>
<p>Una prima bozza dopo una settimana di lavoro inizia a prendere forma:</p>
<p><iframe width="584" height="329" src="http://www.youtube.com/embed/2TdYyzgHNQ8?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>Ci sono già diverse scene per l&#8217;implementazione dei credits iniziali, del menu di gioco e della schermata principale, basata su uno sfondo con scrolling in parallasse e la nostra mappa di bunker al centro.</p>
<p>Per poter lavorare al meglio, ho esteso la CCTXMTiledMap, per aggiungere tutte quelle proprietà e metodi che dovranno snellire e semplificare lo sviluppo e la gestione della mappa.</p>
<p>ecco un esempio della sua interfaccia:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6e371a;">#import &quot;cocos2d.h&quot;</span><br />
<span style="color: #6e371a;">#import &quot;CCTMXTiledMap.h&quot;</span><br />
<br />
<span style="color: #a61390;">@interface</span> BunkerMap <span style="color: #002200;">:</span> CCTMXTiledMap<br />
<span style="color: #002200;">&#123;</span><br />
CCTMXLayer <span style="color: #002200;">*</span>_baseLayer;<br />
<span style="color: #a61390;">int</span> _homeBunkerPosition;<br />
<span style="color: #a61390;">int</span> _lastSelectedBunkerId;<br />
CCSprite<span style="color: #002200;">*</span> _lastSelectedBunker;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>nonatomic,retain<span style="color: #002200;">&#41;</span>CCTMXLayer <span style="color: #002200;">*</span>baseLayer;<br />
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>nonatomic,readwrite<span style="color: #002200;">&#41;</span><span style="color: #a61390;">int</span> homeBunkerPosition;<br />
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>nonatomic,readonly<span style="color: #002200;">&#41;</span><span style="color: #a61390;">int</span> lastSelectedBunkerId;<br />
<span style="color: #11740a; font-style: italic;">//TODO: convertire il lastSelectedBunker da sprite a oggetto Bunker</span><br />
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>nonatomic,readonly<span style="color: #002200;">&#41;</span>CCSprite <span style="color: #002200;">*</span>lastSelectedBunker;<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>selectBunker<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>bunkerNumber;<br />
<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>centerToBunkerNumber<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>bunkerNumber select<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>flag;<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>centerToBunkerPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>location select<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>flag;<br />
<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span> findBunkerByPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>location;<br />
<span style="color: #a61390;">@end</span></div></div>
<p>ed un esempio di implementazione della funzione per capire su che bunker ho selezionato (per poterlo centrare ad esempio o visualizzarne la sua scheda):</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span> findBunkerByPosition<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CGPoint<span style="color: #002200;">&#41;</span>location<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; CGSize s <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self.baseLayer layerSize<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> x<span style="color: #002200;">=</span><span style="color: #2400d9;">0</span>; x&lt;s.width;x<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> y<span style="color: #002200;">=</span><span style="color: #2400d9;">0</span>; y&lt; s.height; y<span style="color: #002200;">++</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CCTMXLayer <span style="color: #002200;">*</span>l;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CCARRAY_FOREACH<span style="color: #002200;">&#40;</span>self.children, l<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>l isKindOfClass<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>CCTMXLayer class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CCSprite <span style="color: #002200;">*</span>tile <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>l tileAt<span style="color: #002200;">:</span>ccp<span style="color: #002200;">&#40;</span>x,y<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>CGRectContainsPoint<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>tile boundingBox<span style="color: #002200;">&#93;</span>,<span style="color: #002200;">&#91;</span>self convertToNodeSpace<span style="color: #002200;">:</span>location<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// NSLog(@&quot;TILE:%@&quot;,[tile position]);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// &nbsp;unsigned int tmpgid =[layer tileGIDAt:ccp(x,y)];</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>;<br />
<span style="color: #002200;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=985</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Osx Lion e la cartella Library nel Finder</title>
		<link>http://www.metalide.com/kiraya/?p=978</link>
		<comments>http://www.metalide.com/kiraya/?p=978#comments</comments>
		<pubDate>Fri, 02 Mar 2012 10:32:54 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Appunti di programmazione]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Appunti]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Guida]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Library]]></category>
		<category><![CDATA[Libreria]]></category>
		<category><![CDATA[Lion]]></category>
		<category><![CDATA[Osx]]></category>
		<category><![CDATA[User]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=978</guid>
		<description><![CDATA[Installato Lion sul mio mac mi sono reso conto che la cartella Library dell&#8217;utente loggato non è più visibile all&#8217;interno del Finder.. Grave mancanza soprattutto per chi sviluppa e deve testare continuamente i files generati dalle apps. Fortunatamente la soluzione &#8230; <a href="http://www.metalide.com/kiraya/?p=978">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Installato Lion sul mio mac mi sono reso conto che la cartella Library dell&#8217;utente loggato non è più visibile all&#8217;interno del Finder..<br />
Grave mancanza soprattutto per chi sviluppa e deve testare continuamente i files generati dalle apps.</p>
<p>Fortunatamente la soluzione è molto semplice, basta renderla nuovamente visibile con questo comando da terminale:</p>
<div class="codecolorer-container bash railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">chflags nohidden <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>ILVOSTRONOMEUTENTE<span style="color: #000000; font-weight: bold;">/</span>Library</div></div>
<p>ovviamente al posto di ILVOSTRONOMEUTENTE mettete il nome dell&#8217;utente con cui loggate. Non il nome esteso.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=978</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leggere configurazione plist di default</title>
		<link>http://www.metalide.com/kiraya/?p=961</link>
		<comments>http://www.metalide.com/kiraya/?p=961#comments</comments>
		<pubDate>Wed, 29 Feb 2012 17:05:24 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Appunti di programmazione]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Appunti]]></category>
		<category><![CDATA[Bundle]]></category>
		<category><![CDATA[Dictionary]]></category>
		<category><![CDATA[Guida]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Osx]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=961</guid>
		<description><![CDATA[Su mac è possibile leggere il file di default contenente la configurazione dell&#8217;applicativo in maniera molto semplice. basta usare gli NSBundle per poter accedere al bundle di default, il file info.plist generalmente contenuto delle Resources dell&#8217;applicativo: NSBundle* mainBundle = &#91;NSBundle &#8230; <a href="http://www.metalide.com/kiraya/?p=961">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Su mac è possibile leggere il file di default contenente la configurazione dell&#8217;applicativo in maniera molto semplice.<br />
basta usare gli NSBundle</p>
<p>per poter accedere al bundle di default, il file info.plist generalmente contenuto delle Resources dell&#8217;applicativo:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #400080;">NSBundle</span><span style="color: #002200;">*</span> mainBundle <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span>;</div></div>
<p>per poter accedere alle info contenute, basta usare il dictionary.</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">BOOL</span> stats<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>mainBundle infoDictionary<span style="color: #002200;">&#93;</span> valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;ShowStats&quot;</span><span style="color: #002200;">&#93;</span>boolValue<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> version<span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>mainBundle infoDictionary<span style="color: #002200;">&#93;</span> valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Version&quot;</span><span style="color: #002200;">&#93;</span>;</div></div>
<p>e&#8217; possibile mettere nel bundle anche dictionary :</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #400080;">NSDictionary</span><span style="color: #002200;">*</span> list <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>mainBundle infoDictionary <span style="color: #002200;">&#93;</span>valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Resolution&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>list<span style="color: #002200;">!=</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #400080;">NSNumber</span><span style="color: #002200;">*</span> width <span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span>list valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Width&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #400080;">NSNumber</span><span style="color: #002200;">*</span> height <span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span>list valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Height&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> CGSizeMake<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>width doubleValue<span style="color: #002200;">&#93;</span>,<span style="color: #002200;">&#91;</span>height doubleValue<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=961</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creare Classi Statiche e Singleton in Objective C</title>
		<link>http://www.metalide.com/kiraya/?p=950</link>
		<comments>http://www.metalide.com/kiraya/?p=950#comments</comments>
		<pubDate>Tue, 28 Feb 2012 12:21:27 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Guida]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Osx]]></category>
		<category><![CDATA[Singleton]]></category>
		<category><![CDATA[Static]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=950</guid>
		<description><![CDATA[Per creare una classe che sia raggiungibile da ogni parte del nostro codice, abbiamo due alternative: realizzare una classe statica con metodi e attributi statici, oppure implementare il pattern del Singleton. Preferisco generalmente la seconda scelta più orientata ad un &#8230; <a href="http://www.metalide.com/kiraya/?p=950">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Per creare una classe che sia raggiungibile da ogni parte del nostro codice, abbiamo due alternative: realizzare una classe statica con metodi e attributi statici, oppure implementare il pattern del Singleton.<br />
Preferisco generalmente la seconda scelta più orientata ad un design pulito del nostro codice e rimanendo legato alla programmazione ad oggetti. </p>
<p>Per creare una classe statica, con attributi e metodi statici definiamo l&#8217;interfaccia:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">@interface</span> MyStaticClass <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span><br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>getIntMethod;<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setIntMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>value;<br />
<span style="color: #a61390;">@end</span></div></div>
<p>e poi implementiamola:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6e371a;">#import &quot;MyStaticClass.h&quot;</span><br />
<br />
<span style="color: #a61390;">@implementation</span> MyStaticClass<br />
<br />
<span style="color: #a61390;">static</span> <span style="color: #a61390;">int</span> staticValue <span style="color: #002200;">=</span> <span style="color: #2400d9;">1</span>;<br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>getIntMethod <span style="color: #002200;">&#123;</span><br />
&nbsp; <span style="color: #a61390;">return</span> staticValue;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setIntMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>value <span style="color: #002200;">&#123;</span><br />
&nbsp; staticValue <span style="color: #002200;">=</span> value;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>alloc <span style="color: #002200;">&#123;</span><br />
&nbsp; <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSException</span> <span style="color: #a61390;">raise</span><span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Non può essere istanziata format:@&quot;</span>Static class <span style="color: #bf1d1a;">'ClassName'</span> non può essere instanziato<span style="color: #bf1d1a;">&quot;];<br />
&nbsp; return nil;<br />
}<br />
<br />
@end</span></div></div>
<p>importante l&#8217;override dell&#8217;alloc per non permettere alla classe di essere istanziata.</p>
<p>Per un approccio più elegante e sicuramente più riusabile, implementiamo invece il Design Pattern del Singleton:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">@interface</span> MySingleton <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span><br />
<span style="color: #002200;">&#123;</span><br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>getIntMethod;<br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setIntMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>value; <br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>MySingleton <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> m_MySingleton;<br />
&nbsp;<br />
<span style="color: #a61390;">@end</span></div></div>
<p>Implementiamo la nostra interfaccia:</p>
<div class="codecolorer-container objc railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6e371a;">#import &quot;MySingleton.h&quot;</span><br />
&nbsp;<br />
<span style="color: #a61390;">@implementation</span> MySingleton<br />
&nbsp;<br />
<span style="color: #a61390;">static</span> MySingleton <span style="color: #002200;">*</span>m_MySingleton <span style="color: #002200;">=</span><span style="color: #a61390;">nil</span>;<br />
<span style="color: #a61390;">static</span> <span style="color: #a61390;">int</span> staticValue <span style="color: #002200;">=</span> <span style="color: #2400d9;">1</span>;<br />
<br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>MySingleton <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> m_MySingleton<br />
<span style="color: #002200;">&#123;</span> <br />
&nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>m_MySingleton <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span><br />
&nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">//creo l'istanza</span><br />
&nbsp; &nbsp; m_MySingleton <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>super allocWithZone<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;<br />
&nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; <span style="color: #a61390;">return</span> m_MySingleton;<br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>getIntMethod <span style="color: #002200;">&#123;</span><br />
&nbsp; <span style="color: #a61390;">return</span> staticValue;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setIntMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>value <span style="color: #002200;">&#123;</span><br />
&nbsp; staticValue <span style="color: #002200;">=</span> value;<br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>allocWithZone<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSZone</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>zone<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp;<span style="color: #11740a; font-style: italic;">//sincronizzo in modo da rendere la fase di allocazione ThreadSafe </span><br />
&nbsp;<span style="color: #11740a; font-style: italic;">//in modo da gestire più thread che richiedono contemporaneamente il Singleton</span><br />
&nbsp;<span style="color: #a61390;">@synchronized</span><span style="color: #002200;">&#40;</span>self<span style="color: #002200;">&#41;</span><br />
&nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>m_MySingleton <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;m_MySingleton <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super allocWithZone<span style="color: #002200;">:</span>zone<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #a61390;">return</span> m_MySingleton;<br />
&nbsp; &nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp;<span style="color: #002200;">&#125;</span><br />
&nbsp;<span style="color: #a61390;">return</span> <span style="color: #a61390;">nil</span>;<br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>copyWithZone<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">NSZone</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>zone<br />
<span style="color: #002200;">&#123;</span> <br />
&nbsp;<span style="color: #11740a; font-style: italic;">//non e' possibile clonarlo e quindi ritorna sempre la stessa istanza.</span><br />
&nbsp;<span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>retain<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp;<span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>NSUInteger<span style="color: #002200;">&#41;</span>retainCount <br />
<span style="color: #002200;">&#123;</span><br />
&nbsp;<span style="color: #11740a; font-style: italic;">//in questo modo il suo refCount non scenderà mai a zero.</span><br />
&nbsp;<span style="color: #a61390;">return</span> NSUIntegerMax;<br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> release<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; <span style="color: #11740a; font-style: italic;">//non fa nulla.</span><br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>autorelease<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp;<span style="color: #a61390;">return</span> self;<br />
<span style="color: #002200;">&#125;</span><br />
&nbsp;<br />
<span style="color: #a61390;">@end</span></div></div>
<p>Piccola correzione. I metodi nel singleton ovviamente non devono essere statici (tranne il metodo che permette l&#8217;accesso all&#8217;istanza).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=950</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G.r.a. Capitolo 6: Il miglio verde</title>
		<link>http://www.metalide.com/kiraya/?p=897</link>
		<comments>http://www.metalide.com/kiraya/?p=897#comments</comments>
		<pubDate>Sun, 26 Feb 2012 08:00:02 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[I Diari della Motocicletta e altri mezzi immobili]]></category>
		<category><![CDATA[A24]]></category>
		<category><![CDATA[Alpha]]></category>
		<category><![CDATA[blindato]]></category>
		<category><![CDATA[Bravo]]></category>
		<category><![CDATA[Charlie]]></category>
		<category><![CDATA[G.R.A.]]></category>
		<category><![CDATA[Laurentina]]></category>
		<category><![CDATA[Nato]]></category>
		<category><![CDATA[Raccordo]]></category>
		<category><![CDATA[Renault]]></category>
		<category><![CDATA[Roma]]></category>
		<category><![CDATA[Tango]]></category>
		<category><![CDATA[Traffico]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=897</guid>
		<description><![CDATA[E&#8217; quello che ti frega. Quello che ti illude. Quell&#8217;ultima fottuta chilometrata e mezza o giu di li.. un solo miglio.. il miglio verde..l&#8217;ultimo tratto di strada, due fottuti chilometri scarsi, che ti separano dal punto di contatto Tango, il &#8230; <a href="http://www.metalide.com/kiraya/?p=897">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>E&#8217; quello che ti frega.<br />
Quello che ti illude.<br />
Quell&#8217;ultima fottuta chilometrata e mezza o giu di li..<br />
un solo miglio..<br />
il miglio verde..l&#8217;ultimo tratto di strada, due fottuti chilometri scarsi, che ti separano dal punto di contatto Tango, il Target.. il bersaglio, la destinazione finale.. generalmente coincidente con un pallosissimo ma retribuito posto di lavoro in cui non riesci a dare il meglio di te stesso, se non in bagno.</p>
<p>Dopo essere partiti da casa base, e aver transitato per Alpha 24 (la spettacolare opera antagonista della viabilità chiamata a24), Charlie 1.80 (il casello e il suo fottuto costo), e aver costeggiato tutta la Echo 80 (il raccordo), fino all&#8217;uscita Lima 25 (la cazzosissima uscita Laurentina), ti trovi dinanzi al muro della morte. Se fossi in un blindato ONU alla ricerca di superstiti senzienti in questo mondo di zombie da traffico, adesso mi attaccherei alla radio gridando &#8220;Fuori Fuori Fuori.. Contatto Sierra Rosso Fuori a destra&#8221;.. Cercando di evitare quel cazzo di semaforo perennemente rosso all&#8217;inizio di Via Laurentina appena usciti dal raccordo..<br />
Ma dalla base mi risponderebbe quell&#8217;occhialuto del cazzo che risponde al nome di Jolly Bravo Hotel che con voce alla Ralph di Happy Days mi intimerebbe di andare avanti verso Tango ,che sta per scadere il tempo di contatto a disposizione, prima che passino le 6.45 Zulu (le 7.45 italiane).<br />
E cosi armato di pazienza, metto in coda il blindato, armando gli spara imprecazioni di costruzione bulgara, e gli scudi antiscommessa con tecnologia israeliana. Questi ultimi sono un meccanismo unico nel suo genere, in grado di evitare di fare pronostici sull&#8217;orario di arrivo, puntualmente sovvertito dalla polarità avversa della sfiga.</p>
<p>Evito un Sierra November Charlie , una svolta non conforme, e tra un Papa in idle (un pedone frastornato in mezzo alla strada), e un Mike 150 (uno scooter con motorizzazione indecisa) , arrivo finalmente a Tango, in perfetto orario. Non sono un papero e non salverò il mondo, ma anche oggi il mio blindato Renault 1200 del 98 mi ha portato sano e salvo a destinazione.. Partono le note dell&#8217;HomeRun, da casa base arrivano i complimenti, e un  &#8220;ci sentiamo tra 9 ore ,Kilo (pare fatto apposta che pure il mio soprannome in alfabeto nato sia in sovrappeso), passo e chiudo&#8221;..<br />
Tiro su la felpa con il camo da ufficio, cerco un posto dove nascondere il blindato, lo mimetizzo (mettendo vecchie multe sul parabrezza), lo sporco un po per nasconderlo agli indigeni del luogo, e mi incammino, a testa bassa, per difendere ancora una volta, con dignità, la mia postazione..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=897</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Estendere il WebClient per gestire un CookieStore</title>
		<link>http://www.metalide.com/kiraya/?p=928</link>
		<comments>http://www.metalide.com/kiraya/?p=928#comments</comments>
		<pubDate>Thu, 23 Feb 2012 08:36:09 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Microsoft .Net]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Asp.Net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Cookie]]></category>
		<category><![CDATA[Csharp]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[System.Net]]></category>
		<category><![CDATA[System.Web]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WebClient]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=928</guid>
		<description><![CDATA[In C# , le system.net mettono a disposizione un oggetto chiamato WebClient per fare delle chiamate http in post a risorse identificate da un URI. Nel mio caso l&#8217;ho utilizzato per fare delle chiamate dal CodeBehind di un applicazione web, &#8230; <a href="http://www.metalide.com/kiraya/?p=928">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In C# , le system.net mettono a disposizione un oggetto chiamato WebClient per fare delle chiamate http in post a risorse identificate da un URI.</p>
<p>Nel mio caso l&#8217;ho utilizzato per fare delle chiamate dal CodeBehind di un applicazione web, per interrogare dei servizi web esposti in maniera restfull che accettavano dati in POST.</p>
<p>Dovendo gestire la sessione con questi servizi di backend e a volte avendo la necessità di dovergli pasare dei Cookie di autenticazione o altri cookie , mi sono trovato a doverlo estendere (per non lavorare direttamente con il WebRequest, oggetto su cui poggia il WebClient).</p>
<p>Il webclient offre pochissime funzionalità, ma estenderlo è molto facile.</p>
<p>In questo esempio aggiungiamo la possibilità di creare un proprio CookieStore, prima di una chiamata, in modo da potergli passare tutti i cookie (presi ad esempio dalla Request arrivata alla nostra pagina aspx) necessari al servizio che risponde all&#8217;URI interrogata.</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Net</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ExtendedWebClient <span style="color: #008000;">:</span> WebClient<br />
<br />
<span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> CookieContainer m_container <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> CookieContainer<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> WebRequest GetWebRequest<span style="color: #008000;">&#40;</span>Uri address<span style="color: #008000;">&#41;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; WebRequest request <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetWebRequest</span><span style="color: #008000;">&#40;</span>address<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpWebRequest webRequest <span style="color: #008000;">=</span> request <span style="color: #0600FF; font-weight: bold;">as</span> HttpWebRequest<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>webRequest<span style="color: #008000;">!=</span><span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; webRequest<span style="color: #008000;">.</span><span style="color: #0000FF;">CookieContainer</span> <span style="color: #008000;">=</span> m_container<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> request<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetCookies<span style="color: #008000;">&#40;</span>HttpCookieCollection collection,<span style="color: #6666cc; font-weight: bold;">string</span> domain<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; m_container <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> CookieStore<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> j<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>j<span style="color: #008000;">&lt;</span>collection<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span>j<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpCookie httpCookie <span style="color: #008000;">=</span> collection<span style="color: #008000;">.</span><span style="color: #0000FF;">Get</span><span style="color: #008000;">&#40;</span>j<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cookie cookie <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Cookie<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Domain</span> <span style="color: #008000;">=</span> domain<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Expires</span> <span style="color: #008000;">=</span> httpCookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Expires</span><span style="color: #008000;">;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> httpCookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span> <span style="color: #008000;">=</span> httpCookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Path</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Secure</span> <span style="color: #008000;">=</span> httpCookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Secure</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> httpCookie<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_container<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>cookie<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Oltre a gestire il cookieStore, dobbiamo preoccuparci della conversione dei cookies da HttpCookie (arrivati dalla Request) a quelli più dettagliati della System.Net.</p>
<p>Per utilizzare il nostro nuovo webclient e passargli i cookie possiamo fare in questo modo:</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; ExtendendWebClient client <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ExtendedWebClient<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; client<span style="color: #008000;">.</span><span style="color: #0000FF;">SetCookies</span><span style="color: #008000;">&#40;</span>request<span style="color: #008000;">.</span><span style="color: #0000FF;">Cookies</span>,request<span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Host</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> data <span style="color: #008000;">=</span> client<span style="color: #008000;">.</span><span style="color: #0000FF;">DownloadData</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://www.google.it&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Encoding</span> enc <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Encoding</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UTF8</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> output <span style="color: #008000;">=</span> enc<span style="color: #008000;">.</span><span style="color: #0000FF;">GetString</span><span style="color: #008000;">&#40;</span>data<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>In questo modo tutti i cookie vengono impostati nel webclient prima di eseguire la webRequest.</p>
<p>Giocando con il parametro Domain, possiamo andare a filtrare i cookie che ci interessano per la chiamata in questione.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=928</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G.r.a. Capitolo 5: I Gemelli Derrick-Bartolini</title>
		<link>http://www.metalide.com/kiraya/?p=772</link>
		<comments>http://www.metalide.com/kiraya/?p=772#comments</comments>
		<pubDate>Thu, 16 Feb 2012 07:45:42 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[I Diari della Motocicletta e altri mezzi immobili]]></category>
		<category><![CDATA[Calcio]]></category>
		<category><![CDATA[Diario]]></category>
		<category><![CDATA[G.R.A.]]></category>
		<category><![CDATA[Gemelli Derrick]]></category>
		<category><![CDATA[Holly e Benji]]></category>
		<category><![CDATA[Renault Clio]]></category>
		<category><![CDATA[Roma]]></category>
		<category><![CDATA[Traffico]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=772</guid>
		<description><![CDATA[Oggi voglio descrivervi due personaggi che mi hanno folgorato qualche giorno fa.. Ve li ricordate i gemelli Derrick,James e Jason? quelli di Holly e Benji? quelli che quando dovevano tirare in porta, eseguivano la catapulta infernale, arrivando a sfidare e &#8230; <a href="http://www.metalide.com/kiraya/?p=772">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Oggi voglio descrivervi due personaggi che mi hanno folgorato qualche giorno fa..</p>
<p>Ve li ricordate i gemelli Derrick,James e Jason? quelli di Holly e Benji? quelli che quando dovevano tirare in porta, eseguivano la catapulta infernale, arrivando a sfidare e superare ogni legge della fisica? Quelli che Don Chuck castoro in confronto era senza denti.. Quelli che ad ogni puntata gli crescevano misteriosamente gli incisivi ?</p>
<p>Questi due personaggi esistono e giorni fa, nel gelo artico che avvolgeva il Grande Parcheggio Anulare, li ho visti mimetizzati da trasportatori in un furgone rosso di Bartolini (il corriere espresso)..</p>
<p>Me ne stavo li al freddo e al gelo nella mia Clio Second Hand del 1999 modello Noluxe Spagnolo, quindi senza ausilio di spiegazioni in italiano, sprovvista di aria condizionata funzionante, e con 2 alzacristalli elettrici di cui uno diselettrizzato causa fuga criceto nel motorino, con aria calda fuori uso su cauzione,e accessoriata di grande crepa sul cristallo anteriore, quando li vedo vicino a me..</p>
<p>Dallo stereo senza frontalino (causa furto fuori casa) le note del dolce rumore del Motore Renault 1200, mi facevano da sottofondo melodico e armonioso, una dolce Sonata in 4 quarti, uno per ogni tempo del motore..</p>
<p>Loro erano li, Giacomo e Giasone Derrick-Bartolini, due amici divenuti gemelli per osmosi..</p>
<p>Entrambi ricci e mori, fisico atletico,trasudavano partita di calcetto del giovedi pomeriggio da ogni poro.. La loro giornata lavorativa serve ad occupare il tempo che li separa da una partita a calcetto e la successiva..</p>
<p>Io sono li atterrito dalla visione surreale, immaginandoli mentre pianificano accuratamente la catapulta infernale di stasera ai danni della squadra avversaria, la temuta TNTSWAPTEAM, la squadra di calcetto più temuta della zona, formata solo da veterani del trasporto su ruote, esperti dello stoccaggio in furgone e del &#8220;lascio il biglietto tanto sicuramente non c&#8217;e&#8217; nessuno in casa&#8221;..</p>
<p>Giacomo, quello con i capelli piu corti, era alla guida del mezzo espresso, mentre l&#8217;altro mangiava allegramente un metro quadro di pizza raccontando con fare concitato la partita di CEMPIONS LIG del mercoledi.. Le grida di Giasone arrivavano fino alla mia macchina quanto era fitto il suo lancio di sproloqui verso ogni forma di squadra straniera dal nome inpronunciabile.. Tipo il PARIS SANGIERMENNE, IL BORUSSIA DORTMUNDE, IL MANCESTERE IUNITE, LA CHITTESSENKAPPAA MOSCA,LA PATATINAIKOS,LA MECCAFI HAIBOS (sembra un antivirus), LA STRUNZ GRAZ, la squadra poi del giornalista di rai tre, la BORAC BANJANBAUNA, o la sempre verde STENDAR LIEGI BASTON LIEGI..</p>
<p>Tra i fumi dei gas di scarico e complice l&#8217;amniotico traffico costante, questi due personaggi, in partenza due individui separati, si sono incontrati e  divenuti amici tramite un processo di meiosi inversa.. Un rapporto osmotico che li rende praticamente cloni.</p>
<p>Che l&#8217;artefice di questa fusione sia forse l&#8217;effetto Calcio? Che sia modificato geneticamente e la sua assunzione quotidiana può arrivare a creare questa mutazione genetica che ti trasforma in un incrocio tra Pruzzo e Bergomi?</p>
<p>Con questi dubbi amletici, e le grida fatidiche di Giacomo con il sempre verde &#8220;machecazzostaiadechelosietepagato20milionideurostocazzodegiocatorechenunsegna&#8221;, il traffico si sblocca, qualcosa si muove, lascio la frizione e riparto, versi nuovi mondi.. dove nessuna clio è mai stata prima di oggi..ad un metro davanti a me..</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=772</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problemi di deserializzazione array in c#</title>
		<link>http://www.metalide.com/kiraya/?p=908</link>
		<comments>http://www.metalide.com/kiraya/?p=908#comments</comments>
		<pubDate>Mon, 13 Feb 2012 09:52:40 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[Microsoft .Net]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Asp.Net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[Csharp]]></category>
		<category><![CDATA[Deserialize]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Serializable]]></category>
		<category><![CDATA[Xml]]></category>
		<category><![CDATA[XmlRoot]]></category>
		<category><![CDATA[XmlSerializer]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=908</guid>
		<description><![CDATA[Un caso semplicissimo,può diventare un incubo per diverse ore&#8230; Un xml di questo tipo: &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;Applicazioni&#62; &#60;Applicazione&#62; &#60;NomeApplicazione&#62;XXX1&#60;/NomeApplicazione&#62; &#60;Stato&#62;Attiva&#60;/Stato&#62; &#60;/Applicazione&#62; &#60;Applicazione&#62; &#60;NomeApplicazione&#62;XXX2&#60;/NomeApplicazione&#62; &#60;Stato&#62;Attiva&#60;/Stato&#62; &#60;/Applicazione&#62; &#60;/Applicazioni&#62; L&#8217;utilizzo di una classe per deserializzare il contenuto di questo xml in un &#8230; <a href="http://www.metalide.com/kiraya/?p=908">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Un caso semplicissimo,può diventare un incubo per diverse ore&#8230;</p>
<p>Un xml di questo tipo:</p>
<div class="codecolorer-container xml railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><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><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Applicazioni<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XXX1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Attiva<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XXX2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Attiva<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Applicazioni<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>L&#8217;utilizzo di una classe per deserializzare il contenuto di questo xml in un oggetto, in c# , diventa difficile a causa della natura del Root Item di questo xml, &#8220;Applicazioni&#8221;, che risulta essere un Array di &#8220;Applicazione&#8221; .</p>
<p>Per poter lavorare in maniera corretta con gli attributi XmlArray e XmlArrayItem, senza stare a romperci la testa, aggiungiamo un nodo contenitore ad &#8220;Applicazioni&#8221;, come nell&#8217;esempio seguente:</p>
<div class="codecolorer-container xml railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><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><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ServizioStato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Applicazioni<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XXX1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Attiva<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>XXX2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/NomeApplicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Attiva<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Stato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Applicazione<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Applicazioni<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ServizioStato<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>In questo modo possiamo andare a definire un oggetto per la deserializzazione cosi definito :</p>
<div class="codecolorer-container csharp railscasts" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:550px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Xml.Serialization</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">namespace</span> ServizioStato<br />
<span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #008000;">&#91;</span>Serializable<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #008000;">&#91;</span>XmlRoot<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ServizioStato&quot;</span>,<span style="color: #0600FF; font-weight: bold;">Namespace</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;&quot;</span>,IsNullable<span style="color: #008000;">=</span><span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ServizioStatoApplicazioni<br />
<span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> Applicazione<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> applicazioni<span style="color: #008000;">;</span><br />
<br />
<span style="color: #008000;">&#91;</span>XmlArray<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Applicazioni&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #008000;">&#91;</span>XmlArrayItem<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Applicazione&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #008000;">&#40;</span>Applicazione<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> Applicazione<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> StatoApplicazioni<br />
<span style="color: #008000;">&#123;</span><br />
get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">applicazioni</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
set <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">applicazioni</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008000;">&#91;</span>Serializable<span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Applicazione<br />
<span style="color: #008000;">&#123;</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> nomeApplicazioneField<span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> statoField<span style="color: #008000;">;</span><br />
<br />
<span style="color: #008000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Serialization</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Applicazione&quot;</span>, <span style="color: #0600FF; font-weight: bold;">Namespace</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;&quot;</span>,Form <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Schema</span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlSchemaForm</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Unqualified</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Applicazione<br />
<span style="color: #008000;">&#123;</span><br />
get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">nomeApplicazioneField</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
set <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">nomeApplicazioneField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Serialization</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlElementAttribute</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Stato&quot;</span>, <span style="color: #0600FF; font-weight: bold;">Namespace</span><span style="color: #008000;">=</span><span style="color: #666666;">&quot;&quot;</span>,Form <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Xml</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Schema</span><span style="color: #008000;">.</span><span style="color: #0000FF;">XmlSchemaForm</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Unqualified</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span><br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Stato<br />
<span style="color: #008000;">&#123;</span><br />
get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">statoField</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
set <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">statoField</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Una cosa su cui riflettere è che il tool XSD per la generazione degli oggetti, non ci viene in aiuto con delle strutture definite come il primo esempio (prima dell&#8217;aggiunta del nodo ServizioStato), non riuscendo a generare le classi in maniera corretta.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=908</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G.r.a. Capitolo 4: Lady Ceramica</title>
		<link>http://www.metalide.com/kiraya/?p=774</link>
		<comments>http://www.metalide.com/kiraya/?p=774#comments</comments>
		<pubDate>Tue, 08 Nov 2011 13:09:50 +0000</pubDate>
		<dc:creator>Kiraya</dc:creator>
				<category><![CDATA[I Diari della Motocicletta e altri mezzi immobili]]></category>
		<category><![CDATA[Atlantide]]></category>
		<category><![CDATA[Cane]]></category>
		<category><![CDATA[Carlino]]></category>
		<category><![CDATA[Ceramica]]></category>
		<category><![CDATA[G.R.A.]]></category>
		<category><![CDATA[Giacobbo]]></category>
		<category><![CDATA[Kabuchi]]></category>
		<category><![CDATA[La Rustica]]></category>
		<category><![CDATA[Lady Ceramica]]></category>
		<category><![CDATA[Miyazaki]]></category>
		<category><![CDATA[Nautilus]]></category>
		<category><![CDATA[Norman Bates]]></category>
		<category><![CDATA[Roma]]></category>
		<category><![CDATA[Shakuhachi]]></category>
		<category><![CDATA[Totoro]]></category>
		<category><![CDATA[Traffico]]></category>
		<category><![CDATA[Volvo]]></category>
		<category><![CDATA[Zero]]></category>

		<guid isPermaLink="false">http://www.metalide.com/kiraya/?p=774</guid>
		<description><![CDATA[Oggi prendo il raccordo dall&#8217;entrata de &#8220;La Rustica&#8221;, un posto semi abbandonato dagli dei che presto diventerà la prossima zona popolata di Roma; ogni percorso è valido pur di arrivare qualche entrata piu avanti su questa infernale pista Polistil a &#8230; <a href="http://www.metalide.com/kiraya/?p=774">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Oggi prendo il raccordo dall&#8217;entrata de &#8220;La Rustica&#8221;, un posto semi abbandonato dagli dei che presto diventerà la prossima zona popolata di Roma; ogni percorso è valido pur di arrivare qualche entrata piu avanti su questa infernale pista Polistil a 3 corsie. Telecomando alla mano, pigio il pulsante, le spazzole scintillano e mi monodireziono sull&#8217;entrata..</p>
<p>Una melodia suonata con un flauto Shakuhachi, nella mente, mi sveglia dal torpore quotidiano e capisco subito il tema della giornata.. Tra i fiori di ciliegio, il vento, e questo fantastico giardino zen di 50km costruito intorno a veicoli in disuso da diverse ore, nella monotonia di questa monorotaia lenta e precisa,come in un film di Miyazaki entro in una dimensione onirica (perche sto ancora dormendo) , magica e fantastica, in cui strane e improbabili creature si avvicendano alla guida di mezzi immobili..</p>
<p>E tra un porco rosso che sorvola Anagnina, e un gatto taxi che saltella sui cartelli stradali, scrivendo Acab con la sua urina, arrivo cosi, chiacchierando con l&#8217;invisibile Totoro, con la mia macchina sul Raccordo Anulare e mi imbatto subito in Lady Ceramica, una strana sessantenne che incontro spesso. E&#8217; talmente truccata che la sua faccia sembra fatta di porcellana. Ricorda molto le maschere del teatro Kabuki, solo che qui non siamo a Tokio, e quello non è un palco ma una Volvo 240  color panna del &#8217;78 con interni rivestiti di peli di cane..</p>
<p>Lady Ceramica sarà alta un metro e tanti dubbi su quel metro, e già penso a Giacobbo che indaga sulla sua provenienza &#8230; sicuramente Atlantide transitando per l&#8217;egitto..</p>
<p>Dal finestrino di dietro un Carlino salta compulsivamente cercando di attirare l&#8217;attenzione, alitando e sbavando su tutto..</p>
<p>Lei impassibile, con gli occhi a binocolo, l&#8217;immancabile sigaretta lunga 20 cm in bocca, cerca di scrutare l&#8217;orizzonte e guida il suo Nautilus color panna come un freddo e calcolatore Capitano Nemo&#8230; Potete suonargli, lampeggiargli, lei è immobile..per alcuni l&#8217;unico elemento vivo in macchina è il Carlino che salta..</p>
<p>Sembra una nave fantasma nel mare di Bering.. I sedili strappati come vele divelte dal tempo e dalle intemperie..quest&#8217;aria di stato avanzato di decomposizione (dato anche dal colore sbiadito della macchina).. ci si aspetta da un momento all&#8217;altro di essere catturati da questo strano essere dall&#8217;innocuo aspetto di nonnetta dei cartoni giapponesi.. una sorta di Sakurambo al femminile,una Banshee nana, che sembra avere il doppio dei suoi anni..</p>
<p>Immobile come l&#8217;ambiente che la circonda e un cane epilettico in braccio, sembra la madre di Norman Bates, eppure è viva, e te ne accorgi quando prima di collidere con la macchina davanti a te a causa di un suo improvviso cambio di corsia,  il suo collo si muove di mezzo grado, quanto basta per guardare con la coda della coda dell&#8217;occhio lo specchietto di destra, e con una calma che sfiora livelli da natura morta, mette la freccia a indicare che &#8220;si è spostata&#8221;.. un gesto faticoso e ritardato probabilmente dal sottile rigor mortis in arrivo&#8230;</p>
<p>Dietro di lei uno stormo impazzito di  &#8220;Zero&#8221; giapponesi , gli scooteroni Mistubishi A6M, strombazzano sparando tutti i loro decibel in segno di protesta per la micidiale quanto kamikaze manovra che nemmeno a Pearl Harbor si era vista (ma questa è un altra storia).. La macchina davanti a me si ferma, io inchiodo, le passa, impassibile, il suo Carlino salta quasi sfottendo l&#8217;automobilista dietro di lui, il mega ingranaggio GRA ruota di qualche secondo, scatta il reset, ed il resto e&#8217; la solita attesa..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metalide.com/kiraya/?feed=rss2&#038;p=774</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: www.metalide.com @ 2012-05-21 00:58:01 by W3 Total Cache -->
