public StandardExceptionBehaviorAttribute(string customBizExceptionTypeName, string exceptionHandlerTypeName)
 {
     m_ServiceBehavior = new StandardExceptionBehavior(customBizExceptionTypeName, exceptionHandlerTypeName);
 }
 public StandardExceptionBehaviorAttribute(Type customBizExceptionType, Type exceptionHandlerType)
 {
     m_ServiceBehavior = new StandardExceptionBehavior(customBizExceptionType, exceptionHandlerType);
 }
 public StandardExceptionBehaviorAttribute()
 {
     m_ServiceBehavior = new StandardExceptionBehavior();
 }
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            ServiceHost host         = new ServiceHost(serviceType, baseAddresses); //base.CreateServiceHost(serviceType, baseAddresses);
            Type        contractType = FindServiceContractInterface(serviceType);

            host.AddServiceEndpoint(contractType, FindBinding(m_BindingType), "");
            ServiceMetadataBehavior b1 = host.Description.Behaviors.Find <ServiceMetadataBehavior>();

            if (b1 == null)
            {
                b1 = new ServiceMetadataBehavior()
                {
                    HttpGetEnabled = true
                };
                host.Description.Behaviors.Add(b1);
            }
            else
            {
                b1.HttpGetEnabled = true;
            }
            StandardExceptionBehavior b = host.Description.Behaviors.Find <StandardExceptionBehavior>();

            if (b == null)
            {
                host.Description.Behaviors.Add(new StandardExceptionBehavior(m_BizExceptionTypeName, m_ExceptionHandlerTypeName));
            }
            //if (url.IndexOf("http://") < 0)
            //{
            //    b1.HttpGetUrl = new Uri(string.Format("http://{0}{1}{2}", hostIP, (service.Port > 0 ? (":" + service.Port) : string.Empty), url));
            //}
            ServiceDebugBehavior b2 = host.Description.Behaviors.Find <ServiceDebugBehavior>();

            if (b2 == null)
            {
                host.Description.Behaviors.Add(new ServiceDebugBehavior()
                {
                    IncludeExceptionDetailInFaults = true
                });
            }
            else
            {
                b2.IncludeExceptionDetailInFaults = true;
            }
            ServiceBehaviorAttribute bb = host.Description.Behaviors.Find <ServiceBehaviorAttribute>();

            if (bb == null)
            {
                bb = new ServiceBehaviorAttribute();
                host.Description.Behaviors.Add(bb);
            }
            bb.ConcurrencyMode       = ConcurrencyMode.Multiple;
            bb.AddressFilterMode     = AddressFilterMode.Any;
            bb.InstanceContextMode   = InstanceContextMode.Single;
            bb.MaxItemsInObjectGraph = Int32.MaxValue;
            if (ServiceHostingEnvironment.AspNetCompatibilityEnabled)
            {
                AspNetCompatibilityRequirementsAttribute a = host.Description.Behaviors.Find <AspNetCompatibilityRequirementsAttribute>();
                if (a == null)
                {
                    host.Description.Behaviors.Add(new AspNetCompatibilityRequirementsAttribute()
                    {
                        RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed
                    });
                }
                else
                {
                    a.RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed;
                }
            }
            //------- 设置 dataContractSerializer的 maxItemsInObjectGraph属性为int.MaxValue
            Type             t   = host.GetType();
            object           obj = t.Assembly.CreateInstance("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", true, BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { false, int.MaxValue }, null, null);
            IServiceBehavior myServiceBehavior = obj as IServiceBehavior;

            if (myServiceBehavior != null)
            {
                host.Description.Behaviors.Add(myServiceBehavior);
            }
            //-------

            return(host);
        }
 public StandardExceptionBehaviorAttribute(Type customBizExceptionType, Type exceptionHandlerType)
 {
     m_ServiceBehavior = new StandardExceptionBehavior(customBizExceptionType, exceptionHandlerType);
 }
 public StandardExceptionBehaviorAttribute(string customBizExceptionTypeName, string exceptionHandlerTypeName)
 {
     m_ServiceBehavior = new StandardExceptionBehavior(customBizExceptionTypeName, exceptionHandlerTypeName);
 }
 public StandardExceptionBehaviorAttribute()
 {
     m_ServiceBehavior = new StandardExceptionBehavior();
 }