/// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="method"></param>
 /// <param name="credential"></param>
 /// <param name="address"></param>
 /// <param name="contentType"></param>
 public WfServiceAddressDefinition(WfServiceRequestMethod method,
                                   WfNetworkCredential credential, string address, WfServiceContentType contentType)
 {
     this.RequestMethod = method;
     this.Credential    = credential;
     this.Address       = address;
     this.ContentType   = contentType;
 }
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfNetworkCredential credential = new WfNetworkCredential();

            credential.Key       = DictionaryHelper.GetValue(dictionary, "Key", string.Empty);
            credential.LogOnName = DictionaryHelper.GetValue(dictionary, "LogOnName", string.Empty);
            credential.Password  = DictionaryHelper.GetValue(dictionary, "Password", string.Empty);

            return(credential);
        }
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            IDictionary <string, object> dictionary = new Dictionary <string, object>();

            WfNetworkCredential credential = (WfNetworkCredential)obj;

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Key", credential.Key);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "LogOnName", credential.LogOnName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "LogOnNameWithDomain", credential.LogOnNameWithDomain);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "LogOnNameWithoutDomain", credential.LogOnNameWithoutDomain);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Domain", credential.Domain);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Password", credential.Password);

            return(dictionary);
        }
        /// <summary>
        /// 从配置项初始化
        /// </summary>
        /// <param name="element"></param>
        public void FromConfigurationElement(WfServiceAddressDefinitionConfigurationElement element)
        {
            element.NullCheck("element");

            this.Key           = element.Name;
            this.RequestMethod = element.RequestMethod;
            this.ContentType   = element.ContentType;
            this.ServiceNS     = element.ServiceNS;

            this.Address = element.Uri.ToUriString();

            if (element.Identity != null)
            {
                this.Credential = new WfNetworkCredential(element.Identity.LogOnNameWithoutDomain, element.Identity.Password, element.Identity.Domain);
            }
        }
        public WfServiceOperationDefinition SetAddress(WfServiceRequestMethod method, string address, WfServiceContentType contentType, WfNetworkCredential credential)
        {
            this.AddressDef = new WfServiceAddressDefinition(method, credential, address, contentType);

            return(this);
        }