Exemple #1
0
        public FtMetaSequence New()
        {
            FtMetaSequence result = SequenceFactory.CreateMetaSequence();

            Add(result);
            return(result);
        }
        public void Sequence_Creation_Is_Ok()
        {
            var factory = new SequenceFactory();
            var seq     = factory.Create <int>("FibonacciNumbers", 1);

            Assert.IsNotNull(seq);
        }
Exemple #3
0
        internal FtMetaSequence CreateCopyExcludingRedirects(FtMetaFieldList fieldList, FtMetaFieldList sourceFieldList)
        {
            FtMetaSequence sequence = SequenceFactory.CreateMetaSequence();

            sequence.AssignExcludingRedirects(this, fieldList, sourceFieldList);
            return(sequence);
        }
Exemple #4
0
        public DocumentSchema(StoreOptions options, IConnectionFactory factory, IMartenLogger logger)
        {
            _factory = factory;
            _logger  = logger;

            StoreOptions = options;

            options.AllDocumentMappings.Each(x => _mappings[x.DocumentType] = x);

            _sequences = new Lazy <SequenceFactory>(() =>
            {
                var sequences = new SequenceFactory(this, _factory, options, _logger);

                var patch = new SchemaPatch();

                sequences.GenerateSchemaObjectsIfNecessary(StoreOptions.AutoCreateSchemaObjects, this, patch);

                apply(sequences, patch);

                return(sequences);
            });

            Parser = new MartenExpressionParser(StoreOptions.Serializer(), StoreOptions);

            HandlerFactory = new QueryHandlerFactory(this, options.Serializer());

            DbObjects = new DbObjects(_factory, this);


            addSystemFunction(options, "mt_immutable_timestamp");
        }
Exemple #5
0
        public static void GetBytes_Encoding_ReadOnlySequence_Span()
        {
            Span <byte> destination = stackalloc byte[32];

            // First try the single-segment code path.

            ReadOnlySequence <char> sequence = new ReadOnlySequence <char>("Hello!".ToCharArray());

            Assert.Equal(
                expected: Encoding.UTF8.GetBytes("Hello!"),
                actual: destination.Slice(0, EncodingExtensions.GetBytes(Encoding.UTF8, sequence, destination)).ToArray());

            // Next try the multi-segment code path.
            // We've intentionally split multi-char subsequences here to test flushing mechanisms.

            sequence = SequenceFactory.Create(
                new char[] { '\u0020' },           // U+0020
                new char[] { '\u0061', '\u0080' }, // U+0061 and U+0080 (continues on next line)
                new char[] { '\ud800' },           // U+10000 (continues on next line)
                new char[] { },                    // empty segment, just to make sure we handle it correctly
                new char[] { '\udc00', '\udbff' }, // (cont.) + U+10FFFF (continues on next line)
                new char[] { '\udfff' },           // (cont.)
                new char[] { '\ud800' });          // leftover data (should be replaced)

            Assert.Equal(
                expected: Encoding.UTF8.GetBytes("\u0020\u0061\u0080\U00010000\U0010FFFF\ufffd"),
                actual: destination.Slice(0, EncodingExtensions.GetBytes(Encoding.UTF8, sequence, destination)).ToArray());
        }
Exemple #6
0
        public void ProcessLine_MultiSequence_ReadToEnd()
        {
            var segment1 = @"This is the first line
This is the second line
This is the third line, it's quite a bit bigger than the other lines.

This is the fifth line, coming after an empty line, but it spans into a ";

            var segment2 = @"line in the second sequence.
This is the second line of the second sequence that spans";

            var segment3 = @" into the third sequence.
This is the second line of the third sequence";

            var sequence = SequenceFactory.CreateUtf8(segment1, segment2, segment3);

            var results = new List <string>();

            sequence.ProcessLine(s => results.Add(s.ToUtf8String()), true);

            Assert.Equal(7, results.Count);
            Assert.Equal("This is the first line", results[0]);
            Assert.Equal("This is the second line", results[1]);
            Assert.Equal("This is the third line, it's quite a bit bigger than the other lines.", results[2]);
            Assert.Equal("", results[3]);
            Assert.Equal("This is the fifth line, coming after an empty line, but it spans into a line in the second sequence.", results[4]);
            Assert.Equal("This is the second line of the second sequence that spans into the third sequence.", results[5]);
            Assert.Equal("This is the second line of the third sequence", results[6]);
        }
