/// <summary> /// Gets the ImpersonateOnSerializingReplyMessageProperty property from a message. /// </summary> /// <param name="message">The message to extract the property from.</param> /// <param name="property">An output paramter to hold the ImpersonateOnSerializingReplyMessageProperty property.</param> /// <returns>True if the ImpersonateOnSerializingReplyMessageProperty property was found.</returns> public static bool TryGet(Message message, out ImpersonateOnSerializingReplyMessageProperty property) { if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message)); } return(TryGet(message.Properties, out property)); }
private T ImpersonateCall <T>(Func <T> callToImpersonate) { if (ImpersonateOnSerializingReplyMessageProperty.TryGet(_innerMessage, out ImpersonateOnSerializingReplyMessageProperty impersonationProperty)) { return(impersonationProperty.RunImpersonated(callToImpersonate)); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.UnableToImpersonateWhileSerializingReponse)); } }
private void ImpersonateCall(Action callToImpersonate) { if (ImpersonateOnSerializingReplyMessageProperty.TryGet(_innerMessage, out ImpersonateOnSerializingReplyMessageProperty impersonationProperty)) { _ = impersonationProperty.RunImpersonated(() => { callToImpersonate(); return((object)null); }); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.UnableToImpersonateWhileSerializingReponse)); } }
/// <summary> /// Gets the ImpersonateOnSerializingReplyMessageProperty property from MessageProperties. /// </summary> /// <param name="properties">The MessagePropeties object.</param> /// <param name="property">An output paramter to hold the ImpersonateOnSerializingReplyMessageProperty property.</param> /// <returns>True if the ImpersonateOnSerializingReplyMessageProperty property was found.</returns> public static bool TryGet(MessageProperties properties, out ImpersonateOnSerializingReplyMessageProperty property) { if (properties == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties)); } if (properties.TryGetValue(PropertyName, out object value)) { property = value as ImpersonateOnSerializingReplyMessageProperty; } else { property = null; } return(property != null); }