private UserInputLookup Load(IUserInputLookupOwner owner, string lookupName) { var filename = GetUserInputLookupFileName(lookupName); var lookup = new UserInputLookup(owner, lookupName); string json; try { json = File.ReadAllText(filename); } catch (FileNotFoundException) { return(lookup); } try { lookup = JsonConvert .DeserializeObject <UserInputLookup>(json); lookup.Owner = owner; } catch (JsonSerializationException ex) { lookup.SelectedItem = ex.Message; return(lookup); } lookup.Name = lookupName; foreach (var value in lookup) { lookup.Add(value); } return(lookup); }
public IUserInputLookup Get( IUserInputLookupOwner owner, string lookupName, string selectedItem) { var value = Get(owner, lookupName); value.SelectedItem = selectedItem; return(value); }
public IUserInputLookup Get(IUserInputLookupOwner owner, string lookupName) { if (string.IsNullOrEmpty(lookupName)) { return(UserInputLookup.Empty); } var value = GetInstance(owner, lookupName); value.IsPropertyChangedNotificationEnabled = true; return(value); }
private UserInputLookup GetInstance( IUserInputLookupOwner owner, string lookupName) { UserInputLookup value; if (!_registry.ContainsKey(lookupName)) { value = Load(owner, lookupName); _registry.Add(lookupName, value); value.CollectionChanged += OnLookupCollectionChanged; } else { value = _registry[lookupName]; } return(value); }