Exemple #7
0
        internal FtSequence New(FtFieldDefinitionList fieldDefinitionList)
        {
            FtSequence sequence = SequenceFactory.CreateSequence(Count);

            sequence.LoadRootFieldDefinitionList(fieldDefinitionList);
            return(sequence);
        }
Exemple #8
0
        internal FtSequence New()
        {
            FtSequence sequence = SequenceFactory.CreateSequence(Count);

            list.Add(sequence);
            return(sequence);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            #region Initialize logger

            var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly());
            XmlConfigurator.Configure(logRepository, new System.IO.FileInfo("Log4Net.config"));
            log.Info("Application [FileParser] Start");

            #endregion

            SequenceType sequenceType;
            int          sequenceTypeString;
            IntRange     range;

            #region Check input data

            sequenceTypeString = Parser.TryGetInt(args, SequenceTypeInputIndex, out ErrorCode errorCode);
            if (errorCode != ErrorCode.Void)
            {
                ConsoleShowError(errorCode);
                return;
            }

            if (!Enum.IsDefined(typeof(SequenceType), sequenceTypeString))
            {
                log.Error(ErrorCode.InvalidParameter.ToString());
                ConsoleShowError(ErrorCode.InvalidParameter, "SequenceType");

                return;
            }
            else
            {
                sequenceType = (SequenceType)sequenceTypeString;
            }

            range = Parser.TryGetRange(args, out errorCode);
            if (errorCode != ErrorCode.Void)
            {
                ConsoleShowError(errorCode);
                return;
            }

            if (!Validator.IsNaturalNumber(range.Start) || !Validator.IsNaturalNumber(range.End) ||
                !Validator.IsNaturalNumber(range.Count()) ||
                !Validator.IsNumberInRange(range.End, 0, (sequenceType == SequenceType.Fibonacci) ? MaxForFibonacci : Int32.MaxValue))
            {
                ConsoleShowError(ErrorCode.OverflowRange);
                return;
            }

            #endregion

            SequenceCalculator sequenceCalculator = new SequenceCalculator(SequenceFactory.Build(sequenceType));

            sequenceCalculator.PrintGeneratedString(range, ',');
            Console.ReadKey();

            log.Info("Application [FileParser] End");
        }
        public IActionResult Get()
        {
            var names = SequenceFactory.List();

            names = names.Concat(_memoryCache.Keys());

            return(new JsonResult(names));
        }
Exemple #11
0
 public static void Saw(IStackList<object> stack)
 {
     if (stack.HasA<int>())
     {
         var x = 0;
         var width = stack.Pop<int>();
         var seq = SequenceFactory.From(() => Math.Pow(x++ % width, 2));
         stack.Push(seq);
     }
 }
        public void Build_Fibonnaci_Positive(SequenceType sequenceType)
        {
            //arrange

            //act
            ISequence sequence = SequenceFactory.Build(sequenceType);

            //assert
            Assert.NotNull(sequence);
        }
        public void Build_UndefinedType_Negative()
        {
            //arrange

            //act
            ISequence sequence = null;

            //assert
            Assert.Throws <ArgumentException>(() => sequence = SequenceFactory.Build(0));
        }
Exemple #14
0
        public DocumentSchema(StoreOptions options, IConnectionFactory factory, IDocumentSchemaCreation creation)
        {
            _factory  = factory;
            _creation = creation;

            StoreOptions = options;

            Sequences = new SequenceFactory(this, _factory, _creation);

            Events = new EventGraph();
        }
