Beispiel #1
0
        public override bool Execute()
        {
            if (Input == null)
            {
                return(true);
            }

            Dictionary <string, ITaskItem> include = Include?.ToDictionary(inc => inc.ItemSpec);
            Dictionary <string, ITaskItem> exclude = Exclude?.ToDictionary(ex => ex.ItemSpec);
            Dictionary <string, ITaskItem> items   = Items?.ToDictionary(item => item.ItemSpec);

            // filter
            var output = Input.Where(item => (include == null || include.ContainsKey(item.ItemSpec)) &&
                                     (exclude == null || !exclude.ContainsKey(item.ItemSpec)));

            // use items
            if (items != null)
            {
                ITaskItem x;
                output = output.Select(o => items.TryGetValue(o.ItemSpec, out x) ? x : o);
            }
            // filter Meta items
            output = output.Where(item => (string.IsNullOrEmpty(Meta) || string.IsNullOrEmpty(item.GetMetadata(Meta)) || item.GetMetadata(Meta) == "false"));

            Output = output.ToArray();

            return(true);
        }