示例#1
0
 public bool Equals(AppRegistryItem other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Id == other.Id);
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }