public IWorkflowActivity Activate()
        {
            IWorkflowActivity activity = null;

            try
            {
                _logger.Information("Activate Activity {0}", _process.Process);
                activity = LoadActivity();

                //get the list of the required attributes from Activity
                List <string> required = new List <string>(activity.RequiredAttributes);
                //check if we have what we need
                WorkflowActivityArgs activity_args = new WorkflowActivityArgs();
                if (!ProcessAttributeRequest(activity_args, required))
                {
                    throw new Exception("Not all requested Attributes are available");
                }

                activity_args.Logger = _logger;
                activity.Configure(activity_args);
            }
            catch (Exception ex)
            {
                //result = WfResult.Create(WfStatus.Failed, ex.Message, -5);
                throw ex;
            }
            return(activity);
        }
        private bool ProcessAttributeRequest(WorkflowActivityArgs args, List <string> required)
        {
            bool ret = true;
            WorkflowAttributeCollection found = new WorkflowAttributeCollection();
            List <string> attr_list           = new List <string>();

            if (required != null && required.Count > 0)
            {
                List <WorkflowParameter> list = _process.Parameters;
                foreach (string name in required)
                {
                    ret = false;
                    WorkflowParameter curr_param = list.FirstOrDefault(p => p.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
                    //find if override exist
                    if (curr_param != null && curr_param.Override != null)
                    {
                        foreach (string attr_name in curr_param.Override)
                        {
                            if (_attributes.Keys.Contains(attr_name))
                            {
                                found.Add(name, _attributes[attr_name]);
                                ret = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (_attributes.Keys.Contains(name))
                        {
                            found.Add(name, _attributes[name]);
                            ret = true;
                        }
                    }

                    if (!ret)
                    {
                        if (curr_param == null || curr_param.Default == null)
                        {
                            _logger.Error("Error {ErrorCode}: Attribute {Name} is not found", -11, name);
                            break;
                        }
                        else
                        {
                            found.Add(name, curr_param.Default);
                            ret = true;
                        }
                    }
                }
            }

            args.RequiredAttributes = found;
            return(ret);
        }