Ejemplo n.º 1
0
        public virtual void CopyFrom([NotNull] ExecutableBase executableBase)
        {
            ThrowIfDisposed();
            if (executableBase == null)
            {
                throw new ArgumentNullException(nameof(executableBase));
            }
            if (IsBusy)
            {
                throw new InvalidOperationException("Cannot change properties when a task is being executed.");
            }
            if (CanChangeExecutableName)
            {
                ExecutableName = executableBase.ExecutableName;
            }

            Arguments.Clear();

            foreach (IProperty property in executableBase.Arguments)
            {
                if (!Arguments.TryGetValue(property.Name, out IProperty argument))
                {
                    Arguments.Add(property);
                    continue;
                }

                if (argument.ValueType.IsAssignableFrom(property.ValueType))
                {
                    throw new InvalidCastException();
                }
                argument.Value = property.Value;
            }
        }
Ejemplo n.º 2
0
 public void CopyTo([NotNull] ExecutableBase executable)
 {
     if (executable == null)
     {
         throw new ArgumentNullException(nameof(executable));
     }
     executable.CopyFrom(this);
 }