private void AddBehaviors(string behaviorConfiguration, ServiceEndpoint serviceEndpoint, ServiceModelSectionGroup group) { if (string.IsNullOrEmpty(behaviorConfiguration)) { return; } if (group == null) { return; } EndpointBehaviorElement endpointBehaviorElement = group.Behaviors.EndpointBehaviors[behaviorConfiguration]; if (endpointBehaviorElement != null) { for (int i = 0; i < endpointBehaviorElement.Count; i++) { BehaviorExtensionElement behaviorExtensionElement = endpointBehaviorElement[i]; object obj = behaviorExtensionElement.GetType().InvokeMember("CreateBehavior", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, behaviorExtensionElement, null); if (obj != null) { serviceEndpoint.Behaviors.Add((IEndpointBehavior)obj); } } } }
private static T CreateBehavior <T>(BehaviorExtensionElement behaviorElement) { MethodInfo method = behaviorElement.GetType().GetMethod("CreateBehavior", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { return((T)method.Invoke(behaviorElement, null)); } return(default(T)); }
public static IEndpointBehavior CreateBehavior(BehaviorExtensionElement behaviorExtension) { IEndpointBehavior endPointBehavior = (IEndpointBehavior)behaviorExtension.GetType().InvokeMember( "CreateBehavior", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, behaviorExtension, null); return(endPointBehavior); }
/// <summary> /// Method ApplyMultiBehaviors /// </summary> /// <param name="serviceModelSectionGroup">ServiceModel section group.</param> /// <returns>true if succeeded; otherwise, false.</returns> private bool ApplyMultiBehaviors(ServiceModelSectionGroup serviceModelSectionGroup) { if (serviceModelSectionGroup == null) { return(false); } foreach (ServiceBehaviorElement element in serviceModelSectionGroup.Behaviors.ServiceBehaviors) { foreach (BehaviorExtensionElement behavior in element) { BehaviorExtensionElement behaviorExtensionElement = behavior; object extention = behaviorExtensionElement.GetType().InvokeMember( "CreateBehavior", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, behaviorExtensionElement, null); if (extention == null) { continue; } IServiceBehavior serviceBehavior = (IServiceBehavior)extention; bool isBehaviorExist = false; foreach (IServiceBehavior item in this.Description.Behaviors) { if (item.GetType().Name == serviceBehavior.GetType().Name) { isBehaviorExist = true; break; } } if (isBehaviorExist) { break; } this.Description.Behaviors.Add((IServiceBehavior)extention); } } return(true); }
public static object CreateBehavior(this BehaviorExtensionElement extensionElement) { try { return(extensionElement.GetType(). GetMethod( "CreateBehavior", BindingFlags.Instance | BindingFlags.NonPublic). Invoke(extensionElement, new object[] { })); } catch (TargetInvocationException ex) { throw ex.InnerException; } }
private void method_2(string string_1, ServiceEndpoint serviceEndpoint_0, ServiceModelSectionGroup serviceModelSectionGroup_0) { if (!string.IsNullOrEmpty(string_1)) { EndpointBehaviorElement endpointBehaviorElement = serviceModelSectionGroup_0.Behaviors.EndpointBehaviors[string_1]; for (int i = 0; i < endpointBehaviorElement.Count; i++) { BehaviorExtensionElement behaviorExtensionElement = endpointBehaviorElement[i]; object obj = behaviorExtensionElement.GetType().InvokeMember("CreateBehavior", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, behaviorExtensionElement, null); if (obj != null) { serviceEndpoint_0.Behaviors.Add((IEndpointBehavior)obj); } } } }
/// <summary> /// Adds the configured behavior to the selected endpoint /// </summary> /// <param name="behaviorConfiguration"></param> /// <param name="serviceEndpoint"></param> /// <param name="group"></param> private void AddBehaviors(string behaviorConfiguration, ServiceEndpoint serviceEndpoint, ServiceModelSectionGroup group) { EndpointBehaviorElement behaviorElement = group.Behaviors.EndpointBehaviors[behaviorConfiguration]; for (int i = 0; i < behaviorElement.Count; i++) { BehaviorExtensionElement behaviorExtension = behaviorElement[i]; object extension = behaviorExtension.GetType().InvokeMember("CreateBehavior", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, behaviorExtension, null); if (extension != null) { serviceEndpoint.Behaviors.Add((IEndpointBehavior)extension); } } }
protected internal static void AddBehaviors(string behaviorConfiguration, ServiceEndpoint serviceEndpoint, BehaviorsSection section) { if (string.IsNullOrEmpty(behaviorConfiguration)) { return; } EndpointBehaviorElement behaviorElement = section.EndpointBehaviors[behaviorConfiguration]; for (int i = 0; i < behaviorElement.Count; i++) { BehaviorExtensionElement behaviorExtension = behaviorElement[i]; object extension = behaviorExtension.GetType().InvokeMember("CreateBehavior", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, behaviorExtension, null); if (extension != null) { serviceEndpoint.Behaviors.Add((IEndpointBehavior)extension); } } }