blob: 23b67be267879e9a68e9fac8b18fa93ce9ce4a80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
//-----------------------------------------------------------------------
// <copyright file="TestMessage.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.Mocks {
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Reflection;
internal abstract class TestMessage : IDirectResponseProtocolMessage {
private MessageTransport transport;
private Dictionary<string, string> extraData = new Dictionary<string, string>();
protected TestMessage()
: this(MessageTransport.Direct) {
}
protected TestMessage(MessageTransport transport) {
this.transport = transport;
}
[MessagePart("age", IsRequired = true)]
public int Age { get; set; }
[MessagePart("Name")]
public string Name { get; set; }
[MessagePart]
public string EmptyMember { get; set; }
[MessagePart(null)] // null name tests that Location is still the name.
public Uri Location { get; set; }
[MessagePart(IsRequired = true)]
public DateTime Timestamp { get; set; }
#region IProtocolMessage Properties
Version IMessage.Version {
get { return new Version(1, 0); }
}
MessageProtections IProtocolMessage.RequiredProtection {
get { return MessageProtections.None; }
}
MessageTransport IProtocolMessage.Transport {
get { return this.transport; }
}
IDictionary<string, string> IMessage.ExtraData {
get { return this.extraData; }
}
#endregion
#region IDirectResponseProtocolMessage Members
public IDirectedProtocolMessage OriginatingRequest { get; set; }
#endregion
#region IMessage Methods
void IMessage.EnsureValidMessage() {
if (this.EmptyMember != null || this.Age < 0) {
throw new ProtocolException();
}
}
#endregion
}
}
|