public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            if (serviceDescription == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceDescription");
            }

            ContextBindingElement.ValidateContextBindingElementOnAllEndpointsWithSessionfulContract(serviceDescription, this);

            if (serviceDescription.Behaviors != null)
            {
                ServiceBehaviorAttribute serviceBehavior = serviceDescription.Behaviors.Find <ServiceBehaviorAttribute>();

                if (serviceBehavior != null)
                {
                    if (serviceBehavior.InstanceContextMode != InstanceContextMode.PerSession)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                  new InvalidOperationException(
                                      SR2.GetString(SR2.InstanceContextModeMustBePerSession, serviceBehavior.InstanceContextMode)));
                    }

                    if (serviceBehavior.ConcurrencyMode == ConcurrencyMode.Multiple)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                  new InvalidOperationException(
                                      SR2.GetString(SR2.ConcurrencyMultipleNotSupported)));
                    }

                    if (serviceBehavior.ConcurrencyMode == ConcurrencyMode.Reentrant &&
                        this.UnknownExceptionAction == UnknownExceptionAction.AbortInstance)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                  new InvalidOperationException(
                                      SR2.GetString(SR2.ConcurrencyReentrantAndAbortNotSupported)));
                    }
                }
            }

            bool foundSessionfulContract = false;

            foreach (ServiceEndpoint serviceEndpoint in serviceDescription.Endpoints)
            {
                if (serviceEndpoint != null && !serviceEndpoint.InternalIsSystemEndpoint(serviceDescription))
                {
                    if (serviceEndpoint.Contract.SessionMode != SessionMode.NotAllowed)
                    {
                        foundSessionfulContract = true;
                    }

                    foreach (OperationDescription operation in serviceEndpoint.Contract.Operations)
                    {
                        DurableOperationAttribute durableBehavior =
                            operation.Behaviors.Find <DurableOperationAttribute>();

                        if (durableBehavior == null)
                        {
                            durableBehavior = defaultDurableOperationBehavior;
                        }

                        if (serviceEndpoint.Contract.SessionMode == SessionMode.NotAllowed)
                        {
                            if (!durableBehavior.CanCreateInstanceForOperation(operation.IsOneWay))
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                          new InvalidOperationException(
                                              SR2.GetString(
                                                  SR2.CanCreateInstanceMustBeTrue,
                                                  serviceEndpoint.Contract.Name,
                                                  operation.Name)));
                            }
                        }
                        else
                        {
                            if (operation.IsOneWay &&
                                durableBehavior.CanCreateInstanceForOperation(operation.IsOneWay))
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                          new InvalidOperationException(
                                              SR2.GetString(
                                                  SR2.CanCreateInstanceMustBeTwoWay,
                                                  serviceEndpoint.Contract.Name,
                                                  serviceEndpoint.Contract.SessionMode,
                                                  operation.Name)));
                            }
                        }

                        if (this.saveStateInOperationTransaction)
                        {
                            bool hasTransaction = false;

                            OperationBehaviorAttribute operationBehavior = operation.Behaviors.Find <OperationBehaviorAttribute>();

                            if (operationBehavior != null)
                            {
                                if (operationBehavior.TransactionScopeRequired)
                                {
                                    hasTransaction = true;
                                }
                            }

                            TransactionFlowAttribute transactionBehavior = operation.Behaviors.Find <TransactionFlowAttribute>();

                            if (transactionBehavior != null)
                            {
                                if (transactionBehavior.Transactions == TransactionFlowOption.Mandatory)
                                {
                                    hasTransaction = true;
                                }
                            }

                            if (!hasTransaction)
                            {
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                                          new InvalidOperationException(
                                              SR2.GetString(
                                                  SR2.SaveStateInTransactionValidationFailed,
                                                  operation.Name,
                                                  serviceEndpoint.ListenUri)));
                            }
                        }
                    }
                }
            }

            if (!foundSessionfulContract)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(
                              SR2.GetString(SR2.SessionfulContractNotFound)));
            }
        }
 public void Validate(ServiceDescription description, ServiceHostBase serviceHostBase)
 {
     ContextBindingElement.ValidateContextBindingElementOnAllEndpointsWithSessionfulContract(description, this);
 }