diff --git a/README.md b/README.md index 4ceb1eb..aebf183 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,6 @@ English readme not available at this time, it's only available in [french](readme.fr.md) + +Narrainasamy Jeremy +Marzilli Gaetan \ No newline at end of file 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 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..d57beb6 --- /dev/null +++ b/Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs @@ -0,0 +1,76 @@ +/* + * 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; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; + +namespace nget_v2 +{ + class Program + { + + public static void Main(string[] args) + { + + try{ + + 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")){ + 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){ + Console.WriteLine("Une erreur est survenue : " + e); + } + + } + + 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); + return s; + } + + public static void getChargementUrl(String url, int nbTest, bool avg){ + var request = (HttpWebRequest)WebRequest.Create(url); + System.Diagnostics.Stopwatch timer = new Stopwatch(); + + var listeTemps = new List(); + + 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 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