Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellabyte/2714746 to your computer and use it in GitHub Desktop.
Save kellabyte/2714746 to your computer and use it in GitHub Desktop.
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