Skip to content

Commit 6acb1a2

Browse files
author
William Spitzer
committed
Fixed up small bugs and updated examples
1 parent f82b999 commit 6acb1a2

27 files changed

+12176
-38
lines changed

.gitattributes

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

csharp/rosette_api/CAPI.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ public Dictionary<string, object> TranslatedName(string name, string sourceLangu
702702
{ "targetScheme", targetScheme},
703703
{ "sourceLanguageOfOrigin", sourceLanguageOfOrigin},
704704
{ "entityType", entityType}
705-
}.Where(f => String.IsNullOrEmpty(f.Value.ToString())).ToDictionary(x => x.Key, x => x.Value)));
705+
}.Where(f => !String.IsNullOrEmpty(f.Value)).ToDictionary(x => x.Key, x => x.Value)));
706706
}
707707

708708
/// <summary>TranslatedName
@@ -749,6 +749,10 @@ private Dictionary<string, Object> getResponse(HttpClient client, string jsonReq
749749

750750
while (responseMsg == null || (!responseMsg.IsSuccessStatusCode && retry <= MaxRetry))
751751
{
752+
if (retry > 0)
753+
{
754+
System.Threading.Thread.Sleep(500);
755+
}
752756
if (jsonRequest != null)
753757
{
754758
HttpContent content = new StringContent(jsonRequest);
@@ -829,13 +833,13 @@ private Dictionary<string, Object> Process(string content = null, string languag
829833
unit = "doc";
830834
}
831835

832-
Dictionary<string, object> dict = new Dictionary<string, object>(){
836+
Dictionary<string, string> dict = new Dictionary<string, string>(){
833837
{ "language", language},
834838
{ "content", content},
835839
{ "contentType", contentType},
836840
{ "unit", unit},
837841
{ "contentUri", contentUri}
838-
}.Where(f => String.IsNullOrEmpty(f.Value.ToString())).ToDictionary(x => x.Key, x => x.Value);
842+
}.Where(f => !String.IsNullOrEmpty(f.Value)).ToDictionary(x => x.Key, x => x.Value);
839843

840844
return getResponse(SetupClient(), new JavaScriptSerializer().Serialize(dict));
841845
}
@@ -912,6 +916,10 @@ private bool checkVersion(string versionToCheck = null)
912916

913917
while (responseMsg == null || (!responseMsg.IsSuccessStatusCode && retry <= MaxRetry))
914918
{
919+
if (retry > 0)
920+
{
921+
System.Threading.Thread.Sleep(500);
922+
}
915923
responseMsg = client.GetAsync("info/").Result;
916924
retry = retry + 1;
917925
}

csharp/rosette_api/rosette_api.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProjectGuid>{D719A8A7-C5C7-49CF-BFFC-523D605E5E37}</ProjectGuid>
8-
<OutputType>Library</OutputType>
8+
<OutputType>WinExe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>rosette_api</RootNamespace>
1111
<AssemblyName>rosette_api</AssemblyName>

0 commit comments

Comments
 (0)