Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1.sln
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Nget_V1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{4EDE27D5-4FA7-43CD-B8F8-3CB3C8C9C03B}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Nget_V1</RootNamespace>
<AssemblyName>Nget_V1</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
<Commandlineparameters>test -url "http://www.google.com" -times 5 avg</Commandlineparameters>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
113 changes: 113 additions & 0 deletions students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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("")]

40 changes: 40 additions & 0 deletions students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions students/niyitegeka-pascal/nget-v1/Nget_V1/Nget_V1/abc2.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty