├── .gitignore
├── Behaviors
└── PocoServiceHost
│ ├── PocoServiceBehavior.cs
│ ├── PocoServiceHost.cs
│ ├── PocoServiceHost.csproj
│ ├── PocoServiceHost.sln
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── app.config
├── DataContractResolver
├── Client
│ ├── Client.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── app.config
├── Common
│ ├── Common.csproj
│ ├── DynamicTypeBuilder.cs
│ ├── DynamicTypeResolver.cs
│ ├── MyHolder.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── DataContractResolverForDynamicTypes.sln
└── Server
│ ├── DynamicService.cs
│ ├── IDynamicContract.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Server.csproj
│ └── app.config
├── ExtensibleObjects
└── SharingDataThroughPipeline
│ ├── CalculatorService.cs
│ ├── ICalculator.cs
│ ├── MyChannelExtension.cs
│ ├── MyInspector.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SharingDataThroughPipeline.csproj
│ ├── SharingDataThroughPipeline.sln
│ └── app.config
├── IErrorHandler
├── ParameterValidation
│ ├── Contact.cs
│ ├── ContactManager.svc
│ ├── ContactManager.svc.cs
│ ├── ContactManagerFactory.cs
│ ├── Default.htm
│ ├── ParameterValidation.csproj
│ ├── ParameterValidation.sln
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── UnitTests.htm
│ ├── ValidatingParameterInspector.cs
│ ├── ValidationAwareErrorHandler.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ ├── WebHttpWithValidationBehavior.cs
│ └── scripts
│ │ ├── json2.js
│ │ ├── qunit.css
│ │ └── qunit.js
└── ParameterValidationWithSoap
│ ├── Contact.cs
│ ├── ContactManager.cs
│ ├── ParameterValidationWithSoap.csproj
│ ├── ParameterValidationWithSoap.sln
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── ValidatingBehavior.cs
│ ├── ValidatingParameterInspector.cs
│ ├── ValidationAwareErrorHandler.cs
│ └── app.config
├── InitializerSamples
├── GlobAwareService
│ ├── GlobAwareCallContextInitializer.cs
│ ├── GlobAwareEndpointBehavior.cs
│ ├── GlobAwareService.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Service.cs
│ ├── StringRetriever.cs
│ └── app.config
├── InitializerSamples.sln
└── TrackingClients
│ ├── ClientTrackerChannelInitializer.cs
│ ├── ClientTrackerEndpointBehavior.cs
│ ├── Contracts.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── TrackingClients.csproj
│ └── app.config
├── InstanceContext
└── SimulatedSessions
│ ├── Contracts.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SharedSessionEndpointBehavior.cs
│ ├── SharedSessionInstanceContextProvider.cs
│ ├── SimulatedSessions.csproj
│ ├── SimulatedSessions.sln
│ └── app.config
├── InstanceProvider
└── TestableWcfServices
│ ├── Local.testsettings
│ ├── PricingService.Test
│ ├── AnyInstance.cs
│ ├── MockProductRepository.cs
│ ├── PricingService.Test.csproj
│ ├── PricingServiceInWCFTest.cs
│ ├── PricingServiceTest.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── PricingService
│ ├── DataContracts.cs
│ ├── FileBasedProductRepository.cs
│ ├── IPricingService.cs
│ ├── IProductRepository.cs
│ ├── InstanceProviderBehavior.cs
│ ├── PricingService.cs
│ ├── PricingService.csproj
│ ├── ProductRepositoryFactory.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── app.config
│ ├── TestableWcfServices.sln
│ ├── TestableWcfServices.vsmdi
│ └── TraceAndTestImpact.testsettings
├── InteractiveChannelInitializer
├── Client
│ ├── AsyncResult.cs
│ ├── Client.csproj
│ ├── ClientCredentialsEx.cs
│ ├── ClientForm.Designer.cs
│ ├── ClientForm.cs
│ ├── ClientForm.resx
│ ├── ClientPasswordDialog.Designer.cs
│ ├── ClientPasswordDialog.cs
│ ├── ClientPasswordDialog.resx
│ ├── MyClientCredentialsSecurityTokenManager.cs
│ ├── MyUserNameSecurityTokenProvider.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── Service References
│ │ └── ServiceReference1
│ │ │ ├── Reference.cs
│ │ │ ├── Reference.svcmap
│ │ │ ├── Service.disco
│ │ │ ├── Service.wsdl
│ │ │ ├── Service.xsd
│ │ │ ├── Service1.xsd
│ │ │ ├── configuration.svcinfo
│ │ │ └── configuration91.svcinfo
│ ├── ShowCredentialsUI.cs
│ └── app.config
├── InteractiveChannelInitializer.sln
└── Server
│ ├── CustomAuthorizationPolicy.cs
│ ├── CustomPrincipal.cs
│ ├── MyPasswordValidator.cs
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ ├── Server.csproj
│ ├── ServerForm.Designer.cs
│ ├── ServerForm.cs
│ ├── ServerForm.resx
│ ├── Service.cs
│ └── app.config
├── MessageEncoder
├── ChangeXmlPrefixes
│ ├── CalculatorService.cs
│ ├── ChangeXmlPrefixes.csproj
│ ├── ChangeXmlPrefixes.sln
│ ├── ICalculator.cs
│ ├── LoggingMessageEncodingBindingElement.cs
│ ├── PrefixReplacer.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ReplacePrefixMessageEncodingBindingElement.cs
│ └── app.config
├── CompositeEncoder
│ ├── CompositeEncoder.csproj
│ ├── CompositeEncoder.sln
│ ├── Contracts.cs
│ ├── MyReadMtomWriteXmlEncoder.cs
│ ├── MyReadMtomWriteXmlEncoderFactory.cs
│ ├── MyReadMtomWriteXmlEncodingBindingElement.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── app.config
└── GZipEncoderAndAutoFormatSelection
│ ├── App.config
│ ├── CompressionAndFormatSelectionMessageInspector.cs
│ ├── GZipEncoder.cs
│ ├── GZipEncoderAndAutoFormatSelection.csproj
│ ├── GZipEncoderAndAutoFormatSelection.sln
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── Service.cs
├── MessageFormatter
├── MessageFormatter
│ ├── JsonNetMessageFormatter
│ │ ├── DataContracts.cs
│ │ ├── ITestService.cs
│ │ ├── JsonNetMessageFormatter.csproj
│ │ ├── NewtonsoftJsonBehavior.cs
│ │ ├── NewtonsoftJsonClientFormatter.cs
│ │ ├── NewtonsoftJsonDispatchFormatter.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── RawBodyWriter.cs
│ │ ├── Service.cs
│ │ └── app.config
│ ├── MessageFormatter.sln
│ └── lib
│ │ └── Newtonsoft.Json.dll
└── PerOperationContentTypeMapper
│ ├── DualModeFormatter.cs
│ ├── DualModeWebHttpBehavior.cs
│ ├── NonRawAttribute.cs
│ ├── PerOperationContentTypeMapper.csproj
│ ├── PerOperationContentTypeMapper.sln
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── RawContentTypeMapper.cs
│ ├── Service.cs
│ └── app.config
├── MessageInspector
└── InspectNonXmlMessages
│ ├── ContactManagerService.cs
│ ├── Contracts.cs
│ ├── IncomingMessageLogger.cs
│ ├── InspectNonXmlMessages.csproj
│ ├── InspectNonXmlMessages.sln
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── app.config
├── OperationInvoker
└── CachingOperationInvoker
│ ├── CacheableOperationAttribute.cs
│ ├── CachingOperationInvoker.cs
│ ├── CachingOperationInvoker.csproj
│ ├── CachingOperationInvoker.sln
│ ├── Interface.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Service.cs
│ └── app.config
├── OperationSelector
└── HttpMethodOverrideOperationSelection
│ ├── ContactManagerService.cs
│ ├── Contracts.cs
│ ├── HttpMethodOverrideOperationSelection.csproj
│ ├── HttpMethodOverrideOperationSelection.sln
│ ├── HttpOverrideBehavior.cs
│ ├── HttpOverrideOperationSelector.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── app.config
├── README
├── Scenarios
└── CORS
│ ├── CORS.sln
│ ├── CorsEnabledService
│ ├── CorsConstants.cs
│ ├── CorsEnabledAttribute.cs
│ ├── CorsEnabledMessageInspector.cs
│ ├── CorsEnabledService.csproj
│ ├── CorsEnabledServiceHostFactory.cs
│ ├── EnableCorsEndpointBehavior.cs
│ ├── Global.asax
│ ├── Global.asax.cs
│ ├── IValues.cs
│ ├── PreflightOperationBehavior.cs
│ ├── PreflightOperationInvoker.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TestPage.htm
│ ├── ValuesService.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ └── scripts
│ │ └── jquery-1.7.2.js
│ └── MashupApp
│ ├── Default.htm
│ ├── MashupApp.csproj
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ └── scripts
│ └── jquery-1.7.2.js
├── Silverlight
├── JsonClient
│ ├── JsonClient.sln
│ ├── SLApp.Web
│ │ ├── IRestService.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── RestService.svc
│ │ ├── RestService.svc.cs
│ │ ├── SLApp.Web.csproj
│ │ ├── SLAppTestPage.aspx
│ │ ├── SLAppTestPage.html
│ │ ├── Silverlight.js
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ └── Web.config
│ └── SLApp
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── MainPage.xaml
│ │ ├── MainPage.xaml.cs
│ │ ├── Properties
│ │ ├── AppManifest.xml
│ │ └── AssemblyInfo.cs
│ │ ├── SLApp.csproj
│ │ └── WebMessageEncodingBindingElement.cs
└── StreamedResponses
│ ├── SLApp.Web
│ ├── IWcfDownloadService.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SLApp.Web.csproj
│ ├── SLAppTestPage.aspx
│ ├── SLAppTestPage.html
│ ├── Silverlight.js
│ ├── WcfDownloadService.svc
│ ├── WcfDownloadService.svc.cs
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ └── Web.config
│ ├── SLApp
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Properties
│ │ ├── AppManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── SLApp.csproj
│ ├── Service References
│ │ └── ServiceReference1
│ │ │ ├── Reference.cs
│ │ │ ├── Reference.svcmap
│ │ │ ├── WcfDownloadService.disco
│ │ │ ├── WcfDownloadService.wsdl
│ │ │ ├── WcfDownloadService.xsd
│ │ │ ├── WcfDownloadService1.wsdl
│ │ │ ├── WcfDownloadService1.xsd
│ │ │ ├── WcfDownloadService2.xsd
│ │ │ ├── configuration.svcinfo
│ │ │ └── configuration91.svcinfo
│ └── ServiceReferences.ClientConfig
│ └── StreamedResponses.sln
├── SilverlightSelfHostedService
├── SLApp.Web
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SLApp.Web.csproj
│ ├── SLAppTestPage.aspx
│ ├── SLAppTestPage.html
│ ├── Silverlight.js
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ └── Web.config
├── SLApp
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Properties
│ │ ├── AppManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── SLApp.csproj
│ ├── Service References
│ │ └── ServiceReference1
│ │ │ ├── Reference.cs
│ │ │ ├── Reference.svcmap
│ │ │ ├── Service.wsdl
│ │ │ ├── configuration.svcinfo
│ │ │ ├── configuration91.svcinfo
│ │ │ ├── item.disco
│ │ │ ├── item.xsd
│ │ │ ├── item1.xsd
│ │ │ └── item2.xsd
│ └── ServiceReferences.ClientConfig
├── SelfHostedService
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SelfHostedService.csproj
│ └── app.config
└── SilverlightSelfHostedService.sln
├── SilverlightTcpSelfHostedService
├── SLApp.Web
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SLApp.Web.csproj
│ ├── SLAppTestPage.aspx
│ ├── SLAppTestPage.html
│ ├── Silverlight.js
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ └── Web.config
├── SLApp
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Properties
│ │ ├── AppManifest.xml
│ │ └── AssemblyInfo.cs
│ ├── SLApp.csproj
│ ├── Service References
│ │ └── ServiceReference1
│ │ │ ├── Reference.cs
│ │ │ ├── Reference.svcmap
│ │ │ ├── configuration.svcinfo
│ │ │ ├── configuration91.svcinfo
│ │ │ ├── service.wsdl
│ │ │ ├── service.xsd
│ │ │ └── service1.xsd
│ └── ServiceReferences.ClientConfig
├── Service
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Service.csproj
│ └── app.config
└── SilverlightTcpSelfHostedService.sln
├── StreamingInsideDataContracts
├── Client
│ ├── Client.csproj
│ ├── ContextExtra.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SomeServiceImpl.cs
│ └── app.config
├── Server
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Server.csproj
│ └── app.config
└── StreamingInsideDataContracts.sln
├── TransportChannels
├── CustomTcpDuplexTransport
│ ├── Channels
│ │ ├── AsyncResult.cs
│ │ ├── Channels.csproj
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── SizedTcpBaseChannel.cs
│ │ ├── SizedTcpDuplexChannel.cs
│ │ ├── SizedTcpDuplexChannelFactory.cs
│ │ ├── SizedTcpDuplexChannelListener.cs
│ │ └── SizedTcpDuplexTransportBindingElement.cs
│ ├── CustomTcpDuplexTransport.sln
│ ├── Utils
│ │ ├── Debugging.cs
│ │ ├── Formatting.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── Utils.csproj
│ ├── WcfClient
│ │ ├── Dispatcher.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── SocketServer.cs
│ │ ├── WcfClient.csproj
│ │ └── app.config
│ ├── WcfDuplex
│ │ ├── Contracts.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Service.cs
│ │ ├── WcfDuplex.csproj
│ │ └── app.config
│ └── WcfServer
│ │ ├── Contracts.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── WcfServer.csproj
│ │ └── app.config
└── JsonRpcOverTcp
│ ├── Channels.Test
│ ├── BaseChannelTests.cs
│ ├── Channels.Test.csproj
│ ├── Mocks.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ReflectionHelper.cs
│ ├── RequestChannelTests.cs
│ └── SimpleEchoServer.cs
│ ├── Channels
│ ├── AsyncResult.cs
│ ├── Channels.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SizedTcpBaseChannel.cs
│ ├── SizedTcpChannelFactory.cs
│ ├── SizedTcpChannelListener.cs
│ ├── SizedTcpReplyChannel.cs
│ ├── SizedTcpRequestChannel.cs
│ ├── SizedTcpRequestContext.cs
│ └── SizedTcpTransportBindingElement.cs
│ ├── ConsoleTester
│ ├── ConsoleTester.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── JsonRpcOverTcp.sln
│ ├── ServiceModel
│ ├── JsonRpcConstants.cs
│ ├── JsonRpcEndpointBehavior.cs
│ ├── JsonRpcErrorHandler.cs
│ ├── JsonRpcException.cs
│ ├── JsonRpcHelpers.cs
│ ├── JsonRpcMessageFormatter.cs
│ ├── JsonRpcMessageInspector.cs
│ ├── JsonRpcOperationSelector.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── ServiceModel.csproj
│ ├── SimpleServer
│ ├── Dispatcher.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SimpleServer.cs
│ ├── SimpleServer.csproj
│ └── app.config
│ ├── Utils
│ ├── Debugging.cs
│ ├── Formatting.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RawBodyWriter.cs
│ └── Utils.csproj
│ ├── WcfClient
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── WcfClient.csproj
│ └── app.config
│ ├── WcfServer
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Service.cs
│ ├── WcfServer.csproj
│ └── app.config
│ └── lib
│ ├── Newtonsoft.Json.dll
│ ├── Newtonsoft.Json.xml
│ ├── xunit.dll
│ ├── xunit.extensions.dll
│ ├── xunit.extensions.xml
│ └── xunit.xml
├── WCFBinaryTools
├── BinaryFormatParser
│ ├── BinaryFormatParser.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── WcfDictionary.cs
│ ├── XmlBinaryElements.cs
│ ├── XmlBinaryNodeType.cs
│ └── XmlBinaryParser.cs
├── SerializeWithSessionDictionary
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── SerializeWithSessionDictionary.csproj
├── WcfBinaryParser
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── WcfBinaryParser.csproj
├── WcfBinaryTools.sln
└── WcfBinaryViewer
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ ├── WcfBinaryViewer.csproj
│ ├── XmlBinaryViewer.Designer.cs
│ ├── XmlBinaryViewer.cs
│ └── XmlBinaryViewer.resx
├── WCFRiaServices
└── CallingRIAFromForms
│ ├── CallingRIAFromForms.sln
│ ├── SLApp.Web
│ ├── CanReceiveFormsUrlEncodedInputAttribute.cs
│ ├── ContactImporter.htm
│ ├── ContactsDomainService.cs
│ ├── FormUrlEncodedEnabledJsonEndpointFactory.cs
│ ├── GlobalSuppressions.cs
│ ├── HelpEnabledJsonEndpointFactory.cs
│ ├── Models
│ │ ├── Contact.cs
│ │ ├── ContactRepository.cs
│ │ ├── RegistrationData.cs
│ │ ├── Shared
│ │ │ └── User.shared.cs
│ │ └── User.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── RegistrationDataResources.Designer.cs
│ │ ├── RegistrationDataResources.resx
│ │ ├── ValidationErrorResources.Designer.cs
│ │ └── ValidationErrorResources.resx
│ ├── SLApp.Web.csproj
│ ├── SLAppTestPage.aspx
│ ├── SLAppTestPage.html
│ ├── Services
│ │ ├── AuthenticationService.cs
│ │ └── UserRegistrationService.cs
│ ├── Silverlight.js
│ ├── Web.Debug.config
│ ├── Web.Release.config
│ ├── Web.config
│ └── scripts
│ │ ├── jquery-1.7.1.js
│ │ └── json2.js
│ └── SLApp
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Assets
│ ├── Resources
│ │ ├── ApplicationResources.cs
│ │ ├── ApplicationStrings.Designer.cs
│ │ ├── ApplicationStrings.resx
│ │ ├── ErrorResources.Designer.cs
│ │ ├── ErrorResources.resx
│ │ ├── SecurityQuestions.Designer.cs
│ │ └── SecurityQuestions.resx
│ └── Styles.xaml
│ ├── Controls
│ ├── BusyIndicator.cs
│ ├── BusyIndicator.xaml
│ └── VisualStates.cs
│ ├── Generated_Code
│ ├── Models
│ │ └── Shared
│ │ │ └── User.shared.cs
│ └── SLApp.Web.g.cs
│ ├── GlobalSuppressions.cs
│ ├── Helpers
│ ├── DataFieldExtensions.cs
│ ├── NotOperatorValueConverter.cs
│ └── TargetNullValueConverter.cs
│ ├── Libs
│ └── System.Windows.Controls.Data.DataForm.Toolkit.dll
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── Models
│ ├── LoginInfo.cs
│ ├── RegistrationData.partial.cs
│ └── User.partial.cs
│ ├── Properties
│ ├── AppManifest.xml
│ ├── AssemblyInfo.cs
│ └── OutOfBrowserSettings.xml
│ ├── SLApp.csproj
│ └── Views
│ ├── About.xaml
│ ├── About.xaml.cs
│ ├── ErrorWindow.xaml
│ ├── ErrorWindow.xaml.cs
│ ├── Home.xaml
│ ├── Home.xaml.cs
│ └── Login
│ ├── LoginForm.xaml
│ ├── LoginForm.xaml.cs
│ ├── LoginRegistrationWindow.xaml
│ ├── LoginRegistrationWindow.xaml.cs
│ ├── LoginStatus.xaml
│ ├── LoginStatus.xaml.cs
│ ├── RegistrationForm.xaml
│ └── RegistrationForm.xaml.cs
├── WcfRuntime
├── AllExtensions
│ ├── AllExtensions.csproj
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
└── WcfRuntime.sln
└── shoebox
├── JsonRpc
└── DuplexChannels
│ ├── SizedTcpDuplexChannel.cs
│ ├── SizedTcpDuplexChannelFactory.cs
│ ├── SizedTcpDuplexChannelListener.cs
│ └── SizedTcpDuplexTransportBindingElement.cs
└── README
/.gitignore:
--------------------------------------------------------------------------------
1 | # Visual Studio files #
2 | #######################
3 | *.suo
4 | *.csproj.user
5 | bin/
6 | obj/
7 | ClientBin/
8 |
--------------------------------------------------------------------------------
/Behaviors/PocoServiceHost/PocoServiceHost.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Description;
4 |
5 | namespace PocoServiceHost
6 | {
7 | public class PocoServiceHost : ServiceHost
8 | {
9 | public PocoServiceHost(Type serviceType, Uri baseAddress)
10 | : base(serviceType, baseAddress)
11 | {
12 | }
13 |
14 | protected override void InitializeRuntime()
15 | {
16 | this.Description.Behaviors.Insert(0, new PocoServiceBehavior());
17 | this.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true });
18 | base.InitializeRuntime();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Behaviors/PocoServiceHost/PocoServiceHost.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual C# Express 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocoServiceHost", "PocoServiceHost.csproj", "{3EEDDFC6-7357-400A-B07F-3E6B8AA92007}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {3EEDDFC6-7357-400A-B07F-3E6B8AA92007}.Debug|x86.ActiveCfg = Debug|x86
13 | {3EEDDFC6-7357-400A-B07F-3E6B8AA92007}.Debug|x86.Build.0 = Debug|x86
14 | {3EEDDFC6-7357-400A-B07F-3E6B8AA92007}.Release|x86.ActiveCfg = Release|x86
15 | {3EEDDFC6-7357-400A-B07F-3E6B8AA92007}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Behaviors/PocoServiceHost/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("PocoServiceHost")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("PocoServiceHost")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("5fb3ace0-6851-4c21-8aa9-b52233d9e5c6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Behaviors/PocoServiceHost/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DataContractResolver/Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Client")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Client")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d8792fca-41af-4deb-ad12-4de9bddfe6e3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DataContractResolver/Client/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DataContractResolver/Common/MyHolder.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace Common
4 | {
5 | [DataContract]
6 | public class MyHolder
7 | {
8 | [DataMember]
9 | public object MyObject { get; set; }
10 |
11 | public override string ToString()
12 | {
13 | return string.Format("MyHolder[MyObject={0}]", this.MyObject);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/DataContractResolver/Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Common")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Common")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("95af7ed4-d64b-4f7a-8773-89b107c7bc17")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DataContractResolver/Server/DynamicService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Common;
3 |
4 | namespace Server
5 | {
6 | public class DynamicService : IDynamicContract
7 | {
8 | public MyHolder EchoHolder(MyHolder holder)
9 | {
10 | Console.WriteLine("In service, holder = {0}", holder);
11 | return holder;
12 | }
13 |
14 | public MyHolder GetHolder(string typeName, string[] propertyNames, object[] propertyValues)
15 | {
16 | Console.WriteLine("In service, creating a type called {0}", typeName);
17 | Type type = DynamicTypeBuilder.Instance.GetDynamicType(typeName);
18 | object instance = Activator.CreateInstance(type);
19 | for (int i = 0; i < propertyNames.Length; i++)
20 | {
21 | type.GetProperty(propertyNames[i]).SetValue(instance, propertyValues[i], null);
22 | }
23 |
24 | return new MyHolder { MyObject = instance };
25 | }
26 |
27 | public string PutHolder(MyHolder holder)
28 | {
29 | Console.WriteLine("In service, holder = {0}", holder);
30 | return holder.ToString();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/DataContractResolver/Server/IDynamicContract.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using Common;
3 |
4 | namespace Server
5 | {
6 | [ServiceContract(Name = "IDynamicContract", Namespace = "http://my.dynamic.contract")]
7 | public interface IDynamicContract
8 | {
9 | [OperationContract]
10 | MyHolder EchoHolder(MyHolder holder);
11 | [OperationContract]
12 | MyHolder GetHolder(string typeName, string[] propertyNames, object[] propertyValues);
13 | [OperationContract]
14 | string PutHolder(MyHolder holder);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/DataContractResolver/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Description;
4 | using Common;
5 |
6 | namespace Server
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
13 | ServiceHost host = new ServiceHost(typeof(DynamicService), new Uri(baseAddress));
14 | ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IDynamicContract), new BasicHttpBinding(), "");
15 | foreach (OperationDescription operation in endpoint.Contract.Operations)
16 | {
17 | operation.Behaviors.Find().DataContractResolver = new DynamicTypeResolver();
18 | }
19 |
20 | host.Open();
21 | Console.WriteLine("Host opened, press ENTER to close");
22 | Console.ReadLine();
23 | host.Close();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/DataContractResolver/Server/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Server")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("Server")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("550b4628-9a70-443c-a401-dfe4592ffafd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DataContractResolver/Server/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ExtensibleObjects/SharingDataThroughPipeline/CalculatorService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SharingDataThroughPipeline
4 | {
5 | public class CalculatorService : ICalculator
6 | {
7 | public double Add(double x, double y)
8 | {
9 | return x + y;
10 | }
11 |
12 | public double Subtract(double x, double y)
13 | {
14 | return x - y;
15 | }
16 |
17 | public double Multiply(double x, double y)
18 | {
19 | return x * y;
20 | }
21 |
22 | public double Divide(double x, double y)
23 | {
24 | return x / y;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ExtensibleObjects/SharingDataThroughPipeline/ICalculator.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace SharingDataThroughPipeline
4 | {
5 | [ServiceContract]
6 | public interface ICalculator
7 | {
8 | [OperationContract]
9 | double Add(double x, double y);
10 | [OperationContract]
11 | double Subtract(double x, double y);
12 | [OperationContract]
13 | double Multiply(double x, double y);
14 | [OperationContract]
15 | double Divide(double x, double y);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ExtensibleObjects/SharingDataThroughPipeline/MyChannelExtension.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.ServiceModel.Channels;
3 |
4 | namespace SharingDataThroughPipeline
5 | {
6 | class MyChannelExtension : IExtension
7 | {
8 | public Binding Binding { get; set; }
9 | public bool IntroduceErrors { get; set; }
10 |
11 | // Not used in this scenario
12 | public void Attach(IContextChannel owner) { }
13 | public void Detach(IContextChannel owner) { }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ExtensibleObjects/SharingDataThroughPipeline/SharingDataThroughPipeline.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharingDataThroughPipeline", "SharingDataThroughPipeline.csproj", "{5FD37440-D2C6-4A2F-9114-0C243E8832CE}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {5FD37440-D2C6-4A2F-9114-0C243E8832CE}.Debug|x86.ActiveCfg = Debug|x86
13 | {5FD37440-D2C6-4A2F-9114-0C243E8832CE}.Debug|x86.Build.0 = Debug|x86
14 | {5FD37440-D2C6-4A2F-9114-0C243E8832CE}.Release|x86.ActiveCfg = Release|x86
15 | {5FD37440-D2C6-4A2F-9114-0C243E8832CE}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/ExtensibleObjects/SharingDataThroughPipeline/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/Contact.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.Runtime.Serialization;
3 |
4 | namespace ParameterValidation
5 | {
6 | [DataContract]
7 | public class Contact
8 | {
9 | [DataMember]
10 | [Required(ErrorMessage = "Name is required")]
11 | [StringLength(20, MinimumLength = 1, ErrorMessage = "Name must have between 1 and 20 characters")]
12 | public string Name { get; set; }
13 |
14 | [DataMember]
15 | [Range(0, 150, ErrorMessage = "Age must be an integer between 0 and 150")]
16 | public int Age { get; set; }
17 |
18 | [DataMember]
19 | [Required(ErrorMessage = "E-mail is required")]
20 | [RegularExpression(@"[^\@]+\@[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+", ErrorMessage = "E-mail is invalid")]
21 | public string Email { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/ContactManager.svc:
--------------------------------------------------------------------------------
1 | <%@ ServiceHost Language="C#" Debug="true" Service="ParameterValidation.ContactManager" CodeBehind="ContactManager.svc.cs" Factory="ParameterValidation.ContactManagerFactory" %>
2 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/ContactManagerFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Activation;
4 | using System.ServiceModel.Description;
5 |
6 | namespace ParameterValidation
7 | {
8 | public class ContactManagerFactory : ServiceHostFactory
9 | {
10 | protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
11 | {
12 | ServiceHost host = new ServiceHost(serviceType, baseAddresses);
13 | ServiceEndpoint endpoint = host.AddServiceEndpoint(serviceType, new WebHttpBinding(), "");
14 | endpoint.Behaviors.Add(new WebHttpWithValidationBehavior());
15 | return host;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/ParameterValidation.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Web Developer Express 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParameterValidation", "ParameterValidation.csproj", "{724BCFB7-3806-49C5-A61F-77B1E8A03535}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {724BCFB7-3806-49C5-A61F-77B1E8A03535}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {724BCFB7-3806-49C5-A61F-77B1E8A03535}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {724BCFB7-3806-49C5-A61F-77B1E8A03535}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {724BCFB7-3806-49C5-A61F-77B1E8A03535}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ParameterValidation")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ParameterValidation")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("34da4ce1-e08f-4e21-b92e-c01372c03aa3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/ValidatingParameterInspector.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ServiceModel.Dispatcher;
3 |
4 | namespace ParameterValidation
5 | {
6 | public class ValidatingParameterInspector : IParameterInspector
7 | {
8 | public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
9 | {
10 | }
11 |
12 | public object BeforeCall(string operationName, object[] inputs)
13 | {
14 | foreach (var input in inputs)
15 | {
16 | if (input != null)
17 | {
18 | ValidationContext context = new ValidationContext(input, null, null);
19 | Validator.ValidateObject(input, context, true);
20 | }
21 | }
22 |
23 | return null;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidation/WebHttpWithValidationBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Description;
2 | using System.ServiceModel.Dispatcher;
3 |
4 | namespace ParameterValidation
5 | {
6 | public class WebHttpWithValidationBehavior : WebHttpBehavior
7 | {
8 | protected override void AddServerErrorHandlers(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
9 | {
10 | int errorHandlerCount = endpointDispatcher.ChannelDispatcher.ErrorHandlers.Count;
11 | base.AddServerErrorHandlers(endpoint, endpointDispatcher);
12 | IErrorHandler webHttpErrorHandler = endpointDispatcher.ChannelDispatcher.ErrorHandlers[errorHandlerCount];
13 | endpointDispatcher.ChannelDispatcher.ErrorHandlers.RemoveAt(errorHandlerCount);
14 | ValidationAwareErrorHandler newHandler = new ValidationAwareErrorHandler(webHttpErrorHandler);
15 | endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(newHandler);
16 | }
17 |
18 | public override void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
19 | {
20 | base.ApplyDispatchBehavior(endpoint, endpointDispatcher);
21 | foreach (DispatchOperation operation in endpointDispatcher.DispatchRuntime.Operations)
22 | {
23 | operation.ParameterInspectors.Add(new ValidatingParameterInspector());
24 | }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidationWithSoap/Contact.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.Runtime.Serialization;
3 |
4 | namespace ParameterValidationWithSoap
5 | {
6 | [DataContract]
7 | public class Contact
8 | {
9 | [DataMember]
10 | [Required(ErrorMessage = "Name is required")]
11 | [StringLength(20, MinimumLength = 1, ErrorMessage = "Name must have between 1 and 20 characters")]
12 | public string Name { get; set; }
13 |
14 | [DataMember]
15 | [Range(0, 150, ErrorMessage = "Age must be an integer between 0 and 150")]
16 | public int Age { get; set; }
17 |
18 | [DataMember]
19 | [Required(ErrorMessage = "E-mail is required")]
20 | [RegularExpression(@"[^\@]+\@[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+", ErrorMessage = "E-mail is invalid")]
21 | public string Email { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidationWithSoap/ParameterValidationWithSoap.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual C# Express 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParameterValidationWithSoap", "ParameterValidationWithSoap.csproj", "{9A763A68-174D-42D0-B5B2-4B5A22F057A6}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {9A763A68-174D-42D0-B5B2-4B5A22F057A6}.Debug|x86.ActiveCfg = Debug|x86
13 | {9A763A68-174D-42D0-B5B2-4B5A22F057A6}.Debug|x86.Build.0 = Debug|x86
14 | {9A763A68-174D-42D0-B5B2-4B5A22F057A6}.Release|x86.ActiveCfg = Release|x86
15 | {9A763A68-174D-42D0-B5B2-4B5A22F057A6}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidationWithSoap/ValidatingBehavior.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel.Description;
6 | using System.ServiceModel.Channels;
7 | using System.ServiceModel.Dispatcher;
8 |
9 | namespace ParameterValidationWithSoap
10 | {
11 | public class ValidatingBehavior : IEndpointBehavior
12 | {
13 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
14 | {
15 | }
16 |
17 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
18 | {
19 | }
20 |
21 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
22 | {
23 | endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(new ValidationAwareErrorHandler());
24 | foreach (DispatchOperation op in endpointDispatcher.DispatchRuntime.Operations)
25 | {
26 | op.ParameterInspectors.Add(new ValidatingParameterInspector());
27 | }
28 | }
29 |
30 | public void Validate(ServiceEndpoint endpoint)
31 | {
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidationWithSoap/ValidatingParameterInspector.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ServiceModel.Dispatcher;
3 |
4 | namespace ParameterValidationWithSoap
5 | {
6 | public class ValidatingParameterInspector : IParameterInspector
7 | {
8 | public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
9 | {
10 | }
11 |
12 | public object BeforeCall(string operationName, object[] inputs)
13 | {
14 | foreach (var input in inputs)
15 | {
16 | if (input != null)
17 | {
18 | ValidationContext context = new ValidationContext(input, null, null);
19 | Validator.ValidateObject(input, context, true);
20 | }
21 | }
22 |
23 | return null;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidationWithSoap/ValidationAwareErrorHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ServiceModel;
4 | using System.ServiceModel.Channels;
5 | using System.ServiceModel.Dispatcher;
6 |
7 | namespace ParameterValidationWithSoap
8 | {
9 | public class ValidationAwareErrorHandler : IErrorHandler
10 | {
11 | public ValidationAwareErrorHandler()
12 | {
13 | }
14 |
15 | public bool HandleError(Exception error)
16 | {
17 | return error is ValidationException;
18 | }
19 |
20 | public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
21 | {
22 | ValidationException validationException = error as ValidationException;
23 | if (validationException != null)
24 | {
25 | FaultException faultException = new FaultException("Error: " + validationException.ValidationResult.ErrorMessage);
26 | MessageFault messageFault = faultException.CreateMessageFault();
27 | fault = Message.CreateMessage(version, messageFault, null);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/IErrorHandler/ParameterValidationWithSoap/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/InitializerSamples/GlobAwareService/GlobAwareEndpointBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace GlobAwareService
6 | {
7 | class GlobAwareEndpointBehavior : IEndpointBehavior
8 | {
9 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
10 | {
11 | }
12 |
13 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
14 | {
15 | }
16 |
17 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
18 | {
19 | foreach (DispatchOperation operation in endpointDispatcher.DispatchRuntime.Operations)
20 | {
21 | operation.CallContextInitializers.Add(new GlobAwareCallContextInitializer());
22 | }
23 | }
24 |
25 | public void Validate(ServiceEndpoint endpoint)
26 | {
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/InitializerSamples/GlobAwareService/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/InitializerSamples/InitializerSamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlobAwareService", "GlobAwareService\GlobAwareService.csproj", "{AEED6743-B7C5-498E-B5E4-A59FCF2DF818}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrackingClients", "TrackingClients\TrackingClients.csproj", "{EC85F612-1DB2-4A84-8F29-7F0D442A5C67}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {AEED6743-B7C5-498E-B5E4-A59FCF2DF818}.Debug|x86.ActiveCfg = Debug|x86
15 | {AEED6743-B7C5-498E-B5E4-A59FCF2DF818}.Debug|x86.Build.0 = Debug|x86
16 | {AEED6743-B7C5-498E-B5E4-A59FCF2DF818}.Release|x86.ActiveCfg = Release|x86
17 | {AEED6743-B7C5-498E-B5E4-A59FCF2DF818}.Release|x86.Build.0 = Release|x86
18 | {EC85F612-1DB2-4A84-8F29-7F0D442A5C67}.Debug|x86.ActiveCfg = Debug|x86
19 | {EC85F612-1DB2-4A84-8F29-7F0D442A5C67}.Debug|x86.Build.0 = Debug|x86
20 | {EC85F612-1DB2-4A84-8F29-7F0D442A5C67}.Release|x86.ActiveCfg = Release|x86
21 | {EC85F612-1DB2-4A84-8F29-7F0D442A5C67}.Release|x86.Build.0 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/InitializerSamples/TrackingClients/ClientTrackerChannelInitializer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace TrackingClients
6 | {
7 | class ClientTrackerChannelInitializer : IChannelInitializer
8 | {
9 | internal static int ConnectedClientCount = 0;
10 |
11 | public void Initialize(IClientChannel channel)
12 | {
13 | ConnectedClientCount++;
14 | Console.WriteLine("Client {0} initialized", channel.SessionId);
15 | channel.Closed += ClientDisconnected;
16 | channel.Faulted += ClientDisconnected;
17 | }
18 |
19 | static void ClientDisconnected(object sender, EventArgs e)
20 | {
21 | Console.WriteLine("Client {0} disconnected", ((IClientChannel)sender).SessionId);
22 | ConnectedClientCount--;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/InitializerSamples/TrackingClients/ClientTrackerEndpointBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace TrackingClients
6 | {
7 | class ClientTrackerEndpointBehavior : IEndpointBehavior
8 | {
9 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
10 | {
11 | }
12 |
13 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
14 | {
15 | }
16 |
17 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
18 | {
19 | endpointDispatcher.ChannelDispatcher.ChannelInitializers.Add(new ClientTrackerChannelInitializer());
20 | }
21 |
22 | public void Validate(ServiceEndpoint endpoint)
23 | {
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/InitializerSamples/TrackingClients/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/InstanceContext/SimulatedSessions/SharedSessionEndpointBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace SimulatedSessions
6 | {
7 | class SharedSessionEndpointBehavior : IEndpointBehavior
8 | {
9 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
10 | {
11 | }
12 |
13 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
14 | {
15 | }
16 |
17 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
18 | {
19 | SharedSessionInstanceContextProvider extension = new SharedSessionInstanceContextProvider();
20 | endpointDispatcher.DispatchRuntime.InstanceContextProvider = extension;
21 | endpointDispatcher.DispatchRuntime.MessageInspectors.Add(extension);
22 | }
23 |
24 | public void Validate(ServiceEndpoint endpoint)
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/InstanceContext/SimulatedSessions/SimulatedSessions.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimulatedSessions", "SimulatedSessions.csproj", "{2AB31B55-A7A2-4325-9AFC-50EB097C6784}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {2AB31B55-A7A2-4325-9AFC-50EB097C6784}.Debug|x86.ActiveCfg = Debug|x86
13 | {2AB31B55-A7A2-4325-9AFC-50EB097C6784}.Debug|x86.Build.0 = Debug|x86
14 | {2AB31B55-A7A2-4325-9AFC-50EB097C6784}.Release|x86.ActiveCfg = Release|x86
15 | {2AB31B55-A7A2-4325-9AFC-50EB097C6784}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/InstanceContext/SimulatedSessions/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/Local.testsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | These are default test settings for a local test run.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService.Test/AnyInstance.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace PricingService.Test
7 | {
8 | public class AnyInstance
9 | {
10 | public const double AnyDouble = 2.34;
11 | public const int AnyInt = 3;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService.Test/MockProductRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace PricingService.Test
7 | {
8 | public class MockProductRepository : IProductRepository
9 | {
10 | Func getProductFunction;
11 | public MockProductRepository(Func getProductFunction)
12 | {
13 | this.getProductFunction = getProductFunction;
14 | }
15 |
16 | public Product GetProduct(int productId)
17 | {
18 | return this.getProductFunction.Invoke(productId);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("PricingService.Test")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("PricingService.Test")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8d7aa6dc-fff1-4a30-9d70-d85b2bb47e5a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/DataContracts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.Runtime.Serialization;
7 |
8 | namespace PricingService
9 | {
10 | [DataContract]
11 | public class OrderItem
12 | {
13 | [DataMember]
14 | public int ItemId { get; set; }
15 | [DataMember]
16 | public string Name { get; set; }
17 | [DataMember]
18 | public double Amount;
19 | }
20 |
21 | [DataContract]
22 | public class Product
23 | {
24 | [DataMember]
25 | public int Id { get; set; }
26 | [DataMember]
27 | public string Name { get; set; }
28 | [DataMember]
29 | public string Unit { get; set; }
30 | [DataMember]
31 | public double UnitPrice { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/FileBasedProductRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Runtime.Serialization;
7 | using System.Runtime.Serialization.Json;
8 |
9 | namespace PricingService
10 | {
11 | public class FileBasedProductRepository : IProductRepository
12 | {
13 | private List products;
14 |
15 | public FileBasedProductRepository(string fileName)
16 | {
17 | this.LoadProducts(fileName);
18 | }
19 |
20 | public Product GetProduct(int productId)
21 | {
22 | return this.products.Where(x => x.Id == productId).FirstOrDefault();
23 | }
24 |
25 | private void LoadProducts(string fileName)
26 | {
27 | DataContractJsonSerializer dcs = new DataContractJsonSerializer(typeof(List));
28 | using (FileStream fs = File.OpenRead(fileName))
29 | {
30 | this.products = (List)dcs.ReadObject(fs);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/IPricingService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.Runtime.Serialization;
7 |
8 | namespace PricingService
9 | {
10 | [ServiceContract(SessionMode = SessionMode.Required)]
11 | public interface IPricingService
12 | {
13 | [OperationContract(IsTerminating = true)]
14 | double PriceOrder();
15 | [OperationContract(IsInitiating = true)]
16 | void AddToCart(OrderItem item);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/IProductRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Runtime.Serialization;
7 | using System.Runtime.Serialization.Json;
8 |
9 | namespace PricingService
10 | {
11 | public interface IProductRepository
12 | {
13 | Product GetProduct(int productId);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/PricingService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.Runtime.Serialization;
7 |
8 | namespace PricingService
9 | {
10 | [ServiceBehavior(
11 | InstanceContextMode = InstanceContextMode.PerSession,
12 | IncludeExceptionDetailInFaults = true)]
13 | [InstanceProviderBehavior]
14 | public class PricingService : IPricingService
15 | {
16 | List cart = new List();
17 | IProductRepository productRepository;
18 |
19 | public PricingService(IProductRepository productRepository)
20 | {
21 | this.productRepository = productRepository;
22 | }
23 |
24 | public void AddToCart(OrderItem item)
25 | {
26 | this.cart.Add(item);
27 | }
28 |
29 | public double PriceOrder()
30 | {
31 | double result = 0;
32 | foreach (var item in this.cart)
33 | {
34 | Product product = this.productRepository.GetProduct(item.ItemId);
35 | result += product.UnitPrice * item.Amount;
36 | }
37 |
38 | this.cart.Clear();
39 | return result;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/ProductRepositoryFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Runtime.Serialization;
7 | using System.Runtime.Serialization.Json;
8 |
9 | namespace PricingService
10 | {
11 | public class ProductRepositoryFactory
12 | {
13 | private static ProductRepositoryFactory instance;
14 | private IProductRepository repository;
15 |
16 | private ProductRepositoryFactory() { }
17 |
18 | public static ProductRepositoryFactory Instance
19 | {
20 | get
21 | {
22 | if (instance == null)
23 | {
24 | instance = new ProductRepositoryFactory();
25 | }
26 |
27 | return instance;
28 | }
29 | }
30 |
31 | public void SetProductRepository(IProductRepository repository)
32 | {
33 | this.repository = repository;
34 | }
35 |
36 | public IProductRepository CreateProductRepository()
37 | {
38 | return this.repository;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/PricingService/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/InstanceProvider/TestableWcfServices/TestableWcfServices.vsmdi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/ClientCredentialsEx.cs:
--------------------------------------------------------------------------------
1 | using System.IdentityModel.Selectors;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace Client
6 | {
7 | class ClientCredentialsEx : ClientCredentials
8 | {
9 | ClientForm clientForm;
10 |
11 | public ClientCredentialsEx(ClientForm clientForm)
12 | : base()
13 | {
14 | this.clientForm = clientForm;
15 | }
16 |
17 | public ClientCredentialsEx(ClientCredentialsEx other, ClientForm clientForm)
18 | : base(other)
19 | {
20 | this.clientForm = clientForm;
21 | }
22 |
23 | protected override ClientCredentials CloneCore()
24 | {
25 | return new ClientCredentialsEx(this, this.clientForm);
26 | }
27 |
28 | public override void ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime clientRuntime)
29 | {
30 | clientRuntime.InteractiveChannelInitializers.Add(new ShowCredentialsUI(this.clientForm));
31 | base.ApplyClientBehavior(serviceEndpoint, clientRuntime);
32 | }
33 |
34 | public override SecurityTokenManager CreateSecurityTokenManager()
35 | {
36 | return new MyClientCredentialsSecurityTokenManager(this);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/ClientPasswordDialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace Client
5 | {
6 | public partial class ClientPasswordDialog : Form
7 | {
8 | private bool okSelected;
9 | private string userName;
10 | private string password;
11 |
12 | public ClientPasswordDialog()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 | public bool OkSelected
18 | {
19 | get { return this.okSelected; }
20 | }
21 |
22 | public string UserName
23 | {
24 | get { return this.userName; }
25 | }
26 |
27 | public string Password
28 | {
29 | get { return this.password; }
30 | }
31 |
32 | private void btnCancel_Click(object sender, EventArgs e)
33 | {
34 | this.okSelected = false;
35 | this.userName = null;
36 | this.password = null;
37 | this.Close();
38 | }
39 |
40 | private void btnOk_Click(object sender, EventArgs e)
41 | {
42 | this.okSelected = true;
43 | this.userName = this.txtUserName.Text;
44 | this.password = this.txtPassword.Text;
45 | this.Close();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/MyClientCredentialsSecurityTokenManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Description;
7 | using System.IdentityModel.Selectors;
8 | using System.IdentityModel.Tokens;
9 | using System.Net;
10 | using System.ServiceModel.Channels;
11 | using System.ServiceModel.Security.Tokens;
12 |
13 | namespace Client
14 | {
15 | class MyClientCredentialsSecurityTokenManager : ClientCredentialsSecurityTokenManager
16 | {
17 | public MyClientCredentialsSecurityTokenManager(ClientCredentials parent) : base(parent) { }
18 | public override SecurityTokenProvider CreateSecurityTokenProvider(SecurityTokenRequirement tokenRequirement)
19 | {
20 | if (tokenRequirement.KeyUsage == SecurityKeyUsage.Signature)
21 | {
22 | NetworkCredential token = null;
23 | ChannelParameterCollection obj;
24 | obj = (ChannelParameterCollection)tokenRequirement.Properties[
25 | ServiceModelSecurityTokenRequirement.ChannelParametersCollectionProperty];
26 | token = obj[0] as NetworkCredential;
27 | if (tokenRequirement.TokenType == SecurityTokenTypes.UserName)
28 | {
29 | return new MyUserNameSecurityTokenProvider(token);
30 | }
31 | }
32 |
33 | return base.CreateSecurityTokenProvider(tokenRequirement);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/MyUserNameSecurityTokenProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IdentityModel.Selectors;
3 | using System.IdentityModel.Tokens;
4 | using System.Net;
5 |
6 | namespace Client
7 | {
8 | class MyUserNameSecurityTokenProvider : SecurityTokenProvider
9 | {
10 | private NetworkCredential credentials;
11 |
12 | public MyUserNameSecurityTokenProvider(NetworkCredential credentials)
13 | {
14 | this.credentials = credentials;
15 | }
16 |
17 | protected override SecurityToken GetTokenCore(TimeSpan timeout)
18 | {
19 | return new UserNameSecurityToken(this.credentials.UserName, this.credentials.Password);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace Client
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new ClientForm());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.239
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Client.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Client/Service References/ServiceReference1/Service.disco:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/InteractiveChannelInitializer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{ACDBF4EA-C3B5-4221-9B06-F9BB338B385C}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{13231D86-39FF-4551-B2B6-FB9516243621}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {ACDBF4EA-C3B5-4221-9B06-F9BB338B385C}.Debug|x86.ActiveCfg = Debug|x86
15 | {ACDBF4EA-C3B5-4221-9B06-F9BB338B385C}.Debug|x86.Build.0 = Debug|x86
16 | {ACDBF4EA-C3B5-4221-9B06-F9BB338B385C}.Release|x86.ActiveCfg = Release|x86
17 | {ACDBF4EA-C3B5-4221-9B06-F9BB338B385C}.Release|x86.Build.0 = Release|x86
18 | {13231D86-39FF-4551-B2B6-FB9516243621}.Debug|x86.ActiveCfg = Debug|x86
19 | {13231D86-39FF-4551-B2B6-FB9516243621}.Debug|x86.Build.0 = Debug|x86
20 | {13231D86-39FF-4551-B2B6-FB9516243621}.Release|x86.ActiveCfg = Release|x86
21 | {13231D86-39FF-4551-B2B6-FB9516243621}.Release|x86.Build.0 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/CustomAuthorizationPolicy.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IdentityModel.Claims;
4 | using System.IdentityModel.Policy;
5 | using System.Security.Principal;
6 |
7 | namespace Server
8 | {
9 | class CustomAuthorizationPolicy : IAuthorizationPolicy
10 | {
11 | string id = Guid.NewGuid().ToString();
12 |
13 | public string Id
14 | {
15 | get { return this.id; }
16 | }
17 |
18 | public ClaimSet Issuer
19 | {
20 | get { return ClaimSet.System; }
21 | }
22 |
23 | public bool Evaluate(EvaluationContext context, ref object state)
24 | {
25 | object obj;
26 | if (!context.Properties.TryGetValue("Identities", out obj))
27 | return false;
28 |
29 | IList identities = obj as IList;
30 | if (obj == null || identities.Count <= 0)
31 | return false;
32 |
33 | context.Properties["Principal"] = new CustomPrincipal(identities[0]);
34 | return true;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/CustomPrincipal.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Principal;
2 |
3 | namespace Server
4 | {
5 | class CustomPrincipal : IPrincipal
6 | {
7 | IIdentity identity;
8 | public CustomPrincipal(IIdentity identity)
9 | {
10 | this.identity = identity;
11 | }
12 |
13 | public IIdentity Identity
14 | {
15 | get { return this.identity; }
16 | }
17 |
18 | public bool IsInRole(string role)
19 | {
20 | return true;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/MyPasswordValidator.cs:
--------------------------------------------------------------------------------
1 | using System.IdentityModel.Selectors;
2 | using System.IdentityModel.Tokens;
3 |
4 | namespace Server
5 | {
6 | class MyPasswordValidator : UserNamePasswordValidator
7 | {
8 | public override void Validate(string userName, string password)
9 | {
10 | // Very secure password scheme
11 | if (userName != password)
12 | {
13 | throw new SecurityTokenException("Unauthorized");
14 | }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace Server
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new ServerForm());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.239
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Server.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/Service.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.Threading;
3 |
4 | namespace Server
5 | {
6 | [ServiceContract]
7 | public interface ICalculator
8 | {
9 | [OperationContract]
10 | int Add(int x, int y);
11 | [OperationContract]
12 | int Subtract(int x, int y);
13 | [OperationContract]
14 | int Multiply(int x, int y);
15 | [OperationContract]
16 | int Divide(int x, int y);
17 | }
18 |
19 | [ServiceBehavior(UseSynchronizationContext = false)]
20 | public class Service : ICalculator
21 | {
22 | public int Add(int x, int y)
23 | {
24 | this.UpdateServerFormUi("Add");
25 | return x + y;
26 | }
27 |
28 | public int Subtract(int x, int y)
29 | {
30 | this.UpdateServerFormUi("Subtract");
31 | return x - y;
32 | }
33 |
34 | public int Multiply(int x, int y)
35 | {
36 | this.UpdateServerFormUi("Multiply");
37 | return x * y;
38 | }
39 |
40 | public int Divide(int x, int y)
41 | {
42 | this.UpdateServerFormUi("Divide");
43 | return x / y;
44 | }
45 |
46 | private void UpdateServerFormUi(string operationName)
47 | {
48 | ServerForm.UserCalled(Thread.CurrentPrincipal.Identity.Name, operationName);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/InteractiveChannelInitializer/Server/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MessageEncoder/ChangeXmlPrefixes/CalculatorService.cs:
--------------------------------------------------------------------------------
1 | namespace ChangeXmlPrefixes
2 | {
3 | public class CalculatorService : ICalculator
4 | {
5 | public int Add(int x, int y)
6 | {
7 | return x + y;
8 | }
9 |
10 | public int Subtract(int x, int y)
11 | {
12 | return x - y;
13 | }
14 |
15 | public int Multiply(int x, int y)
16 | {
17 | return x * y;
18 | }
19 |
20 | public int Divide(int x, int y)
21 | {
22 | return x / y;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/MessageEncoder/ChangeXmlPrefixes/ChangeXmlPrefixes.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChangeXmlPrefixes", "ChangeXmlPrefixes.csproj", "{517FFFC9-2279-4ECB-B44D-29FCB7C51EAF}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {517FFFC9-2279-4ECB-B44D-29FCB7C51EAF}.Debug|x86.ActiveCfg = Debug|x86
13 | {517FFFC9-2279-4ECB-B44D-29FCB7C51EAF}.Debug|x86.Build.0 = Debug|x86
14 | {517FFFC9-2279-4ECB-B44D-29FCB7C51EAF}.Release|x86.ActiveCfg = Release|x86
15 | {517FFFC9-2279-4ECB-B44D-29FCB7C51EAF}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MessageEncoder/ChangeXmlPrefixes/ICalculator.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace ChangeXmlPrefixes
4 | {
5 | [ServiceContract(Name = "ITest", Namespace = "http://service.contract.namespace")]
6 | public interface ICalculator
7 | {
8 | [OperationContract]
9 | int Add(int x, int y);
10 |
11 | [OperationContract]
12 | int Subtract(int x, int y);
13 |
14 | [OperationContract]
15 | int Multiply(int x, int y);
16 |
17 | [OperationContract]
18 | int Divide(int x, int y);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/MessageEncoder/ChangeXmlPrefixes/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MessageEncoder/CompositeEncoder/CompositeEncoder.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompositeEncoder", "CompositeEncoder.csproj", "{3CBF5FE1-A74E-4651-A88D-0CDC54F8BDB6}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {3CBF5FE1-A74E-4651-A88D-0CDC54F8BDB6}.Debug|x86.ActiveCfg = Debug|x86
13 | {3CBF5FE1-A74E-4651-A88D-0CDC54F8BDB6}.Debug|x86.Build.0 = Debug|x86
14 | {3CBF5FE1-A74E-4651-A88D-0CDC54F8BDB6}.Release|x86.ActiveCfg = Release|x86
15 | {3CBF5FE1-A74E-4651-A88D-0CDC54F8BDB6}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MessageEncoder/CompositeEncoder/Contracts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 | using System.ServiceModel;
4 | using System.ServiceModel.Channels;
5 | using System.Net;
6 |
7 | namespace CompositeEncoder
8 | {
9 | [DataContract]
10 | public class MyDC
11 | {
12 | [DataMember]
13 | public string Name;
14 | [DataMember]
15 | public byte[] Contents;
16 | }
17 |
18 | [ServiceContract]
19 | public interface ITest
20 | {
21 | [OperationContract]
22 | MyDC Echo(MyDC input);
23 | }
24 |
25 | public class Service : ITest
26 | {
27 | public MyDC Echo(MyDC input)
28 | {
29 | HttpRequestMessageProperty requestProperty;
30 | requestProperty = (HttpRequestMessageProperty)OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name];
31 | Console.WriteLine("In service, incoming content-type = {0}", requestProperty.Headers[HttpRequestHeader.ContentType]);
32 | return input;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/MessageEncoder/CompositeEncoder/MyReadMtomWriteXmlEncoderFactory.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 |
3 | namespace CompositeEncoder
4 | {
5 | class MyReadMtomWriteXmlEncoderFactory : MessageEncoderFactory
6 | {
7 | MessageEncoderFactory mtom;
8 | MessageEncoderFactory text;
9 |
10 | public MyReadMtomWriteXmlEncoderFactory(MessageEncoderFactory mtom, MessageEncoderFactory text)
11 | {
12 | this.mtom = mtom;
13 | this.text = text;
14 | }
15 |
16 | public override MessageEncoder Encoder
17 | {
18 | get { return new MyReadMtomWriteXmlEncoder(this.mtom.Encoder, this.text.Encoder); }
19 | }
20 |
21 | public override MessageVersion MessageVersion
22 | {
23 | get { return this.mtom.MessageVersion; }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MessageEncoder/CompositeEncoder/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MessageEncoder/GZipEncoderAndAutoFormatSelection/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/MessageEncoder/GZipEncoderAndAutoFormatSelection/GZipEncoderAndAutoFormatSelection.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GZipEncoderAndAutoFormatSelection", "GZipEncoderAndAutoFormatSelection.csproj", "{C08A5E90-14AB-4E21-A400-EF6807AA1C67}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C08A5E90-14AB-4E21-A400-EF6807AA1C67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {C08A5E90-14AB-4E21-A400-EF6807AA1C67}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {C08A5E90-14AB-4E21-A400-EF6807AA1C67}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {C08A5E90-14AB-4E21-A400-EF6807AA1C67}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/MessageEncoder/GZipEncoderAndAutoFormatSelection/Service.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel;
3 | using System.Runtime.Serialization;
4 | using System.ServiceModel;
5 | using System.ServiceModel.Web;
6 |
7 | namespace GZipEncoderAndAutoFormatSelection
8 | {
9 | [DataContract(Name = "DataObject", Namespace = "")]
10 | public class DataObject : IExtensibleDataObject
11 | {
12 | [DataMember]
13 | public string Name { get; set; }
14 |
15 | [DataMember]
16 | public string Description { get; set; }
17 |
18 | [DataMember]
19 | public int UID { get; set; }
20 |
21 | public ExtensionDataObject ExtensionData { get; set; }
22 | }
23 |
24 | [ServiceContract]
25 | public interface ITest
26 | {
27 | [OperationContract]
28 | [Description("Gets a collection of objects.")]
29 | [WebGet(UriTemplate = "Objects")]
30 | List GetObjects();
31 |
32 | [OperationContract]
33 | [Description("Adds a new Object")]
34 | [WebInvoke(Method = "POST", UriTemplate = "Objects")]
35 | void PostObject(DataObject o);
36 | }
37 |
38 | public class Service : ITest
39 | {
40 | protected static List data = new List();
41 |
42 | public List GetObjects()
43 | {
44 | return data;
45 | }
46 |
47 | public void PostObject(DataObject o)
48 | {
49 | data.Add(o);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/MessageFormatter/MessageFormatter/JsonNetMessageFormatter/ITestService.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.ServiceModel.Web;
3 |
4 | namespace JsonNetMessageFormatter
5 | {
6 | [ServiceContract]
7 | public interface ITestService
8 | {
9 | [WebGet, OperationContract]
10 | Person GetPerson();
11 | [WebInvoke, OperationContract]
12 | Pet EchoPet(Pet pet);
13 | [WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest), OperationContract]
14 | int Add(int x, int y);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/MessageFormatter/MessageFormatter/JsonNetMessageFormatter/RawBodyWriter.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.Xml;
3 |
4 | namespace JsonNetMessageFormatter
5 | {
6 | class RawBodyWriter : BodyWriter
7 | {
8 | byte[] content;
9 | public RawBodyWriter(byte[] content)
10 | : base(true)
11 | {
12 | this.content = content;
13 | }
14 |
15 | protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
16 | {
17 | writer.WriteStartElement("Binary");
18 | writer.WriteBase64(content, 0, content.Length);
19 | writer.WriteEndElement();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/MessageFormatter/MessageFormatter/JsonNetMessageFormatter/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace JsonNetMessageFormatter
5 | {
6 | public class Service : ITestService
7 | {
8 | public Person GetPerson()
9 | {
10 | return new Person
11 | {
12 | FirstName = "First",
13 | LastName = "Last",
14 | BirthDate = new DateTime(1993, 4, 17, 2, 51, 37, 47, DateTimeKind.Local),
15 | Id = 0,
16 | Pets = new List
17 | {
18 | new Pet { Name= "Generic Pet 1", Color = "Beige", Id = 0, Markings = "Some markings" },
19 | new Pet { Name= "Generic Pet 2", Color = "Gold", Id = 0, Markings = "Other markings" },
20 | },
21 | };
22 | }
23 |
24 | public Pet EchoPet(Pet pet)
25 | {
26 | return pet;
27 | }
28 |
29 | public int Add(int x, int y)
30 | {
31 | return x + y;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/MessageFormatter/MessageFormatter/JsonNetMessageFormatter/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MessageFormatter/MessageFormatter/MessageFormatter.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonNetMessageFormatter", "JsonNetMessageFormatter\JsonNetMessageFormatter.csproj", "{3C8DF9B5-BECF-4EC0-AA12-C9C78173E6BE}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {3C8DF9B5-BECF-4EC0-AA12-C9C78173E6BE}.Debug|x86.ActiveCfg = Debug|x86
13 | {3C8DF9B5-BECF-4EC0-AA12-C9C78173E6BE}.Debug|x86.Build.0 = Debug|x86
14 | {3C8DF9B5-BECF-4EC0-AA12-C9C78173E6BE}.Release|x86.ActiveCfg = Release|x86
15 | {3C8DF9B5-BECF-4EC0-AA12-C9C78173E6BE}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MessageFormatter/MessageFormatter/lib/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/carlosfigueira/WCFSamples/d490563ed37b41433ffb5c5c0820c2a861ef319b/MessageFormatter/MessageFormatter/lib/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/MessageFormatter/PerOperationContentTypeMapper/DualModeWebHttpBehavior.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Web;
7 | using System.IO;
8 | using System.ServiceModel.Channels;
9 | using System.ServiceModel.Description;
10 | using System.ServiceModel.Dispatcher;
11 | using System.Net;
12 |
13 | namespace PerOperationContentTypeMapper
14 | {
15 | public class DualModeWebHttpBehavior : WebHttpBehavior
16 | {
17 | protected override IDispatchMessageFormatter GetRequestDispatchFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
18 | {
19 | IDispatchMessageFormatter originalFormatter = base.GetRequestDispatchFormatter(operationDescription, endpoint);
20 | return new DualModeFormatter(operationDescription, originalFormatter);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/MessageFormatter/PerOperationContentTypeMapper/NonRawAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Web;
7 | using System.IO;
8 | using System.ServiceModel.Channels;
9 | using System.ServiceModel.Description;
10 | using System.ServiceModel.Dispatcher;
11 | using System.Net;
12 |
13 | namespace PerOperationContentTypeMapper
14 | {
15 | public class NonRawAttribute : Attribute, IOperationBehavior
16 | {
17 | public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
18 | {
19 | }
20 |
21 | public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
22 | {
23 | }
24 |
25 | public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
26 | {
27 | }
28 |
29 | public void Validate(OperationDescription operationDescription)
30 | {
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/MessageFormatter/PerOperationContentTypeMapper/PerOperationContentTypeMapper.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerOperationContentTypeMapper", "PerOperationContentTypeMapper.csproj", "{5A2EF653-22D8-4200-B821-84A7425D1037}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {5A2EF653-22D8-4200-B821-84A7425D1037}.Debug|x86.ActiveCfg = Debug|x86
13 | {5A2EF653-22D8-4200-B821-84A7425D1037}.Debug|x86.Build.0 = Debug|x86
14 | {5A2EF653-22D8-4200-B821-84A7425D1037}.Release|x86.ActiveCfg = Release|x86
15 | {5A2EF653-22D8-4200-B821-84A7425D1037}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MessageFormatter/PerOperationContentTypeMapper/RawContentTypeMapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Web;
7 | using System.IO;
8 | using System.ServiceModel.Channels;
9 | using System.ServiceModel.Description;
10 | using System.ServiceModel.Dispatcher;
11 | using System.Net;
12 |
13 | namespace PerOperationContentTypeMapper
14 | {
15 | class RawContentTypeMapper : WebContentTypeMapper
16 | {
17 | public override WebContentFormat GetMessageFormatForContentType(string contentType)
18 | {
19 | return WebContentFormat.Raw;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/MessageFormatter/PerOperationContentTypeMapper/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Web;
7 | using System.IO;
8 | using System.ServiceModel.Channels;
9 | using System.ServiceModel.Description;
10 | using System.ServiceModel.Dispatcher;
11 | using System.Net;
12 |
13 | namespace PerOperationContentTypeMapper
14 | {
15 | [ServiceContract]
16 | public class Service
17 | {
18 | [WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest)]
19 | [NonRaw]
20 | public int Add(int x, int y)
21 | {
22 | return x + y;
23 | }
24 |
25 | [WebInvoke]
26 | public string Upload(Stream data)
27 | {
28 | return new StreamReader(data).ReadToEnd();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MessageFormatter/PerOperationContentTypeMapper/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MessageInspector/InspectNonXmlMessages/InspectNonXmlMessages.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual C# Express 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InspectNonXmlMessages", "InspectNonXmlMessages.csproj", "{B933DA5F-6BF0-471E-9DFC-68621C1111A1}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {B933DA5F-6BF0-471E-9DFC-68621C1111A1}.Debug|x86.ActiveCfg = Debug|x86
13 | {B933DA5F-6BF0-471E-9DFC-68621C1111A1}.Debug|x86.Build.0 = Debug|x86
14 | {B933DA5F-6BF0-471E-9DFC-68621C1111A1}.Release|x86.ActiveCfg = Release|x86
15 | {B933DA5F-6BF0-471E-9DFC-68621C1111A1}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MessageInspector/InspectNonXmlMessages/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/OperationInvoker/CachingOperationInvoker/CacheableOperationAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel.Channels;
3 | using System.ServiceModel.Description;
4 | using System.ServiceModel.Dispatcher;
5 |
6 | namespace OperationSelectorExample
7 | {
8 | public class CacheableOperationAttribute : Attribute, IOperationBehavior
9 | {
10 | double secondsToCache;
11 | public CacheableOperationAttribute()
12 | {
13 | this.secondsToCache = 30;
14 | }
15 |
16 | public double SecondsToCache
17 | {
18 | get { return this.secondsToCache; }
19 | set { this.secondsToCache = value; }
20 | }
21 |
22 | public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
23 | {
24 | }
25 |
26 | public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
27 | {
28 | }
29 |
30 | public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
31 | {
32 | dispatchOperation.Invoker = new CachingOperationInvoker(dispatchOperation.Invoker, this.secondsToCache);
33 | }
34 |
35 | public void Validate(OperationDescription operationDescription)
36 | {
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/OperationInvoker/CachingOperationInvoker/CachingOperationInvoker.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CachingOperationInvoker", "CachingOperationInvoker.csproj", "{4FD4988A-06E7-4CC7-82A4-79B203137A15}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {4FD4988A-06E7-4CC7-82A4-79B203137A15}.Debug|x86.ActiveCfg = Debug|x86
13 | {4FD4988A-06E7-4CC7-82A4-79B203137A15}.Debug|x86.Build.0 = Debug|x86
14 | {4FD4988A-06E7-4CC7-82A4-79B203137A15}.Release|x86.ActiveCfg = Release|x86
15 | {4FD4988A-06E7-4CC7-82A4-79B203137A15}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/OperationInvoker/CachingOperationInvoker/Interface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 |
4 | namespace OperationSelectorExample
5 | {
6 | [ServiceContract]
7 | public interface ITest
8 | {
9 | [OperationContract]
10 | int Add(int x, int y);
11 |
12 | [OperationContract]
13 | [CacheableOperation(SecondsToCache = 10)]
14 | string Reverse(string input);
15 |
16 | [OperationContract(AsyncPattern=true)]
17 | [CacheableOperation(SecondsToCache = 30)]
18 | IAsyncResult BeginPower(double x, double y, AsyncCallback callback, object state);
19 | double EndPower(IAsyncResult asyncResult);
20 |
21 | [OperationContract, CacheableOperation]
22 | bool TryParseInt(string input, out int value);
23 |
24 | [OperationContract(AsyncPattern = true), CacheableOperation]
25 | IAsyncResult BeginTryParseDouble(string input, AsyncCallback callback, object state);
26 | bool EndTryParseDouble(out double value, IAsyncResult asyncResult);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/OperationInvoker/CachingOperationInvoker/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/OperationSelector/HttpMethodOverrideOperationSelection/HttpMethodOverrideOperationSelection.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpMethodOverrideOperationSelection", "HttpMethodOverrideOperationSelection.csproj", "{DD26848E-F3BD-4940-81FF-621434801FAE}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {DD26848E-F3BD-4940-81FF-621434801FAE}.Debug|x86.ActiveCfg = Debug|x86
13 | {DD26848E-F3BD-4940-81FF-621434801FAE}.Debug|x86.Build.0 = Debug|x86
14 | {DD26848E-F3BD-4940-81FF-621434801FAE}.Release|x86.ActiveCfg = Release|x86
15 | {DD26848E-F3BD-4940-81FF-621434801FAE}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/OperationSelector/HttpMethodOverrideOperationSelection/HttpOverrideBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace HttpMethodOverrideOperationSelection
6 | {
7 | public class HttpOverrideBehavior : IEndpointBehavior
8 | {
9 | public const string HttpMethodOverrideHeaderName = "X-HTTP-Method-Override";
10 | public const string OriginalHttpMethodPropertyName = "OriginalHttpMethod";
11 |
12 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
13 | {
14 | }
15 |
16 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
17 | {
18 | }
19 |
20 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
21 | {
22 | endpointDispatcher.DispatchRuntime.OperationSelector = new HttpOverrideOperationSelector(endpointDispatcher.DispatchRuntime.OperationSelector);
23 | }
24 |
25 | public void Validate(ServiceEndpoint endpoint)
26 | {
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/OperationSelector/HttpMethodOverrideOperationSelection/HttpOverrideOperationSelector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel.Channels;
3 | using System.ServiceModel.Dispatcher;
4 |
5 | namespace HttpMethodOverrideOperationSelection
6 | {
7 | class HttpOverrideOperationSelector : IDispatchOperationSelector
8 | {
9 | private IDispatchOperationSelector originalSelector;
10 |
11 | public HttpOverrideOperationSelector(IDispatchOperationSelector originalSelector)
12 | {
13 | this.originalSelector = originalSelector;
14 | }
15 |
16 | public string SelectOperation(ref Message message)
17 | {
18 | if (message.Properties.ContainsKey(HttpRequestMessageProperty.Name))
19 | {
20 | HttpRequestMessageProperty reqProp;
21 | reqProp = (HttpRequestMessageProperty)message.Properties[HttpRequestMessageProperty.Name];
22 | string httpMethodOverride = reqProp.Headers[HttpOverrideBehavior.HttpMethodOverrideHeaderName];
23 | if (!String.IsNullOrEmpty(httpMethodOverride))
24 | {
25 | message.Properties[HttpOverrideBehavior.OriginalHttpMethodPropertyName] = reqProp.Method;
26 | reqProp.Method = httpMethodOverride;
27 | }
28 | }
29 |
30 | return this.originalSelector.SelectOperation(ref message);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/OperationSelector/HttpMethodOverrideOperationSelection/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Those are samples which I've posted in the MSDN Code Gallery, at
2 | http://code.msdn.microsoft.com/site/search?f[0].Type=User&f[0].Value=CarlosFigueira,
3 | along with some additional code not in the sample (for example, some additional
4 | projects I used to answer some questions in the associated posts.
5 |
6 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CORS.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CorsEnabledService", "CorsEnabledService\CorsEnabledService.csproj", "{E37581A8-6A34-4EFF-B82A-9CE85B6F8571}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MashupApp", "MashupApp\MashupApp.csproj", "{8C0F330C-89F9-4CAD-B94C-45F32CE5374E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {E37581A8-6A34-4EFF-B82A-9CE85B6F8571}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {E37581A8-6A34-4EFF-B82A-9CE85B6F8571}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {E37581A8-6A34-4EFF-B82A-9CE85B6F8571}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {E37581A8-6A34-4EFF-B82A-9CE85B6F8571}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {8C0F330C-89F9-4CAD-B94C-45F32CE5374E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {8C0F330C-89F9-4CAD-B94C-45F32CE5374E}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {8C0F330C-89F9-4CAD-B94C-45F32CE5374E}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {8C0F330C-89F9-4CAD-B94C-45F32CE5374E}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/CorsConstants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CorsEnabledService
4 | {
5 | class CorsConstants
6 | {
7 | internal const string Origin = "Origin";
8 | internal const string AccessControlAllowOrigin = "Access-Control-Allow-Origin";
9 | internal const string AccessControlRequestMethod = "Access-Control-Request-Method";
10 | internal const string AccessControlRequestHeaders = "Access-Control-Request-Headers";
11 | internal const string AccessControlAllowMethods = "Access-Control-Allow-Methods";
12 | internal const string AccessControlAllowHeaders = "Access-Control-Allow-Headers";
13 |
14 | internal const string PreflightSuffix = "_preflight_";
15 | }
16 | }
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/CorsEnabledAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel.Channels;
3 | using System.ServiceModel.Description;
4 | using System.ServiceModel.Dispatcher;
5 |
6 | namespace CorsEnabledService
7 | {
8 | public class CorsEnabledAttribute : Attribute, IOperationBehavior
9 | {
10 | public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
11 | {
12 | }
13 |
14 | public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
15 | {
16 | }
17 |
18 | public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
19 | {
20 | }
21 |
22 | public void Validate(OperationDescription operationDescription)
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/EnableCorsEndpointBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.ServiceModel.Channels;
4 | using System.ServiceModel.Description;
5 | using System.ServiceModel.Dispatcher;
6 |
7 | namespace CorsEnabledService
8 | {
9 | class EnableCorsEndpointBehavior : IEndpointBehavior
10 | {
11 | public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
12 | {
13 | }
14 |
15 | public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
16 | {
17 | }
18 |
19 | public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
20 | {
21 | List corsEnabledOperations = endpoint.Contract.Operations
22 | .Where(o => o.Behaviors.Find() != null)
23 | .ToList();
24 | endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new CorsEnabledMessageInspector(corsEnabledOperations));
25 | }
26 |
27 | public void Validate(ServiceEndpoint endpoint)
28 | {
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="CorsEnabledService.Global" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Security;
6 | using System.Web.SessionState;
7 | using System.Web.Routing;
8 | using System.ServiceModel.Activation;
9 |
10 | namespace CorsEnabledService
11 | {
12 | public class Global : System.Web.HttpApplication
13 | {
14 |
15 | protected void Application_Start(object sender, EventArgs e)
16 | {
17 | RouteTable.Routes.Add(new ServiceRoute("api", new CorsEnabledServiceHostFactory(), typeof(ValuesService)));
18 | }
19 |
20 | protected void Session_Start(object sender, EventArgs e)
21 | {
22 |
23 | }
24 |
25 | protected void Application_BeginRequest(object sender, EventArgs e)
26 | {
27 |
28 | }
29 |
30 | protected void Application_AuthenticateRequest(object sender, EventArgs e)
31 | {
32 |
33 | }
34 |
35 | protected void Application_Error(object sender, EventArgs e)
36 | {
37 |
38 | }
39 |
40 | protected void Session_End(object sender, EventArgs e)
41 | {
42 |
43 | }
44 |
45 | protected void Application_End(object sender, EventArgs e)
46 | {
47 |
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/IValues.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.ServiceModel;
6 | using System.Text;
7 | using System.ServiceModel.Web;
8 |
9 | namespace CorsEnabledService
10 | {
11 | [ServiceContract]
12 | public interface IValues
13 | {
14 | [WebGet(UriTemplate = "values", ResponseFormat = WebMessageFormat.Json), CorsEnabled]
15 | List GetValues();
16 | [WebGet(UriTemplate = "values/{id}", ResponseFormat = WebMessageFormat.Json), CorsEnabled]
17 | string GetValue(string id);
18 | [WebInvoke(UriTemplate = "/values", Method = "POST", ResponseFormat = WebMessageFormat.Json), CorsEnabled]
19 | void AddValue(string value);
20 | [WebInvoke(UriTemplate = "/values/{id}", Method = "DELETE", ResponseFormat = WebMessageFormat.Json), CorsEnabled]
21 | void DeleteValue(string id);
22 | [WebInvoke(UriTemplate = "/values/{id}", Method = "PUT", ResponseFormat = WebMessageFormat.Json), CorsEnabled]
23 | string UpdateValue(string id, string value);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/PreflightOperationBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.ServiceModel.Description;
3 | using System.ServiceModel.Dispatcher;
4 | using System.Collections.Generic;
5 |
6 | namespace CorsEnabledService
7 | {
8 | class PreflightOperationBehavior : IOperationBehavior
9 | {
10 | private OperationDescription preflightOperation;
11 | private List allowedMethods;
12 |
13 | public PreflightOperationBehavior(OperationDescription preflightOperation)
14 | {
15 | this.preflightOperation = preflightOperation;
16 | this.allowedMethods = new List();
17 | }
18 |
19 | public void AddAllowedMethod(string httpMethod)
20 | {
21 | this.allowedMethods.Add(httpMethod);
22 | }
23 |
24 | public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
25 | {
26 | }
27 |
28 | public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
29 | {
30 | }
31 |
32 | public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
33 | {
34 | dispatchOperation.Invoker = new PreflightOperationInvoker(operationDescription.Messages[1].Action, this.allowedMethods);
35 | }
36 |
37 | public void Validate(OperationDescription operationDescription)
38 | {
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CorsEnabledService")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CorsEnabledService")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7804dad6-45f6-401c-971d-b14eb2366412")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/Scenarios/CORS/CorsEnabledService/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Scenarios/CORS/MashupApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MashupApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MashupApp")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f09d3b10-92cd-4d33-b9da-7faa70e48a86")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Scenarios/CORS/MashupApp/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/Scenarios/CORS/MashupApp/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/Scenarios/CORS/MashupApp/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/JsonClient.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLApp", "SLApp\SLApp.csproj", "{0FDEEBA0-1E86-41D7-957D-048B9AA76EC2}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLApp.Web", "SLApp.Web\SLApp.Web.csproj", "{02DA7756-BD50-4BA3-A681-4345D8738803}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {0FDEEBA0-1E86-41D7-957D-048B9AA76EC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {0FDEEBA0-1E86-41D7-957D-048B9AA76EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {0FDEEBA0-1E86-41D7-957D-048B9AA76EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {0FDEEBA0-1E86-41D7-957D-048B9AA76EC2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {02DA7756-BD50-4BA3-A681-4345D8738803}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {02DA7756-BD50-4BA3-A681-4345D8738803}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {02DA7756-BD50-4BA3-A681-4345D8738803}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {02DA7756-BD50-4BA3-A681-4345D8738803}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp.Web/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp.Web")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp.Web")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f9da8457-d3d6-4da6-806c-641ebd203db0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp.Web/RestService.svc:
--------------------------------------------------------------------------------
1 | <%@ ServiceHost Language="C#" Debug="true" Service="SLApp.Web.RestService" CodeBehind="RestService.svc.cs" %>
2 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp.Web/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp.Web/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp.Web/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Silverlight/JsonClient/SLApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("65529901-a156-43c3-882e-db2f3e2704b9")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp.Web/IWcfDownloadService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | #if SILVERLIGHT
4 | using System.Runtime.Serialization;
5 | #endif
6 | using System.ServiceModel;
7 | #if !SILVERLIGHT
8 | using System.ServiceModel.Activation;
9 | #endif
10 | using System.ServiceModel.Channels;
11 |
12 | namespace SLApp.Web
13 | {
14 | [ServiceContract(Namespace = "")]
15 | public interface IWcfDownloadService
16 | {
17 | #if !SILVERLIGHT
18 | [OperationContract(Action = Constants.DownloadAction, ReplyAction = Constants.DownloadReplyAction)]
19 | Stream Download(string fileName, long fileSize);
20 | #else
21 | [OperationContract(AsyncPattern = true, Action = Constants.DownloadAction, ReplyAction = Constants.DownloadReplyAction)]
22 | IAsyncResult BeginDownload(Message request, AsyncCallback callback, object state);
23 | Message EndDownload(IAsyncResult asyncResult);
24 | #endif
25 | }
26 |
27 | public static class Constants
28 | {
29 | public const string DownloadAction = "http://my.company.com/download";
30 | public const string DownloadReplyAction = "http://my.company.com/download";
31 | }
32 |
33 | #if SILVERLIGHT
34 | [DataContract(Name = "Download", Namespace = "")] // same namespace as the [ServiceContract], same name as operation
35 | public class DownloadRequest
36 | {
37 | [DataMember(Order = 1)]
38 | public string fileName;
39 | [DataMember(Order = 2)]
40 | public long fileSize;
41 | }
42 | #endif
43 | }
44 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp.Web/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp.Web")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp.Web")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7545f2a0-40e8-4b8f-aacf-2c5992629fce")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp.Web/WcfDownloadService.svc:
--------------------------------------------------------------------------------
1 | <%@ ServiceHost Language="C#" Debug="true" Service="SLApp.Web.WcfDownloadService" CodeBehind="WcfDownloadService.svc.cs" %>
2 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp.Web/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp.Web/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp.Web/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
24 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1301a8ec-f38d-40f7-820c-6ebc77bdf838")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/Service References/ServiceReference1/WcfDownloadService.disco:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/Service References/ServiceReference1/WcfDownloadService1.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/Service References/ServiceReference1/WcfDownloadService2.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Silverlight/StreamedResponses/SLApp/ServiceReferences.ClientConfig:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
21 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp.Web/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp.Web")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp.Web")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cd977fd3-8ff6-4bcc-9821-f24fd34ffbd4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp.Web/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp.Web/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp.Web/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace SLApp
6 | {
7 | public partial class MainPage : UserControl
8 | {
9 | public MainPage()
10 | {
11 | InitializeComponent();
12 | }
13 |
14 | private void Button_Click(object sender, RoutedEventArgs e)
15 | {
16 | ServiceReference1.TestClient client = new ServiceReference1.TestClient();
17 | client.EchoCompleted += new EventHandler(client_EchoCompleted);
18 | client.EchoAsync("Hello");
19 | this.txtDebug.Text = this.txtDebug.Text + "Called the service" + Environment.NewLine;
20 | }
21 |
22 | void client_EchoCompleted(object sender, ServiceReference1.EchoCompletedEventArgs e)
23 | {
24 | this.txtDebug.Text = this.txtDebug.Text + "Server response: " + e.Result + Environment.NewLine;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("5ef4a36c-5474-4c67-9590-86c7794e34d4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/Service References/ServiceReference1/configuration.svcinfo:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/Service References/ServiceReference1/item.disco:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/Service References/ServiceReference1/item.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SLApp/ServiceReferences.ClientConfig:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/SilverlightSelfHostedService/SelfHostedService/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp.Web/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp.Web")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp.Web")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0edb4942-94fa-45e8-ba8b-a81024711a6d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp.Web/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp.Web/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp.Web/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 | using System.Windows.Input;
9 | using System.Windows.Media;
10 | using System.Windows.Media.Animation;
11 | using System.Windows.Shapes;
12 |
13 | namespace SLApp
14 | {
15 | public partial class MainPage : UserControl
16 | {
17 | public MainPage()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | private void Button_Click(object sender, RoutedEventArgs e)
23 | {
24 | ServiceReference1.TestClient client = new ServiceReference1.TestClient();
25 | client.EchoCompleted += new EventHandler(client_EchoCompleted);
26 | client.EchoAsync("Hello world");
27 | this.AddToDebug("Called the service");
28 | }
29 |
30 | void client_EchoCompleted(object sender, ServiceReference1.EchoCompletedEventArgs e)
31 | {
32 | this.AddToDebug("Service replied: {0}", e.Result);
33 | }
34 |
35 | void AddToDebug(string text, params object[] args)
36 | {
37 | if (args != null && args.Length > 0)
38 | {
39 | text = string.Format(text, args);
40 | }
41 |
42 | this.txtDebug.Text = this.txtDebug.Text + text + Environment.NewLine;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SLApp")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("SLApp")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c8c730bf-c771-4bca-9446-3f90a4816770")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/Service References/ServiceReference1/service.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/SLApp/ServiceReferences.ClientConfig:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/Service/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Description;
4 |
5 | namespace Service
6 | {
7 | [ServiceContract]
8 | public interface ITest
9 | {
10 | [OperationContract]
11 | string Echo(string text);
12 | }
13 | public class Service : ITest
14 | {
15 | public string Echo(string text)
16 | {
17 | return text;
18 | }
19 | }
20 |
21 | class Program
22 | {
23 | static void Main(string[] args)
24 | {
25 | string baseAddressTcp = "net.tcp://localhost:4504/Service";
26 | ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddressTcp));
27 | host.AddServiceEndpoint(typeof(ITest), new NetTcpBinding(SecurityMode.None), "");
28 | ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
29 | host.Description.Behaviors.Add(smb);
30 | host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
31 | host.Open();
32 | Console.WriteLine("Host opened");
33 | Console.Write("Press ENTER to close");
34 | Console.ReadLine();
35 | host.Close();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/SilverlightTcpSelfHostedService/Service/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/StreamingInsideDataContracts/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 |
7 | namespace StreamingInsideDataContractsClient
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | SomeServiceClient c = new SomeServiceClient();
14 |
15 | byte[] fileContents = new byte[100];
16 | for (int i = 0; i < fileContents.Length; i++)
17 | {
18 | fileContents[i] = (byte)'a';
19 | }
20 |
21 | RequestClass request = new RequestClass
22 | {
23 | id = "id",
24 | token = "token",
25 | content = new Content
26 | {
27 | name = "file",
28 | extension = "ext",
29 | //data = fileContents,
30 | DataStream = new MemoryStream(fileContents),
31 | },
32 | };
33 |
34 | c.SendRequest(request);
35 |
36 | ResponseClass resp = c.GetResponse(234);
37 | Console.WriteLine(resp.content.name);
38 | Stream dataStream = resp.content.GetDataStream();
39 | string text = new StreamReader(dataStream).ReadToEnd();
40 | Console.WriteLine("Data stream: {0}", text);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/StreamingInsideDataContracts/Client/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/StreamingInsideDataContracts/Server/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/StreamingInsideDataContracts/StreamingInsideDataContracts.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{C1B397D1-EB24-4FC2-8DE0-FD19207E5E90}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{77B577C1-3D35-495C-B46E-9539E4328D05}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C1B397D1-EB24-4FC2-8DE0-FD19207E5E90}.Debug|x86.ActiveCfg = Debug|x86
15 | {C1B397D1-EB24-4FC2-8DE0-FD19207E5E90}.Debug|x86.Build.0 = Debug|x86
16 | {C1B397D1-EB24-4FC2-8DE0-FD19207E5E90}.Release|x86.ActiveCfg = Release|x86
17 | {C1B397D1-EB24-4FC2-8DE0-FD19207E5E90}.Release|x86.Build.0 = Release|x86
18 | {77B577C1-3D35-495C-B46E-9539E4328D05}.Debug|x86.ActiveCfg = Debug|x86
19 | {77B577C1-3D35-495C-B46E-9539E4328D05}.Debug|x86.Build.0 = Debug|x86
20 | {77B577C1-3D35-495C-B46E-9539E4328D05}.Release|x86.ActiveCfg = Release|x86
21 | {77B577C1-3D35-495C-B46E-9539E4328D05}.Release|x86.Build.0 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/Utils/Formatting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel.Channels;
3 | using System.Xml;
4 |
5 | namespace CustomTcpDuplex.Utils
6 | {
7 | public static class Formatting
8 | {
9 | public static int BytesToSize(byte[] bytes, int offset)
10 | {
11 | return bytes[offset] << 24 |
12 | bytes[offset + 1] << 16 |
13 | bytes[offset + 2] << 8 |
14 | bytes[offset + 3];
15 | }
16 |
17 | public static void SizeToBytes(int size, byte[] bytes, int offset)
18 | {
19 | bytes[offset + 0] = (byte)(size >> 24);
20 | bytes[offset + 1] = (byte)(size >> 16);
21 | bytes[offset + 2] = (byte)(size >> 8);
22 | bytes[offset + 3] = (byte)(size);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfClient/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel;
6 | using System.ServiceModel.Channels;
7 | using CustomTcpDuplex.Channels;
8 |
9 | namespace CustomTcpDuplex.WcfClient
10 | {
11 | [ServiceContract]
12 | public interface ITypedTest
13 | {
14 | [OperationContract]
15 | int Add(int x, int y);
16 | [OperationContract]
17 | int Subtract(int x, int y);
18 | }
19 |
20 | class Program
21 | {
22 | static void Main(string[] args)
23 | {
24 | SocketsServer s = new SocketsServer(8000);
25 | s.StartServing();
26 |
27 | Binding binding = new CustomBinding(new SizedTcpDuplexTransportBindingElement());
28 | string address = SizedTcpDuplexTransportBindingElement.SizedTcpScheme + "://localhost:8000";
29 | ChannelFactory factory = new ChannelFactory(binding, new EndpointAddress(address));
30 | ITypedTest proxy = factory.CreateChannel();
31 |
32 | Console.WriteLine(proxy.Add(4, 5));
33 | Console.WriteLine(proxy.Subtract(44, 66));
34 |
35 | s.StopServing();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfClient/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfDuplex/Contracts.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace WcfDuplex
4 | {
5 | [ServiceContract(CallbackContract = typeof(ITestCallback))]
6 | public interface ITest
7 | {
8 | [OperationContract]
9 | void Hello(string text);
10 | }
11 |
12 | [ServiceContract]
13 | public interface ITestCallback
14 | {
15 | [OperationContract(IsOneWay = true)]
16 | void OnHello(string text);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfDuplex/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.Threading;
4 |
5 | namespace WcfDuplex
6 | {
7 | public class Service : ITest
8 | {
9 | public void Hello(string text)
10 | {
11 | Console.WriteLine("[server received] {0}", text);
12 | ITestCallback callback = OperationContext.Current.GetCallbackChannel();
13 | ThreadPool.QueueUserWorkItem(delegate
14 | {
15 | for (int i = 1; i <= 5; i++)
16 | callback.OnHello(text + ", " + i);
17 | });
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfDuplex/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfServer/Contracts.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 | using System.ServiceModel.Channels;
3 |
4 | namespace CustomTcpDuplex.WcfServer
5 | {
6 | [ServiceContract]
7 | public interface IUntypedTest
8 | {
9 | [OperationContract(Action = "*", ReplyAction = "*")]
10 | Message Process(Message input);
11 | }
12 | [ServiceContract]
13 | public interface ITypedTest
14 | {
15 | [OperationContract]
16 | int Add(int x, int y);
17 | [OperationContract]
18 | int Subtract(int x, int y);
19 | }
20 | public class Service : IUntypedTest, ITypedTest
21 | {
22 | public Message Process(Message input)
23 | {
24 | Message result = Message.CreateMessage(input.Version, "ReplyAction", "The response");
25 | result.Headers.To = input.Headers.ReplyTo.Uri;
26 | return result;
27 | }
28 |
29 | public int Add(int x, int y)
30 | {
31 | return x + y;
32 | }
33 |
34 | public int Subtract(int x, int y)
35 | {
36 | return x - y;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/TransportChannels/CustomTcpDuplexTransport/WcfServer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/Channels.Test/Mocks.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel.Channels;
6 | using System.Net.Sockets;
7 | using System.Net;
8 |
9 | namespace JsonRpcOverTcp.Channels.Test
10 | {
11 | static class Mocks
12 | {
13 | public static ChannelManagerBase GetChannelManagerBase()
14 | {
15 | HttpTransportBindingElement httpBE = new HttpTransportBindingElement();
16 | CustomBinding binding = new CustomBinding(httpBE);
17 | return (ChannelManagerBase)httpBE.BuildChannelFactory(new BindingContext(binding, new BindingParameterCollection()));
18 | }
19 |
20 | public static Socket GetConnectedSocket(int port)
21 | {
22 | Socket socket = null;
23 | IPHostEntry hostEntry = Dns.GetHostEntry(Environment.MachineName);
24 | for (int i = 0; i < hostEntry.AddressList.Length; i++)
25 | {
26 | try
27 | {
28 | IPAddress address = hostEntry.AddressList[i];
29 | socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
30 | socket.Connect(new IPEndPoint(address, port));
31 | break;
32 | }
33 | catch (SocketException)
34 | {
35 | }
36 | }
37 |
38 | return socket;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/ConsoleTester/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using JsonRpcOverTcp.Channels.Test;
6 |
7 | namespace JsonRpcOverTcp.ConsoleTester
8 | {
9 | class Program
10 | {
11 | static void Main(string[] args)
12 | {
13 | var tests = new RequestChannelTests();
14 | tests.AsynchronousOpen();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/ServiceModel/JsonRpcConstants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace JsonRpcOverTcp.ServiceModel
7 | {
8 | static class JsonRpcConstants
9 | {
10 | public const string IdKey = "id";
11 | public const string MethodKey = "method";
12 | public const string ErrorKey = "error";
13 | public const string ResultKey = "result";
14 | public const string ParamsKey = "params";
15 | public const string RequestIdMessageProperty = "jsonRpcRequestId";
16 | public const string JObjectMessageProperty = "MessageAsJObject";
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/ServiceModel/JsonRpcException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json.Linq;
3 |
4 | namespace JsonRpcOverTcp.ServiceModel
5 | {
6 | public class JsonRpcException : Exception
7 | {
8 | public JToken JsonException
9 | {
10 | get;
11 | private set;
12 | }
13 |
14 | public JsonRpcException(JToken json)
15 | : base()
16 | {
17 | this.JsonException = json;
18 | }
19 |
20 | public JsonRpcException(JToken json, string message)
21 | : base(message)
22 | {
23 | this.JsonException = json;
24 | }
25 |
26 | public JsonRpcException(JToken json, string message, Exception innerException)
27 | : base(message, innerException)
28 | {
29 | this.JsonException = json;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/ServiceModel/JsonRpcOperationSelector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.ServiceModel.Dispatcher;
6 | using System.ServiceModel.Channels;
7 | using Newtonsoft.Json.Linq;
8 |
9 | namespace JsonRpcOverTcp.ServiceModel
10 | {
11 | class JsonRpcOperationSelector : IDispatchOperationSelector
12 | {
13 | public string SelectOperation(ref Message message)
14 | {
15 | JObject json = JsonRpcHelpers.GetJObjectPreservingMessage(ref message);
16 | return json[JsonRpcConstants.MethodKey].Value();
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/SimpleServer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace JsonRpcOverTcp.SimpleServer
4 | {
5 | public class CalculatorService
6 | {
7 | public int Add(int x, int y) { return x + y; }
8 | public int Subtract(int x, int y) { return x - y; }
9 | public int Multiply(int x, int y) { return x * y; }
10 | public int Divide(int x, int y)
11 | {
12 | try
13 | {
14 | return x / y;
15 | }
16 | catch (Exception e)
17 | {
18 | throw new ArgumentException("Error dividing", e);
19 | }
20 | }
21 | }
22 |
23 | class Program
24 | {
25 | static void Main(string[] args)
26 | {
27 | SocketsServer server = new SocketsServer(8000, new CalculatorService());
28 | server.StartServing();
29 |
30 | Console.WriteLine("Press ENTER to close");
31 | Console.ReadLine();
32 |
33 | server.StopServing();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/SimpleServer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/Utils/RawBodyWriter.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel.Channels;
2 | using System.Xml;
3 |
4 | namespace JsonRpcOverTcp.Utils
5 | {
6 | public class RawBodyWriter : BodyWriter
7 | {
8 | byte[] bytes;
9 | public RawBodyWriter(byte[] bytes)
10 | : base(true)
11 | {
12 | this.bytes = bytes;
13 | }
14 |
15 | protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
16 | {
17 | writer.WriteStartElement("Binary");
18 | writer.WriteBase64(this.bytes, 0, this.bytes.Length);
19 | writer.WriteEndElement();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/WcfClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WcfClient")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WcfClient")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f69c918a-8ee8-4e67-bb9b-3fbfae7fa934")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/WcfClient/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/WcfServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WcfServer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WcfServer")]
13 | [assembly: AssemblyCopyright("Copyright © 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("6c326ee9-5c87-4a50-9fe9-1025fa8e7879")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/WcfServer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/lib/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/carlosfigueira/WCFSamples/d490563ed37b41433ffb5c5c0820c2a861ef319b/TransportChannels/JsonRpcOverTcp/lib/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/lib/xunit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/carlosfigueira/WCFSamples/d490563ed37b41433ffb5c5c0820c2a861ef319b/TransportChannels/JsonRpcOverTcp/lib/xunit.dll
--------------------------------------------------------------------------------
/TransportChannels/JsonRpcOverTcp/lib/xunit.extensions.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/carlosfigueira/WCFSamples/d490563ed37b41433ffb5c5c0820c2a861ef319b/TransportChannels/JsonRpcOverTcp/lib/xunit.extensions.dll
--------------------------------------------------------------------------------
/WCFBinaryTools/WcfBinaryViewer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace WcfBinaryViewer
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// The main entry point for the application.
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new XmlBinaryViewer());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/WCFBinaryTools/WcfBinaryViewer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WcfBinaryViewer.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WCFBinaryTools/WcfBinaryViewer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/CanReceiveFormsUrlEncodedInputAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel.Channels;
3 | using System.ServiceModel.Description;
4 | using System.ServiceModel.Dispatcher;
5 |
6 | namespace SLApp.Web
7 | {
8 | public class CanReceiveFormsUrlEncodedInputAttribute : Attribute, IOperationBehavior
9 | {
10 | public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters)
11 | {
12 | }
13 |
14 | public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
15 | {
16 | }
17 |
18 | public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
19 | {
20 | }
21 |
22 | public void Validate(OperationDescription operationDescription)
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 | //
6 | // To add a suppression to this file, right-click the message in the
7 | // Error List, point to "Suppress Message(s)", and click
8 | // "In Project Suppression File".
9 | // You do not need to add suppressions to this file manually.
10 |
11 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
12 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "SLApp.Web.Web.UserRegistrationService.#CreateUser(SLApp.Web.Web.RegistrationData,System.String)")]
13 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "SLApp.Web.Web.UserRegistrationService.#GetRegistrationData()")]
14 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Scope = "member", Target = "SLApp.Web.Web.UserRegistrationService.#GetRegistrationData()")]
15 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/HelpEnabledJsonEndpointFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.ServiceModel.Description;
4 | using System.ServiceModel.DomainServices.Hosting;
5 | using System.ServiceModel.DomainServices.Server;
6 | using Microsoft.ServiceModel.DomainServices.Hosting;
7 |
8 | namespace SLApp.Web
9 | {
10 | public class HelpEnabledJsonEndpointFactory : JsonEndpointFactory
11 | {
12 | public override IEnumerable CreateEndpoints(DomainServiceDescription description, DomainServiceHost serviceHost)
13 | {
14 | List endpoints = base.CreateEndpoints(description, serviceHost).ToList();
15 | foreach (ServiceEndpoint endpoint in endpoints)
16 | {
17 | WebHttpBehavior behavior = endpoint.Behaviors.Find();
18 | if (behavior != null)
19 | {
20 | behavior.HelpEnabled = true;
21 | }
22 | }
23 |
24 | return endpoints;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/Models/Contact.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace SLApp.Web.Models
4 | {
5 | public class Contact
6 | {
7 | [Key]
8 | public int Id { get; set; }
9 |
10 | [Required]
11 | public string Name { get; set; }
12 |
13 | public int Age { get; set; }
14 |
15 | public string Telephone { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/Models/Shared/User.shared.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp.Web
2 | {
3 | ///
4 | /// Partial class extending the User type that adds shared properties and methods.
5 | /// These properties and methods will be available both to the server app and the client app.
6 | ///
7 | public partial class User
8 | {
9 | ///
10 | /// Returns the user display name, which by default is its FriendlyName.
11 | /// If FriendlyName is not set, the User Name is returned.
12 | ///
13 | public string DisplayName
14 | {
15 | get
16 | {
17 | if (!string.IsNullOrEmpty(this.FriendlyName))
18 | {
19 | return this.FriendlyName;
20 | }
21 | else
22 | {
23 | return this.Name;
24 | }
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/Models/User.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp.Web
2 | {
3 | using System.Runtime.Serialization;
4 | using System.ServiceModel.DomainServices.Server.ApplicationServices;
5 |
6 | ///
7 | /// Class containing information about the authenticated user.
8 | ///
9 | public partial class User : UserBase
10 | {
11 | //// NOTE: Profile properties can be added for use in Silverlight application.
12 | //// To enable profiles, edit the appropriate section of web.config file.
13 | ////
14 | //// public string MyProfileProperty { get; set; }
15 |
16 | ///
17 | /// Gets and sets the friendly name of the user.
18 | ///
19 | public string FriendlyName { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/Services/AuthenticationService.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp.Web
2 | {
3 | using System.Security.Authentication;
4 | using System.ServiceModel.DomainServices.Hosting;
5 | using System.ServiceModel.DomainServices.Server;
6 | using System.ServiceModel.DomainServices.Server.ApplicationServices;
7 | using System.Threading;
8 |
9 | // TODO: Switch to a secure endpoint when deploying the application.
10 | // The user's name and password should only be passed using https.
11 | // To do this, set the RequiresSecureEndpoint property on EnableClientAccessAttribute to true.
12 | //
13 | // [EnableClientAccess(RequiresSecureEndpoint = true)]
14 | //
15 | // More information on using https with a Domain Service can be found on MSDN.
16 |
17 | ///
18 | /// Domain Service responsible for authenticating users when they log on to the application.
19 | ///
20 | /// Most of the functionality is already provided by the AuthenticationBase class.
21 | ///
22 | [EnableClientAccess]
23 | public class AuthenticationService : AuthenticationBase { }
24 | }
25 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp.Web/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/App.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Assets/Resources/ApplicationResources.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp
2 | {
3 | using System;
4 | using System.ComponentModel;
5 | using System.Globalization;
6 | using System.Windows.Browser;
7 |
8 | ///
9 | /// Wraps access to the strongly-typed resource classes so that you can bind control properties to resource strings in XAML.
10 | ///
11 | public sealed class ApplicationResources
12 | {
13 | private static readonly ApplicationStrings applicationStrings = new ApplicationStrings();
14 | private static readonly ErrorResources errorResources = new ErrorResources();
15 |
16 | ///
17 | /// Gets the .
18 | ///
19 | public ApplicationStrings Strings
20 | {
21 | get { return applicationStrings; }
22 | }
23 |
24 | ///
25 | /// Gets the .
26 | ///
27 | public ErrorResources Errors
28 | {
29 | get { return errorResources; }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Controls/VisualStates.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace SLApp.Controls
3 | {
4 | ///
5 | /// Names and helpers for visual states in the controls.
6 | ///
7 | internal static class VisualStates
8 | {
9 | #region GroupBusyStatus
10 | ///
11 | /// Busy state for BusyIndicator.
12 | ///
13 | public const string StateBusy = "Busy";
14 |
15 | ///
16 | /// Idle state for BusyIndicator.
17 | ///
18 | public const string StateIdle = "Idle";
19 |
20 | ///
21 | /// Busy states group name.
22 | ///
23 | public const string GroupBusyStatus = "BusyStatusStates";
24 | #endregion
25 |
26 | #region GroupVisibility
27 | ///
28 | /// Visible state name for BusyIndicator.
29 | ///
30 | public const string StateVisible = "Visible";
31 |
32 | ///
33 | /// Hidden state name for BusyIndicator.
34 | ///
35 | public const string StateHidden = "Hidden";
36 |
37 | ///
38 | /// BusyDisplay group.
39 | ///
40 | public const string GroupVisibility = "VisibilityStates";
41 | #endregion
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Generated_Code/Models/Shared/User.shared.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp.Web
2 | {
3 | ///
4 | /// Partial class extending the User type that adds shared properties and methods.
5 | /// These properties and methods will be available both to the server app and the client app.
6 | ///
7 | public partial class User
8 | {
9 | ///
10 | /// Returns the user display name, which by default is its FriendlyName.
11 | /// If FriendlyName is not set, the User Name is returned.
12 | ///
13 | public string DisplayName
14 | {
15 | get
16 | {
17 | if (!string.IsNullOrEmpty(this.FriendlyName))
18 | {
19 | return this.FriendlyName;
20 | }
21 | else
22 | {
23 | return this.Name;
24 | }
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Libs/System.Windows.Controls.Data.DataForm.Toolkit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/carlosfigueira/WCFSamples/d490563ed37b41433ffb5c5c0820c2a861ef319b/WCFRiaServices/CallingRIAFromForms/SLApp/Libs/System.Windows.Controls.Data.DataForm.Toolkit.dll
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Models/User.partial.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp.Web
2 | {
3 | using System;
4 | using System.ComponentModel;
5 |
6 | ///
7 | /// Extensions to the class.
8 | ///
9 | public partial class User
10 | {
11 | #region Make DisplayName Bindable
12 |
13 | ///
14 | /// Override of the OnPropertyChanged method that generates property change notifications when changes.
15 | ///
16 | /// The property change event args.
17 | protected override void OnPropertyChanged(PropertyChangedEventArgs e)
18 | {
19 | base.OnPropertyChanged(e);
20 |
21 | if (e.PropertyName == "Name" || e.PropertyName == "FriendlyName")
22 | {
23 | this.RaisePropertyChanged("DisplayName");
24 | }
25 | }
26 | #endregion
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Properties/OutOfBrowserSettings.xml:
--------------------------------------------------------------------------------
1 |
2 | SLApp Application on your desktop; at home, at work or on the go.
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Views/About.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Views/About.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp
2 | {
3 | using System.Windows.Controls;
4 | using System.Windows.Navigation;
5 |
6 | ///
7 | /// class to present information about the current application.
8 | ///
9 | public partial class About : Page
10 | {
11 | ///
12 | /// Creates a new instance of the class.
13 | ///
14 | public About()
15 | {
16 | InitializeComponent();
17 |
18 | this.Title = ApplicationStrings.AboutPageTitle;
19 | }
20 |
21 | ///
22 | /// Executes when the user navigates to this page.
23 | ///
24 | protected override void OnNavigatedTo(NavigationEventArgs e)
25 | {
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Views/Home.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SLApp
2 | {
3 | using System.Windows.Controls;
4 | using System.Windows.Navigation;
5 | using SLApp.Web;
6 | using SLApp.Web.Models;
7 | using System;
8 |
9 | ///
10 | /// Home page for the application.
11 | ///
12 | public partial class Home : Page
13 | {
14 | ///
15 | /// Creates a new instance.
16 | ///
17 | public Home()
18 | {
19 | InitializeComponent();
20 |
21 | this.Title = ApplicationStrings.HomePageTitle;
22 | }
23 |
24 | ///
25 | /// Executes when the user navigates to this page.
26 | ///
27 | protected override void OnNavigatedTo(NavigationEventArgs e)
28 | {
29 | }
30 |
31 | private void contactDomainDataSource_LoadedData(object sender, System.Windows.Controls.LoadedDataEventArgs e)
32 | {
33 |
34 | if (e.HasError)
35 | {
36 | System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
37 | e.MarkErrorAsHandled();
38 | }
39 | }
40 |
41 | private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
42 | {
43 | new ContactsDomainContext();
44 | this.contactDomainDataSource.SubmitChanges();
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/WCFRiaServices/CallingRIAFromForms/SLApp/Views/Login/LoginRegistrationWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/WcfRuntime/WcfRuntime.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AllExtensions", "AllExtensions\AllExtensions.csproj", "{71AFDC74-CF39-4A94-99BB-0C700CCF9ABA}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {71AFDC74-CF39-4A94-99BB-0C700CCF9ABA}.Debug|x86.ActiveCfg = Debug|x86
13 | {71AFDC74-CF39-4A94-99BB-0C700CCF9ABA}.Debug|x86.Build.0 = Debug|x86
14 | {71AFDC74-CF39-4A94-99BB-0C700CCF9ABA}.Release|x86.ActiveCfg = Release|x86
15 | {71AFDC74-CF39-4A94-99BB-0C700CCF9ABA}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/shoebox/README:
--------------------------------------------------------------------------------
1 | Projects still under development (broken) stay here, until they're
2 | stable enough to go to their proper place.
3 |
--------------------------------------------------------------------------------