Пример #1
0
        public override bool Filter(IReadOnlyEntity entity, QueryParameter param)
        {
            var fileInfo = entity.GetComponent(FileInfo.TypeCode);

            if (fileInfo == null)
            {
                return(true);
            }

            if (param.Template == Parameters.FileName)
            {
                return(param.FilterOperatorString(fileInfo.FileName));
            }
            else if (param.Template == Parameters.HashMD5)
            {
                return(param.FilterOperatorString(fileInfo.HashMD5));
            }
            else if (param.Template == Parameters.HashSHA1OfMD5)
            {
                return(param.FilterOperatorString(fileInfo.HashSHA1OfMD5));
            }
            else
            {
                return(true);
            }
        }
Пример #2
0
        public override void GetQueryFormat(IReadOnlyEntity entity, QueryFormat format)
        {
            var fileInfo = entity.GetComponent(FileInfo.TypeCode);

            if (fileInfo == null)
            {
                return;
            }

            format.AddParameter(Parameters.FileName);
            format.AddParameter(Parameters.HashMD5);
            format.AddParameter(Parameters.HashSHA1OfMD5);
        }
        public override void GetQueryFormat(IReadOnlyEntity entity, QueryFormat format)
        {
            var card = entity.GetComponent(KoikatuCharacterCard.TypeCode);

            if (card == null)
            {
                return;
            }

            format.AddParameter(Parameters.Name);
            format.AddSelectableValue(Parameters.Sex, card.Sex);
            format.AddSelectableValue(Parameters.Personality, card.Personality);
            format.AddSelectableValue(Parameters.ClubActivities, card.ClubActivity);
            format.AddSelectableValue(Parameters.BloodType, card.BloodType);

            format.AddSelectableValue(Parameters.TeethType, card.TeethType);

            format.AddSelectableValue(Parameters.HeightType, card.HeightType);
            format.AddSelectableValue(Parameters.BustSizeType, card.BustSizeType);
            format.AddSelectableValue(Parameters.SkinType, card.SkinType);
            foreach (var adjective in Palettes.Skin.GetAdjectives(card.SkinColor))
            {
                format.AddSelectableValue(Parameters.SkinColorType, adjective);
#if DEBUG
                format.AddSelectableValue(Parameters.InverseSkinColorType, adjective);
#endif
            }

            format.AddSelectableValue(Parameters.HairStyle, card.HairStyle);
            foreach (var adjective in card.HairColors.Select(i => Palettes.Hair.GetAdjectives(i)).SelectMany(i => i))
            {
                format.AddSelectableValue(Parameters.HairColorType, adjective);
#if DEBUG
                format.AddSelectableValue(Parameters.InverseHairColorType, adjective);
#endif
            }
        }
        public override bool Filter(IReadOnlyEntity entity, QueryParameter param)
        {
            var card = entity.GetComponent(KoikatuCharacterCard.TypeCode);

            if (card == null)
            {
                return(true);
            }

            if (param.Template == Parameters.Name)
            {
                var value = param.Value as string;
                if (string.IsNullOrWhiteSpace(value))
                {
                    return(true);
                }

                var normalizedValue = StringUtil.NormalizeString(value);
                var lastName        = StringUtil.NormalizeString(card.LastName);
                var firstName       = StringUtil.NormalizeString(card.FirstName);
                var nickname        = StringUtil.NormalizeString(card.Nickname);

                return(StringUtil.TestOperatorString(normalizedValue, query =>
                                                     nickname.FuzzyContains(query) ||
                                                     $"{lastName}{firstName}".FuzzyContains(query) ||
                                                     $"{lastName} {firstName}".FuzzyContains(query) ||
                                                     $"{firstName}{lastName}".FuzzyContains(query) ||
                                                     $"{firstName} {lastName}".FuzzyContains(query)));
            }
            else if (param.Template == Parameters.Sex)
            {
                return(param.FilterSelection(card.Sex));
            }
            else if (param.Template == Parameters.Personality)
            {
                return(param.FilterSelection(card.Personality));
            }
            else if (param.Template == Parameters.ClubActivities)
            {
                return(param.FilterSelection(card.ClubActivity));
            }
            else if (param.Template == Parameters.BloodType)
            {
                return(param.FilterSelection(card.BloodType));
            }
            else if (param.Template == Parameters.TeethType)
            {
                return(param.FilterSelection(card.TeethType));
            }
            else if (param.Template == Parameters.HeightType)
            {
                return(param.FilterSelection(card.HeightType));
            }
            else if (param.Template == Parameters.BustSizeType)
            {
                return(param.FilterSelection(card.BustSizeType));
            }
            else if (param.Template == Parameters.HairStyle)
            {
                return(param.FilterSelection(card.HairStyle));
            }
            else if (param.Template == Parameters.SkinType)
            {
                return(param.FilterSelection(card.SkinType));
            }
            else if (param.Template == Parameters.SkinColorType)
            {
                return(Palettes.Skin.GetAdjectives(card.SkinColor).Any(param.FilterSelection));
            }
            else if (param.Template == Parameters.HairColorType)
            {
                return(card.HairColors
                       .Select(i => Palettes.Hair.GetAdjectives(i))
                       .SelectMany(i => i)
                       .Any(param.FilterSelection));
            }
            else if (param.Template == Parameters.InverseSkinColorType)
            {
                return(param.Selection.Count == 0 ||
                       !Palettes.Skin.GetAdjectives(card.SkinColor).Any(param.FilterSelection));
            }
            else if (param.Template == Parameters.InverseHairColorType)
            {
                return(param.Selection.Count == 0 ||
                       !card.HairColors
                       .Select(i => Palettes.Hair.GetAdjectives(i))
                       .SelectMany(i => i)
                       .Any(param.FilterSelection));
            }
            else
            {
                return(true);
            }
        }