예제 #1
0
		public void OneArg()
		{
			var args = new RantPatternArgs
			{
				["foo"] = "Bar"
			};
			Assert.AreEqual("FooBar", rant.Do(@"Foo[in:foo]", 0, 0, args).Main);
		}
예제 #2
0
        public void OneArgAnonymousType()
        {
            var args = new
            {
                msg = "Hello World"
            };

            Assert.AreEqual("Hello World", rant.Do(@"[in:msg]", 0, 0, RantPatternArgs.CreateFrom(args)).Main);
        }
예제 #3
0
        public void OneArg()
        {
            var args = new RantPatternArgs
            {
                ["foo"] = "Bar"
            };

            Assert.AreEqual("FooBar", rant.Do(@"Foo[in:foo]", 0, 0, args).Main);
        }
예제 #4
0
 public Sandbox(RantEngine engine, RantPattern pattern, RNG rng, int sizeLimit = 0, RantPatternArgs args = null)
 {
     _engine     = engine;
     _format     = engine.Format;
     _sizeLimit  = new Limit(sizeLimit);
     _baseOutput = new OutputWriter(this);
     _outputs    = new Stack <OutputWriter>();
     _outputs.Push(_baseOutput);
     _rng               = rng;
     _startingGen       = rng.Generation;
     _pattern           = pattern;
     _objects           = new ObjectStack(engine.Objects);
     _blocks            = new Stack <BlockState>();
     _matches           = new Stack <Match>();
     _queryState        = new QueryState();
     _subroutineArgs    = new Stack <Dictionary <string, RantAction> >();
     _syncManager       = new SyncManager(this);
     _blockManager      = new BlockManager();
     _scriptObjectStack = new Stack <object>();
     _patternArgs       = args;
     _stopwatch         = new Stopwatch();
 }
예제 #5
0
파일: Sandbox.cs 프로젝트: W-h-a-t-s/Rant
        public Sandbox(RantEngine engine, RantPattern pattern, RNG rng, int sizeLimit = 0, RantPatternArgs args = null)
        {
            _engine = engine;
            _format = engine.Format;
            _sizeLimit = new Limit(sizeLimit);
            _baseOutput = new OutputWriter(this);
            _outputs = new Stack<OutputWriter>();
            _outputs.Push(_baseOutput);
            _rng = rng;
            _startingGen = rng.Generation;
            _pattern = pattern;
            _objects = new ObjectStack(engine.Objects);
            _blocks = new Stack<BlockState>();
            _matches = new Stack<Match>();
            _queryState = new QueryState();
            _subroutineArgs = new Stack<Dictionary<string, RantAction>>();
            _syncManager = new SyncManager(this);
            _blockManager = new BlockManager();
            _scriptObjectStack = new Stack<object>();
	        _patternArgs = args;
            _stopwatch = new Stopwatch();
        }
예제 #6
0
        public void CustomArgsClass()
        {
            var args = new TestCustomArgsClass
            {
                A = "Hello",
                B = "World"
            };

            Assert.AreEqual("Hello World!", rant.Do(@"[in:word-a] [in:word-b]!", 0, 0, RantPatternArgs.CreateFrom(args)).Main);
        }