<?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>Azstar</title>
	<atom:link href="https://blog.developpez.com/azstar/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.developpez.com/azstar</link>
	<description>Consultant .NET</description>
	<lastBuildDate>Fri, 28 Nov 2014 16:35:19 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Protéger mes données de configuration dans une dll compilée</title>
		<link>https://blog.developpez.com/azstar/p12127/csharp/proteger-mes-donnees-de-configuration-dans-dll-de-compile</link>
		<comments>https://blog.developpez.com/azstar/p12127/csharp/proteger-mes-donnees-de-configuration-dans-dll-de-compile#comments</comments>
		<pubDate>Tue, 16 Jul 2013 14:38:15 +0000</pubDate>
		<dc:creator><![CDATA[azstar]]></dc:creator>
				<category><![CDATA[Csharp]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/azstar/?p=56</guid>
		<description><![CDATA[Dans ce petit exemple, je vais travailler la réflexion et la configuration sous c#, pour préparer une dll qui peut être utilisé comme une dll de configuration à partir d’un fichier de configuration afin de protéger la configuration. Le besoin &#8230; <a href="https://blog.developpez.com/azstar/p12127/csharp/proteger-mes-donnees-de-configuration-dans-dll-de-compile">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Dans ce petit exemple, je vais travailler la réflexion et la configuration sous c#, pour préparer une dll qui peut  être utilisé comme une dll de configuration  à partir d’un fichier de configuration afin de protéger la configuration. </p>
<ul>
<li> <strong>Le besoin</strong>	</li>
</ul>
<p>Le besoin est de trouver une solution pour protéger la configuration.<br />
On veut que la configuration se fait par l’administrateur de l’application (après l’installation) et de la protéger pour ne pas être changer par d&rsquo;autres utilisateurs.</p>
<p>La solution est :</p>
<ul>
<li> l’administrateur peux changer le fichier de configuration </li>
<li> l’application compile une dll qui contient les données de configuration et qui va être chargé et utilisé par l’application.</li>
<li>L&rsquo;administrateur peut aussi redémarrer la configuration s’il change la configuration.</li>
</ul>
<ul>
<li> <strong>La récupération des données </strong>	</li>
</ul>
<p>la récupération des données est simple, mais pourquoi ne pas avoir la possibilité de recharger le fichier <em><strong>&laquo;&nbsp;app.config&nbsp;&raquo;</strong> </em> en cas de besoin :</p>
<p>je peux utiliser l’objet configurationManger pour le faire:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CC<span style="color: #008000;">.</span><span style="color: #0000FF;">Nom</span><span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ConfigurationManager</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AppSettings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Nom&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
CC<span style="color: #008000;">.</span><span style="color: #0000FF;">Prenom</span> <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ConfigurationManager</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AppSettings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Prenom&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span></div></div>
<p>Mais je préfère considérer  mon “app.config” comme un fichier de configuration externe afin de pouvoir le recharger en cas de besoin sans redémarrer mon application :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ExeConfigurationFileMap configMap <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ExeConfigurationFileMap<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
configMap<span style="color: #008000;">.</span><span style="color: #0000FF;">ExeConfigFilename</span> <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;{0}.{1}.{2}&quot;</span>,FileConfigName,<span style="color: #666666;">&quot;exe&quot;</span>, <span style="color: #666666;">&quot;config&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
Configuration config <span style="color: #008000;">=</span> ConfigurationManager<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenMappedExeConfiguration</span><span style="color: #008000;">&#40;</span>configMap,ConfigurationUserLevel<span style="color: #008000;">.</span><span style="color: #0000FF;">None</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <br />
ClassConfig CC <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ClassConfig<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">ConfigurationManager</span><span style="color: #008000;">.</span><span style="color: #0000FF;">RefreshSection</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;AppSettings&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
CC<span style="color: #008000;">.</span><span style="color: #0000FF;">Nom</span><span style="color: #008000;">=</span> config<span style="color: #008000;">.</span><span style="color: #0000FF;">AppSettings</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Settings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Nom&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span><br />
CC<span style="color: #008000;">.</span><span style="color: #0000FF;">Prenom</span> <span style="color: #008000;">=</span> config<span style="color: #008000;">.</span><span style="color: #0000FF;">AppSettings</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Settings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Prenom&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">;</span></div></div>
<ul>
<li> <strong>La compilation </strong>	</li>
</ul>
<p>Dans cette partie :</p>
<p>&#8211; les données de configuration sont dans l&rsquo;objet CC (de type ClassConfig ) qui est définie comme :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;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;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ClassConfig<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _Nom <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Nom&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Nom<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _Nom<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #008000;">&#123;</span> _Nom <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _Prenom <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Prenom&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Prenom<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _Prenom<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #008000;">&#123;</span> _Prenom <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">string</span> ToString<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//string _usings = &quot;using System;using System.Collections.Generic;using System.Text; \n&quot;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _className <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _nameSpace <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Namespace</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _Params <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyInfo</span> h <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProperties</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Params <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\t</span> private &quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;_&quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Type<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTypeCode</span><span style="color: #008000;">&#40;</span>h<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyType</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> TypeCode<span style="color: #008000;">.</span><span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Params <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;= <span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\&quot;</span>; <span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Params <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;= &quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;; <span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Params <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot; <span style="color: #008080; font-weight: bold;">\t</span> public &quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\t</span> { <span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\t</span><span style="color: #008080; font-weight: bold;">\t</span> get { return &quot;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;_&quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;; }<span style="color: #008080; font-weight: bold;">\n</span><span style="color: #008080; font-weight: bold;">\t</span><span style="color: #008080; font-weight: bold;">\t</span> set {&quot;</span><span style="color: #008000;">+</span> <span style="color: #666666;">&quot;_&quot;</span> <span style="color: #008000;">+</span> h<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; = value; }<span style="color: #008080; font-weight: bold;">\n</span> <span style="color: #008080; font-weight: bold;">\t</span>}<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> codesource <span style="color: #008000;">=</span> <span style="color: #008080; font-style: italic;">/*_usings + */</span><span style="color: #666666;">&quot; namespace &quot;</span> <span style="color: #008000;">+</span> _nameSpace <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;{ <span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; codesource <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot; public class &quot;</span> <span style="color: #008000;">+</span> _className <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; { <span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; codesource <span style="color: #008000;">+=</span> _Params<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; codesource <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;}}&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> codesource<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></div>
<p>Qui représente mes données de configuration : </p>
<p>  <a href="http://blog.developpez.com/azstar/files/2013/07/config.jpg"><img src="http://blog.developpez.com/azstar/files/2013/07/config-300x154.jpg" alt="config" width="300" height="154" class="alignnone size-medium wp-image-77" /></a></p>
<p>C’est pourquoi on a deux propriétés  Nom et Prenom dans la définition de ma classe. </p>
<ul>
<li> <strong>la récupération du code source de ma classe </strong>	</li>
</ul>
<p>J’ai redéfini la fonction Tostring  pour avoir la définition de ma classe en code csharp pour que je puisque le compiler par la suite.</p>
<p>L&rsquo;idée n’est claire, je m’explique .</p>
<p>exemple :</p>
<p>Pour les valeurs de mes données de configurations (Nom=azstar;Prenom=abdo) la fonction va me générer un classe de définition:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">namespace</span> ClassConfig<br />
<span style="color: #008000;">&#123;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ClassConfig<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _Nom <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;azstar&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Nom<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _Nom<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #008000;">&#123;</span> _Nom <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> _Prenom <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;abdo&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Prenom<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _Prenom<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set <span style="color: #008000;">&#123;</span> _Prenom <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p><strong>La fonction ToString </strong>va me générer le code source de la classe avec mes données de configuration dedans (je me limite aux propriétés ).</p>
<p>Au premier temps je récupère le nom de la classe et le Namespace</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">string</span> _className <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span><br />
<span style="color: #6666cc; font-weight: bold;">string</span> _nameSpace <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Namespace</span><span style="color: #008000;">;</span></div></div>
<p>Pour faire :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">string</span> codesource <span style="color: #008000;">=</span> <span style="color: #008080; font-style: italic;">/*_usings + */</span><span style="color: #666666;">&quot; namespace &quot;</span> <span style="color: #008000;">+</span> _nameSpace <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;{ <span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
codesource <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot; public class &quot;</span> <span style="color: #008000;">+</span> _className <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; { <span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span></div></div>
<p>Donc jusque-là je doit avoir :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">namespace</span> ClassConfig<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> ClassConfig &nbsp; &nbsp;<span style="color: #008000;">&#123;</span></div></div>
<p>Ensuite je me lance à récupérer les propriétés</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyInfo</span> h <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProperties</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><span style="color: #008000;">&#125;</span></div></div>
<p>pour chaque propriété je vais avoir un code semblable à ça :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">string</span> _Nom <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;azstar&quot;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//la valeur de la propriété </span><br />
&nbsp;<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Nom<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp;get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _Nom<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;set <span style="color: #008000;">&#123;</span> _Nom <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp;<span style="color: #008000;">&#125;</span></div></div>
<p>Et finalement je vais avoir le code total de ma classe.Je ne sais pas est ce qu’ il existe une fonction qui génère le code facilement dans framework? mais je n’ai pas cherché!.</p>
<p>Donc à ce stade  on a le code source de ma classe avec les valeurs des données de configuration (ToString est appelé depuis mon objet CC qui contient mes données de configuration).  </p>
<ul>
<li> <strong>la compilation de code source </strong>	</li>
</ul>
<p>Pour cette partie je n’ai que utilisé un code que j’ai trouvé dans msdn pour compiler mon code source :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;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;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> CompileDLL<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">String</span> source, <span style="color: #6666cc; font-weight: bold;">string</span> AssemblyName,<span style="color: #0600FF; font-weight: bold;">out</span> <span style="color: #6666cc; font-weight: bold;">string</span> message<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CodeDomProvider provider <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">bool</span> compileOk <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; provider <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Microsoft<span style="color: #008000;">.</span><span style="color: #0000FF;">CSharp</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CSharpCodeProvider</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>provider <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Format the DLL file name.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">String</span> DLLName <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">@&quot;{0}.dll&quot;</span>,AssemblyName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CompilerParameters cp <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CompilerParameters<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Generate an DLL </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cp<span style="color: #008000;">.</span><span style="color: #0000FF;">GenerateExecutable</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Specify the assembly file name to generate.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cp<span style="color: #008000;">.</span><span style="color: #0000FF;">OutputAssembly</span> <span style="color: #008000;">=</span> DLLName<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Save the assembly as a physical file.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cp<span style="color: #008000;">.</span><span style="color: #0000FF;">GenerateInMemory</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Set whether to treat all warnings as errors.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cp<span style="color: #008000;">.</span><span style="color: #0000FF;">TreatWarningsAsErrors</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CompilerResults cr <span style="color: #008000;">=</span> provider<span style="color: #008000;">.</span><span style="color: #0000FF;">CompileAssemblyFromSource</span><span style="color: #008000;">&#40;</span>cp, source<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>cr<span style="color: #008000;">.</span><span style="color: #0000FF;">Errors</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Display compilation errors.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Errors building {0} into {1}&quot;</span>, AssemblyName, cr<span style="color: #008000;">.</span><span style="color: #0000FF;">PathToAssembly</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Console.WriteLine(&quot;Errors building {0} into {1}&quot;, sourceName, cr.PathToAssembly);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>CompilerError ce <span style="color: #0600FF; font-weight: bold;">in</span> cr<span style="color: #008000;">.</span><span style="color: #0000FF;">Errors</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">/*Console.WriteLine(&quot; &nbsp;{0}&quot;, ce.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine();*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message <span style="color: #008000;">+=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; {0}&quot;</span>, ce<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Display a successful compilation message.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Console.WriteLine(&quot;Source {0} built into {1} successfully.&quot;, &nbsp;sourceName, cr.PathToAssembly);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message <span style="color: #008000;">+=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Source {0} built into {1} successfully.&quot;</span>, AssemblyName, cr<span style="color: #008000;">.</span><span style="color: #0000FF;">PathToAssembly</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Return the results of the compilation.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>cr<span style="color: #008000;">.</span><span style="color: #0000FF;">Errors</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; compileOk <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; compileOk <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> compileOk<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></div>
<p>Ce code me générer une DLL (  cp.GenerateExecutable = false;) que je vais l’utiliser dans mon application comme source de configuration. </p>
<p>Enfin j’ai une dll qui contient la définition de ma classe et qui contient les valeurs de mes données de configuration. l&rsquo;étape suivante c’est de charger mes données dans l’application.</p>
<ul>
<li>La Chargement de la dll et la récupération des données de la  configuration.</li>
</ul>
<p>Pour charger ma dll automatiquement je dois passer par un assembly et faire :</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> bytes <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">IO</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">File</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ReadAllBytes</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ClassConfig2.Dll&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
Assembly a <span style="color: #008000;">=</span> Assembly<span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>bytes<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008080; font-style: italic;">// Get the type to use.</span><br />
Type myType <span style="color: #008000;">=</span> a<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ClassConfig.ClassConfig&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp;<span style="color: #008080; font-style: italic;">// Create an instance. </span><br />
<span style="color: #6666cc; font-weight: bold;">object</span> obj <span style="color: #008000;">=</span> Activator<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateInstance</span><span style="color: #008000;">&#40;</span>myType<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>Avec <em><strong>GetType </strong></em>je peux récupérer le type de ma classe qui est définie automatiquement par un code source généré.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;Type myType <span style="color: #008000;">=</span> a<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ClassConfig&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>Par la suite je peux instancier un objet de ma classe sans passer par le constructeur avec</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #6666cc; font-weight: bold;">object</span> obj <span style="color: #008000;">=</span> Activator<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateInstance</span><span style="color: #008000;">&#40;</span>myType<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>Et avoir un objet qui contient mes données de configuration.</p>
<p>Le type de ma classe n’est pas reconnu dans l’application  donc il faut passer par une classe qui a la même structure que mon objet que je l’ai nommé aussi ClassConfig.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ClassConfig config <span style="color: #008000;">=</span> newClassConfig<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>J’ai créé une fonction pour parcourir mon obj pour le copier dans mon objet config</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><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;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">object</span> CopieObjectInobject<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> obj1, <span style="color: #6666cc; font-weight: bold;">object</span> obj2<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyInfo</span> obj1h <span style="color: #0600FF; font-weight: bold;">in</span> obj1<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProperties</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Reflection</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">PropertyInfo</span> obj2h <span style="color: #0600FF; font-weight: bold;">in</span> obj2<span style="color: #008000;">.</span><span style="color: #0000FF;">GetType</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProperties</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>obj1h<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">==</span> obj2h<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj1h<span style="color: #008000;">.</span><span style="color: #0000FF;">SetValue</span><span style="color: #008000;">&#40;</span>obj1, obj2h<span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&#40;</span>obj2, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> obj1<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></div>
<p>NB: Pour récupérer mes données depuis mon objet obj , je peux aussi les stocker dans un dictionnary.<br />
 Il pourra y’ avoir plusieurs méthodes pour faire ça sans passer par une classe !!. </p>
<p>Enfin j’ai un objet reconnu dans mon application et qui contient toutes mes données de configuration. Je peux si besoin de recharger mon “app.config”(un autre fichier text ,xml ou un autre source) dans ma classe et avoir la dll qui contient les données et je peux aussi protéger cette fonctionnalité, pour qu elle soit utiliser seulement par l’administrateur de mon application; ou bien faire plus , générer la dll lors de l’installation de l’application.</p>
<p>Finalement,même si que les données sont à l&rsquo;intérieur de la dll ; je ne peux pas dire qu&rsquo; ils sont sécurisés car je peux par un simple réflecteur, désassembler la dll et avoir les données même si elles sont obfusquées.  </p>
<p><a href="http://dotnet.developpez.com/telecharger/detail/id/3505/Proteger-mes-donnees-de-configuration-dans-une-dll-compilee">Voir le code source</a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La simulation de navigation dans internet explorer avec Interop.SHDocVw</title>
		<link>https://blog.developpez.com/azstar/p12113/csharp/simulation-de-navigation-avec-interop-shdocvw-dans-internet-explorer</link>
		<comments>https://blog.developpez.com/azstar/p12113/csharp/simulation-de-navigation-avec-interop-shdocvw-dans-internet-explorer#comments</comments>
		<pubDate>Mon, 08 Jul 2013 15:44:25 +0000</pubDate>
		<dc:creator><![CDATA[azstar]]></dc:creator>
				<category><![CDATA[Csharp]]></category>

		<guid isPermaLink="false">http://blog.developpez.com/azstar/?p=14</guid>
		<description><![CDATA[Par fois le besoin de simuler un internaute (clic souris ,remplir input ,choisir radioBox/CheckBox&#8230;) dans un site et de récupérer le résultat, est la dernière solution qui vous reste. dans mon cas, j’ai été obligé de faire ça, afin d’avoir &#8230; <a href="https://blog.developpez.com/azstar/p12113/csharp/simulation-de-navigation-avec-interop-shdocvw-dans-internet-explorer">Lire la suite <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Par fois le besoin de simuler un internaute (clic souris ,remplir input ,choisir radioBox/CheckBox&#8230;) dans un site et de récupérer le résultat, est la dernière solution  qui vous  reste. dans mon cas, j’ai été obligé de faire ça, afin d’avoir extraire une information depuis un site Web (dans l’absence d’un web service dédié ) .Voila je partage avec vous ce que j’ai trouvé : </p>
<p><strong>Class Internet Explorer Simulation :</strong></p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> IESimulatorClass<br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Url <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">InternetExplorer</span> IE <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">private</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> Process IEProcess <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsReadyToGetData <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#region StartIE Simulator</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> IESimulatorClass<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> _url<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Url <span style="color: #008000;">=</span> _url<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE <span style="color: #008000;">=</span> GetIEIntance<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IE <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE<span style="color: #008000;">.</span><span style="color: #0000FF;">Width</span> <span style="color: #008000;">=</span> IE<span style="color: #008000;">.</span><span style="color: #0000FF;">Height</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">800</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE<span style="color: #008000;">.</span><span style="color: #0000FF;">Visible</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE<span style="color: #008000;">.</span><span style="color: #0000FF;">DocumentComplete</span> <span style="color: #008000;">+=</span> IE_DocumentComplete<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">void</span> IE_DocumentComplete<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> pDisp, <span style="color: #0600FF; font-weight: bold;">ref</span> <span style="color: #6666cc; font-weight: bold;">object</span> URL<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IsReadyToGetData <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">InternetExplorer</span> GetIEIntance<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">ShellWindowsClass</span> shellwindows <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">ShellWindowsClass</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">InternetExplorer</span> IE<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &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> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;=</span> shellwindows<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">InternetExplorer</span><span style="color: #008000;">&#41;</span>shellwindows<span style="color: #008000;">.</span><span style="color: #0000FF;">Item</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IE <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IE<span style="color: #008000;">.</span><span style="color: #0000FF;">LocationURL</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span>Url<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Process</span> p <span style="color: #0600FF; font-weight: bold;">in</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Process</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetProcesses</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>p<span style="color: #008000;">.</span><span style="color: #0000FF;">MainWindowHandle</span> <span style="color: #008000;">!=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IntPtr</span><span style="color: #008000;">&#40;</span>IE<span style="color: #008000;">.</span><span style="color: #0000FF;">HWND</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">continue</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IEProcess <span style="color: #008000;">=</span> p<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> IE<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> StartIEInstanceProcess<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: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">InternetExplorer</span> StartIEInstanceProcess<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IEProcess <span style="color: #008000;">=</span> StartIEProcess<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">ShellWindows</span> foundBrowsers <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">ShellWindowsClass</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>SHDocVw<span style="color: #008000;">.</span><span style="color: #0000FF;">InternetExplorer</span> Browser <span style="color: #0600FF; font-weight: bold;">in</span> foundBrowsers<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IntPtr</span><span style="color: #008000;">&#40;</span>Browser<span style="color: #008000;">.</span><span style="color: #0000FF;">HWND</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">!=</span> <span style="color: #008000;">&#40;</span>IEProcess<span style="color: #008000;">.</span><span style="color: #0000FF;">MainWindowHandle</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">continue</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE <span style="color: #008000;">=</span> Browser<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> IE<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Process</span> StartIEProcess<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Process newProcess <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Process<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newProcess<span style="color: #008000;">.</span><span style="color: #0000FF;">StartInfo</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CreateNoWindow</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// newProcess.StartInfo.UseShellExecute = false;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newProcess<span style="color: #008000;">.</span><span style="color: #0000FF;">StartInfo</span><span style="color: #008000;">.</span><span style="color: #0000FF;">FileName</span> <span style="color: #008000;">=</span> @<span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>C<span style="color: #008000;">:</span>\Program Files\Internet Explorer\iexplore<span style="color: #008000;">.</span><span style="color: #0000FF;">exe</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newProcess<span style="color: #008000;">.</span><span style="color: #0000FF;">StartInfo</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Arguments</span> <span style="color: #008000;">=</span> <span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;-</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #008000;">-</span>nohome<span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newProcess<span style="color: #008000;">.</span><span style="color: #0000FF;">Start</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">System.<span style="color: #0000FF;">Threading</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Thread</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Sleep</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3000</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//attendre que le process demarrer </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> newProcess<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#endregion </span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#region GetData</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> GoToUrl<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> url<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IsReadyToGetData <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">object</span> obj <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IE <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IE<span style="color: #008000;">.</span><span style="color: #0000FF;">Navigate</span><span style="color: #008000;">&#40;</span>url, <span style="color: #0600FF; font-weight: bold;">ref</span> obj, <span style="color: #0600FF; font-weight: bold;">ref</span> &nbsp;obj, <span style="color: #0600FF; font-weight: bold;">ref</span> &nbsp;obj, <span style="color: #0600FF; font-weight: bold;">ref</span> obj<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WaitTobeReady<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: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsNavigated<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> url<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IE <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> IE<span style="color: #008000;">.</span><span style="color: #0000FF;">LocationURL</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span>url<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><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;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetHTMLInputValue<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id, <span style="color: #6666cc; font-weight: bold;">string</span> value<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// mshtml.HTMLInputElementClass input =GetInputElement(id);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">IHTMLElement</span> input<span style="color: #008000;">=</span> &nbsp;GetElementById<span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>input <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp;input.value = value;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; input<span style="color: #008000;">.</span><span style="color: #0000FF;">setAttribute</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>value<span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>, value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ClickHTMLButton<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> btnId<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IsReadyToGetData <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp; mshtml.HTMLInputElementClass input = GetInputElement(btnId);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">IHTMLElement</span> input <span style="color: #008000;">=</span> GetElementById<span style="color: #008000;">&#40;</span>btnId<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>input <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; input<span style="color: #008000;">.</span><span style="color: #0000FF;">click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WaitTobeReady<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: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> SetRadiobox<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IsReadyToGetData <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// &nbsp; mshtml.HTMLInputElementClass input = GetInputElement(btnId);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">IHTMLElement</span> input <span style="color: #008000;">=</span> GetElementById<span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>input <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; input<span style="color: #008000;">.</span><span style="color: #0000FF;">click</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// WaitTobeReady();</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">IHTMLElement</span> GetElementById<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">HTMLDocument</span> document <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">HTMLDocument</span><span style="color: #008000;">&#41;</span>IE<span style="color: #008000;">.</span><span style="color: #0000FF;">Document</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">IHTMLElement</span> element <span style="color: #008000;">=</span> document<span style="color: #008000;">.</span><span style="color: #0000FF;">getElementById</span><span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> element<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">HTMLInputElementClass</span> GetInputElement<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>mshtml<span style="color: #008000;">.</span><span style="color: #0000FF;">HTMLInputElementClass</span><span style="color: #008000;">&#41;</span>GetElementById<span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> WaitTobeReady<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>IsReadyToGetData<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">System.<span style="color: #0000FF;">Threading</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Thread</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Sleep</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080;">#endregion </span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span></div></div>
<p>Et pour tester j’ai pris l’exemple de s&#039;authentifier à <a href="http://chat.developpez.com/" target="_blank">http://chat.developpez.com/</a></p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">class</span> Program<br />
<span style="color: #008000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#91;</span>STAThread<span style="color: #008000;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; signintoDeveloppezChat<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> signintoDeveloppezChat<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6666cc; font-weight: bold;">string</span> DeveloppezChatUrl <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;http://chat.developpez.com/&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IESimulatorClass ie <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> IESimulatorClass<span style="color: #008000;">&#40;</span>DeveloppezChatUrl<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">GoToUrl</span><span style="color: #008000;">&#40;</span>DeveloppezChatUrl<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>ie<span style="color: #008000;">.</span><span style="color: #0000FF;">IsNavigated</span><span style="color: #008000;">&#40;</span>DeveloppezChatUrl<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">SetHTMLInputValue</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;identPseudo&quot;</span>, <span style="color: #666666;">&quot;azstar&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//identifiant </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">SetHTMLInputValue</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;identMdp&quot;</span>, <span style="color: #666666;">&quot;*******&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//mot de passe </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">SetRadiobox</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;salonConnexion0&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//choisir le salon &quot;Développement Web&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ie<span style="color: #008000;">.</span><span style="color: #0000FF;">ClickHTMLButton</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;identAction&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception e<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">throw</span> e<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Edit : j’espère que j&#039;ai donné un code claire et je suis toute a fait la pour expliquer mon code et je suis à l’écoute pour toute suggestion pour l&rsquo;améliorer. </p>
<p><a href="http://dotnet.developpez.com/telecharger/detail/id/3486/Simulation-de-navigation-avec-Interop-SHDocVw-dans-internet-explorer">Voir source </a></p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
