Skip to content
Closed
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
6 changes: 4 additions & 2 deletions tik4net/Api/ApiCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ private IEnumerable<ApiSentence> EnsureApiSentences(IEnumerable<ITikSentence> se

private ApiSentence EnsureSingleResponse(IEnumerable<ApiSentence> response)
{
if (response.Count() != 1)
if (response.Count(x => !(x.Words.Count() == 1 && x.Words.ContainsKey(".section"))) != 1)
throw new TikCommandUnexpectedResponseException("Single response sentence expected.", this, response.Cast<ITikSentence>());

return response.Single();
return response.Last();
}

private void EnsureOneReAndDone(IEnumerable<ApiSentence> response)
Expand Down Expand Up @@ -403,6 +403,8 @@ private IEnumerable<ITikReSentence> ExecuteListInternal(params string[] proplist
EnsureReReponse(response.Take(response.Count() - 1).ToArray()); //!re - reapeating
EnsureDoneResponse(response.Last()); //!done

if (response.First() is ApiEmptySentence)
return new List<ITikReSentence>();
return response.Take(response.Count() - 1).Cast<ITikReSentence>().ToList();
}
finally
Expand Down
1 change: 1 addition & 0 deletions tik4net/Api/ApiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ private ITikSentence ReadSentence()
case "!trap": return new ApiTrapSentence(sentenceWords);
case "!re": return new ApiReSentence(sentenceWords);
case "!fatal": return new ApiFatalSentence(sentenceWords);
case "!empty": return new ApiEmptySentence();
case "": throw new IOException("Can not read sentence from connection"); // With SSL possibly not logged in (SSL and new router with SSL_V2)
default: throw new NotImplementedException(string.Format("Response type '{0}' not supported", sentenceName));
}
Expand Down
25 changes: 25 additions & 0 deletions tik4net/Api/ApiEmptySentence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace tik4net.Api
{
internal class ApiEmptySentence : ApiReSentence, ITikDoneSentence
{
public ApiEmptySentence()
: base(Array.Empty<string>())
{
}

public string GetResponseWord()
{
return GetWordValue(TikSpecialProperties.Ret);
}

public string GetResponseWordOrDefault(string defaultValue)
{
return GetWordValueOrDefault(TikSpecialProperties.Ret, defaultValue);
}
}
}
2 changes: 1 addition & 1 deletion tik4net/Api/ApiSentence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public string Tag

public ApiSentence(IEnumerable<string> words)
{
Regex keyValueRegex = new Regex("^=?(?<KEY>[^=]+)=(?<VALUE>.+)$", RegexOptions.Singleline);
Regex keyValueRegex = new Regex("^=?(?<KEY>[^=]+)=(?<VALUE>.*)$", RegexOptions.Singleline);
foreach(string word in words)
{
Match match = keyValueRegex.Match(word);
Expand Down
6 changes: 6 additions & 0 deletions tik4net/tik4net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@
<DefineConstants>TRACE;DEBUG</DefineConstants>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<PackageId>SinisterDev.Tik4Net</PackageId>
<Version>3.5.2-pre</Version>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
</PropertyGroup>

</Project>