public WfServiceInvoker(WfServiceOperationDefinition svcOperationDef)
        {
            this._SvcOperationDef = svcOperationDef;

            this.InitConnectionMappings();
            this.InitHeaders();
        }
        public WfServiceInvoker(WfServiceOperationDefinition svcOperationDef, WfApplicationRuntimeParameters invokeContext)
        {
            this._SvcOperationDef = svcOperationDef;
            this._InvokeContext   = invokeContext;

            this.InitConnectionMappings();
            this.InitHeaders();
        }
        public static WfServiceOperationDefinition CreateFromAction <TChannel>(Action <TChannel> action, string xmlStoreParaName = "")
        {
            WfServiceOperationDefinition opDefine = new WfServiceOperationDefinition();

            opDefine.RtnXmlStoreParamName = xmlStoreParaName;
            FillFromChannel(opDefine, action);

            return(opDefine);
        }
        private static void FillFromChannel <TChannel>(WfServiceOperationDefinition opDefine, Action <TChannel> action)
        {
            if (action != null)
            {
                WfClientOperationInfo opInfo = WfClientInspector.InspectParameters <TChannel>(action);

                opDefine.OperationName = opInfo.Name;

                foreach (WfClientParameter parameter in opInfo.Parameters)
                {
                    opDefine.AddParameter(parameter.Name, parameter.Value);
                }
            }
        }
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfServiceOperationDefinition svcOperationDef = new WfServiceOperationDefinition();

            svcOperationDef.Key               = DictionaryHelper.GetValue(dictionary, "Key", string.Empty);
            svcOperationDef.OperationName     = DictionaryHelper.GetValue(dictionary, "OperationName", string.Empty);
            svcOperationDef.InvokeWhenPersist = DictionaryHelper.GetValue(dictionary, "InvokeWhenPersist", false);

            if (dictionary.ContainsKey("Timeout"))
            {
                string strTimeout = DictionaryHelper.GetValue(dictionary, "Timeout", string.Empty);

                if (strTimeout.IsNotEmpty())
                {
                    string[] parts = strTimeout.Split('T');

                    if (parts.Length > 1)
                    {
                        strTimeout = parts[1];
                    }

                    TimeSpan timeoutSpan = TimeSpan.Parse(strTimeout);
                    svcOperationDef.Timeout = timeoutSpan;
                }
            }

            svcOperationDef.RtnXmlStoreParamName = DictionaryHelper.GetValue(dictionary, "RtnXmlStoreParamName", string.Empty);

            if (dictionary.ContainsKey("AddressDef"))
            {
                var addressDef = JSONSerializerExecute.Deserialize <WfServiceAddressDefinition>(dictionary["AddressDef"]);
                svcOperationDef.AddressDef = addressDef;
            }

            if (dictionary.ContainsKey("Params"))
            {
                var templates = JSONSerializerExecute.Deserialize <WfServiceOperationParameterCollection>(dictionary["Params"]);
                svcOperationDef.Params.Clear();
                svcOperationDef.Params.CopyFrom(templates);
            }

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

            WfServiceOperationDefinition svcAddressDef = (WfServiceOperationDefinition)obj;

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "OperationName", svcAddressDef.OperationName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "RtnXmlStoreParamName", svcAddressDef.RtnXmlStoreParamName);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Key", svcAddressDef.Key);
            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "InvokeWhenPersist", svcAddressDef.InvokeWhenPersist);

            DateTime dtTimeOut = new DateTime(2008, 8, 8, svcAddressDef.Timeout.Hours, svcAddressDef.Timeout.Minutes, svcAddressDef.Timeout.Seconds);

            DictionaryHelper.AddNonDefaultValue <string, object>(dictionary, "Timeout", dtTimeOut);

            dictionary.Add("Params", svcAddressDef.Params);
            dictionary.Add("AddressDef", svcAddressDef.AddressDef);

            return(dictionary);
        }