public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue) { Executable from = null; Executable to = null; string fromName = null; string toName = null; var map = new Dictionary <string, DTSExecResult>(StringComparer.InvariantCultureIgnoreCase) { { Success, DTSExecResult.Success }, { Failure, DTSExecResult.Failure }, { Completion, DTSExecResult.Completion }, { Cancel, DTSExecResult.Canceled } }; if (!map.ContainsKey(itemTypeName)) { throw new ArgumentException(String.Format( @"The specified item type '{0}' is not valid. Please use one of the following values: {1}", itemTypeName, String.Join(", ", NewItemTypeNames))); } var valueType = newItemValue.GetType(); if (valueType == typeof(string)) { GetConstraintTaskNames(newItemValue, out fromName, out toName); } else if (valueType == typeof(object[])) { var names = (object[])newItemValue; fromName = names[0].ToString(); toName = names[1].ToString(); } var exes = _executables.Cast <TaskHost>().ToList(); from = exes.FirstOrDefault(e => StringComparer.InvariantCultureIgnoreCase.Equals(fromName, e.Name)); to = exes.FirstOrDefault(e => StringComparer.InvariantCultureIgnoreCase.Equals(toName, e.Name)); if (null == from) { throw new ArgumentException("The task name '" + fromName + "' could not be found in the executables for this component"); } if (null == to) { throw new ArgumentException("The task name '" + toName + "' could not be found in the executables for this component"); } var constraint = _items.Add(from, to); constraint.Name = path; constraint.Value = map[itemTypeName]; var resolvedItem = context.ResolvePath(context.Path); return(resolvedItem.GetNodeValue()); }
public ExecutableCollectionNodeFactory(string collectionName, Executables items, Converter <Executable, INodeFactory> adapter) : base(collectionName, items.Cast <Executable>().ToList(), adapter) { _items = items; }