Exemple #15
0
        public DocumentSchema(StoreOptions options, ICommandRunner runner, IDocumentSchemaCreation creation)
        {
            _creation = creation;
            _runner   = runner;

            StoreOptions = options;

            Sequences = new SequenceFactory(this, _runner, _creation);

            Events = new EventGraph();
        }
Exemple #16
0
        private void resetSequences()
        {
            _sequences = new Lazy <SequenceFactory>(() =>
            {
                var sequences = new SequenceFactory(_options, this);

                generateOrUpdateFeature(typeof(SequenceFactory), sequences);

                return(sequences);
            });
        }
        public DocumentSchema(StoreOptions options, IConnectionFactory factory, IDocumentSchemaCreation creation)
        {
            _factory  = factory;
            _creation = creation;

            StoreOptions = options;

            options.AllDocumentMappings.Each(x => _mappings[x.DocumentType] = x);

            Sequences = new SequenceFactory(this, _factory, _creation);
        }
Exemple #18
0
        // for Test
        SequenceFile GenerateTestSequenceFile()
        {
            SequenceFile seqFile = new SequenceFile();

            seqFile.Name                  = "TestSequenceFile";
            seqFile.Description           = "This is a test sequenceFile.";
            seqFile.Comment               = "Nothing";
            seqFile.Version.MarjorVersion = "1";

            ISequence mainSequence = SequenceFactory.CreateSequence(SequenceTypes.Normal);

            mainSequence.Name          = "MainSequence1";
            mainSequence.Description   = "Main sequence for test.";
            mainSequence.EnableLogging = false;
            mainSequence.TestTimeout   = 3000;
            mainSequence.BreakPoint    = true;

            IStep actionStep = StepFactory.CreateStep(StepTypes.Action);

            actionStep.Name        = "Action step test";
            actionStep.Description = "this is a test action step";
            IAdaptor adaptor = AdaptorFactory.CreateAdaptor(AdaptorTypes.DotnetAdaptor);

            adaptor.MethodName     = "Test";
            adaptor.TestModuleName = "DotNetTest.dll";
            adaptor.Parameters.Add(new DotNetParameter());
            adaptor.Parameters.Add(new DotNetParameter("parameter1"));
            adaptor.Parameters.Add(new DotNetParameter("parameter2"));
            actionStep.Adaptor = adaptor;

            IStep subActionStep = StepFactory.CreateStep(StepTypes.Action);

            subActionStep.Name        = "SubAction step test";
            subActionStep.Description = "this is a sub test action step";

            actionStep.Children.Add(subActionStep);

            mainSequence.Children.Add(actionStep);
            mainSequence.Children.Add(subActionStep);
            mainSequence.Children.Add(subActionStep);

            ISequence mainSequence2 = SequenceFactory.CreateSequence(SequenceTypes.Normal);

            mainSequence2.Name          = "MainSequence2";
            mainSequence2.Description   = "Main sequence 2 for test.";
            mainSequence2.EnableLogging = false;
            mainSequence2.TestTimeout   = 3000;
            mainSequence2.BreakPoint    = true;

            seqFile.Sequences.Add(mainSequence);
            seqFile.Sequences.Add(mainSequence2);
            return(seqFile);
        }
Exemple #19
0
        public void OpenMenu()
        {
            _layoutRenderer.FrameIndex = 0;
            _layoutRenderer.SelectedSequenceGroupIndex = 0;

            _backgroundSeq.Begin();
            _subMenu = new MainMenu(this);
            _subMenu.Open();

            _subMenuDescriptionInfo.Clear();
            _subMenuDescriptionSeq = SequenceFactory.Create(new List <AnimatedSequenceDesc>());
            _subMenuDescriptionSeq.Begin();

            IsMenuOpen = true;
        }
Exemple #20
0
        private void resetSequences()
        {
            _sequences = new Lazy <SequenceFactory>(() =>
            {
                var sequences = new SequenceFactory(_options, this);

#if NETSTANDARD2_0
                generateOrUpdateFeature(typeof(SequenceFactory), sequences, default).GetAwaiter().GetResult();
#else
                generateOrUpdateFeature(typeof(SequenceFactory), sequences, default).AsTask().GetAwaiter().GetResult();
#endif

                return(sequences);
            });
        }
 private IEnumerable <double> MakeSequence(string key)
 {
     if (SequenceFactory.List().Contains(key))
     {
         return(SequenceFactory.Load(key));
     }
     else
     {
         var doc = _repository.Read(key);
         if (doc != null)
         {
             _stackMachine.Eval((string[])doc.Value);
         }
     }
     throw new ArgumentException("key");
 }
Exemple #22
0
        public DocumentSchema(StoreOptions options, IConnectionFactory factory, IMartenLogger logger)
        {
            _factory = factory;
            _logger  = logger;

            StoreOptions = options;

            options.AllDocumentMappings.Each(x => _mappings[x.DocumentType] = x);

            Sequences = new SequenceFactory(this, _factory, options, _logger);

            Parser = new MartenExpressionParser(StoreOptions.Serializer(), StoreOptions);

            HandlerFactory = new QueryHandlerFactory(this, options.Serializer());

            DbObjects = new DbObjects(_factory, this);
        }
        public No33_CreateSequenceComponentDependingOnRequest()
        {
            //目的:
            //①イテレータメソッドの引数にシーケンスを渡さず、必要な要素のみをもつシーケンスを生成する

            //概要:
            //--------------------------------------------------------------------------------------
            //利用する側がシーケンスを生成してフィルタするより、要求を投げてそれに応じたシーケンスを生成するメソッドを作成する

            //利用時
            var suquence1 = SequenceFactory.StepBySequence(100, 0, 5);

            //コレクション変更時にイベント実行
            //BindingListのコンストラクタは引数のコレクションの参照コピーを行うので、ToList()でList<int>オブジェクトを生成する
            var sequence2 = new BindingList <int>(SequenceFactory.StepBySequence(100, 0, 5).ToList());

            //遅延実行により、途中で止めることも可能(要素の値が1000未満の場合のみ実行)
            var suquence3 = SequenceFactory.StepBySequence(10000, 0, 5).TakeWhile(num => num < 1000);
        }
Exemple #24
0
    public void StartGame(MiniGameDelegate miniGameDelegate, IDictionary <Move, IEnemy[]> actions, string battleText)
    {
        Debug.Log("starting mini game");
        //TODO pass in info
        _delegate = miniGameDelegate;
        gameObject.SetActive(true);
        foreach (ActionInput actionInput in _actionInputs)
        {
            actionInput.Hide();
        }
        //CalcInputActions(partsUsed);//should be an empty set
        Sequence[] sequenceArray = SequenceFactory.CreateSequenceArray(actions, numberOfBeats);
        for (int i = 0; i < sequenceArray.Length; i++)
        {
            _actionInputs[i].CreateGems(0.0f, sequenceArray[i]);
        }

        ShowText(battleText);
    }
Exemple #25
0
        public static void GetString_Encoding_ReadOnlySequence()
        {
            // First try the single-segment code path.

            ReadOnlySequence <byte> sequence = new ReadOnlySequence <byte>(Encoding.UTF8.GetBytes("Hello!"));

            Assert.Equal("Hello!", EncodingExtensions.GetString(Encoding.UTF8, sequence));

            // Next try the multi-segment code path.
            // We've intentionally split multi-byte subsequences here to test flushing mechanisms.

            sequence = SequenceFactory.Create(
                new byte[] { 0x20 },                   // U+0020
                new byte[] { 0x61, 0xC2 },             // U+0061 and U+0080 (continues on next line)
                new byte[] { 0x80, 0xED },             // (cont.) + U+D7FF (continues on next line)
                new byte[] { },                        // empty segment, just to make sure we handle it correctly
                new byte[] { 0x9F, 0xBF, 0xF4, 0x80 }, // (cont.) + U+100000 (continues on next line)
                new byte[] { 0x80, 0x80 },             // (cont.)
                new byte[] { 0xC2 });                  // leftover data (should be replaced)

            Assert.Equal("\u0020\u0061\u0080\ud7ff\U00100000\ufffd", EncodingExtensions.GetString(Encoding.UTF8, sequence));
        }
