public static bool TryGet(Message message, out CorrelationMessageProperty property)
 {
     if (message == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
     }
     return(TryGet(message.Properties, out property));
 }
 public static bool TryGet(Message message, out CorrelationMessageProperty property)
 {
     if (message == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
     }
     return TryGet(message.Properties, out property);
 }
 public static bool TryGet(MessageProperties properties, out CorrelationMessageProperty property)
 {
     if (properties == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
     }
     object obj2 = null;
     if (properties.TryGetValue("CorrelationMessageProperty", out obj2))
     {
         property = obj2 as CorrelationMessageProperty;
     }
     else
     {
         property = null;
     }
     return (property != null);
 }
        public static bool TryGet(MessageProperties properties, out CorrelationMessageProperty property)
        {
            if (properties == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }
            object obj2 = null;

            if (properties.TryGetValue("CorrelationMessageProperty", out obj2))
            {
                property = obj2 as CorrelationMessageProperty;
            }
            else
            {
                property = null;
            }
            return(property != null);
        }
        public static bool TryGet(MessageProperties properties, out CorrelationMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            object value = null;

            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as CorrelationMessageProperty;
            }
            else
            {
                property = null;
            }
            return(property != null);
        }
        // pass OperationContext.Current if you don't already have an OperationContext.
        protected void GetInstanceKeys(OperationContext operationContext, out InstanceKey instanceKey, out ICollection<InstanceKey> additionalKeys)
        {
            CorrelationMessageProperty correlationMessageProperty = null;
            InstanceKey localInstanceKey;
            ICollection<InstanceKey> localAdditionalKeys;

            instanceKey = InstanceKey.InvalidKey;
            additionalKeys = new ReadOnlyCollection<InstanceKey>(new InstanceKey[] { });

            if (!CorrelationMessageProperty.TryGet(operationContext.IncomingMessageProperties,
                out correlationMessageProperty))
            {
                if (this.keyCalculator != null)
                {
                    MessageBuffer requestMessageBuffer;
                    bool success;

                    if (operationContext.IncomingMessageProperties.TryGetValue(ChannelHandler.MessageBufferPropertyName, out requestMessageBuffer))
                    {
                        success = this.keyCalculator.CalculateKeys(requestMessageBuffer, operationContext.IncomingMessage, out localInstanceKey, out localAdditionalKeys);
                    }
                    else
                    {
                        // Message is not preserved.(DispatchRuntime.PreserveMessage is false.)
                        // this could be a case where we only have context queries, in this case we don't preserve the message
                        success = this.keyCalculator.CalculateKeys(operationContext.IncomingMessage, out localInstanceKey, out localAdditionalKeys);
                    }
                    if (success)
                    {
                        if (localInstanceKey != null)
                        {
                            instanceKey = localInstanceKey;
                        }
                        if (localAdditionalKeys != null)
                        {
                            additionalKeys = localAdditionalKeys;
                        }

                        correlationMessageProperty = new CorrelationMessageProperty(instanceKey, additionalKeys);

                        operationContext.IncomingMessageProperties.Add(CorrelationMessageProperty.Name, correlationMessageProperty);
                    }
                }
            }
            else
            {
                instanceKey = correlationMessageProperty.CorrelationKey;
                additionalKeys = correlationMessageProperty.AdditionalKeys;
            }

            //If InstanceKey is still not resolved do the activation operation validation.
            if (instanceKey == null || !instanceKey.IsValid)
            {
                if (!this.CanCreateInstance)
                {
                    this.host.RaiseUnknownMessageReceived(operationContext.IncomingMessage);

                    throw FxTrace.Exception.AsError(
                        new FaultException(
                        new DurableDispatcherAddressingFault()));
                }
            }
        }
        public static bool TryGet(MessageProperties properties, out CorrelationMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as CorrelationMessageProperty;
            }
            else
            {
                property = null;
            }
            return property != null;
        }
 protected void GetInstanceKeys(OperationContext operationContext, out InstanceKey instanceKey, out ICollection<InstanceKey> additionalKeys)
 {
     CorrelationMessageProperty property = null;
     instanceKey = InstanceKey.InvalidKey;
     additionalKeys = new ReadOnlyCollection<InstanceKey>(new InstanceKey[0]);
     if (!CorrelationMessageProperty.TryGet(operationContext.IncomingMessageProperties, out property))
     {
         if (this.keyCalculator != null)
         {
             InstanceKey key;
             ICollection<InstanceKey> is2;
             MessageBuffer buffer;
             bool flag;
             if (operationContext.IncomingMessageProperties.TryGetValue<MessageBuffer>("_RequestMessageBuffer_", out buffer))
             {
                 flag = this.keyCalculator.CalculateKeys(buffer, operationContext.IncomingMessage, out key, out is2);
             }
             else
             {
                 flag = this.keyCalculator.CalculateKeys(operationContext.IncomingMessage, out key, out is2);
             }
             if (flag)
             {
                 if (key != null)
                 {
                     instanceKey = key;
                 }
                 if (is2 != null)
                 {
                     additionalKeys = is2;
                 }
                 property = new CorrelationMessageProperty(instanceKey, additionalKeys);
                 operationContext.IncomingMessageProperties.Add(CorrelationMessageProperty.Name, property);
             }
         }
     }
     else
     {
         instanceKey = property.CorrelationKey;
         additionalKeys = property.AdditionalKeys;
     }
     if (((instanceKey == null) || !instanceKey.IsValid) && !this.CanCreateInstance)
     {
         this.host.RaiseUnknownMessageReceived(operationContext.IncomingMessage);
         throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new FaultException(new DurableDispatcherAddressingFault()));
     }
 }