internal void EnsureInvariants()
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("AChannelServiceEndpointSContractSNameIsNull0")));
            }
            if (this.Namespace == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("AChannelServiceEndpointSContractSNamespace0")));
            }
            if (this.Operations.Count == 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxContractHasZeroOperations", new object[] { this.Name })));
            }
            bool flag = false;

            for (int i = 0; i < this.Operations.Count; i++)
            {
                OperationDescription description = this.Operations[i];
                description.EnsureInvariants();
                if (description.IsInitiating)
                {
                    flag = true;
                }
                if ((!description.IsInitiating || description.IsTerminating) && (this.SessionMode != System.ServiceModel.SessionMode.Required))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("ContractIsNotSelfConsistentItHasOneOrMore2", new object[] { this.Name })));
                }
            }
            if (!flag)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxContractHasZeroInitiatingOperations", new object[] { this.Name })));
            }
        }
Exemplo n.º 2
0
        internal void EnsureInvariants()
        {
            if (string.IsNullOrEmpty(Name))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR.AChannelServiceEndpointSContractSNameIsNull0));
            }
            if (Namespace == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR.AChannelServiceEndpointSContractSNamespace0));
            }
            if (Operations.Count == 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR.Format(SR.SFxContractHasZeroOperations, Name)));
            }
            bool thereIsAtLeastOneInitiatingOperation = false;

            for (int i = 0; i < Operations.Count; i++)
            {
                OperationDescription operationDescription = Operations[i];
                operationDescription.EnsureInvariants();
                if (operationDescription.IsInitiating)
                {
                    thereIsAtLeastOneInitiatingOperation = true;
                }

                if ((!operationDescription.IsInitiating || operationDescription.IsTerminating) &&
                    (SessionMode != SessionMode.Required))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.Format(SR.ContractIsNotSelfConsistentItHasOneOrMore2, Name)));
                }
            }
            if (!thereIsAtLeastOneInitiatingOperation)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR.Format(SR.SFxContractHasZeroInitiatingOperations, Name)));
            }
        }