예제 #1
0
        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));
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        public DbObjectPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container, DirectoryInfo directory) : base(database, metaData, container)
        {
            Directory = directory;

            container.GetChangedByProperty(metaData.Property).Subscribe(OnChanged);
        }
예제 #5
0
 protected DbNode(SexyDatabase database)
 {
     Database = database;
 }
예제 #6
0
 protected DbPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container) : base(database)
 {
     MetaData  = metaData;
     Container = container;
 }