public DbValuePropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container, FileInfo file) : base(database, metaData, container) { File = file; var isSavePending = false; container.GetChangedByProperty(metaData.Property) .Do(x => Database.StartAction(() => !isSavePending && (isSavePending = true))) .Throttle(TimeSpan.FromSeconds(.5)) .Subscribe(x => { OnChanged(x); database.FinishAction(() => isSavePending = false); }); if (File.Exists) { Load(); } else { System.IO.File.WriteAllText(file.FullName, ""); } var newValue = metaData.Property.GetValue(container, null); if (newValue != metaData.DefaultValue) { OnChanged(new PropertyChanged <object>(metaData.Property, null, newValue)); } }
public DbObjectNode(SexyDatabase database, IRxObject obj, DirectoryInfo directory) : base(database) { if (!directory.Exists) { directory.Create(); directory.Refresh(); } Object = obj; MetaData = DbObjectMetaDataCache.GetMetaData(obj.GetType()); Directory = directory; PropertyNodes = MetaData.Properties.Select(x => CreateNode(x, obj)).ToImmutableDictionary(x => x.MetaData.Name); }
public DbObjectListPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container, DirectoryInfo directory) : base(database, metaData, container) { Directory = directory; ItemNodes = new List <DbObjectNode>(); List = (IRxList)metaData.Property.GetValue(container, null); if (List == null) { throw new ArgumentException($"{metaData.Property.DeclaringType.FullName}.{metaData.Property.Name} cannot be null"); } for (var i = 0; i < List.Count; i++) { var item = List[i]; ItemNodes.Add(new DbObjectNode(database, (IRxObject)item, new DirectoryInfo(Path.Combine(Directory.FullName, i.ToString())))); } List.Changed.Subscribe(x => OnChanged(x)); }
public DbObjectPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container, DirectoryInfo directory) : base(database, metaData, container) { Directory = directory; container.GetChangedByProperty(metaData.Property).Subscribe(OnChanged); }
protected DbNode(SexyDatabase database) { Database = database; }
protected DbPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container) : base(database) { MetaData = metaData; Container = container; }