WCF Azure Silverlight Calculator

This sample creates a simple WCF calculator service and builds a Silverlight client for it. The client is then hosted alonside the service in the Azure fabric.

 
 
 
 
 
4 Star
(4)
5,454 times
Add to favorites
4/27/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
VB.NET
Imports System.Linq
Imports System.Runtime.Serialization
Imports System.ServiceModel
Imports System.ServiceModel.Activation
Imports System.Text

Namespace SilverlightService
    <ServiceContract()> _
    Public Class Service
        <OperationContract()> _
        Public Function Calculate(ByVal op As Operation, ByVal a As Integer, ByVal b As Integer) As Integer

            Trace.Listeners("AzureDiagnostics").WriteLine("Performing operation: " & op)

            Select Case op
                Case Operation.Add
                    Return a + b

                Case Operation.Subtract
                    Return a - b

                Case Operation.Multiply
                    Return a * b

                Case Operation.Divide
                    Return a \ b
            End Select

            Return 0
        End Function
    End Class

	Public Enum Operation
		Add
		Subtract
		Multiply
		Divide
	End Enum
End Namespace