Пример #1
0
 public EnumNode(
     Action <ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : base(action, family, name)
 {
 }
Пример #2
0
        protected TextNodeBase(
            IEnumerable <ITextClass> textClasses,
            Action <ActionNode, IToken, IResultAccumulator> action,
            INodeFamily family,
            string name)
            : base(action, family, name)
        {
            if (textClasses == null)
            {
                throw new ArgumentNullException(nameof(textClasses));
            }

            var textClassesList = textClasses.ToList(); // to avoid multiple enumerating.

            if (textClassesList.Count == 0)
            {
                throw new ArgumentException($"'{nameof(textClasses)}' cannot be empty.");
            }

            if (textClassesList.Any(x => x == null))
            {
                throw new ArgumentException($"'{nameof(textClasses)}' cannot contain nulls.");
            }

            this.TextClassesImpl = new HashSet <ITextClass>(textClassesList);
            this.TextClasses     = this.TextClassesImpl.ToList();
        }
Пример #3
0
        public ExactTextNode(
            string exactText,
            IEnumerable <ITextClass> textClasses,
            bool isCaseSensitive,
            Action <ActionNode, IToken, IResultAccumulator> action,
            INodeFamily family,
            string name)
            : base(
                textClasses,
                action,
                family,
                name)
        {
            if (exactText == null)
            {
                throw new ArgumentNullException(nameof(exactText));
            }

            if (!isCaseSensitive)
            {
                exactText = exactText.ToLowerInvariant();
            }

            this.ExactText = exactText;

            if (textClasses == null)
            {
                throw new ArgumentNullException(nameof(textClasses));
            }

            this.IsCaseSensitive = isCaseSensitive;
        }
Пример #4
0
 public FallbackNode(
     Func <FallbackNode, IToken, IResultAccumulator, bool> fallbackPredicate,
     INodeFamily family,
     string name)
     : base(family, name)
 {
     this.FallbackPredicate = fallbackPredicate ?? throw new ArgumentNullException(nameof(fallbackPredicate));
 }
Пример #5
0
 protected ActionNode(
     Action <ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : base(family, name)
 {
     this.Action = action; // can be null
 }
Пример #6
0
        public CustomCliHost(string name)
        {
            this.Name = name;

            _output = TextWriter.Null;
            _input  = TextReader.Null;

            _nodeFamily = new NodeFamily($"Node family for empty host '{this.Name}'");
        }
Пример #7
0
 public CustomActionNode(
     Action <ActionNode, IToken, IResultAccumulator> action,
     Func <IToken, IResultAccumulator, bool> tokenAcceptPredicate,
     INodeFamily family,
     string name)
     : base(action, family, name)
 {
     this.TokenAcceptPredicate = tokenAcceptPredicate;
 }
Пример #8
0
 public ExactEnumNode(
     TEnum value,
     Action<ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : base(action, family, name)
 {
     this.Value = value;
 }
Пример #9
0
        protected NodeImpl(INodeFamily family, string name)
        {
            this.Family = family;
            this.Name   = name;

            family?.RegisterNode(this);

            _establishedLinks = new HashSet <INode>();
            _claimedLinkNames = new HashSet <string>();
            _properties       = new Dictionary <string, string>();
        }
Пример #10
0
 protected TextNodeBase(
     ITextClass textClass,
     Action <ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : this(
         new[] { textClass },
         action,
         family,
         name)
 {
 }
Пример #11
0
 public TextNode(
     IEnumerable <ITextClass> textClasses,
     Action <ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : base(
         textClasses,
         action,
         family,
         name)
 {
 }
Пример #12
0
        public ExactPunctuationNode(
            char c,
            Action <ActionNode, IToken, IResultAccumulator> action,
            INodeFamily family,
            string name)
            : base(action, family, name)
        {
            if (!LexingHelper.IsStandardPunctuationChar(c))
            {
                throw new ArgumentOutOfRangeException(nameof(c));
            }

            this.Value = c;
        }
        public virtual void StartSystem()
        {
            Entities   = Engine.FamilyManager.Get(this.RequiredTypes()).Entities;
            NodeFamily = Engine.FamilyManager.GetNodeFamily <T>();

            Entities.ItemAdded += (o, e) =>
            {
                var entity = (Entity)e;
                OnNodeAdded(entity, NodeFamily.NodeForEntity(entity));
            };
            Entities.ItemRemoved += (o, e) =>
            {
                var entity = (Entity)e;
                OnNodeRemoved(entity, NodeFamily.NodeForEntity(entity));
            };
        }
Пример #14
0
 public MultiTextNode(
     IEnumerable <string> texts,
     ITextClass textClass,
     bool isCaseSensitive,
     Action <ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : this(
         texts,
         new[] { textClass },
         isCaseSensitive,
         action,
         family,
         name)
 {
 }
Пример #15
0
 public ExactTextNode(
     string exactText,
     ITextClass textClass,
     bool isCaseSensitive,
     Action <ActionNode, IToken, IResultAccumulator> action,
     INodeFamily family,
     string name)
     : this(
         exactText,
         new[] { textClass },
         isCaseSensitive,
         action,
         family,
         name)
 {
 }
Пример #16
0
        protected CliHostBase(
            string name,
            string version,
            bool supportsHelp)
            : base(name, version, supportsHelp)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name)); // host cannot be nameless.
            }

            _nodeFamily   = new NodeFamily($"Node family for host '{this.Name}'");
            _addInRecords = new Dictionary <string, AddInRecord>();

            _output = TextWriter.Null;
            _input  = TextReader.Null;
        }
Пример #17
0
        protected CliAddInBase(string name, string version, bool supportsHelp)
            : base(name, version, supportsHelp)
        {
            if (name == null)
            {
                if (version != null)
                {
                    throw new ArgumentException("Nameless add-in cannot have version.", nameof(version));
                }

                //if (supportsHelp)
                //{
                //    throw new ArgumentException("Nameless add-in cannot support help.", nameof(supportsHelp));
                //}
            }

            _nodeFamily = new NodeFamily($"Add-in node family: {this.Name ?? string.Empty}. Add-in type is '{this.GetType().FullName}'.");
            _executors  = new List <ICliExecutor>();
        }
Пример #18
0
        public MultiTextNode(
            IEnumerable <string> texts,
            IEnumerable <ITextClass> textClasses,
            bool isCaseSensitive,
            Action <ActionNode, IToken, IResultAccumulator> action,
            INodeFamily family,
            string name)
            : base(
                textClasses,
                action,
                family,
                name)
        {
            if (texts == null)
            {
                throw new ArgumentNullException(nameof(texts));
            }

            var textList = texts.ToList();

            if (textList.Count == 0)
            {
                throw new ArgumentException($"'{nameof(texts)}' cannot be empty.", nameof(texts));
            }

            if (textList.Any(x => x == null))
            {
                throw new ArgumentException($"'{nameof(texts)}' cannot contain nulls.", nameof(texts));
            }

            if (!isCaseSensitive)
            {
                textList = textList.Select(x => x.ToLowerInvariant()).ToList();
            }

            _texts = new HashSet <string>(textList);

            this.IsCaseSensitive = isCaseSensitive;
            this.Texts           = _texts.ToList();
        }
Пример #19
0
 public IdleNode(INodeFamily family, string name)
     : base(family, name)
 {
 }