Example #1
0
        public IExecutionContext AddAlias(Alias alias, bool replace = false)
        {
            //ALL Alias Management is to be done at the root.
            if (Parent != null)
            {
                return(Parent.AddAlias(alias, replace));
            }

            if (replace)
            {
                MyAliases.RemoveAll(a => a.Name == alias.Name);
            }
            if (MyAliases.Exists(a => a.Name == alias.Name))
            {
                throw new RedefinedAliasException($"Alias [{alias.Name}] exists, and replace parameter is false.");
            }
            MyAliases.Add(alias);
            return(this);
        }