private void SetActivityProperties(WfActivityDescriptor actDesp, Dictionary <string, object> activityProperties, IDictionary <string, object> dictionary)
        {
            if (activityProperties.ContainsKey("Variables"))
            {
                var item = (WfVariableDescriptorCollection)activityProperties["Variables"];
                if (item != null)
                {
                    actDesp.Variables.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("Variables"))
            {
                WfVariableDescriptorCollection variables = JSONSerializerExecute.Deserialize <WfVariableDescriptorCollection>(dictionary["Variables"]);
                actDesp.Variables.CopyFrom(variables);
            }

            if (activityProperties.ContainsKey("Condition"))
            {
                var item = (WfConditionDescriptor)activityProperties["Condition"];
                if (item != null)
                {
                    actDesp.Condition = (WfConditionDescriptor)activityProperties["Condition"];
                }
                else
                {
                    actDesp.Condition.Owner = actDesp;
                }
            }
            else if (dictionary.ContainsKey("Condition"))
            {
                actDesp.Condition       = JSONSerializerExecute.Deserialize <WfConditionDescriptor>(dictionary["Condition"]);
                actDesp.Condition.Owner = actDesp;
            }

            if (activityProperties.ContainsKey("BranchProcessTemplates"))
            {
                var item = (WfBranchProcessTemplateCollection)activityProperties["BranchProcessTemplates"];
                if (item != null)
                {
                    actDesp.BranchProcessTemplates.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("BranchProcessTemplates"))
            {
                WfBranchProcessTemplateCollection templates = JSONSerializerExecute.Deserialize <WfBranchProcessTemplateCollection>(dictionary["BranchProcessTemplates"]);
                actDesp.BranchProcessTemplates.CopyFrom(templates);
            }

            if (activityProperties.ContainsKey("Resources"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["Resources"];
                if (item != null)
                {
                    actDesp.Resources.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("Resources"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["Resources"]);
                actDesp.Resources.CopyFrom(resource);
            }

            if (activityProperties.ContainsKey("RelativeLinks"))
            {
                var item = (WfRelativeLinkDescriptorCollection)activityProperties["RelativeLinks"];
                if (item != null)
                {
                    actDesp.RelativeLinks.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("RelativeLinks"))
            {
                WfRelativeLinkDescriptorCollection relativeLinks = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(dictionary["RelativeLinks"]);
                actDesp.RelativeLinks.CopyFrom(relativeLinks);
            }

            if (activityProperties.ContainsKey("EnterEventReceivers"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["EnterEventReceivers"];
                if (item != null)
                {
                    actDesp.EnterEventReceivers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("EnterEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["EnterEventReceivers"]);
                actDesp.EnterEventReceivers.CopyFrom(resource);
            }

            if (activityProperties.ContainsKey("LeaveEventReceivers"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["LeaveEventReceivers"];
                if (item != null)
                {
                    actDesp.LeaveEventReceivers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("LeaveEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["LeaveEventReceivers"]);
                actDesp.LeaveEventReceivers.CopyFrom(resource);
            }

            if (activityProperties.ContainsKey("InternalRelativeUsers"))
            {
                var item = (WfResourceDescriptorCollection)activityProperties["InternalRelativeUsers"];
                if (item != null)
                {
                    actDesp.InternalRelativeUsers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("InternalRelativeUsers"))
            {
                WfResourceDescriptorCollection interRelUser = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["InternalRelativeUsers"]);
                actDesp.InternalRelativeUsers.CopyFrom(interRelUser);
            }

            if (activityProperties.ContainsKey("ExternalUsers"))
            {
                var item = (WfExternalUserCollection)activityProperties["ExternalUsers"];
                if (item != null)
                {
                    actDesp.ExternalUsers.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("ExternalUsers"))
            {
                WfExternalUserCollection externalUser = JSONSerializerExecute.Deserialize <WfExternalUserCollection>(dictionary["ExternalUsers"]);
                actDesp.ExternalUsers.CopyFrom(externalUser);
            }

            if (activityProperties.ContainsKey("EnterEventExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["EnterEventExecuteServices"];
                if (item != null)
                {
                    actDesp.EnterEventExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("EnterEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["EnterEventExecuteServices"]);
                actDesp.EnterEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("LeaveEventExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["LeaveEventExecuteServices"];

                if (item != null)
                {
                    actDesp.LeaveEventExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("LeaveEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["LeaveEventExecuteServices"]);

                actDesp.LeaveEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("WithdrawExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["WithdrawExecuteServices"];

                if (item != null)
                {
                    actDesp.WithdrawExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("WithdrawExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["WithdrawExecuteServices"]);

                actDesp.WithdrawExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("BeWithdrawnExecuteServices"))
            {
                var item = (WfServiceOperationDefinitionCollection)activityProperties["BeWithdrawnExecuteServices"];

                if (item != null)
                {
                    actDesp.BeWithdrawnExecuteServices.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("BeWithdrawnExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["BeWithdrawnExecuteServices"]);

                actDesp.BeWithdrawnExecuteServices.CopyFrom(svcOperationDef);
            }

            if (activityProperties.ContainsKey("ParametersNeedToBeCollected"))
            {
                var item = (WfParameterNeedToBeCollected)activityProperties["ParametersNeedToBeCollected"];
                if (item != null)
                {
                    actDesp.ParametersNeedToBeCollected.CopyFrom(item);
                }
            }
            else if (dictionary.ContainsKey("ParametersNeedToBeCollected"))
            {
                WfParameterNeedToBeCollected parameters =
                    JSONSerializerExecute.Deserialize <WfParameterNeedToBeCollected>(dictionary["ParametersNeedToBeCollected"]);
                actDesp.ParametersNeedToBeCollected.CopyFrom(parameters);
            }
        }
        private void SetProcessProperties(WfProcessDescriptor processDesp, Dictionary <string, object> processProperties, IDictionary <string, object> dictionary)
        {
            if (processProperties.ContainsKey("RelativeLinks"))
            {
                processDesp.RelativeLinks.CopyFrom((WfRelativeLinkDescriptorCollection)processProperties["RelativeLinks"]);
            }
            else if (dictionary.ContainsKey("RelativeLinks"))
            {
                WfRelativeLinkDescriptorCollection relativeLinks = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(dictionary["Variables"]);
                processDesp.RelativeLinks.CopyFrom(relativeLinks);
            }

            if (processProperties.ContainsKey("CancelEventReceivers"))
            {
                processDesp.CancelEventReceivers.CopyFrom((WfResourceDescriptorCollection)processProperties["CancelEventReceivers"]);
            }
            else if (dictionary.ContainsKey("CancelEventReceivers"))
            {
                WfResourceDescriptorCollection cancelEventReceivers = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["CancelEventReceivers"]);
                processDesp.CancelEventReceivers.CopyFrom(cancelEventReceivers);
            }

            if (processProperties.ContainsKey("CompleteEventReceivers"))
            {
                processDesp.CompleteEventReceivers.CopyFrom((WfResourceDescriptorCollection)processProperties["CompleteEventReceivers"]);
            }
            else if (dictionary.ContainsKey("CompleteEventReceivers"))
            {
                WfResourceDescriptorCollection completeEventReceivers = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["CompleteEventReceivers"]);
                processDesp.CompleteEventReceivers.CopyFrom(completeEventReceivers);
            }

            if (processProperties.ContainsKey("CancelBeforeExecuteServices"))
            {
                processDesp.CancelBeforeExecuteServices.CopyFrom((WfServiceOperationDefinitionCollection)processProperties["CancelBeforeExecuteServices"]);
            }
            else if (dictionary.ContainsKey("CancelBeforeExecuteServices"))
            {
                WfServiceOperationDefinitionCollection cancelBeforeExecuteServices = JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["CancelBeforeExecuteServices"]);
                processDesp.CancelBeforeExecuteServices.CopyFrom(cancelBeforeExecuteServices);
            }

            if (processProperties.ContainsKey("CancelAfterExecuteServices"))
            {
                processDesp.CancelAfterExecuteServices.CopyFrom((WfServiceOperationDefinitionCollection)processProperties["CancelAfterExecuteServices"]);
            }
            else if (dictionary.ContainsKey("CancelAfterExecuteServices"))
            {
                WfServiceOperationDefinitionCollection canceAfterExecuteServices = JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["CancelAfterExecuteServices"]);
                processDesp.CancelAfterExecuteServices.CopyFrom(canceAfterExecuteServices);
            }

            if (processProperties.ContainsKey("InternalRelativeUsers"))
            {
                processDesp.InternalRelativeUsers.CopyFrom((WfResourceDescriptorCollection)processProperties["InternalRelativeUsers"]);
            }
            else if (dictionary.ContainsKey("InternalRelativeUsers"))
            {
                WfResourceDescriptorCollection interRelUser = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["InternalRelativeUsers"]);
                processDesp.InternalRelativeUsers.CopyFrom(interRelUser);
            }

            if (processProperties.ContainsKey("ExternalUsers"))
            {
                processDesp.ExternalUsers.CopyFrom((WfExternalUserCollection)processProperties["ExternalUsers"]);
            }
            else if (dictionary.ContainsKey("ExternalUsers"))
            {
                WfExternalUserCollection externalUser = JSONSerializerExecute.Deserialize <WfExternalUserCollection>(dictionary["ExternalUsers"]);
                processDesp.ExternalUsers.CopyFrom(externalUser);
            }

            if (processProperties.ContainsKey("Variables"))
            {
                processDesp.Variables.CopyFrom((WfVariableDescriptorCollection)processProperties["Variables"]);
            }
            else if (dictionary.ContainsKey("Variables"))
            {
                WfVariableDescriptorCollection externalUser = JSONSerializerExecute.Deserialize <WfVariableDescriptorCollection>(dictionary["Variables"]);
                processDesp.Variables.CopyFrom(externalUser);
            }

            if (processProperties.ContainsKey("ParametersNeedToBeCollected"))
            {
                processDesp.ParametersNeedToBeCollected.CopyFrom((WfParameterNeedToBeCollected)processProperties["ParametersNeedToBeCollected"]);
            }
            else if (dictionary.ContainsKey("ParametersNeedToBeCollected"))
            {
                WfParameterNeedToBeCollected parametersNeedToBeCollected = JSONSerializerExecute.Deserialize <WfParameterNeedToBeCollected>(dictionary["ParametersNeedToBeCollected"]);
                processDesp.ParametersNeedToBeCollected.CopyFrom(parametersNeedToBeCollected);
            }
        }
Esempio n. 3
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfActivityDescriptor actDesp = (WfActivityDescriptor)base.Deserialize(dictionary, type, serializer);

            //actDesp.ActivityType = DictionaryHelper.GetValue(dictionary, "ActivityType", WfActivityType.NormalActivity);

            if (true == DictionaryHelper.GetValue(dictionary, "AllowEmptyCandidates", false))
            {
                actDesp.Properties.SetValue("AllowEmptyCandidates", true);
            }

            if (true == DictionaryHelper.GetValue(dictionary, "AllowInvalidCandidates", false))
            {
                if (actDesp.Properties.ContainsKey("AllowInvalidCandidates"))
                {
                    actDesp.Properties.SetValue("AllowInvalidCandidates", true);
                }
            }

            actDesp.Url      = DictionaryHelper.GetValue(dictionary, "Url", string.Empty);
            actDesp.CodeName = DictionaryHelper.GetValue(dictionary, "CodeName", string.Empty);

            WfVariableDescriptorCollection variables = JSONSerializerExecute.Deserialize <WfVariableDescriptorCollection>(dictionary["Variables"]);

            actDesp.Variables.Clear();
            actDesp.Variables.CopyFrom(variables);

            if (dictionary.ContainsKey("Condition"))
            {
                actDesp.Condition       = JSONSerializerExecute.Deserialize <WfConditionDescriptor>(dictionary["Condition"]);
                actDesp.Condition.Owner = actDesp;
            }

            if (dictionary.ContainsKey("BranchProcessTemplates"))
            {
                WfBranchProcessTemplateCollection templates = JSONSerializerExecute.Deserialize <WfBranchProcessTemplateCollection>(dictionary["BranchProcessTemplates"]);
                actDesp.BranchProcessTemplates.Clear();
                actDesp.BranchProcessTemplates.CopyFrom(templates);
            }

            if (dictionary.ContainsKey("Resources"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["Resources"]);
                actDesp.Resources.Clear();
                actDesp.Resources.CopyFrom(resource);
            }

            if (dictionary.ContainsKey("RelativeLinks"))
            {
                WfRelativeLinkDescriptorCollection relativeLinks = JSONSerializerExecute.Deserialize <WfRelativeLinkDescriptorCollection>(dictionary["RelativeLinks"]);

                actDesp.RelativeLinks.Clear();
                actDesp.RelativeLinks.CopyFrom(relativeLinks);
            }

            if (dictionary.ContainsKey("EnterEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["EnterEventReceivers"]);
                actDesp.EnterEventReceivers.Clear();
                actDesp.EnterEventReceivers.CopyFrom(resource);
            }

            if (dictionary.ContainsKey("LeaveEventReceivers"))
            {
                WfResourceDescriptorCollection resource = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["LeaveEventReceivers"]);
                actDesp.LeaveEventReceivers.Clear();
                actDesp.LeaveEventReceivers.CopyFrom(resource);
            }

            if (dictionary.ContainsKey("InternalRelativeUsers"))
            {
                WfResourceDescriptorCollection interRelUser = JSONSerializerExecute.Deserialize <WfResourceDescriptorCollection>(dictionary["InternalRelativeUsers"]);
                actDesp.InternalRelativeUsers.Clear();
                actDesp.InternalRelativeUsers.CopyFrom(interRelUser);
            }

            if (dictionary.ContainsKey("ExternalUsers"))
            {
                WfExternalUserCollection externalUser = JSONSerializerExecute.Deserialize <WfExternalUserCollection>(dictionary["ExternalUsers"]);
                actDesp.ExternalUsers.Clear();
                actDesp.ExternalUsers.CopyFrom(externalUser);
            }

            if (dictionary.ContainsKey("EnterEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["EnterEventExecuteServices"]);
                actDesp.EnterEventExecuteServices.Clear();
                actDesp.EnterEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (dictionary.ContainsKey("LeaveEventExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["LeaveEventExecuteServices"]);
                actDesp.LeaveEventExecuteServices.Clear();
                actDesp.LeaveEventExecuteServices.CopyFrom(svcOperationDef);
            }

            if (dictionary.ContainsKey("WithdrawExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["WithdrawExecuteServices"]);
                actDesp.WithdrawExecuteServices.Clear();
                actDesp.WithdrawExecuteServices.CopyFrom(svcOperationDef);
            }

            if (dictionary.ContainsKey("BeWithdrawnExecuteServices"))
            {
                WfServiceOperationDefinitionCollection svcOperationDef =
                    JSONSerializerExecute.Deserialize <WfServiceOperationDefinitionCollection>(dictionary["BeWithdrawnExecuteServices"]);
                actDesp.BeWithdrawnExecuteServices.Clear();
                actDesp.BeWithdrawnExecuteServices.CopyFrom(svcOperationDef);
            }

            return(actDesp);
        }