public bool Equals(AppRegistryItem other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Id == other.Id); }
public static AppRegistryItem GetOrCreate <T>(this AppRegistry registry) where T : new() { var itemId = registry.CreateItemId <T>(); var itemValue = registry.TryFindItemValue <T>(itemId); if (itemValue != null) { return(itemValue); } itemValue = AppRegistryItem.Create(itemId, new T()).Register(registry); return(itemValue); }
public static AppRegistryItem Register(this AppRegistryItem theItem, AppRegistry registry) { if (theItem == null) { throw new ArgumentNullException(nameof(theItem)); } if (registry == null) { throw new ArgumentNullException(nameof(registry)); } registry.Register(theItem); return(theItem); }
public static void SaveToFile(this AppRegistry registry, AppRegistryItem item) { if (registry == null) { throw new ArgumentNullException(nameof(registry)); } if (item == null) { throw new ArgumentNullException(nameof(item)); } var fileDbHelper = FileDbHelper.Instance; var filePath = fileDbHelper.MakeAppDataFilePath("AppRegistry", $"{item.Id}.json"); fileDbHelper.Save(filePath, item); }
public static AppRegistryItem Create(string metaId, object metaValue) { if (string.IsNullOrWhiteSpace(metaId)) { throw new ArgumentNullException(nameof(metaId)); } if (metaValue == null) { throw new ArgumentNullException(nameof(metaValue)); } var item = new AppRegistryItem { Id = metaId, Title = metaId, Group = RootGroup, Value = metaValue }; return(item); }