Exemple #26
0
        public static void Convert_Decoder_ReadOnlySequence_IBufferWriter()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            ArrayBufferWriter <char> writer = new ArrayBufferWriter <char>();

            // First, input with no flushing and no leftover data.

            ReadOnlySequence <byte> inputData = SequenceFactory.Create(
                new byte[] { 0x20 },                    // U+0020
                new byte[] { 0x61, 0xC2 },              // U+0061 and U+0080 (continues on next line)
                new byte[] { 0x80, 0xED, 0x9F, 0xBF }); // (cont.) + U+D7FF

            EncodingExtensions.Convert(decoder, inputData, writer, flush: false, out long charsUsed, out bool completed);
            Assert.Equal(4, charsUsed);
            Assert.True(completed);

            // Then, input with no flushing and leftover data.

            inputData = SequenceFactory.Create(
                new byte[] { 0xF4, 0x80 }); // U+100000 (continues on next line)
            EncodingExtensions.Convert(decoder, inputData, writer, flush: false, out charsUsed, out completed);
            Assert.Equal(0, charsUsed);
            Assert.False(completed);

            // Then, input with flushing and leftover data (should be replaced).

            inputData = SequenceFactory.Create(
                new byte[] { 0x80, 0x80 }, // (cont.)
                new byte[] { 0xC2 });      // leftover data (should be replaced)
            EncodingExtensions.Convert(decoder, inputData, writer, flush: true, out charsUsed, out completed);
            Assert.Equal(3, charsUsed);
            Assert.True(completed);

            // Now make sure all of the data was decoded properly.

            Assert.Equal("\u0020\u0061\u0080\ud7ff\U00100000\ufffd", writer.WrittenSpan.ToString());
        }
Exemple #27
0
        public static void Convert_Encoder_ReadOnlySequence_IBufferWriter()
        {
            Encoder encoder = Encoding.UTF8.GetEncoder();
            ArrayBufferWriter <byte> writer = new ArrayBufferWriter <byte>();

            // First, input with no flushing and no leftover data.

            ReadOnlySequence <char> inputData = SequenceFactory.Create(
                new char[] { '\u0020' },  // U+0020
                new char[] { '\ud7ff' }); // U+D7FF

            EncodingExtensions.Convert(encoder, inputData, writer, flush: false, out long bytesUsed, out bool completed);
            Assert.Equal(4, bytesUsed);
            Assert.True(completed);

            // Then, input with no flushing and leftover data.

            inputData = SequenceFactory.Create(
                new char[] { '\udbc0' }); // U+100000 (continues on next line)
            EncodingExtensions.Convert(encoder, inputData, writer, flush: false, out bytesUsed, out completed);
            Assert.Equal(0, bytesUsed);
            Assert.False(completed);

            // Then, input with flushing and leftover data (should be replaced).

            inputData = SequenceFactory.Create(
                new char[] { '\udc00' },  // (cont.)
                new char[] { '\ud800' }); // leftover data (should be replaced)
            EncodingExtensions.Convert(encoder, inputData, writer, flush: true, out bytesUsed, out completed);
            Assert.Equal(7, bytesUsed);
            Assert.True(completed);

            // Now make sure all of the data was decoded properly.

            Assert.Equal(Encoding.UTF8.GetBytes("\u0020\ud7ff\U00100000\ufffd"), writer.WrittenSpan.ToArray());
        }
Exemple #28
0
 public static void Base(IStackList<object> stack)
 {
     var x = 0;
     var seq = SequenceFactory.From(() => x++);
     stack.Push(seq);
 }
Exemple #29
0
        public IActionResult GetNames()
        {
            var items = SequenceFactory.List();

            return(new JsonResult(items));
        }
Exemple #30
0
 public static void Para(IStackList<object> stack)
 {
     var x = 0;
     var seq = SequenceFactory.From(() => Math.Pow(x++, 2));
     stack.Push(seq);
 }