Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
0
        private DbPropertyNode CreateNode(DbPropertyMetaData metaData, IRxObject container)
        {
            switch (metaData.Type)
            {
            case DbPropertyType.Value:
                return(new DbValuePropertyNode(Database, metaData, container, new FileInfo(Path.Combine(Directory.FullName, metaData.Name))));

            case DbPropertyType.Object:
                return(new DbObjectPropertyNode(Database, metaData, container, new DirectoryInfo(Path.Combine(Directory.FullName, metaData.Name))));

            case DbPropertyType.ObjectList:
                return(new DbObjectListPropertyNode(Database, metaData, container, new DirectoryInfo(Path.Combine(Directory.FullName, metaData.Name))));

            default:
                throw new Exception();
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
0
        public DbObjectPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container, DirectoryInfo directory) : base(database, metaData, container)
        {
            Directory = directory;

            container.GetChangedByProperty(metaData.Property).Subscribe(OnChanged);
        }
Ejemplo n.º 5
0
 protected DbPropertyNode(SexyDatabase database, DbPropertyMetaData metaData, IRxObject container) : base(database)
 {
     MetaData  = metaData;
     Container = container;
 }