Esempio n. 1
0
        public FaultReason(IEnumerable <FaultReasonText> translations)
        {
            if (translations == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(translations));
            }
            int count = 0;

            foreach (FaultReasonText faultReasonText in translations)
            {
                count++;
            }
            if (count == 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(translations),
                                                                             SR.AtLeastOneFaultReasonMustBeSpecified);
            }
            FaultReasonText[] array = new FaultReasonText[count];
            int index = 0;

            foreach (FaultReasonText faultReasonText in translations)
            {
                if (faultReasonText == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(translations),
                                                                                 SR.NoNullTranslations);
                }

                array[index++] = faultReasonText;
            }
            Init(array);
        }
Esempio n. 2
0
        public FaultReason(FaultReasonText translation)
        {
            if (translation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(translation));
            }

            Init(translation);
        }
Esempio n. 3
0
            internal static FaultReason Construct(FaultReasonData[] nodes)
            {
                FaultReasonText[] reasons = new FaultReasonText[nodes.Length];

                for (int i = 0; i < nodes.Length; i++)
                {
                    reasons[i] = new FaultReasonText(nodes[i].text, nodes[i].xmlLang);
                }

                return(new FaultReason(reasons));
            }
Esempio n. 4
0
 internal static ProtocolException ReceiveShutdownReturnedNonNull(Message message)
 {
     if (message.IsFault)
     {
         try
         {
             MessageFault    fault  = MessageFault.CreateFault(message, 64 * 1024);
             FaultReasonText reason = fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture);
             string          text   = SR.Format(SR.ReceiveShutdownReturnedFault, reason.Text);
             return(new ProtocolException(text));
         }
         catch (QuotaExceededException)
         {
             string text = SR.Format(SR.ReceiveShutdownReturnedLargeFault, message.Headers.Action);
             return(new ProtocolException(text));
         }
     }
     else
     {
         string text = SR.Format(SR.ReceiveShutdownReturnedMessage, message.Headers.Action);
         return(new ProtocolException(text));
     }
 }
Esempio n. 5
0
 private void Init(FaultReasonText translation)
 {
     Init(new FaultReasonText[] { translation });
 }