コード例 #1
0
        public void Add(Field field)
        {
            if (Ids.Contains(field.Id))
            {
                return;
            }

            _passwordFields = _usernameFields = null;

            Ids.Add(field.Id);
            Fields.Add(field);
            AutofillIds.Add(field.AutofillId);
            IdToFieldMap.Add(field.Id, field);

            if (field.Hints != null)
            {
                foreach (var hint in field.Hints)
                {
                    Hints.Add(hint);
                    if (field.Focused)
                    {
                        FocusedHints.Add(hint);
                    }

                    if (!HintToFieldsMap.ContainsKey(hint))
                    {
                        HintToFieldsMap.Add(hint, new List <Field>());
                    }

                    HintToFieldsMap[hint].Add(field);
                }
            }
        }
        public void Add(AutofillFieldMetadata data)
        {
            _size++;
            SaveType |= data.SaveType;
            Ids.Add(data.Id);
            AutofillIds.Add(data.AutofillId);
            IdToFieldMap.Add(data.Id, data);

            if ((data.AutofillHints?.Count ?? 0) > 0)
            {
                AutofillHints.AddRange(data.AutofillHints);
                if (data.IsFocused)
                {
                    FocusedAutofillHints.AddRange(data.AutofillHints);
                }

                foreach (var hint in data.AutofillHints)
                {
                    if (!AutofillHintsToFieldsMap.ContainsKey(hint))
                    {
                        AutofillHintsToFieldsMap.Add(hint, new List <AutofillFieldMetadata>());
                    }

                    AutofillHintsToFieldsMap[hint].Add(data);
                }
            }
        }