Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / MsmqIntegration / MsmqIntegrationValidationBehavior.cs / 1 / MsmqIntegrationValidationBehavior.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.MsmqIntegration { using System.ServiceModel; using System.ServiceModel.Dispatcher; using System.ServiceModel.Description; using System.ServiceModel.Channels; using System.Collections.ObjectModel; using System.Collections.Generic; class MsmqIntegrationValidationBehavior : IEndpointBehavior, IServiceBehavior { static MsmqIntegrationValidationBehavior instance; internal static MsmqIntegrationValidationBehavior Instance { get { if (instance == null) instance = new MsmqIntegrationValidationBehavior(); return instance; } } MsmqIntegrationValidationBehavior() {} void IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint) { if (serviceEndpoint == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceEndpoint"); ContractDescription contract = serviceEndpoint.Contract; Binding binding = serviceEndpoint.Binding; if (NeedValidateBinding(binding)) { ValidateHelper(contract, binding, null); } } void IEndpointBehavior.AddBindingParameters(ServiceEndpoint serviceEndpoint, BindingParameterCollection bindingParameters) { } void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint serviceEndpoint, EndpointDispatcher endpointDispatcher) { } void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint serviceEndpoint, ClientRuntime behavior) { } void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collectionendpoints, BindingParameterCollection parameters) { } void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { } void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { if (description == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); for (int i = 0; i < description.Endpoints.Count; i++) { ServiceEndpoint endpoint = description.Endpoints[i]; if (NeedValidateBinding(endpoint.Binding)) { ValidateHelper(endpoint.Contract, endpoint.Binding, description); break; } } } bool NeedValidateBinding(Binding binding) { if (binding is MsmqIntegrationBinding) return true; if (binding is CustomBinding) { CustomBinding customBinding = new CustomBinding(binding); return (customBinding.Elements.Find () != null); } return false; } void ValidateHelper(ContractDescription contract, Binding binding, ServiceDescription description) { foreach(OperationDescription operation in contract.Operations) { // since this is one-way, we can only have one message (one-way requirement is validated elsewhere) MessageDescription message = operation.Messages[0]; if ((message.Body.Parts.Count == 0) && (message.Headers.Count == 0)) // all message parts are properties, great continue; if (message.Body.Parts.Count == 1) // Single MsmqMessage<> argument is also legal { Type type = message.Body.Parts[0].Type; if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(MsmqMessage<>))) continue; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.MsmqInvalidServiceOperationForMsmqIntegrationBinding, binding.Name, operation.Name, contract.Name))); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlSchemaExporter.cs
- AssemblyNameUtility.cs
- CheckedPointers.cs
- XmlSchemaType.cs
- DbUpdateCommandTree.cs
- ZoneIdentityPermission.cs
- TraceContextRecord.cs
- Registry.cs
- shaperfactory.cs
- WeakReference.cs
- ListViewSelectEventArgs.cs
- NamespaceEmitter.cs
- XmlSchemaException.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- AsymmetricSignatureFormatter.cs
- GlyphTypeface.cs
- WindowsFormsHost.cs
- SamlAuthorizationDecisionClaimResource.cs
- MouseBinding.cs
- StyleModeStack.cs
- AutoGeneratedField.cs
- ClockGroup.cs
- FunctionUpdateCommand.cs
- TypeDescriptor.cs
- RuntimeArgumentHandle.cs
- CoTaskMemHandle.cs
- SchemaElementLookUpTableEnumerator.cs
- ParserOptions.cs
- WebPartTransformerAttribute.cs
- ActiveDesignSurfaceEvent.cs
- User.cs
- DataControlFieldCollection.cs
- ResourceSet.cs
- DataGridTablesFactory.cs
- LinqDataSourceUpdateEventArgs.cs
- OdbcConnection.cs
- RepeaterItemEventArgs.cs
- TransformationRules.cs
- PenContexts.cs
- XhtmlBasicFormAdapter.cs
- SqlFunctions.cs
- Int16.cs
- Cursors.cs
- BuilderPropertyEntry.cs
- ServiceAuthorizationBehavior.cs
- HGlobalSafeHandle.cs
- TableChangeProcessor.cs
- CodeTypeDelegate.cs
- DataGridViewComponentPropertyGridSite.cs
- WsatRegistrationHeader.cs
- SoapCodeExporter.cs
- DesignBinding.cs
- UrlMapping.cs
- WebPartTransformer.cs
- TaskForm.cs
- HtmlInputCheckBox.cs
- TextUtf8RawTextWriter.cs
- PermissionRequestEvidence.cs
- TextEditorParagraphs.cs
- DeclarativeConditionsCollection.cs
- UserControlDocumentDesigner.cs
- TypeSystem.cs
- SerializationInfoEnumerator.cs
- Span.cs
- StreamedWorkflowDefinitionContext.cs
- UserControlBuildProvider.cs
- RootDesignerSerializerAttribute.cs
- XmlAtomicValue.cs
- DataGridViewCheckBoxColumn.cs
- ObjectReaderCompiler.cs
- GuidelineCollection.cs
- EntityStoreSchemaFilterEntry.cs
- WaitHandle.cs
- _StreamFramer.cs
- WeakEventTable.cs
- InputMethodStateTypeInfo.cs
- CultureTableRecord.cs
- ClientFormsIdentity.cs
- ButtonChrome.cs
- _BaseOverlappedAsyncResult.cs
- JpegBitmapDecoder.cs
- ToolboxComponentsCreatingEventArgs.cs
- WebPartAddingEventArgs.cs
- RadioButtonBaseAdapter.cs
- TransactionScopeDesigner.cs
- ClientTarget.cs
- TextOptionsInternal.cs
- MetadataArtifactLoaderResource.cs
- SQLDateTimeStorage.cs
- BamlReader.cs
- ControlCachePolicy.cs
- CounterCreationData.cs
- QuaternionAnimation.cs
- WebRequestModuleElementCollection.cs
- XPathNodeIterator.cs
- WebHttpBehavior.cs
- SHA512CryptoServiceProvider.cs
- RenderData.cs
- InheritedPropertyDescriptor.cs
- QueryInterceptorAttribute.cs