From ec31817f499d4d6efc7bb4c5b1050be9afdd8afc Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Mon, 1 Jun 2015 17:25:44 +0200 Subject: [PATCH 1/8] Readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4ceb1eb..3e93bc2 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,5 @@ English readme not available at this time, it's only available in [french](readme.fr.md) + +Narrainasamy Jeremy \ No newline at end of file From a27c36c1afbe3ec961f34b061bab6409a26d866b Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Mon, 1 Jun 2015 19:27:57 +0200 Subject: [PATCH 2/8] nget-v1 --- .../nget-v1/nget-v1/Program.cs | 106 ++++++++++++++++++ .../nget-v1/Properties/AssemblyInfo.cs | 31 +++++ .../nget-v1/nget-v1/app.config | 6 + .../nget-v1/nget-v1/nget-v1.csproj | 61 ++++++++++ 4 files changed, 204 insertions(+) create mode 100644 Students/narrainasamy-jeremy/nget-v1/nget-v1/Program.cs create mode 100644 Students/narrainasamy-jeremy/nget-v1/nget-v1/Properties/AssemblyInfo.cs create mode 100644 Students/narrainasamy-jeremy/nget-v1/nget-v1/app.config create mode 100644 Students/narrainasamy-jeremy/nget-v1/nget-v1/nget-v1.csproj diff --git a/Students/narrainasamy-jeremy/nget-v1/nget-v1/Program.cs b/Students/narrainasamy-jeremy/nget-v1/nget-v1/Program.cs new file mode 100644 index 0000000..a75da45 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v1/nget-v1/Program.cs @@ -0,0 +1,106 @@ +/* + * Created by SharpDevelop. + * User: Jkn1092 + * Date: 01/06/2015 + * Time: 17:43 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; + +namespace nget_v1 +{ + class Program + { + public static void Main(string[] args) + { + + switch(args.Length){ + case 3: + if(args[0] == "get" && args[1] == "-url"){ + var contenu = getContenuUrl(args[2]); + Console.WriteLine(contenu); + }else{ + Console.WriteLine("Une erreur est survenue : Nombre d'arguments insuffisant"); + } + break; + + case 5: + if(args[0] == "get" && args[1] == "-url" && args[3] == "-save"){ + var contenu = getContenuUrl(args[2]); + System.IO.File.WriteAllText(args[4],contenu); + } + else if(args[0] == "test" && args[1] == "-url" && args[3] == "-times"){ + var nbTest = Convert.ToInt32(args[4]); + + for(var i = 0; i < nbTest; i++){ + var temps = getChargementUrl(args[2]); + Console.WriteLine(temps.TotalSeconds); + } + + }else{ + Console.WriteLine("Une erreur est survenue : Nombre d'arguments in"); + } + break; + + case 6: + if(args[0] == "test" && args[1] == "-url" && args[3] == "-times" && args[5] == "-avg"){ + + var nbTest = Convert.ToInt32(args[4]); + var listeTemps = new List(); + + for(var i = 0; i < nbTest; i++){ + listeTemps.Add(getChargementUrl(args[2])); + } + + var moyenne = TimeSpan.FromSeconds(listeTemps.Average(time=>time.TotalSeconds)); + Console.WriteLine(moyenne); + + }else{ + Console.WriteLine("Une erreur est survenue : Nombre d'arguments in"); + } + break; + + default: + Console.WriteLine("Une erreur est survenue : Nombre d'arguments in"); + break; + } + + Console.Write("Press any key to exit . . . "); + Console.ReadKey(true); + } + + public static String getContenuUrl(String url){ + + var client = new WebClient(); + client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); + + var data = client.OpenRead (url); + var reader = new StreamReader (data); + var s = reader.ReadToEnd (); + + data.Close (); + reader.Close (); + + return s; + } + + public static TimeSpan getChargementUrl(String url){ + + var request = (HttpWebRequest)WebRequest.Create(url); + System.Diagnostics.Stopwatch timer = new Stopwatch(); + + timer.Start(); + var response = (HttpWebResponse)request.GetResponse(); + timer.Stop(); + + return timer.Elapsed; + } + + } +} \ No newline at end of file diff --git a/Students/narrainasamy-jeremy/nget-v1/nget-v1/Properties/AssemblyInfo.cs b/Students/narrainasamy-jeremy/nget-v1/nget-v1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bebfb6 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v1/nget-v1/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("nget-v1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("nget-v1")] +[assembly: AssemblyCopyright("Copyright 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/Students/narrainasamy-jeremy/nget-v1/nget-v1/app.config b/Students/narrainasamy-jeremy/nget-v1/nget-v1/app.config new file mode 100644 index 0000000..970c80b --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v1/nget-v1/app.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Students/narrainasamy-jeremy/nget-v1/nget-v1/nget-v1.csproj b/Students/narrainasamy-jeremy/nget-v1/nget-v1/nget-v1.csproj new file mode 100644 index 0000000..1f59c5f --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v1/nget-v1/nget-v1.csproj @@ -0,0 +1,61 @@ + + + + {7F591218-AA4B-4C94-B566-675AD9026AC8} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + AnyCPU + Exe + nget_v1 + nget-v1 + v4.0 + Properties + False + + + x86 + + + bin\Debug\ + True + Full + False + True + DEBUG;TRACE + Project + test -url "https://msdn.microsoft.com/fr-fr/library/system.net.webclient%28v=vs.110%29.aspx" -times 2 -avg + + + bin\Release\ + False + None + True + False + TRACE + + + + 4.0 + + + + 3.5 + + + + 3.5 + + + + 3.5 + + + + + + + + + + + \ No newline at end of file From 532096b4c474a6f391499422684ba83aa52fd1e2 Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Wed, 17 Jun 2015 16:00:18 +0200 Subject: [PATCH 3/8] =?UTF-8?q?Travail=20en=20=C3=A9quipe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +- .../nget-v2/nget-v2/nget-v2.sln | 18 ++++++ .../nget-v2/nget-v2/nget-v2/Program.cs | 25 ++++++++ .../nget-v2/Properties/AssemblyInfo.cs | 31 ++++++++++ .../nget-v2/nget-v2/nget-v2/app.config | 6 ++ .../nget-v2/nget-v2/nget-v2/nget-v2.csproj | 58 +++++++++++++++++++ 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2.sln create mode 100644 Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs create mode 100644 Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs create mode 100644 Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/app.config create mode 100644 Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/nget-v2.csproj diff --git a/README.md b/README.md index 3e93bc2..aebf183 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,5 @@ English readme not available at this time, it's only available in [french](readme.fr.md) -Narrainasamy Jeremy \ No newline at end of file +Narrainasamy Jeremy +Marzilli Gaetan \ No newline at end of file diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2.sln b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2.sln new file mode 100644 index 0000000..b4c3ca4 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2.sln @@ -0,0 +1,18 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 5.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nget-v2", "nget-v2\nget-v2.csproj", "{730E5EEA-EDEF-495C-A6D6-97334E0998FD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs new file mode 100644 index 0000000..aad06d6 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -0,0 +1,25 @@ +/* + * Created by SharpDevelop. + * User: Jkn1092 + * Date: 17/06/2015 + * Time: 15:58 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; + +namespace nget_v2 +{ + class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + + // TODO: Implement Functionality Here + + Console.Write("Press any key to continue . . . "); + Console.ReadKey(true); + } + } +} \ No newline at end of file diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b2291b5 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("nget-v2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("nget-v2")] +[assembly: AssemblyCopyright("Copyright 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/app.config b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/app.config new file mode 100644 index 0000000..970c80b --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/app.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/nget-v2.csproj b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/nget-v2.csproj new file mode 100644 index 0000000..8fbb171 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/nget-v2.csproj @@ -0,0 +1,58 @@ + + + + {730E5EEA-EDEF-495C-A6D6-97334E0998FD} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + AnyCPU + Exe + nget_v2 + nget-v2 + v4.0 + Properties + + + x86 + + + bin\Debug\ + True + Full + False + True + DEBUG;TRACE + + + bin\Release\ + False + None + True + False + TRACE + + + + 4.0 + + + + 3.5 + + + + 3.5 + + + + 3.5 + + + + + + + + + + + \ No newline at end of file From e892d8208691b7db046a2f93341621473e46c9ce Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Wed, 17 Jun 2015 16:43:11 +0200 Subject: [PATCH 4/8] =?UTF-8?q?Code=20=C3=A0=20cleaner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nget-v2/nget-v2/nget-v2/Program.cs | 77 ++++++++++++++++++- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs index aad06d6..573324e 100644 --- a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -7,6 +7,11 @@ * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; namespace nget_v2 { @@ -14,12 +19,76 @@ class Program { public static void Main(string[] args) { - Console.WriteLine("Hello World!"); - // TODO: Implement Functionality Here - - Console.Write("Press any key to continue . . . "); + switch(args.Length){ + case 3: + if(args[0] == "get" && args[1] == "-url"){ + Console.WriteLine(getContenuUrl(args[2])); + }else{ + Console.WriteLine("Une erreur est survenue."); + } + break; + + case 5: + if(args[0] == "get" && args[1] == "-url" && args[3] == "-save"){ + System.IO.File.WriteAllText(args[4],getContenuUrl(args[2])); + } + else if(args[0] == "test" && args[1] == "-url" && args[3] == "-times"){ + var nbTest = Convert.ToInt32(args[4]); + + for(var i = 0; i < nbTest; i++){ + Console.WriteLine(getChargementUrl(args[2]).TotalSeconds); + } + + }else{ + Console.WriteLine("Une erreur est survenue."); + } + break; + + case 6: + if(args[0] == "test" && args[1] == "-url" && args[3] == "-times" && args[5] == "-avg"){ + + var nbTest = Convert.ToInt32(args[4]); + var listeTemps = new List(); + + for(var i = 0; i < nbTest; i++){ + listeTemps.Add(getChargementUrl(args[2])); + } + + var moyenne = TimeSpan.FromSeconds(listeTemps.Average(time=>time.TotalSeconds)); + Console.WriteLine(moyenne.TotalSeconds); + + }else{ + Console.WriteLine("Une erreur est survenue."); + } + break; + + default: + Console.WriteLine("Une erreur est survenue."); + break; + } + + Console.Write("Press any key to exit . . . "); Console.ReadKey(true); + + } + + public static String getContenuUrl(String url){ + var client = new WebClient(); + var s = client.DownloadString(url); + return s; + } + + public static TimeSpan getChargementUrl(String url){ + var request = (HttpWebRequest)WebRequest.Create(url); + System.Diagnostics.Stopwatch timer = new Stopwatch(); + + timer.Start(); + var response = (HttpWebResponse)request.GetResponse(); + timer.Stop(); + + return timer.Elapsed; } + } } \ No newline at end of file From 40232fdc38c216505a6effa63e9073f66f1757c8 Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Wed, 17 Jun 2015 17:18:08 +0200 Subject: [PATCH 5/8] Code final --- .../nget-v2/nget-v2/nget-v2/Program.cs | 86 +++++++++---------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs index 573324e..baa486e 100644 --- a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -20,54 +20,34 @@ class Program public static void Main(string[] args) { - switch(args.Length){ - case 3: - if(args[0] == "get" && args[1] == "-url"){ - Console.WriteLine(getContenuUrl(args[2])); - }else{ - Console.WriteLine("Une erreur est survenue."); - } - break; - - case 5: - if(args[0] == "get" && args[1] == "-url" && args[3] == "-save"){ - System.IO.File.WriteAllText(args[4],getContenuUrl(args[2])); - } - else if(args[0] == "test" && args[1] == "-url" && args[3] == "-times"){ - var nbTest = Convert.ToInt32(args[4]); + try{ + switch(args.Length){ - for(var i = 0; i < nbTest; i++){ - Console.WriteLine(getChargementUrl(args[2]).TotalSeconds); - } - - }else{ - Console.WriteLine("Une erreur est survenue."); - } - break; - - case 6: - if(args[0] == "test" && args[1] == "-url" && args[3] == "-times" && args[5] == "-avg"){ + case 3: + if(args[0] == "get" && args[1] == "-url"){ Console.WriteLine(getContenuUrl(args[2])); return;} + break; - var nbTest = Convert.ToInt32(args[4]); - var listeTemps = new List(); + case 5: + if(args[0] == "get" && args[1] == "-url" && args[3] == "-save"){ System.IO.File.WriteAllText(args[4],getContenuUrl(args[2])); return;} - for(var i = 0; i < nbTest; i++){ - listeTemps.Add(getChargementUrl(args[2])); + if(args[0] == "test" && args[1] == "-url" && args[3] == "-times"){ + getChargementUrl(args[2], int.Parse(args[4]), false); + return; } + break; - var moyenne = TimeSpan.FromSeconds(listeTemps.Average(time=>time.TotalSeconds)); - Console.WriteLine(moyenne.TotalSeconds); + case 6: + if(args[0] == "test" && args[1] == "-url" && args[3] == "-times" && args[5] == "-avg"){ + getChargementUrl(args[2], int.Parse(args[4]), true); + return; + } + break; + } - }else{ - Console.WriteLine("Une erreur est survenue."); - } - break; - - default: - Console.WriteLine("Une erreur est survenue."); - break; + }catch(Exception e){ + Console.WriteLine("Une erreur est survenue : " + e); } - + Console.Write("Press any key to exit . . . "); Console.ReadKey(true); @@ -79,16 +59,28 @@ public static String getContenuUrl(String url){ return s; } - public static TimeSpan getChargementUrl(String url){ + public static void getChargementUrl(String url, int nbTest, bool avg){ var request = (HttpWebRequest)WebRequest.Create(url); System.Diagnostics.Stopwatch timer = new Stopwatch(); - timer.Start(); - var response = (HttpWebResponse)request.GetResponse(); - timer.Stop(); + var listeTemps = new List(); - return timer.Elapsed; + for(var i = 0; i < nbTest; i++){ + timer.Start(); + var response = (HttpWebResponse)request.GetResponse(); + timer.Stop(); + + if(avg){ + listeTemps.Add(timer.Elapsed); + }else{ + Console.WriteLine(timer.Elapsed.TotalSeconds); + } + } + + if(avg){ + Console.WriteLine(TimeSpan.FromSeconds(listeTemps.Average(time=>time.TotalSeconds)).TotalSeconds); + } } - + } } \ No newline at end of file From 9c84911f491eba43dbc32da56a0cb0b782d689a8 Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Wed, 17 Jun 2015 19:39:03 +0200 Subject: [PATCH 6/8] =?UTF-8?q?Utilisation=20de=20contains=20pour=20contr?= =?UTF-8?q?=C3=B4ler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nget-v2/nget-v2/nget-v2/Program.cs | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs index baa486e..70dfe74 100644 --- a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -17,39 +17,26 @@ namespace nget_v2 { class Program { + public static void Main(string[] args) { - + try{ - switch(args.Length){ - - case 3: - if(args[0] == "get" && args[1] == "-url"){ Console.WriteLine(getContenuUrl(args[2])); return;} - break; - - case 5: - if(args[0] == "get" && args[1] == "-url" && args[3] == "-save"){ System.IO.File.WriteAllText(args[4],getContenuUrl(args[2])); return;} - - if(args[0] == "test" && args[1] == "-url" && args[3] == "-times"){ - getChargementUrl(args[2], int.Parse(args[4]), false); - return; - } - break; - - case 6: - if(args[0] == "test" && args[1] == "-url" && args[3] == "-times" && args[5] == "-avg"){ - getChargementUrl(args[2], int.Parse(args[4]), true); - return; - } - break; + + if(args[0].Equals("get")){ + + if(args.Contains("-url") && args.Contains("-save")){ System.IO.File.WriteAllText(args[4],getContenuUrl(args[2])); return;} + if(args.Contains("-url")){ Console.WriteLine(getContenuUrl(args[2])); return;} + } + + if(args[0].Equals("test")){ + if(args.Contains("-url") && args.Contains("-times") && args.Contains("-avg")){ getChargementUrl(args[2], int.Parse(args[4]), true); return;} + if(args.Contains("-url") && args.Contains("-times")){ getChargementUrl(args[2], int.Parse(args[4]), false); return;} } }catch(Exception e){ Console.WriteLine("Une erreur est survenue : " + e); } - - Console.Write("Press any key to exit . . . "); - Console.ReadKey(true); } From 19ab61cbe4f4a9f65070bc4bda416a52f510036e Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Wed, 17 Jun 2015 20:03:18 +0200 Subject: [PATCH 7/8] Prise en compte des positions des parametres --- .../nget-v2/nget-v2/nget-v2/Program.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs index 70dfe74..441094d 100644 --- a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -25,13 +25,14 @@ public static void Main(string[] args) if(args[0].Equals("get")){ - if(args.Contains("-url") && args.Contains("-save")){ System.IO.File.WriteAllText(args[4],getContenuUrl(args[2])); return;} - if(args.Contains("-url")){ Console.WriteLine(getContenuUrl(args[2])); return;} + if(args.Contains("-url") && args.Contains("-save")){ System.IO.File.WriteAllText(getValeurParametre(args,"-save"),getContenuUrl(getValeurParametre(args,"-url"))); return;} + if(args.Contains("-url")){ Console.WriteLine(getContenuUrl(getValeurParametre(args,"-url"))); return;} + ; } if(args[0].Equals("test")){ - if(args.Contains("-url") && args.Contains("-times") && args.Contains("-avg")){ getChargementUrl(args[2], int.Parse(args[4]), true); return;} - if(args.Contains("-url") && args.Contains("-times")){ getChargementUrl(args[2], int.Parse(args[4]), false); return;} + if(args.Contains("-url") && args.Contains("-times") && args.Contains("-avg")){ getChargementUrl(getValeurParametre(args,"-url"), int.Parse(getValeurParametre(args,"-times")), true); return;} + if(args.Contains("-url") && args.Contains("-times")){ getChargementUrl(getValeurParametre(args,"-url"), int.Parse(getValeurParametre(args,"-times")), false); return;} } }catch(Exception e){ @@ -40,6 +41,10 @@ public static void Main(string[] args) } + public static string getValeurParametre(string[] args, string parametre){ + return args[Array.IndexOf(args,parametre)+1]; + } + public static String getContenuUrl(String url){ var client = new WebClient(); var s = client.DownloadString(url); From e65f7e7f0882b326e61b77e84ab435201edb9c92 Mon Sep 17 00:00:00 2001 From: jkn1092 Date: Wed, 17 Jun 2015 20:06:22 +0200 Subject: [PATCH 8/8] correction erreur --- .../narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs index 441094d..d57beb6 100644 --- a/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -23,11 +23,9 @@ public static void Main(string[] args) try{ - if(args[0].Equals("get")){ - + if(args[0].Equals("get")){ if(args.Contains("-url") && args.Contains("-save")){ System.IO.File.WriteAllText(getValeurParametre(args,"-save"),getContenuUrl(getValeurParametre(args,"-url"))); return;} if(args.Contains("-url")){ Console.WriteLine(getContenuUrl(getValeurParametre(args,"-url"))); return;} - ; } if(args[0].Equals("test")){