Permalink
Browse files

Remove the resources file and move all the config section to Consts.c…

…s file. (resources file are not supported by .net core).
  • Loading branch information...
Copyleaks committed Aug 20, 2018
1 parent 815058a commit 1aa1317b8d87a3587ea10c76f7ecc9780169e1b7
@@ -157,3 +157,4 @@ $RECYCLE.BIN/
Nuget
*.nupkg
/.vs/SDK
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Copyleaks.SDK.API
{
public static class Consts
{
public static string AccountPage = "account";
public static string BusinessesServicePage = "businesses";
public static string EducationServicePage = "education";
public static string MiscellaneousServicePage = "miscellaneous";
public static int RequestsTimeout = 60000; // In Milliseconds. Wait up to 60 seconds to response.
public static string ServiceEntryPoint = "https://api.copyleaks.com/";
public static string ServiceVersion = "v1";
public static string WebsitesServicePage = "websites";
}
}
@@ -41,6 +41,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="Consts.cs" />
<Compile Include="CopyleaksCloud.cs" />
<Compile Include="eProduct.cs" />
<Compile Include="Extentions\ProductHelpers.cs" />
@@ -65,20 +66,9 @@
<Compile Include="Models\ResultRecord.cs" />
<Compile Include="Models\SupportedFileTypes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="CopyleaksProcess.cs" />
<Compile Include="UsersAuthentication.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
@@ -33,7 +33,6 @@
using Copyleaks.SDK.API.Models;
using Copyleaks.SDK.API.Models.Requests;
using Copyleaks.SDK.API.Models.Responses;
using Copyleaks.SDK.API.Properties;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@@ -92,7 +91,7 @@ public uint Credits
{
client.SetCopyleaksClient(HttpContentTypes.Json, this.Token);
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/count-credits", Resources.ServiceVersion, this.Product.ToName())).Result;
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/count-credits", Consts.ServiceVersion, this.Product.ToName())).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -126,7 +125,7 @@ public CopyleaksProcess[] Processes
{
client.SetCopyleaksClient(HttpContentTypes.Json, this.Token);
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/list", Resources.ServiceVersion, this.Product.ToName())).Result;
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/list", Consts.ServiceVersion, this.Product.ToName())).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -204,7 +203,7 @@ public CopyleaksProcess CreateByUrl(Uri url, ProcessOptions options = null)
if (options != null)
options.AddHeaders(client);
msg = client.PostAsync(string.Format("{0}/{1}/{2}", Resources.ServiceVersion, this.Product.ToName(), "create-by-url"), content).Result;
msg = client.PostAsync(string.Format("{0}/{1}/{2}", Consts.ServiceVersion, this.Product.ToName(), "create-by-url"), content).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -261,7 +260,7 @@ public CopyleaksProcess CreateByFile(FileInfo localfile, ProcessOptions options
using (FileStream stream = localfile.OpenRead())
{
content.Add(new StreamContent(stream, (int)stream.Length), "document", Path.GetFileName(localfile.Name));
msg = client.PostAsync(string.Format("{0}/{1}/create-by-file", Resources.ServiceVersion, this.Product.ToName()), content).Result;
msg = client.PostAsync(string.Format("{0}/{1}/create-by-file", Consts.ServiceVersion, this.Product.ToName()), content).Result;
}
if (!msg.IsSuccessStatusCode)
@@ -371,7 +370,7 @@ public CopyleaksProcess CreateByOcr(FileInfo localfile, string ocrLanguage, Proc
{
content.Add(new StreamContent(stream, (int)stream.Length), "document", Path.GetFileName(localfile.Name));
msg = client.PostAsync(
string.Format("{0}/{1}/create-by-file-ocr?language={2}", Resources.ServiceVersion, this.Product.ToName(), Uri.EscapeDataString(ocrLanguage)),
string.Format("{0}/{1}/create-by-file-ocr?language={2}", Consts.ServiceVersion, this.Product.ToName(), Uri.EscapeDataString(ocrLanguage)),
content).Result;
}
@@ -417,7 +416,7 @@ public CopyleaksProcess CreateByText(string text, ProcessOptions options = null)
if (options != null)
options.AddHeaders(client);
msg = client.PostAsync(string.Format("{0}/{1}/{2}", Resources.ServiceVersion, this.Product.ToName(), "create-by-text"), content).Result;
msg = client.PostAsync(string.Format("{0}/{1}/{2}", Consts.ServiceVersion, this.Product.ToName(), "create-by-text"), content).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -452,7 +451,7 @@ public static string[] SupportedOcrLanguages
{
client.SetCopyleaksClient(HttpContentTypes.Json);
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/ocr-languages-list", Resources.ServiceVersion, Resources.MiscellaneousServicePage)).Result;
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/ocr-languages-list", Consts.ServiceVersion, Consts.MiscellaneousServicePage)).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -477,7 +476,7 @@ public static SupportedFileTypes SupportedFileTypes
{
client.SetCopyleaksClient(HttpContentTypes.Json);
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/supported-file-types", Resources.ServiceVersion, Resources.MiscellaneousServicePage)).Result;
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/supported-file-types", Consts.ServiceVersion, Consts.MiscellaneousServicePage)).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -32,7 +32,6 @@
using Copyleaks.SDK.API.Helpers;
using Copyleaks.SDK.API.Models;
using Copyleaks.SDK.API.Models.Responses;
using Copyleaks.SDK.API.Properties;
using Newtonsoft.Json;
namespace Copyleaks.SDK.API
@@ -106,7 +105,7 @@ public bool IsCompleted(out ushort currentProgress)
HttpResponseMessage msg;
msg = Retry.Http<HttpResponseMessage>(
() => client.GetAsync(string.Format("{0}/{1}/{2}/status", Resources.ServiceVersion, this.Product.ToName(), this.PID)).Result,
() => client.GetAsync(string.Format("{0}/{1}/{2}/status", Consts.ServiceVersion, this.Product.ToName(), this.PID)).Result,
TimeSpan.FromSeconds(3),
3);
@@ -135,7 +134,7 @@ public ResultRecord[] GetResults()
{
client.SetCopyleaksClient(HttpContentTypes.Json, this.SecurityToken);
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/{2}/result", Resources.ServiceVersion, this.Product.ToName(), this.PID)).Result;
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/{1}/{2}/result", Consts.ServiceVersion, this.Product.ToName(), this.PID)).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -154,7 +153,7 @@ public Stream DownloadSourceText()
{
client.SetCopyleaksClient(HttpContentTypes.Json, this.SecurityToken);
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/downloads/source-text?pid={1}", Resources.ServiceVersion, this.PID)).Result;
HttpResponseMessage msg = client.GetAsync(string.Format("{0}/downloads/source-text?pid={1}", Consts.ServiceVersion, this.PID)).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
@@ -207,7 +206,7 @@ public void Delete()
{
client.SetCopyleaksClient(HttpContentTypes.Json, this.SecurityToken);
HttpResponseMessage msg = client.DeleteAsync(string.Format("{0}/{1}/{2}/delete", Resources.ServiceVersion, this.Product.ToName(), this.PID)).Result;
HttpResponseMessage msg = client.DeleteAsync(string.Format("{0}/{1}/{2}/delete", Consts.ServiceVersion, this.Product.ToName(), this.PID)).Result;
if (!msg.IsSuccessStatusCode)
throw new CommandFailedException(msg);
}
@@ -27,7 +27,6 @@
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading;
using Copyleaks.SDK.API.Properties;
namespace Copyleaks.SDK.API.Extentions
{
@@ -37,9 +36,9 @@ internal static class HttpClientHelper
public static void SetCopyleaksClient(this HttpClient client, string contentType)
{
client.BaseAddress = new Uri(Resources.ServiceEntryPoint);
client.BaseAddress = new Uri(Consts.ServiceEntryPoint);
client.Timeout = TimeSpan.FromMilliseconds(int.Parse(Resources.RequestsTimeout));
client.Timeout = TimeSpan.FromMilliseconds(Consts.RequestsTimeout);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(contentType));
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Copyleaks.SDK.API.Properties;
namespace Copyleaks.SDK.API.Extentions
{
@@ -14,11 +9,11 @@ public static string ToName(this eProduct product)
switch (product)
{
case eProduct.Businesses:
return Resources.BusinessesServicePage;
return Consts.BusinessesServicePage;
case eProduct.Education:
return Resources.EducationServicePage;
return Consts.EducationServicePage;
case eProduct.Websites:
return Resources.WebsitesServicePage;
return Consts.WebsitesServicePage;
default:
throw new ArgumentOutOfRangeException();
}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 1aa1317

Please sign in to comment.