Skip to content

Commit

Permalink
Merge pull request #127 from Code-Sharp/develop
Browse files Browse the repository at this point in the history
Making contracts serializable
  • Loading branch information
darkl committed Mar 12, 2016
2 parents 71396ff + d5e3437 commit 7bfc94c
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/mono/WampSharp/WampSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@
<Compile Include="..\..\net45\WampSharp\Core\Utilities\Method.cs">
<Link>Core\Utilities\Method.cs</Link>
</Compile>
<Compile Include="..\..\net45\WampSharp\Core\Utilities\SerializableAttribute.cs">
<Link>Core\Utilities\SerializableAttribute.cs</Link>
</Compile>
<Compile Include="..\..\net45\WampSharp\Core\Utilities\ReadOnlyDictionary.cs">
<Link>Core\Utilities\ReadOnlyDictionary.cs</Link>
</Compile>
Expand Down
3 changes: 3 additions & 0 deletions src/net40/WampSharp/WampSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@
<Compile Include="..\..\net45\WampSharp\Core\Utilities\Method.cs">
<Link>Core\Utilities\Method.cs</Link>
</Compile>
<Compile Include="..\..\net45\WampSharp\Core\Utilities\SerializableAttribute.cs">
<Link>Core\Utilities\SerializableAttribute.cs</Link>
</Compile>
<Compile Include="..\..\net45\WampSharp\Core\Utilities\ReadOnlyDictionary.cs">
<Link>Core\Utilities\ReadOnlyDictionary.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

namespace WampSharp.V1
{
#if !PCL
[Serializable]
#endif
public class WampRequestContext
{
#region Static Members
Expand Down
16 changes: 16 additions & 0 deletions src/net45/WampSharp/Core/Utilities/SerializableAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if PCL

namespace System
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal sealed class SerializableAttribute : Attribute
{
}

[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)]
internal sealed class NonSerializedAttribute : Attribute
{
}
}

#endif
2 changes: 0 additions & 2 deletions src/net45/WampSharp/WAMP2/V2/Api/WampEventContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ namespace WampSharp.V2
/// <summary>
/// Includes information about the current event.
/// </summary>
#if !PCL
[Serializable]
#endif
public class WampEventContext
{

Expand Down
2 changes: 0 additions & 2 deletions src/net45/WampSharp/WAMP2/V2/Api/WampInvocationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ namespace WampSharp.V2
/// <summary>
/// Includes information about the current invocation.
/// </summary>
#if !PCL
[Serializable]
#endif
public class WampInvocationContext
{
#region Static Members
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ namespace WampSharp.V2.Authentication
/// An exception that can be thrown if can't authenticate with router.
/// This sends an ABORT message to the router.
/// </summary>
#if !PCL
[Serializable]
#endif
public class WampAuthenticationException : Exception
{
protected const string DefaultMessage = "sorry, I cannot authenticate (onchallenge handler raised an exception)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ namespace WampSharp.V2.Client
/// Occurs when an CHALLENGE message has been received,
/// but no <see cref="IWampClientAuthenticator"/> has been provided.
/// </summary>
#if !PCL
[Serializable]
#endif
public class WampAuthenticationNotImplementedException : WampAuthenticationException
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

namespace WampSharp.V2.Client
{
#if !PCL
[Serializable]
#endif
public class WampSessionNotEstablishedException : Exception
{
public WampSessionNotEstablishedException() : this("No connection to router is currently available.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

Expand All @@ -7,6 +8,7 @@ namespace WampSharp.V2.Core.Contracts
/// Represents details for EVENT message.
/// </summary>
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Event)]
public class EventDetails : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Publish)]
public class PublishOptions : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
public class PublishOptionsExtended : PublishOptions
{
public PublishOptionsExtended(PublishOptions options) : base(options)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Subscribe)]
public class SubscribeOptions : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Call)]
public class CallOptions : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Cancel)]
public class CancelOptions : WampDetailsOptions
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Invocation)]
public class InvocationDetails : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Runtime.Serialization;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
public class InvocationDetailsExtended : InvocationDetails
{
public InvocationDetailsExtended()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Register)]
public class RegisterOptions : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Result)]
public class ResultDetails : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Yield)]
public class YieldOptions : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
/// <summary>
/// Represents details of an ABORT message.
/// </summary>
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Abort)]
public class AbortDetails : GoodbyeAbortDetails
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Authenticate)]
public class AuthenticateExtraData : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Challenge)]
public class ChallengeDetails : WampDetailsOptions
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Runtime.Serialization;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
public abstract class GoodbyeAbortDetails : WampDetailsOptions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
/// <summary>
/// Represents details of a GOODBYE message.
/// </summary>
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Goodbye)]
public class GoodbyeDetails : GoodbyeAbortDetails
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;
using WampSharp.V2.MetaApi;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Hello)]
public class HelloDetails : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;
using WampSharp.Core.Message;

namespace WampSharp.V2.Core.Contracts
{
[DataContract]
[Serializable]
[WampDetailsOptions(WampMessageType.v2Welcome)]
public class WelcomeDetails : WampDetailsOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace WampSharp.V2.Core.Contracts
{
#if !PCL
[Serializable]
#endif
public class WampConnectionBrokenException : Exception
{
private readonly WampSessionCloseEventArgs mEventArgs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;

namespace WampSharp.V2.Core.Contracts
{
/// <summary>
/// An abstract class for WampDetails/WampOptions types.
/// </summary>
[Serializable]
[DataContract]
public abstract class WampDetailsOptions
{
[NonSerialized]
private ISerializedValue mOriginalValue;

/// <summary>
/// The original (serialized) received value.
/// </summary>
[IgnoreDataMember]
public ISerializedValue OriginalValue
{
get;
set;
get { return mOriginalValue; }
set { mOriginalValue = value; }
}
}
}
2 changes: 0 additions & 2 deletions src/net45/WampSharp/WAMP2/V2/Core/Contracts/WampException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

namespace WampSharp.V2.Core.Contracts
{
#if !PCL
[Serializable]
#endif
public class WampException : Exception
{
private readonly string mErrorUri;
Expand Down
2 changes: 0 additions & 2 deletions src/net45/WampSharp/WAMP2/V2/Rpc/WampRpcRuntimeException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

namespace WampSharp.V2.Rpc
{
#if !PCL
[Serializable]
#endif
public class WampRpcRuntimeException : WampException
{
private const string ErrorUri = "wamp.error.runtime_error";
Expand Down
Loading

0 comments on commit 7bfc94c

Please sign in to comment.