Skip to content

Commit

Permalink
Merge pull request #27 from radumg/repo-quality
Browse files Browse the repository at this point in the history
improve repo quality
  • Loading branch information
radumg authored Aug 18, 2018
2 parents ba612a2 + 491ecb6 commit fe54ecf
Show file tree
Hide file tree
Showing 32 changed files with 622 additions and 396 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
language: csharp
solution: src/DynWWW.sln
solution: src/DynaWeb.sln
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DynaWeb
[![Build Status](https://travis-ci.org/radumg/DynWWW.svg?branch=master)](https://travis-ci.org/radumg/DynWWW) [![GitHub version](https://badge.fury.io/gh/radumg%2FDynaWeb.svg)](https://badge.fury.io/gh/radumg%2FDynaWeb) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/radumg/DynaWeb/blob/master/CONTRIBUTING.md)
[![Build Status](https://travis-ci.org/radumg/DynaWeb.svg?branch=master)](https://travis-ci.org/radumg/DynaWeb) [![GitHub version](https://badge.fury.io/gh/radumg%2FDynaWeb.svg)](https://badge.fury.io/gh/radumg%2FDynaWeb) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/radumg/DynaWeb/blob/master/CONTRIBUTING.md) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f482d6c8bb27468e916bba4471511615)](https://www.codacy.com/project/radugidei/DynaWeb/dashboard?utm_source=github.com&utm_medium=referral&utm_content=radumg/DynaWeb&utm_campaign=Badge_Grade_Dashboard)
---
__DynaWeb__ is a [Dynamo](http://www.dynamobim.org) package providing support for interaction with the interwebz in general and with REST APIs in particular.

Expand Down
6 changes: 0 additions & 6 deletions src/DebugApp/App.config

This file was deleted.

59 changes: 0 additions & 59 deletions src/DebugApp/DebugApp.csproj

This file was deleted.

15 changes: 0 additions & 15 deletions src/DebugApp/Program.cs

This file was deleted.

5 changes: 0 additions & 5 deletions src/DebugApp/packages.config

This file was deleted.

19 changes: 8 additions & 11 deletions src/DynaWeb.All.sln → src/DynaWeb.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynaWeb", "DynaWeb\DynaWeb.csproj", "{CE19C882-1AAC-434C-99AF-4A285DA053BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugApp", "DebugApp\DebugApp.csproj", "{F2D82A82-100B-4594-B50F-7C7C815C4370}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynaWeb.Core.Tests", "..\test\DynaWeb.Core.Tests\DynaWeb.Core.Tests.csproj", "{50A649C6-FB32-4C6D-A7B6-6EB99DE8547D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynaWeb.Tests", "..\test\DynaWeb.Tests\DynaWeb.Tests.csproj", "{86015C9C-DEBA-4C2E-B9EF-872C88ED7D6C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -19,16 +17,15 @@ Global
{CE19C882-1AAC-434C-99AF-4A285DA053BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE19C882-1AAC-434C-99AF-4A285DA053BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE19C882-1AAC-434C-99AF-4A285DA053BA}.Release|Any CPU.Build.0 = Release|Any CPU
{F2D82A82-100B-4594-B50F-7C7C815C4370}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2D82A82-100B-4594-B50F-7C7C815C4370}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2D82A82-100B-4594-B50F-7C7C815C4370}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2D82A82-100B-4594-B50F-7C7C815C4370}.Release|Any CPU.Build.0 = Release|Any CPU
{50A649C6-FB32-4C6D-A7B6-6EB99DE8547D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50A649C6-FB32-4C6D-A7B6-6EB99DE8547D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50A649C6-FB32-4C6D-A7B6-6EB99DE8547D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50A649C6-FB32-4C6D-A7B6-6EB99DE8547D}.Release|Any CPU.Build.0 = Release|Any CPU
{86015C9C-DEBA-4C2E-B9EF-872C88ED7D6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86015C9C-DEBA-4C2E-B9EF-872C88ED7D6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86015C9C-DEBA-4C2E-B9EF-872C88ED7D6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86015C9C-DEBA-4C2E-B9EF-872C88ED7D6C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {17904F06-2926-4867-BF32-DB627052F52D}
EndGlobalSection
EndGlobal
23 changes: 9 additions & 14 deletions src/DynaWeb/Classes/Execution.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using RestSharp;
using DynaWeb.Properties;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace DynaWeb
{
Expand All @@ -16,7 +13,7 @@ public static class Execute
#region internal methods
private static WebResponse ClientRequestMethod(WebClient webClient, WebRequest webRequest)
{
if (webRequest == null) throw new ArgumentNullException(DynaWeb.Properties.Resources.WebClientRequestNullMessage);
if (webRequest == null) throw new ArgumentNullException(Resources.WebClientRequestNullMessage);
// build a client & request to execute
WebClient client;
WebRequest request = webRequest;
Expand All @@ -39,16 +36,15 @@ private static WebResponse ClientRequestMethod(WebClient webClient, WebRequest w
try
{
var uri = WebClient.BuildUri(client, request);
if (string.IsNullOrEmpty(uri) || DynaWeb.Helpers.CheckURI(Helpers.ParseUriFromString(uri)) != true)
if (string.IsNullOrEmpty(uri) || !Helpers.IsUrlValid(Helpers.ParseUriFromString(uri)))
{
//TODO : error handling here is limited, needs checking and expanding.
throw new InvalidOperationException("Malformed URL.");
throw new InvalidOperationException();
}
}
catch (Exception e)
{
throw new InvalidOperationException(
DynaWeb.Properties.Resources.WebClientBuildUrlFailed +
Resources.WebClientBuildUrlFailed +
Environment.NewLine +
"Error returned was :" + Environment.NewLine +
e.Message);
Expand All @@ -70,13 +66,12 @@ private static WebResponse ClientRequestMethod(WebClient webClient, WebRequest w
switch (responseFromServer.ResponseStatus)
{
case ResponseStatus.None:
throw new InvalidOperationException(DynaWeb.Properties.Resources.WebResponseNetworkErrorMessage);
case ResponseStatus.Error:
throw new InvalidOperationException(DynaWeb.Properties.Resources.WebResponseNetworkErrorMessage);
throw new InvalidOperationException(Resources.WebResponseNetworkErrorMessage);
case ResponseStatus.TimedOut:
throw new InvalidOperationException(DynaWeb.Properties.Resources.WebRequestTimedOutMessage);
throw new InvalidOperationException(Resources.WebRequestTimedOutMessage);
case ResponseStatus.Aborted:
throw new InvalidOperationException(DynaWeb.Properties.Resources.WebResponseAbortedMessage);
throw new InvalidOperationException(Resources.WebResponseAbortedMessage);
default:
break;
}
Expand Down
5 changes: 3 additions & 2 deletions src/DynaWeb/Classes/WebClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Autodesk.DesignScript.Runtime;
using RestSharp;
using System;
using DynaWeb.Properties;

namespace DynaWeb
{
Expand Down Expand Up @@ -164,7 +165,7 @@ public static WebResponse Execute(WebClient client, WebRequest request)
/// <returns>A string representation of the assembly Uri</returns>
public static string BuildUri(WebClient client, WebRequest request)
{
if (request == null) throw new ArgumentNullException(DynaWeb.Properties.Resources.WebClientRequestNullMessage);
if (request == null) throw new ArgumentNullException(Resources.WebClientRequestNullMessage);

return client.restClient.BuildUri(request.restRequest).ToString();
}
Expand All @@ -178,7 +179,7 @@ public static string BuildUri(WebClient client, WebRequest request)
public WebClient SetBaseURL(string url)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentNullException(DynaWeb.Properties.Resources.WebClientUrlNullMessage);
if (!Helpers.CheckURI(Helpers.ParseUriFromString(url))) throw new ArgumentNullException(DynaWeb.Properties.Resources.WebUrlInvalidMessage);
if (!Helpers.IsUrlValid(Helpers.ParseUriFromString(url))) throw new ArgumentNullException(DynaWeb.Properties.Resources.WebUrlInvalidMessage);
this.BaseUrl = Helpers.ParseUriFromString(url);
return this;
}
Expand Down
7 changes: 4 additions & 3 deletions src/DynaWeb/Classes/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net;
using System.Collections.Specialized;
using System.IO;
using DynaWeb.Properties;

namespace DynaWeb
{
Expand Down Expand Up @@ -414,11 +415,11 @@ public WebRequest AddObject(object obj)
public WebRequest AddParameter(string name, object value, string parameterType)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("Name parameter cannot be null.");
throw new ArgumentNullException("name");
if (value.Equals(null))
throw new ArgumentNullException("Value parameter cannot be null.");
throw new ArgumentNullException("value");
if (Enum.TryParse<ParameterType>(parameterType, true, out ParameterType pType) == false)
throw new ArgumentException("Could not parse the supplied value into a valid Parameter Type.");
throw new ArgumentException("value", Resources.WebRequestParameterValueInvalid);

try
{
Expand Down
2 changes: 1 addition & 1 deletion src/DynaWeb/Classes/WebResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<List<string>> Cookies
values.Add(cookie.Value);
values.Add(cookie.TimeStamp.ToString());

result.Add(new List<string>() { "Name", "Value", "TimeStamp" });
result.Add(new List<string> { "Name", "Value", "TimeStamp" });
result.Add(values);
}

Expand Down
Loading

0 comments on commit fe54ecf

Please sign in to comment.