Created
May 16, 2012 23:04
-
-
Save kellabyte/2714746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IScheduledTask | |
{ | |
[DataMember] | |
Guid TaskId { get; set; } | |
} | |
// This is a generic implementation of IScheduledTask. | |
[DataContract] | |
public class ScheduledTask<T> : IScheduledTask | |
{ | |
[DataMember] | |
public Guid TaskId { get; set; } | |
[DataMember] | |
public T Value { get; set; } | |
public static implicit operator T(ScheduledTask<T> that) | |
{ | |
return that.Value; | |
} | |
} | |
// This is our service contract which takes IScheduledTask. | |
[ServiceContract(Namespace = "http://ServiceLib.TaskService")] | |
public interface IScheduledTaskService | |
{ | |
[OperationContract(IsOneWay = true)] | |
void Submit(IScheduledTask task); | |
} | |
// This is our actual service implementation. | |
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] | |
public class ScheduledTaskService : IScheduledTaskService | |
{ | |
public void Submit(IScheduledTask task) | |
{ | |
Console.WriteLine("We got a task!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment