Пример #1
0
        public static FileMappingItem ParseItem(JToken item)
        {
            if (item.Type == JTokenType.Object)
            {
                return JsonConvert.DeserializeObject<FileMappingItem>(item.ToString());
            }
            else if (item.Type == JTokenType.Property)
            {
                JProperty jProperty = item as JProperty;
                FileMappingItem model = new FileMappingItem { Name = jProperty.Name };
                var value = jProperty.Value;
                if (value.Type == JTokenType.Array)
                {
                    model.Files = new FileItems(value.Select(s => s.Value<string>()));
                }
                else if (value.Type == JTokenType.String)
                {
                    model.Files = new FileItems((string)value);
                }
                else
                {
                    throw new JsonReaderException(string.Format("Unsupported value {0} (type: {1}).", value, value.Type));
                }

                return model;
            }
            else if (item.Type == JTokenType.String)
            {
                return new FileMappingItem { Files = new FileItems(item.Value<string>()) };
            }
            else
            {
                throw new JsonReaderException(string.Format("Unsupported value {0} (type: {1}).", item, item.Type));
            }
        }
Пример #2
0
 private static GlobMatcherOptions GetMatchOptionsFromItem(FileMappingItem item)
 {
     GlobMatcherOptions options = item?.CaseSensitive ?? false ? GlobMatcherOptions.None : GlobMatcherOptions.IgnoreCase;
     if (item?.AllowDotMatch ?? false) options |= GlobMatcherOptions.AllowDotMatch;
     if (!(item?.DisableEscape ?? false)) options |= GlobMatcherOptions.AllowEscape;
     if (!(item?.DisableExpand ?? false)) options |= GlobMatcherOptions.AllowExpand;
     if (!(item?.DisableGlobStar ?? false)) options |= GlobMatcherOptions.AllowGlobStar;
     if (!(item?.DisableNegate ?? false)) options |= GlobMatcherOptions.AllowNegate;
     return options;
 }
Пример #3
0
        /// <summary>
        /// Should not merge FileMappingItems even if they are using the same name, because other propertes also matters, e.g. cwd, exclude.
        /// </summary>
        /// <param name="item"></param>
        public void Add(FileMappingItem item)
        {
            if (item == null || item.Files == null || item.Files.Count == 0) return;

            _items.Add(item);
        }
Пример #4
0
 public FileMapping(FileMappingItem item)
 {
     this.Add(item);
 }