Example #1
0
File: Config.cs Project: uheee/Nett
        internal void Set(TPath path, object value, IConfigSource source)
        {
            path.CheckNotNull(nameof(path));
            value.CheckNotNull(nameof(value));

            this.Set(tbl => path.Set(tbl, cur => CreateNewValueObject(cur, tbl.Root, value)), source);
        }
Example #2
0
        internal void Set(TPath path, object value, IConfigSource source)
        {
            path.CheckNotNull(nameof(path));
            value.CheckNotNull(nameof(value));

            this.Set(tbl => path.SetValue(tbl, TomlObject.CreateFrom(tbl.Root, value, null)), source);
        }
Example #3
0
        public void push()
        {
            var   path1 = new TPath("s1/s2/s3/t1");
            TPath path2 = path1.Push("top");

            path2.Locator.ShouldEqual("top/s1/s2/s3/t1");
        }
Example #4
0
        internal TomlObject GetFromPath(TPath path)
        {
            path.CheckNotNull(nameof(path));

            var cfg = this.persistable.Load();

            return(path.Apply(cfg));
        }
Example #5
0
        internal bool Clear(TPath path, IConfigSource source)
        {
            var sourceTable = this.persistable.Load(source);
            var wasRemoved  = path.ClearFrom(sourceTable);

            this.persistable.Save(sourceTable, source);
            return(wasRemoved);
        }
Example #6
0
        internal IConfigSource TryGetSource(TPath path)
        {
            path.CheckNotNull(nameof(path));

            var cfgTable = this.persistable.LoadSourcesTable();
            var source   = path.TryApply(cfgTable) as TomlSource;

            return(source?.Value);
        }
Example #7
0
        public IFixtureNode Find(TPath path)
        {
            if (path.IsRoot)
            {
                return(this);
            }

            FixtureGraph fixture = FixtureFor(path.Next);

            return(path.IsEnd ? fixture : (IFixtureNode)fixture.GrammarFor(path.Pop().Next));
        }
Example #8
0
        internal bool Clear(TPath path)
        {
            var ste = path.TryApply(this.persistable.LoadSourcesTable()) as TomlSource;

            if (ste == null)
            {
                return(false);
            }

            return(this.Clear(path, ste.Value));
        }
Example #9
0
        public TPath GetPath()
        {
            var path = new TPath(Name);

            if (Parent != null)
            {
                path = path.Push(Parent.Name);
            }

            return(path);
        }
Example #10
0
File: Config.cs Project: uheee/Nett
        private bool ClearTable(TPath tablePath, TomlTable table, bool fromAllSources)
        {
            bool cleared = false;

            foreach (var rowPath in tablePath.BuildForTableItems(table))
            {
                cleared |= this.Clear(rowPath, fromAllSources);
            }

            this.persistable.RemoveEmptyTables();

            return(cleared);
        }
Example #11
0
File: Config.cs Project: uheee/Nett
        internal void Set(TPath path, object value)
        {
            path.CheckNotNull(nameof(path));
            value.CheckNotNull(nameof(value));

            bool notStoredInConfigYet = this.TryGetSource(path) == null;

            if (notStoredInConfigYet)
            {
                this.Set(path, value, this.persistable.RootSource);
            }
            else
            {
                this.Set(tbl => path.Set(tbl, cur => CreateNewValueObject(cur, tbl.Root, value)));
            }
        }
Example #12
0
        internal void Set(TPath path, object value)
        {
            path.CheckNotNull(nameof(path));
            value.CheckNotNull(nameof(value));

            var src = this.TryGetSource(path);

            bool notStoredInConfigYet = this.TryGetSource(path) == null;

            if (notStoredInConfigYet)
            {
                this.Set(path, value, this.persistable.RootSource);
            }
            else
            {
                this.Set(tbl => path.SetValue(tbl, TomlObject.CreateFrom(tbl.Root, value, null)));
            }
        }
Example #13
0
File: Config.cs Project: uheee/Nett
        internal bool Clear(TPath path, bool fromAllSources)
        {
            if (path.TryGet(this.persistable.LoadSourcesTable()) is TomlSource ste)
            {
                if (fromAllSources)
                {
                    bool cleared = false;
                    foreach (var s in this.persistable.Sources)
                    {
                        cleared |= this.Clear(path, s);
                    }
                }
                else
                {
                    return(this.Clear(path, ste.Value));
                }
            }
            else if (path.TryGet(this.persistable.Load()) is TomlTable tbl)
            {
                return(this.ClearTable(path, tbl, fromAllSources));
            }

            return(false);
        }
Example #14
0
 public TPathDot(TPath result, TPath pathExpression)
 {
     this.result         = result;
     this.pathExpression = pathExpression;
 }
Example #15
0
        public void locator()
        {
            var path1 = new TPath("s1/s2/s3/t1");

            path1.Locator.ShouldEqual("s1/s2/s3/t1");
        }
Example #16
0
        public void an_empty_string_path_is_the_hierarchy()
        {
            var path = new TPath(string.Empty);

            path.Locator.ShouldEqual(string.Empty);
        }
Example #17
0
 public TPathIndex(TPath result, Int32 index)
 {
     this.result = result;
     this.index  = index;
 }
Example #18
0
        public void append()
        {
            var path = new TPath("s1/s2/s3");

            path.Append("t1").Locator.ShouldEqual("s1/s2/s3/t1");
        }
Example #19
0
 public static TPath BuildTPath(this LambdaExpression expr)
 {
     expr.CheckNotNull(nameof(expr));
     return(TPath.Build(expr));
 }
Example #20
0
 private static TPath Build <TR>(Expression <Func <Tpo, TR> > expression)
 => TPath.Build(expression);
Example #21
0
 public IProcessErrorItem <TPath, TError, TAction> GetErrorItem(TPath item, IProcessError <TError, TAction> error) => new ProcessErrorItem(item, error);