Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Method to Apply Endpoint behaviors
- private static void ApplyEndPointBehaviors(object factory)
- {
- ((ChannelFactory)factory).Endpoint.Behaviors.Add(new PortalContextHeaderClientBehavior());
- ((ChannelFactory)factory).Endpoint.Behaviors.Add(new CorpFaultBehavior());
- }
- //Method to collect all EndPoint addresses
- private static List<Uri> ApplyAddressCollection(out List<string> contractCollection, out object address,
- out ClientSection clientSection)
- {
- List<Uri> addressCollection = new List<Uri>();
- contractCollection = new List<string>();
- List<string> bindinCollection = new List<string>();
- address = null;
- clientSection = GetClientSection();
- for (int j = 0; j < clientSection.Endpoints.Count; j++)
- {
- addressCollection.Add(clientSection.Endpoints[j].Address);
- contractCollection.Add(clientSection.Endpoints[j].Contract);
- bindinCollection.Add(clientSection.Endpoints[j].Binding);
- }
- return addressCollection;
- }
- //Method to apply the Binding Collection
- private static Binding ApplyBindingConfiguration(BindingsSection section, string bindingName, Binding binding)
- {
- foreach (var bindingCollection in section.BindingCollections)
- {
- if (bindingCollection.BindingName.Equals(bindingName))
- {
- for (int i = 0; i < bindingCollection.ConfiguredBindings.Count; i++)
- {
- if (bindingCollection.ConfiguredBindings.Count > 0)
- {
- var bindingElement = bindingCollection.ConfiguredBindings[i];
- binding = (Binding)Activator.CreateInstance(bindingCollection.BindingType);
- binding.Name = bindingElement.Name;
- bindingElement.ApplyConfiguration(binding);
- }
- }
- }
- }
- return binding;
- }
- //Method to fetch Client Section
- private static ClientSection GetClientSection()
- {
- ClientSection clientSection = (ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
- return clientSection;
- }
- //This will return all the bindings from the config file
- private static BindingsSection GetBindingsSection()
- {
- BindingsSection bindingsSection = (BindingsSection)ConfigurationManager.GetSection("system.serviceModel/bindings");
- return bindingsSection;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement