Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IAsyncCallTesterContract
{
[OperationContract]
string Query (string query);
}
[ServiceBehavior (InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class AsyncCallTester : IAsyncCallTesterContract
{
public string Query (string query)
{
return query + query;
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Threading;
namespace MonoTests.Features.Contracts
{
// Define a service contract.
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IAsyncPattern
{
[OperationContractAttribute (AsyncPattern = true)]
IAsyncResult BeginAsyncMethod (AsyncCallback callback, object asyncState);
int EndAsyncMethod (IAsyncResult result);
// TODO: Need to investigate asyn methods that have ref/out params that are not necessarily first
// e.g. how does foo(in, ref, out, in) map to AsyncPattern?
}
public class AsyncPatternServer : IAsyncPattern
{
// Simple async result implementation.
class CompletedAsyncResult<T> : IAsyncResult
{
T data;
object state;
public CompletedAsyncResult (T data, object state) { this.data = data; this.state = state; }
public T Data { get { return data; } }
#region IAsyncResult Members
public object AsyncState { get { return (object) state; } }
public WaitHandle AsyncWaitHandle { get { throw new Exception ("The method or operation is not implemented."); } }
public bool CompletedSynchronously { get { return true; } }
public bool IsCompleted { get { return true; } }
#endregion
}
public IAsyncResult BeginAsyncMethod (AsyncCallback callback, object asyncState) {
IAsyncResult result = new CompletedAsyncResult<int> (3, asyncState);
new Thread (new ThreadStart (
delegate {
callback (result);
})).Start ();
return result;
}
public int EndAsyncMethod (IAsyncResult r) {
return ((CompletedAsyncResult<int>) r).Data;
}
}
}

View File

@@ -0,0 +1,19 @@
2008-04-07 Vladimir Krasnov <vladimirk@mainsoft.com>
* added: AsyncCallTester.cs
FaultsTester.cs
* fixed: MessageContractTester.cs
2008-04-06 Vladimir Krasnov <vladimirk@mainsoft.com>
* added UntypedMessageTester.cs
2008-04-06 Vladimir Krasnov <vladimirk@mainsoft.com>
* added: KnownTypeTester.cs
* removed 3.5 dependencies
2006-04-03 Roei Erez <roeie@ximian.com>
* DataContractTester.cs
MessageContractTester.cs
PrimitiveTester

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Runtime.Serialization;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Integrative.Contracts")]
public interface IDataContractTesterContract
{
[OperationContract]
ComplexPrimitiveClass Add (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2);
[OperationContract]
void AddByRef (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2, out ComplexPrimitiveClass result);
}
public class DataContractTester : IDataContractTesterContract
{
public ComplexPrimitiveClass Add (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2) {
n1._byte += n2._byte;
n1._sbyte += n2._sbyte;
n1._short += n2._short;
n1._ushort += n2._ushort;
n1._int += n2._int;
n1._uint += n2._uint;
n1._long += n2._long;
n1._ulong += n2._ulong;
n1._double += n2._double;
n1._float += n2._float;
return n1;
}
public void AddByRef (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2, out ComplexPrimitiveClass result) {
result = Add (n1, n2);
}
}
#region Class Data
[DataContract (Namespace = "http://MonoTests.Features.Client")]
public class ComplexPrimitiveClass
{
[DataMember(Name="byteMember")]
public byte _byte = 1;
[DataMember (Name = "sbyteMember")]
public sbyte _sbyte = 1;
[DataMember (Name = "shortMember")]
public short _short = 1;
[DataMember (Name = "ushortMember")]
public ushort _ushort = 1;
[DataMember (Name = "intMember")]
public int _int = 1;
[DataMember (Name = "uintMember")]
public uint _uint = 1;
[DataMember (Name = "longMember")]
public long _long = 1;
[DataMember (Name = "ulongMember")]
public ulong _ulong = 1;
[DataMember (Name = "doubleMember")]
public double _double = 1;
[DataMember (Name = "floatMember")]
public float _float = 1;
}
#endregion
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Threading;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IFirstContract
{
[OperationContract]
int FirstMethod ();
}
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface ISecondContract
{
[OperationContract]
int SecondMethod ();
}
public class DualContractServer : IFirstContract, ISecondContract
{
public int FirstMethod () { return 1; }
public int SecondMethod () { return 2; }
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Threading;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IExitProcessHelper
{
[OperationContract(IsOneWay=true)]
void ExitProcess (int code);
}
public class ExitProcessHelperServer : IExitProcessHelper
{
public void ExitProcess (int code) {
Environment.Exit (code);
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Web.Services.Description;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IFaultsTesterContract
{
[OperationContract]
void FaultMethod (string faultText);
}
public class FaultsTester : IFaultsTesterContract
{
public void FaultMethod (string faultText)
{
throw new Exception (faultText);
}
}
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IFaultsTesterContractIncludeDetails
{
[OperationContract]
void FaultMethod (string faultText);
}
[ServiceBehavior (IncludeExceptionDetailInFaults = true)]
public class FaultsTesterIncludeDetails : IFaultsTesterContractIncludeDetails
{
public void FaultMethod (string faultText)
{
throw new Exception (faultText);
}
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IKnownTypeTesterContract
{
[OperationContract]
Point2D Move (Point2D point, Point2D delta);
[OperationContract]
double Distance (Point2D point1, Point2D point2);
[OperationContract]
BaseContract [] foo ();
}
public class KnownTypeTester : IKnownTypeTesterContract
{
public Point2D Move (Point2D point, Point2D delta)
{
return new AdvPoint2D (point.X + delta.X, point.Y + delta.Y);
}
public double Distance (Point2D point1, Point2D point2)
{
return Math.Sqrt (Math.Abs (point1.X - point2.X) +
Math.Abs (point1.Y - point2.Y));
}
public BaseContract [] foo () {
return new BaseContract[] {new DerivedContract ()};
}
}
[DataContract (Namespace = "http://MonoTests.Features.Contracts")]
[KnownType (typeof (AdvPoint2D))]
public class Point2D
{
int x;
int y;
public Point2D () { }
public Point2D (int x, int y)
{
this.x = x;
this.y = y;
}
[DataMember]
public int X
{
get { return x; }
set { x = value; }
}
[DataMember]
public int Y
{
get { return y; }
set { y = value; }
}
}
[DataContract (Namespace = "http://MonoTests.Features.Contracts")]
public class AdvPoint2D : Point2D
{
public AdvPoint2D (int x, int y)
: base (x, y)
{
}
[DataMember]
public double ZeroDistance
{
get { return Math.Sqrt (X * X + Y * Y); }
set { }
}
}
[DataContract]
[KnownType (typeof (DerivedContract))]
public class BaseContract
{
[DataMember]
string name;
}
[DataContract]
public class DerivedContract : BaseContract
{
[DataMember]
bool blah;
}
}

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel.Description;
using System.ServiceModel;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IMessageContractTesterContract
{
[OperationContract (Action = "http://test/TestMessage_action", ReplyAction = "http://test/TestMessage_action")]
TestMessage FormatDate (TestMessage testMessage);
}
[MessageContract]
public class TestMessage
{
private string formatString;
private DateTime date;
private string formattedDate;
public TestMessage ()
{
}
public TestMessage (DateTime date, string formatString, string formattedDate)
{
this.date = date;
this.formatString = formatString;
this.formattedDate = formattedDate;
}
public TestMessage (TestMessage message)
{
this.date = message.date;
this.formatString = message.formatString;
this.formattedDate = message.formattedDate;
}
[MessageHeader]
public string FormatString
{
get { return formatString; }
set { formatString = value; }
}
[MessageBodyMember]
public DateTime Date
{
get { return date; }
set { date = value; }
}
[MessageBodyMember]
public string FormattedDate
{
get { return formattedDate; }
set { formattedDate = value; }
}
}
public class MessageContractTester : IMessageContractTesterContract
{
public TestMessage FormatDate (TestMessage testMessage)
{
TestMessage r = new TestMessage (testMessage);
r.FormattedDate = r.Date.ToString (r.FormatString);
return r;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Threading;
namespace MonoTests.Features.Contracts
{
// Define a service contract.
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IOperationContract
{
[OperationContract (Name = "RenamedMethod")]
int OrigMethod ();
[OperationContract (Name = "OrigMethod")]
int RenamedMethod ();
[OperationContract (IsOneWay = true)]
void Sleep (int mili);
}
public class OperationContractServer : IOperationContract
{
public int OrigMethod () { return 1; }
public int RenamedMethod () { return 2; }
public void Sleep(int mili)
{
Thread.Sleep(mili);
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
namespace MonoTests.Features.Contracts
{
// Define a service contract.
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IPrimitiveTesterContract
{
[OperationContract]
void DoNothing ();
[OperationContract]
int AddByte (byte n1, byte n2);
[OperationContract]
int AddSByte (sbyte n1, sbyte n2);
[OperationContract]
int AddShort (short n1, short n2);
[OperationContract]
int AddUShort (ushort n1, ushort n2);
[OperationContract]
int AddInt (int n1, int n2);
[OperationContract]
uint AddUInt (uint n1, uint n2);
[OperationContract]
long AddLong (long n1, long n2);
[OperationContract]
ulong AddULong (ulong n1, ulong n2);
[OperationContract]
double AddDouble (double n1, double n2);
[OperationContract]
float AddFloat (float n1, float n2);
[OperationContract]
char AddChar (char n1, char c2);
[OperationContract]
void AddByRef(double n1, double n2, out double n3, out double n4);
[OperationContract]
int? NullableInt (int? x);
[OperationContract]
float? NullableFloat (float? x);
[OperationContract]
TimeSpan AddTimeSpan (TimeSpan t1, TimeSpan t2);
[OperationContract]
byte [] AddByteArray (byte [] b1, byte [] b2);
}
public class PrimitiveTester : IPrimitiveTesterContract
{
public void DoNothing () {
}
public int AddByte (byte n1, byte n2) {
return (byte) n1 + n2;
}
public int AddSByte (sbyte n1, sbyte n2) {
return n1 + n2;
}
public int AddShort (short n1, short n2) {
return n1 + n2;
}
public int AddUShort (ushort n1, ushort n2) {
return n1 + n2;
}
public int AddInt (int n1, int n2) {
return n1 + n2;
}
public uint AddUInt (uint n1, uint n2) {
return n1 + n2;
}
public long AddLong (long n1, long n2) {
return n1 + n2;
}
public ulong AddULong (ulong n1, ulong n2) {
return n1 + n2;
}
public double AddDouble (double n1, double n2) {
return n1 + n2;
}
public float AddFloat (float n1, float n2) {
return n1 + n2;
}
public char AddChar (char n1, char n2) {
return (char)(n1 + n2);
}
public void AddByRef (double n1, double n2, out double n3, out double n4) {
n3 = n4 = n1 + n2;
}
public int? NullableInt(int?x) {
return x==null ? x : x+1;
}
public float? NullableFloat (float? x) {
return x == null ? x : x + 1;
}
public TimeSpan AddTimeSpan (TimeSpan t1, TimeSpan t2) {
return t1.Add (t2);
}
public byte [] AddByteArray (byte [] b1, byte [] b2) {
byte [] ret = new byte [b1.Length];
for (int i = 0; i < b1.Length; i++)
ret [i] = (byte) (b1 [i] + b2 [i]);
return ret;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
namespace MonoTests.Features.Contracts
{
[ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
public interface IUntypedMessageTesterContract
{
[OperationContract (Action = UntypedMessageTester.RequestAction, ReplyAction = UntypedMessageTester.ReplyAction)]
Message ConcatStrings (Message request);
}
public class UntypedMessageTester : IUntypedMessageTesterContract
{
public const String ReplyAction = "http://localhost/UntypedMessageTester/Message_ReplyAction";
public const String RequestAction = "http://localhost/UntypedMessageTester/Message_RequestAction";
public Message ConcatStrings (Message request)
{
string str = string.Empty;
string [] inputStrings = request.GetBody<string []> ();
for (int i = 0; i < inputStrings.Length; i++)
str += inputStrings [i];
Message response = Message.CreateMessage (request.Version, ReplyAction, str);
return response;
}
}
}