public ProcessJobFieldValue(IProcessJobDefinitionField definition)
 {
     _definition = definition;
 }
        protected void ReplaceField(IProcessJobDefinitionField field, IProcessJobDefinitionField replacement)
        {
            if (field == null) throw Ex.ArgNull(() => field);
            if (replacement == null) throw Ex.ArgNull(() => replacement);

            try
            {
                _fields.ReadWrite((fields) =>
                    {
                        var index = fields.IndexOf(field);
                        if (index < 0)
                        {
                            throw new InvalidOperationException("Couldn't find field in fields list");
                        }

                        fields[index] = replacement;

                        return fields;
                    });
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to replace field", ex);
            }
        }
 public bool Match(IProcessJobDefinitionField field, bool matchConfig = true)
 {
     return AllCChain<bool>
         .If(false, () => this.Name == field.Name, true)
         .ThenIf(() => this.Mode == field.Mode, true)
         .ThenIf(() => this.Type.Equals(field.Type), true)
         .ThenIf(() => this.DisplayName == field.DisplayName, true)
         .ThenIf(() => (matchConfig == true) ? this.Config.Match(field.Config) : true, true)
         .Result;
 }
        void IJob_Internal.SetOutputValue(IProcessJobDefinitionField defField, object value)
        {
            if (defField == null) throw Ex.ArgNull(() => defField);

            try
            {
                _outputValueFields.ReadWrite((outFields) =>
                {
                    var vField = outFields.SingleOrDefault(f => f.Definition.Name == defField.Name);

                    if (vField != null)
                    {
                        vField.Value = value;
                    }
                    else
                    {
                        var pf = ProcessJobFieldFactory.CreateValueField(defField);
                        ((IProcessJobFieldConfig_Internal)pf.Definition.Config).Adopt(defField.Config);
                        pf.Value = value;
                        outFields.Add(pf);
                    }

                    return outFields;
                });
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to set output value", ex);
            }
        }