Skip to content
Snippets Groups Projects
Commit 1b286335 authored by brewdente's avatar brewdente
Browse files

Only lower case the first letter of the property. If there is an error, no...

Only lower case the first letter of the property.  If there is an error, no request id, and there is only 1 request, then we know what to do.  Renaming the file for the EVentHandler.
parent b0759f1c
Branches
Tags
No related merge requests found
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<Compile Include="CommandResponse.cs" /> <Compile Include="CommandResponse.cs" />
<Compile Include="CommandResponseAttribute.cs" /> <Compile Include="CommandResponseAttribute.cs" />
<Compile Include="CommandResponseFactory.cs" /> <Compile Include="CommandResponseFactory.cs" />
<Compile Include="CommandResponseHandler.cs" /> <Compile Include="EventHandler.cs" />
<Compile Include="ErrorResponse.cs" /> <Compile Include="ErrorResponse.cs" />
<Compile Include="Event.cs" /> <Compile Include="Event.cs" />
<Compile Include="EventAttribute.cs" /> <Compile Include="EventAttribute.cs" />
......
...@@ -131,6 +131,18 @@ namespace ChromeDevTools ...@@ -131,6 +131,18 @@ namespace ChromeDevTools
_responses.AddOrUpdate(response.Id, id => response, (key, value) => response); _responses.AddOrUpdate(response.Id, id => response, (key, value) => response);
requestMre.Set(); requestMre.Set();
} }
else
{
// in the case of an error, we don't always get the request Id back :(
// if there is only one pending requests, we know what to do ... otherwise
if (1 == _requestWaitHandles.Count)
{
var requestId = _requestWaitHandles.Keys.First();
_requestWaitHandles.TryGetValue(requestId, out requestMre);
_responses.AddOrUpdate(requestId, id => response, (key, value) => response);
requestMre.Set();
}
}
} }
private Task<ICommandResponse> SendCommand(Command command) private Task<ICommandResponse> SendCommand(Command command)
......
using System; using Newtonsoft.Json.Serialization;
using System.Collections.Generic; using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Serialization;
namespace ChromeDevTools.Serialization namespace ChromeDevTools.Serialization
{ {
class MessageContractResolver : DefaultContractResolver internal class MessageContractResolver : DefaultContractResolver
{ {
protected override string ResolvePropertyName(string propertyName) protected override string ResolvePropertyName(string propertyName)
{ {
return propertyName.ToLower(); if (String.IsNullOrEmpty(propertyName))
{
return propertyName;
}
if (1 == propertyName.Length)
{
return Char.ToLowerInvariant(propertyName[0]).ToString();
}
return Char.ToLowerInvariant(propertyName[0]) + propertyName.Substring(1);
} }
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment