예제 #1
0
 public static DivinityMissingModData FromData(DivinityModData modData)
 {
     return(new DivinityMissingModData
     {
         Name = modData.Name,
         UUID = modData.UUID,
         Index = modData.Index,
         Author = modData.Author
     });
 }
예제 #2
0
 public static DivinityModDependencyData FromModData(DivinityModData m)
 {
     return(new DivinityModDependencyData
     {
         Folder = m.Folder,
         Name = m.Name,
         UUID = m.UUID,
         MD5 = m.MD5,
         Version = m.Version
     });
 }
        public bool Match(DivinityModData mod)
        {
            if (String.IsNullOrWhiteSpace(FilterValue))
            {
                return(true);
            }

            if (PropertyContains("Author"))
            {
                if (ValueContains(mod.Author))
                {
                    return(true);
                }
            }

            if (PropertyContains("version"))
            {
                if (ValueContains(mod.Version.Version))
                {
                    return(true);
                }
            }

            if (PropertyContains("Mode"))
            {
                foreach (var mode in mod.Modes)
                {
                    if (ValueContains(mode))
                    {
                        return(true);
                    }
                }
            }

            if (PropertyContains("Depend"))
            {
                foreach (var dependency in mod.Dependencies.Items)
                {
                    if (ValueContains(dependency.Name))
                    {
                        return(true);
                    }
                }
            }

            if (PropertyContains("Name"))
            {
                //Trace.WriteLine($"Searching for '{FilterValue}' in '{mod.Name}' | {mod.Name.IndexOf(FilterValue)}");
                if (ValueContains(mod.Name))
                {
                    return(true);
                }
            }

            if (PropertyContains("File"))
            {
                if (ValueContains(mod.FileName))
                {
                    return(true);
                }
            }

            if (PropertyContains("Desc"))
            {
                if (ValueContains(mod.Description))
                {
                    return(true);
                }
            }

            if (PropertyContains("Type"))
            {
                if (ValueContains(mod.Type))
                {
                    return(true);
                }
            }

            if (PropertyContains("UUID"))
            {
                if (ValueContains(mod.UUID))
                {
                    return(true);
                }
            }

            if (PropertyContains("Selected"))
            {
                if (mod.IsSelected)
                {
                    return(true);
                }
            }

            if (PropertyContains("Editor"))
            {
                if (mod.IsEditorMod)
                {
                    return(true);
                }
            }

            if (PropertyContains("Modified") || PropertyContains("Updated"))
            {
                DateTime date = DateTime.Now;
                if (DateTime.TryParse(FilterValue, out date))
                {
                    if (mod.LastModified >= date)
                    {
                        return(true);
                    }
                }
            }

            if (PropertyContains("Tag"))
            {
                if (mod.Tags != null && mod.Tags.Count > 0)
                {
                    var f = this;
                    if (mod.Tags.Any(x => f.ValueContains(x)))
                    {
                        return(true);
                    }
                    // GM, Story, Arena are technically tags as well
                    foreach (var mode in mod.Modes)
                    {
                        if (ValueContains(mode))
                        {
                            return(true);
                        }
                    }
                }
            }

            /*
             *	var propertyValue = (string)mod.GetType().GetProperty(FilterProperty).GetValue(mod, null);
             *      if(propertyValue != null)
             *      {
             *              return CultureInfo.CurrentCulture.CompareInfo.IndexOf(propertyValue, FilterValue, CompareOptions.IgnoreCase) >= 0;
             *      }
             */
            return(false);
        }