From 5a28f0355e5087cd7be56b4ab13e1df34224b371 Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 1 Jun 2015 17:26:30 +0200 Subject: [PATCH 1/2] Niyitegeka Pascal ReadMe --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 4ceb1eb..1f1ca75 100644 --- a/README.md +++ b/README.md @@ -1,6 +1 @@ -# cleancode-webget-tool - -[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rhwy/cleancode-webget-tool?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - -English readme not available at this time, it's only available in [french](readme.fr.md) +Niyitegeka Pascal 4A-AL1 \ No newline at end of file From e0966df515f3f3215479fc25cb372505ffc30890 Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 1 Jun 2015 20:03:38 +0200 Subject: [PATCH 2/2] Niyitegeka Pascal 4A-AL1 NGET version 1 --- .../nget-v1/Nget_V1/Nget_V1.sln | 17 +++ .../nget-v1/Nget_V1/Nget_V1/Nget_V1.csproj | 41 +++++++ .../nget-v1/Nget_V1/Nget_V1/Program.cs | 113 ++++++++++++++++++ .../Nget_V1/Properties/AssemblyInfo.cs | 27 +++++ .../nget-v1/Nget_V1/Nget_V1/abc.json | 40 +++++++ .../nget-v1/Nget_V1/Nget_V1/abc2.json | 40 +++++++ .../nget-v1/Nget_V1/Nget_V1/abc3.json | 1 + 7 files changed, 279 insertions(+) create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1.sln create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Nget_V1.csproj create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Program.cs create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Properties/AssemblyInfo.cs create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc.json create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc2.json create mode 100644 students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc3.json diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1.sln b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1.sln new file mode 100644 index 0000000..890264d --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nget_V1", "Nget_V1\Nget_V1.csproj", "{4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B}.Debug|x86.ActiveCfg = Debug|x86 + {4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B}.Debug|x86.Build.0 = Debug|x86 + {4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B}.Release|x86.ActiveCfg = Release|x86 + {4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B}.Release|x86.Build.0 = Release|x86 + EndGlobalSection +EndGlobal diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Nget_V1.csproj b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Nget_V1.csproj new file mode 100644 index 0000000..28e17ca --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Nget_V1.csproj @@ -0,0 +1,41 @@ + + + + Debug + x86 + {4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B} + Exe + Nget_V1 + Nget_V1 + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + test -url "http://www.google.com" -times 5 avg + + + full + true + bin\Release + prompt + 4 + true + x86 + + + + + + + + + + \ No newline at end of file diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Program.cs b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Program.cs new file mode 100644 index 0000000..5124c9b --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Program.cs @@ -0,0 +1,113 @@ +using System; +using System.Net; +using System.IO; +using System.Diagnostics; + +namespace Nget_V1 +{ + class MainClass + { + public static void Main (string[] args) + { + + if (args.Length == 3) { + var url = args [2]; + var method = getProperMethod (args [0]); + Console.WriteLine (getContent(url,method)); + } + + if (args.Length == 5) { + if (args [3].Equals ("-save") && args [4] != null) { + string fileName = args [4]; + string url = args [2]; + var method = getProperMethod (args [0]); + saveToFile (url,method,fileName); + } + if (args [0].Equals ("test") && args [3].Equals ("-times") && args [4] != null){ + string myURL = args [2]; + string times = args [4]; + int repeatTimes = 0; + bool answer = int.TryParse (times, out repeatTimes); + if (answer) { + printURLExecutionTime (myURL,repeatTimes); + } else { + Console.WriteLine ("This is not a number {0}", times); + } + } + + } + if (args.Length == 6) { + if (args [0].Equals ("test") && args [3].Equals ("-times") && args [4] != null && args[5].Equals("avg")) { + string myURL = args [2]; + string times = args [4]; + int repeatTimes = 0; + bool answer = int.TryParse (times, out repeatTimes); + if (answer) { + calculateAverage (myURL, repeatTimes); + } else { + Console.WriteLine ("This is not a number {0}", times); + } + } + } + } + + public static string getContent (string url, string method) + { + WebRequest request = WebRequest.Create(url); + if (method == null) { + request.Method = "GET"; + } else { + request.Method = method; + } + string content = "empty"; + try { + content = new StreamReader (request.GetResponse ().GetResponseStream ()).ReadToEnd (); + } catch{ + Console.WriteLine ("The URL is not valide"); + } + return content; + } + + public static void saveToFile(string url,string method,string fileName){ + var content = getContent(url,method); + string projectPath = Directory.GetParent (Directory.GetCurrentDirectory ()).Parent.FullName; + string filePath = projectPath + "/" + fileName; + using (StreamWriter file = new StreamWriter (filePath)) { + file.WriteLine (content); + } + Console.WriteLine (filePath); + } + + public static void calculateAverage (string url,int repeatTimes){ + int moyenne = 0; + for (int i = 0; i < repeatTimes; i++) { + Stopwatch chrono = new Stopwatch(); + chrono.Start (); + getContent (url, null); + chrono.Stop (); + moyenne +=chrono.Elapsed.Milliseconds; + } + moyenne = moyenne / repeatTimes; + Console.WriteLine ("average time of request execution {0}ms",moyenne); + } + + public static void printURLExecutionTime(string url,int repeatTimes){ + for (int i = 0; i < repeatTimes; i++) { + Stopwatch chrono = new Stopwatch(); + chrono.Start (); + getContent (url, null); + chrono.Stop (); + Console.WriteLine ("{0}ms",chrono.Elapsed.Milliseconds); + } + } + + public static string getProperMethod (string method) + { + if (method != null) { + method = method.Replace ("-", ""); + method = method.ToUpper (); + } + return method; + } + } +} diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Properties/AssemblyInfo.cs b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e4d6d39 --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("Nget_V1")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("pascal")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc.json b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc.json new file mode 100644 index 0000000..d50fdd0 --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc.json @@ -0,0 +1,40 @@ +Google


 

Recherche avanc�eOutils linguistiques

© 2015 - Confidentialit� - Conditions

diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc2.json b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc2.json new file mode 100644 index 0000000..4b6e189 --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc2.json @@ -0,0 +1,40 @@ +Google


 

Recherche avanc�eOutils linguistiques

© 2015 - Confidentialit� - Conditions

diff --git a/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc3.json b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc3.json new file mode 100644 index 0000000..c6cac69 --- /dev/null +++ b/students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc3.json @@ -0,0 +1 @@ +empty