Permalink
Browse files

Merge branch 'dev' of github.com:/EventStore/EventStore into dev

  • Loading branch information...
2 parents a4acb1f + ab0c0ed commit 32f874ce37a839d6aed8235696356fd6fe66349f @anakryiko anakryiko committed Nov 13, 2012
@@ -1,37 +0,0 @@
-// Copyright (c) 2012, Event Store LLP
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-// Neither the name of the Event Store LLP nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-namespace EventStore.ClientAPI
-{
- public enum Mode
- {
- FullConsistency,
- ConsistentWrites,
- ConsistentReads,
- }
-}
@@ -86,7 +86,6 @@
<Compile Include="ClientOperations\TransactionalWriteOperation.cs" />
<Compile Include="Common\Log\DefaultLogger.cs" />
<Compile Include="Common\Utils\Tasks.cs" />
- <Compile Include="ConnectionSettings.cs" />
<Compile Include="Connection\ClusterExplorer.cs" />
<Compile Include="Connection\ProjectionsManager.cs" />
<Compile Include="Connection\Subscription.cs" />
@@ -38,20 +38,45 @@ public static class HttpClientMessageDto
{
#region HTTP DTO
- [XmlType(TypeName = "event")]
- public class ClientEventText
+ public class ClientEventDynamic
{
public Guid EventId { get; set; }
public string EventType { get; set; }
public object Data { get; set; }
public object Metadata { get; set; }
+ }
+
+ public class WriteEventsDynamic
+ {
+ public int ExpectedVersion { get; set; }
+ public ClientEventDynamic[] Events { get; set; }
+
+ public WriteEventsDynamic()
+ {
+ }
+
+ public WriteEventsDynamic(int expectedVersion, ClientEventDynamic[] events)
+ {
+ ExpectedVersion = expectedVersion;
+ Events = events;
+ }
+ }
+
+ [XmlType(TypeName = "event")]
+ public class ClientEventText
+ {
+ public Guid EventId { get; set; }
+ public string EventType { get; set; }
+
+ public string Data { get; set; }
+ public string Metadata { get; set; }
public ClientEventText()
{
}
- public ClientEventText(Guid eventId, string eventType, object data, object metadata)
+ public ClientEventText(Guid eventId, string eventType, string data, string metadata)
{
Ensure.NotEmptyGuid(eventId, "eventId");
Ensure.NotNull(data, "data");
@@ -80,7 +80,7 @@ public static string SmartFormat(ClientMessage.ReadEventCompleted completed, ICo
return targetCodec.To(dto);
}
- private static HttpClientMessageDto.WriteEventsText Load(string s, ICodec sourceCodec)
+ private static HttpClientMessageDto.WriteEventsDynamic Load(string s, ICodec sourceCodec)
{
var requestType = sourceCodec.ContentType;
@@ -92,12 +92,12 @@ private static HttpClientMessageDto.WriteEventsText Load(string s, ICodec source
return null;
}
- private static HttpClientMessageDto.WriteEventsText LoadFromJson(string json)
+ private static HttpClientMessageDto.WriteEventsDynamic LoadFromJson(string json)
{
- return Codec.Json.From<HttpClientMessageDto.WriteEventsText>(json);
+ return Codec.Json.From<HttpClientMessageDto.WriteEventsDynamic>(json);
}
- private static HttpClientMessageDto.WriteEventsText LoadFromXml(string xml)
+ private static HttpClientMessageDto.WriteEventsDynamic LoadFromXml(string xml)
{
try
{
@@ -123,8 +123,8 @@ private static HttpClientMessageDto.WriteEventsText LoadFromXml(string xml)
element.RemoveAttributes();
var json = JsonConvert.SerializeXNode(doc, Formatting.None, false);
- var textEvents = JsonConvert.DeserializeObject<JObject>(json)["write-events"]["Events"].ToObject<HttpClientMessageDto.ClientEventText[]>();
- return new HttpClientMessageDto.WriteEventsText(int.Parse(expectedVersion.Value), textEvents.ToArray());
+ var dynamicEvents = JsonConvert.DeserializeObject<JObject>(json)["write-events"]["Events"].ToObject<HttpClientMessageDto.ClientEventDynamic[]>();
+ return new HttpClientMessageDto.WriteEventsDynamic(int.Parse(expectedVersion.Value), dynamicEvents.ToArray());
}
catch (Exception e)
{
@@ -133,10 +133,10 @@ private static HttpClientMessageDto.WriteEventsText LoadFromXml(string xml)
}
}
- private static Event[] Parse(HttpClientMessageDto.ClientEventText[] textEvents)
+ private static Event[] Parse(HttpClientMessageDto.ClientEventDynamic[] dynamicEvents)
{
- var events = new List<Event>(textEvents.Length);
- foreach (var textEvent in textEvents)
+ var events = new List<Event>(dynamicEvents.Length);
+ foreach (var textEvent in dynamicEvents)
{
bool dataIsJson;
bool metadataIsJson;
@@ -31,7 +31,6 @@
using EventStore.Core.Messages;
using EventStore.Core.Messaging;
using EventStore.Core.Services.Storage.ReaderIndex;
-using EventStore.Transport.Http;
using EventStore.Transport.Http.EntityManagement;
namespace EventStore.Core.Services.Transport.Http
@@ -146,22 +145,6 @@ public static string TextMessage(HttpEntity entity, Message message)
return textMessage != null ? entity.ResponseCodec.To(textMessage) : string.Empty;
}
- public static string WriteEvents(ICodec codec, Message message)
- {
- Debug.Assert(message.GetType() == typeof (ClientMessage.WriteEvents));
-
- var writeEvents = message as ClientMessage.WriteEvents;
- if (writeEvents == null)
- return string.Empty;
-
- return codec.To(new HttpClientMessageDto.WriteEventsText(
- writeEvents.ExpectedVersion,
- writeEvents.Events.Select(e => new HttpClientMessageDto.ClientEventText(e.EventId,
- e.EventType,
- e.Data,
- e.Metadata)).ToArray()));
- }
-
public static string WriteEventsCompleted(HttpEntity entity, Message message)
{
Debug.Assert(message.GetType() == typeof(ClientMessage.WriteEventsCompleted));
@@ -65,15 +65,15 @@ public bool Execute(CommandProcessorContext context, string[] args)
var url = context.Client.HttpEndpoint.ToHttpUrl("/streams/{0}", eventStreamId);
context.Log.Info("Writing to {0}...", url);
- var request = Codec.Json.To(new HttpClientMessageDto.WriteEventsText(
+ var request = Codec.Xml.To(new HttpClientMessageDto.WriteEventsText(
expectedVersion,
new[] { new HttpClientMessageDto.ClientEventText(Guid.NewGuid(), "type", data, metadata) }));
var sw = Stopwatch.StartNew();
client.Post(
url,
request,
- Codec.Json.ContentType,
+ Codec.Xml.ContentType,
response =>
{
sw.Stop();

0 comments on commit 32f874c

Please sign in to comment.