示例#1
0
        private Horizontal WireRow(StringConcat stringConcat, DataFlowConnector <string> stringConcatConnector, Formula formula, Formula[] formulas)
        {
            // To understand this code, you need the wiring diagram of the two row calculator

            // first instantiate objects we need to give names to for wiring.  The rest can be anonymous.
            Text result = new Text();

            // Wire up a calculator row
            Horizontal row = new Horizontal()
                             .WireTo(new TextBox()
                                     .WireTo(new DataFlowConnector <string>()
                                             .WireFrom(stringConcat, "inputs")
                                             )
                                     )
                             .WireTo(new TextBox()
                                     .WireTo(new StringFormat <string, string>("({1})=>{0}")
                                             .WireTo(stringConcatConnector, "inputs")
                                             .WireTo(formula
                                                     .WireTo(new DataFlowConnector <double>()
                                                             .WireFrom(formulas[0], "operands")
                                                             .WireFrom(formulas[1], "operands")
                                                             .WireTo(new NumberToString <double?>()
                                                                     .WireTo(result)
                                                                     )
                                                             )
                                                     )
                                             )
                                     )
                             .WireTo(result)
                             .WireTo(new TextBox());

            return(row);
        }
示例#2
0
        public static void Main()
        {
            UnsortedArrayTask an_array = new UnsortedArrayTask();

            foreach (int a in an_array.Arr)
            {
                Console.WriteLine(a + " ");
            }

            UnsortedArrayTask array2 = new UnsortedArrayTask(7);

            Console.Write("The max element of the array is: ");
            Console.WriteLine(Search_methods.Search_max(an_array.Arr, an_array.Arr.Length - 1));
            foreach (int a in array2.Arr)
            {
                Console.WriteLine(a + " ");
            }

            string abc = "ABCDDFAAAAFSDFDFDF";
            string cba = "AADDGGHFDGFDFDFd";
            string bca = StringConcat.DistinctConcatLinq(abc, cba);

            Console.WriteLine(bca);
            Console.WriteLine("The point of equilibrium is " + Search_methods.Equilibrium(array2.Arr));
            Console.ReadKey();
        }
示例#3
0
        public void ConcatinizationExtensions_SingleString_NoSeparator_Test()
        {
            var s1     = "test";
            var actual = StringConcat.WithSeparator('/', new string[] { s1 });

            Assert.AreEqual(s1, actual);
        }
示例#4
0
        public void ConcatinizationExtensions_ThreeString_MiddleNull_Test()
        {
            var    s1        = "test1";
            string s2        = null;
            var    s3        = "test3";
            var    separator = '/';

            StringConcat.WithSeparator(separator, new[] { s1, s2, s3 });
        }
示例#5
0
        public void ConcatinizationExtensions_ThreeString_FirstNull_Test()
        {
            string s1        = null;
            string s2        = "test2";
            var    s3        = "test3";
            var    separator = '/';

            StringConcat.WithSeparator(separator, new[] { s1, s2, s3 });
        }
示例#6
0
        public void ConcatinizationExtensions_TwoStrings_Separated_Test()
        {
            var s1        = "test1";
            var s2        = "test2";
            var separator = '/';
            var expected  = "test1/test2";
            var actual    = StringConcat.WithSeparator(separator, new[] { s1, s2 });

            Assert.AreEqual(expected, actual);
        }
示例#7
0
        public void ConcatinizationExtensions_FrontSlashOnFirstStringNotTrimmed_Test()
        {
            var s1        = "/test1";
            var s2        = "test2";
            var s3        = "test3";
            var separator = '/';
            var expected  = "/test1/test2/test3";
            var actual    = StringConcat.WithSeparator(separator, new[] { s1, s2, s3 });

            Assert.AreEqual(expected, actual);
        }
示例#8
0
        public void ConcatinizationExtensions_AlreadyHaveSeparatorBothSides_Test()
        {
            var s1        = "/test1/";
            var s2        = "/test2/";
            var s3        = "/test3/";
            var separator = '/';
            var expected  = "/test1/test2/test3";
            var actual    = StringConcat.WithSeparator(separator, new[] { s1, s2, s3 });

            Assert.AreEqual(expected, actual);
        }
示例#9
0
        public void ConcatinizationExtensions_WhiteSpaceMultipleSlashes_Test()
        {
            var s1        = "/test1 /   /";
            var s2        = " /test2/   /";
            var s3        = "/ test3/ \t/";
            var separator = '/';
            var expected  = "/test1/test2/test3";
            var actual    = StringConcat.WithSeparator(separator, new[] { s1, s2, s3 });

            Assert.AreEqual(expected, actual);
        }
示例#10
0
        public void ConcatinizationExtensions_WithSeparator_Data_Test()
        {
            // Arrange
            string left      = TestContext.DataRow[0].ToString();
            string right     = TestContext.DataRow[1].ToString();
            char   separator = TestContext.DataRow[2].ToString().First();
            string expected  = TestContext.DataRow[3].ToString();
            string actual;

            // Act
            actual = StringConcat.WithSeparator(separator, left, right);

            // Assert
            Assert.AreEqual(expected, actual);
        }
示例#11
0
        private MainWindow Calculator2RowHandWired()
        {
            // To understand this code, you need the wiring diagram of the two row calculator

            // first instantiate instances or abstraction we need to give names to for wiring. The rest can be anonymous.
            StringConcat stringConcat = new StringConcat()
            {
                Separator = ","
            };
            DataFlowConnector <string> stringConcatConnector = new DataFlowConnector <string>(); // Connectors are needed when there is fan-out or fan-in in the diagram

            stringConcat.WireTo(stringConcatConnector, "output");
            Formula[] formulas = { new Formula(), new Formula() }; // instantiate both the formulas up-front because we need to cross wire them


            MainWindow mainWindow = new MainWindow("Calculator")
                                    .WireTo(new Vertical()
                                            .WireTo(WireRow(stringConcat, stringConcatConnector, formulas[0], formulas))
                                            .WireTo(WireRow(stringConcat, stringConcatConnector, formulas[1], formulas))
                                            );

            return(mainWindow);
        }
示例#12
0
        public static InstructionCollection Parse(Stream input, long instructionsPosition)
        {
            var instructions = new SortedList <int, InstructionBase>();

            using (var helper = new InstructionParseHelper(input, instructionsPosition))
            {
                var reader = helper.GetReader();
                while (helper.CanParse(instructions))
                {
                    //now reader the instructions
                    var instructionPosition = helper.CurrentPosition;
                    var type             = reader.ReadByteAsEnum <InstructionType>();
                    var requireAlignment = InstructionAlignment.IsAligned(type);

                    if (requireAlignment)
                    {
                        reader.Align(4);
                    }

                    InstructionBase instruction = null;
                    var             parameters  = new List <Value>();

                    switch (type)
                    {
                    case InstructionType.ToNumber:
                        instruction = new ToNumber();
                        break;

                    case InstructionType.NextFrame:
                        instruction = new NextFrame();
                        break;

                    case InstructionType.Play:
                        instruction = new Play();
                        break;

                    case InstructionType.Stop:
                        instruction = new Stop();
                        break;

                    case InstructionType.Add:
                        instruction = new Add();
                        break;

                    case InstructionType.Subtract:
                        instruction = new Subtract();
                        break;

                    case InstructionType.Multiply:
                        instruction = new Multiply();
                        break;

                    case InstructionType.Divide:
                        instruction = new Divide();
                        break;

                    case InstructionType.Not:
                        instruction = new Not();
                        break;

                    case InstructionType.StringEquals:
                        instruction = new StringEquals();
                        break;

                    case InstructionType.Pop:
                        instruction = new Pop();
                        break;

                    case InstructionType.ToInteger:
                        instruction = new ToInteger();
                        break;

                    case InstructionType.GetVariable:
                        instruction = new GetVariable();
                        break;

                    case InstructionType.SetVariable:
                        instruction = new SetVariable();
                        break;

                    case InstructionType.StringConcat:
                        instruction = new StringConcat();
                        break;

                    case InstructionType.GetProperty:
                        instruction = new GetProperty();
                        break;

                    case InstructionType.SetProperty:
                        instruction = new SetProperty();
                        break;

                    case InstructionType.Trace:
                        instruction = new Trace();
                        break;

                    case InstructionType.Random:
                        instruction = new RandomNumber();
                        break;

                    case InstructionType.Delete:
                        instruction = new Delete();
                        break;

                    case InstructionType.Delete2:
                        instruction = new Delete2();
                        break;

                    case InstructionType.DefineLocal:
                        instruction = new DefineLocal();
                        break;

                    case InstructionType.CallFunction:
                        instruction = new CallFunction();
                        break;

                    case InstructionType.Return:
                        instruction = new Return();
                        break;

                    case InstructionType.Modulo:
                        instruction = new Modulo();
                        break;

                    case InstructionType.NewObject:
                        instruction = new NewObject();
                        break;

                    case InstructionType.InitArray:
                        instruction = new InitArray();
                        break;

                    case InstructionType.InitObject:
                        instruction = new InitObject();
                        break;

                    case InstructionType.TypeOf:
                        instruction = new TypeOf();
                        break;

                    case InstructionType.Add2:
                        instruction = new Add2();
                        break;

                    case InstructionType.LessThan2:
                        instruction = new LessThan2();
                        break;

                    case InstructionType.Equals2:
                        instruction = new Equals2();
                        break;

                    case InstructionType.ToString:
                        instruction = new ToString();
                        break;

                    case InstructionType.PushDuplicate:
                        instruction = new PushDuplicate();
                        break;

                    case InstructionType.GetMember:
                        instruction = new GetMember();
                        break;

                    case InstructionType.SetMember:
                        instruction = new SetMember();
                        break;

                    case InstructionType.Increment:
                        instruction = new Increment();
                        break;

                    case InstructionType.Decrement:
                        instruction = new Decrement();
                        break;

                    case InstructionType.CallMethod:
                        instruction = new CallMethod();
                        break;

                    case InstructionType.Enumerate2:
                        instruction = new Enumerate2();
                        break;

                    case InstructionType.EA_PushThis:
                        instruction = new PushThis();
                        break;

                    case InstructionType.EA_PushZero:
                        instruction = new PushZero();
                        break;

                    case InstructionType.EA_PushOne:
                        instruction = new PushOne();
                        break;

                    case InstructionType.EA_CallFunc:
                        instruction = new CallFunc();
                        break;

                    case InstructionType.EA_CallMethodPop:
                        instruction = new CallMethodPop();
                        break;

                    case InstructionType.BitwiseXOr:
                        instruction = new BitwiseXOr();
                        break;

                    case InstructionType.Greater:
                        instruction = new Greater();
                        break;

                    case InstructionType.EA_PushThisVar:
                        instruction = new PushThisVar();
                        break;

                    case InstructionType.EA_PushGlobalVar:
                        instruction = new PushGlobalVar();
                        break;

                    case InstructionType.EA_ZeroVar:
                        instruction = new ZeroVar();
                        break;

                    case InstructionType.EA_PushTrue:
                        instruction = new PushTrue();
                        break;

                    case InstructionType.EA_PushFalse:
                        instruction = new PushFalse();
                        break;

                    case InstructionType.EA_PushNull:
                        instruction = new PushNull();
                        break;

                    case InstructionType.EA_PushUndefined:
                        instruction = new PushUndefined();
                        break;

                    case InstructionType.GotoFrame:
                        instruction = new GotoFrame();
                        parameters.Add(Value.FromInteger(reader.ReadInt32()));
                        break;

                    case InstructionType.GetURL:
                        instruction = new GetUrl();
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.SetRegister:
                        instruction = new SetRegister();
                        parameters.Add(Value.FromInteger(reader.ReadInt32()));
                        break;

                    case InstructionType.ConstantPool:
                    {
                        instruction = new ConstantPool();
                        var count     = reader.ReadUInt32();
                        var constants = reader.ReadFixedSizeArrayAtOffset <uint>(() => reader.ReadUInt32(), count);

                        foreach (var constant in constants)
                        {
                            parameters.Add(Value.FromConstant(constant));
                        }
                    }
                    break;

                    case InstructionType.GotoLabel:
                        instruction = new GotoLabel();
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.DefineFunction2:
                    {
                        instruction = new DefineFunction2();
                        var name       = reader.ReadStringAtOffset();
                        var nParams    = reader.ReadUInt32();
                        var nRegisters = reader.ReadByte();
                        var flags      = reader.ReadUInt24();

                        //list of parameter strings
                        var paramList = reader.ReadFixedSizeListAtOffset <FunctionArgument>(() => new FunctionArgument()
                            {
                                Register  = reader.ReadInt32(),
                                Parameter = reader.ReadStringAtOffset(),
                            }, nParams);

                        parameters.Add(Value.FromString(name));
                        parameters.Add(Value.FromInteger((int)nParams));
                        parameters.Add(Value.FromInteger((int)nRegisters));
                        parameters.Add(Value.FromInteger((int)flags));
                        foreach (var param in paramList)
                        {
                            parameters.Add(Value.FromInteger(param.Register));
                            parameters.Add(Value.FromString(param.Parameter));
                        }
                        //body size of the function
                        parameters.Add(Value.FromInteger(reader.ReadInt32()));
                        //skip 8 bytes
                        reader.ReadUInt64();
                    }
                    break;

                    case InstructionType.PushData:
                    {
                        instruction = new PushData();

                        var count     = reader.ReadUInt32();
                        var constants = reader.ReadFixedSizeArrayAtOffset <uint>(() => reader.ReadUInt32(), count);

                        foreach (var constant in constants)
                        {
                            parameters.Add(Value.FromConstant(constant));
                        }
                    }
                    break;

                    case InstructionType.BranchAlways:
                    {
                        instruction = new BranchAlways();
                        var offset = reader.ReadInt32();
                        parameters.Add(Value.FromInteger(offset));
                        helper.ReportBranchOffset(offset);
                    }
                    break;

                    case InstructionType.GetURL2:
                        instruction = new GetUrl2();
                        break;

                    case InstructionType.DefineFunction:
                    {
                        instruction = new DefineFunction();
                        var name = reader.ReadStringAtOffset();
                        //list of parameter strings
                        var paramList = reader.ReadListAtOffset <string>(() => reader.ReadStringAtOffset());

                        parameters.Add(Value.FromString(name));
                        parameters.Add(Value.FromInteger(paramList.Count));
                        foreach (var param in paramList)
                        {
                            parameters.Add(Value.FromString(param));
                        }
                        //body size of the function
                        parameters.Add(Value.FromInteger(reader.ReadInt32()));
                        //skip 8 bytes
                        reader.ReadUInt64();
                    }
                    break;

                    case InstructionType.BranchIfTrue:
                    {
                        instruction = new BranchIfTrue();
                        var offset = reader.ReadInt32();
                        parameters.Add(Value.FromInteger(offset));
                        helper.ReportBranchOffset(offset);
                    }
                    break;

                    case InstructionType.GotoFrame2:
                        instruction = new GotoFrame2();
                        parameters.Add(Value.FromInteger(reader.ReadInt32()));
                        break;

                    case InstructionType.EA_PushString:
                        instruction = new PushString();
                        //the constant id that should be pushed
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.EA_PushConstantByte:
                        instruction = new PushConstantByte();
                        //the constant id that should be pushed
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.EA_GetStringVar:
                        instruction = new GetStringVar();
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.EA_SetStringVar:
                        instruction = new SetStringVar();
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.EA_GetStringMember:
                        instruction = new GetStringMember();
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.EA_SetStringMember:
                        instruction = new SetStringMember();
                        parameters.Add(Value.FromString(reader.ReadStringAtOffset()));
                        break;

                    case InstructionType.EA_PushValueOfVar:
                        instruction = new PushValueOfVar();
                        //the constant id that should be pushed
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.EA_GetNamedMember:
                        instruction = new GetNamedMember();
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.EA_CallNamedFuncPop:
                        instruction = new CallNamedFuncPop();
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.EA_CallNamedFunc:
                        instruction = new CallNamedFunc();
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.EA_CallNamedMethodPop:
                        instruction = new CallNamedMethodPop();
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.EA_PushFloat:
                        instruction = new PushFloat();
                        parameters.Add(Value.FromFloat(reader.ReadSingle()));
                        break;

                    case InstructionType.EA_PushByte:
                        instruction = new PushByte();
                        parameters.Add(Value.FromInteger(reader.ReadByte()));
                        break;

                    case InstructionType.EA_PushShort:
                        instruction = new PushShort();
                        parameters.Add(Value.FromInteger(reader.ReadUInt16()));
                        break;

                    case InstructionType.End:
                        instruction = new End();
                        break;

                    case InstructionType.EA_CallNamedMethod:
                        instruction = new CallNamedMethod();
                        parameters.Add(Value.FromConstant(reader.ReadByte()));
                        break;

                    case InstructionType.Var:
                        instruction = new Var();
                        break;

                    case InstructionType.EA_PushRegister:
                        instruction = new PushRegister();
                        parameters.Add(Value.FromInteger(reader.ReadByte()));
                        break;

                    case InstructionType.EA_PushConstantWord:
                        instruction = new PushConstantWord();
                        parameters.Add(Value.FromConstant(reader.ReadUInt16()));
                        break;

                    case InstructionType.EA_CallFuncPop:
                        instruction = new CallFunctionPop();
                        break;

                    case InstructionType.StrictEqual:
                        instruction = new StrictEquals();
                        break;

                    default:
                        throw new InvalidDataException("Unimplemented bytecode instruction:" + type.ToString());
                    }

                    if (instruction != null)
                    {
                        instruction.Parameters = parameters;
                        instructions.Add(instructionPosition, instruction);
                    }
                }
            }

            return(new InstructionCollection(instructions));
        }
示例#13
0
        public void Parse()
        {
            var current = _reader.BaseStream.Position;

            _reader.BaseStream.Seek(_offset, SeekOrigin.Begin);
            bool parsing     = true;
            bool branched    = false;
            int  branchBytes = 0;

            while (parsing)
            {
                //now reader the instructions
                var type    = _reader.ReadByteAsEnum <InstructionType>();
                var aligned = InstructionAlignment.IsAligned(type);

                if (aligned)
                {
                    var padding = _reader.Align(4);
                    if (padding > 0)
                    {
                        Items.Add(new Padding(padding));
                        if (branched)
                        {
                            branchBytes -= (int)padding;

                            if (branchBytes <= 0)
                            {
                                branched    = false;
                                branchBytes = 0;
                            }
                        }
                    }
                }

                InstructionBase instruction = null;
                List <Value>    parameters  = new List <Value>();

                switch (type)
                {
                case InstructionType.ToNumber:
                    instruction = new ToNumber();
                    break;

                case InstructionType.NextFrame:
                    instruction = new NextFrame();
                    break;

                case InstructionType.Play:
                    instruction = new Play();
                    break;

                case InstructionType.Stop:
                    instruction = new Stop();
                    break;

                case InstructionType.Add:
                    instruction = new Add();
                    break;

                case InstructionType.Subtract:
                    instruction = new Subtract();
                    break;

                case InstructionType.Multiply:
                    instruction = new Multiply();
                    break;

                case InstructionType.Divide:
                    instruction = new Divide();
                    break;

                case InstructionType.Not:
                    instruction = new Not();
                    break;

                case InstructionType.StringEquals:
                    instruction = new StringEquals();
                    break;

                case InstructionType.Pop:
                    instruction = new Pop();
                    break;

                case InstructionType.ToInteger:
                    instruction = new ToInteger();
                    break;

                case InstructionType.GetVariable:
                    instruction = new GetVariable();
                    break;

                case InstructionType.SetVariable:
                    instruction = new SetVariable();
                    break;

                case InstructionType.StringConcat:
                    instruction = new StringConcat();
                    break;

                case InstructionType.GetProperty:
                    instruction = new GetProperty();
                    break;

                case InstructionType.SetProperty:
                    instruction = new SetProperty();
                    break;

                case InstructionType.Trace:
                    instruction = new Trace();
                    break;

                case InstructionType.Delete:
                    instruction = new Delete();
                    break;

                case InstructionType.Delete2:
                    instruction = new Delete2();
                    break;

                case InstructionType.DefineLocal:
                    instruction = new DefineLocal();
                    break;

                case InstructionType.CallFunction:
                    instruction = new CallFunction();
                    break;

                case InstructionType.Return:
                    instruction = new Return();
                    break;

                case InstructionType.NewObject:
                    instruction = new NewObject();
                    break;

                case InstructionType.InitArray:
                    instruction = new InitArray();
                    break;

                case InstructionType.InitObject:
                    instruction = new InitObject();
                    break;

                case InstructionType.TypeOf:
                    instruction = new InitObject();
                    break;

                case InstructionType.Add2:
                    instruction = new Add2();
                    break;

                case InstructionType.LessThan2:
                    instruction = new LessThan2();
                    break;

                case InstructionType.Equals2:
                    instruction = new Equals2();
                    break;

                case InstructionType.ToString:
                    instruction = new ToString();
                    break;

                case InstructionType.PushDuplicate:
                    instruction = new PushDuplicate();
                    break;

                case InstructionType.GetMember:
                    instruction = new GetMember();
                    break;

                case InstructionType.SetMember:
                    instruction = new SetMember();
                    break;

                case InstructionType.Increment:
                    instruction = new Increment();
                    break;

                case InstructionType.Decrement:
                    instruction = new Decrement();
                    break;

                case InstructionType.CallMethod:
                    instruction = new CallMethod();
                    break;

                case InstructionType.Enumerate2:
                    instruction = new Enumerate2();
                    break;

                case InstructionType.EA_PushThis:
                    instruction = new PushThis();
                    break;

                case InstructionType.EA_PushZero:
                    instruction = new PushZero();
                    break;

                case InstructionType.EA_PushOne:
                    instruction = new PushOne();
                    break;

                case InstructionType.EA_CallFunc:
                    instruction = new CallFunc();
                    break;

                case InstructionType.EA_CallMethodPop:
                    instruction = new CallMethodPop();
                    break;

                case InstructionType.BitwiseXOr:
                    instruction = new BitwiseXOr();
                    break;

                case InstructionType.Greater:
                    instruction = new Greater();
                    break;

                case InstructionType.EA_PushThisVar:
                    instruction = new PushThisVar();
                    break;

                case InstructionType.EA_PushGlobalVar:
                    instruction = new PushGlobalVar();
                    break;

                case InstructionType.EA_ZeroVar:
                    instruction = new ZeroVar();
                    break;

                case InstructionType.EA_PushTrue:
                    instruction = new PushTrue();
                    break;

                case InstructionType.EA_PushFalse:
                    instruction = new PushFalse();
                    break;

                case InstructionType.EA_PushNull:
                    instruction = new PushNull();
                    break;

                case InstructionType.EA_PushUndefined:
                    instruction = new PushUndefined();
                    break;

                case InstructionType.GotoFrame:
                    instruction = new GotoFrame();
                    parameters.Add(Value.FromInteger(_reader.ReadInt32()));
                    break;

                case InstructionType.GetURL:
                    instruction = new GetUrl();
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.SetRegister:
                    instruction = new SetRegister();
                    parameters.Add(Value.FromInteger(_reader.ReadInt32()));
                    break;

                case InstructionType.ConstantPool:
                {
                    instruction = new ConstantPool();
                    var count     = _reader.ReadUInt32();
                    var constants = _reader.ReadFixedSizeArrayAtOffset <uint>(() => _reader.ReadUInt32(), count);

                    foreach (var constant in constants)
                    {
                        parameters.Add(Value.FromConstant(constant));
                    }
                }
                break;

                case InstructionType.GotoLabel:
                    instruction = new GotoLabel();
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.DefineFunction2:
                {
                    instruction = new DefineFunction2();
                    var name       = _reader.ReadStringAtOffset();
                    var nParams    = _reader.ReadUInt32();
                    var nRegisters = _reader.ReadByte();
                    var flags      = _reader.ReadUInt24();

                    //list of parameter strings
                    var paramList = _reader.ReadFixedSizeListAtOffset <FunctionArgument>(() => new FunctionArgument()
                        {
                            Register  = _reader.ReadInt32(),
                            Parameter = _reader.ReadStringAtOffset(),
                        }, nParams);

                    parameters.Add(Value.FromString(name));
                    parameters.Add(Value.FromInteger((int)nParams));
                    parameters.Add(Value.FromInteger((int)nRegisters));
                    parameters.Add(Value.FromInteger((int)flags));
                    foreach (var param in paramList)
                    {
                        parameters.Add(Value.FromInteger(param.Register));
                        parameters.Add(Value.FromString(param.Parameter));
                    }
                    //body size of the function
                    parameters.Add(Value.FromInteger(_reader.ReadInt32()));
                    //skip 8 bytes
                    _reader.ReadUInt64();
                }
                break;

                case InstructionType.PushData:
                {
                    instruction = new PushData();

                    var count     = _reader.ReadUInt32();
                    var constants = _reader.ReadFixedSizeArrayAtOffset <uint>(() => _reader.ReadUInt32(), count);

                    foreach (var constant in constants)
                    {
                        parameters.Add(Value.FromConstant(constant));
                    }
                }
                break;

                case InstructionType.BranchAlways:
                    instruction = new BranchAlways();
                    if (!branched)
                    {
                        branchBytes = _reader.ReadInt32();
                        parameters.Add(Value.FromInteger(branchBytes));

                        if (branchBytes > 0)
                        {
                            branchBytes += (int)instruction.Size + 1;
                            branched     = true;
                        }
                    }
                    else
                    {
                        parameters.Add(Value.FromInteger(_reader.ReadInt32()));
                    }
                    break;

                case InstructionType.GetURL2:
                    instruction = new GetUrl2();
                    break;

                case InstructionType.DefineFunction:
                {
                    instruction = new DefineFunction();
                    var name = _reader.ReadStringAtOffset();
                    //list of parameter strings
                    var paramList = _reader.ReadListAtOffset <string>(() => _reader.ReadStringAtOffset());

                    parameters.Add(Value.FromString(name));
                    parameters.Add(Value.FromInteger(paramList.Count));
                    foreach (var param in paramList)
                    {
                        parameters.Add(Value.FromString(param));
                    }
                    //body size of the function
                    parameters.Add(Value.FromInteger(_reader.ReadInt32()));
                    //skip 8 bytes
                    _reader.ReadUInt64();
                }
                break;

                case InstructionType.BranchIfTrue:
                    instruction = new BranchIfTrue();
                    if (!branched)
                    {
                        branchBytes = _reader.ReadInt32();
                        parameters.Add(Value.FromInteger(branchBytes));

                        if (branchBytes > 0)
                        {
                            branchBytes += (int)instruction.Size + 1;
                            branched     = true;
                        }
                    }
                    else
                    {
                        parameters.Add(Value.FromInteger(_reader.ReadInt32()));
                    }
                    break;

                case InstructionType.GotoFrame2:
                    instruction = new GotoFrame2();
                    parameters.Add(Value.FromInteger(_reader.ReadByte()));
                    break;

                case InstructionType.EA_PushString:
                    instruction = new PushString();
                    //the constant id that should be pushed
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.EA_PushConstantByte:
                    instruction = new PushConstantByte();
                    //the constant id that should be pushed
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.EA_GetStringVar:
                    instruction = new GetStringVar();
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.EA_SetStringVar:
                    instruction = new SetStringMember();
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.EA_GetStringMember:
                    instruction = new GetStringMember();
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.EA_SetStringMember:
                    instruction = new SetStringMember();
                    parameters.Add(Value.FromString(_reader.ReadStringAtOffset()));
                    break;

                case InstructionType.EA_PushValueOfVar:
                    instruction = new PushValueOfVar();
                    //the constant id that should be pushed
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.EA_GetNamedMember:
                    instruction = new GetNamedMember();
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.EA_CallNamedFuncPop:
                    instruction = new CallNamedFuncPop();
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.EA_CallNamedFunc:
                    instruction = new CallNamedFunc();
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.EA_CallNamedMethodPop:
                    instruction = new CallNamedMethodPop();
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.EA_PushFloat:
                    instruction = new PushFloat();
                    parameters.Add(Value.FromFloat(_reader.ReadSingle()));
                    break;

                case InstructionType.EA_PushByte:
                    instruction = new PushByte();
                    parameters.Add(Value.FromInteger(_reader.ReadByte()));
                    break;

                case InstructionType.EA_PushShort:
                    instruction = new PushShort();
                    parameters.Add(Value.FromInteger(_reader.ReadUInt16()));
                    break;

                case InstructionType.End:
                    instruction = new End();

                    if (!branched)
                    {
                        parsing = false;
                    }
                    break;

                case InstructionType.EA_CallNamedMethod:
                    instruction = new CallNamedMethod();
                    parameters.Add(Value.FromConstant(_reader.ReadByte()));
                    break;

                case InstructionType.Var:
                    instruction = new Var();

                    break;

                default:
                    throw new InvalidDataException("Unimplemented bytecode instruction:" + type.ToString());
                }

                if (instruction != null)
                {
                    instruction.Parameters = parameters;
                    Items.Add(instruction);
                }

                if (branched)
                {
                    branchBytes -= (int)instruction.Size + 1;

                    if (branchBytes <= 0)
                    {
                        branched = false;
                    }
                }
            }
            _reader.BaseStream.Seek(current, SeekOrigin.Begin);
        }
示例#14
0
            public CalculatorNRows(out MainWindow mw)
            {
                // These Ratios and MinWidths are for the columns of the calculator
                // Label, Formula, TextBook, Result, Units, Description, Format, Digits
                int[] Ratios    = new int[] { 4, 8, 8, 8, 4, 8, 1 };
                int[] MinWidths = new int[] { 50, 100, 100, 100, 50, 50, 57 };  // 57 is just big enough to show the Fmt enum selections
                int   FontSize  = 25;

                // BEGIN AUTO-GENERATED INSTANTIATIONS FOR CalculatorNRows.xmind
                Button id_803db86064414b379608f65bc07098bc = new Button("Add row")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                CalculatorRowFactory id_012306911dbe485c91ecd24bd35b2420 = new CalculatorRowFactory()
                {
                    InstanceName = "Default"
                };
                DataFlowConnector <string> labelsConcatenatorConnector = new DataFlowConnector <string>()
                {
                    InstanceName = "labelsConcatenatorConnector"
                };
                Horizontal id_24914ab245484fe1b70af8020ca2e831 = new Horizontal()
                {
                    InstanceName = "Default", Ratios = Ratios, MinWidths = MinWidths
                };
                Horizontal id_aa2f23f75c79479e88ccf7ed0ed6c2cc = new Horizontal()
                {
                    InstanceName = "Default", Ratios = new int[] { 1, 8 }, MinWidths = new int[] { 50 }
                };
                MainWindow mainWindow = new MainWindow("Reactive Calculator")
                {
                    InstanceName = "mainWindow"
                };
                Multiple MultipleRow = new Multiple(N: 4)
                {
                    InstanceName = "MultipleRow", ConstructorCallbackMethod = (instance) => { ((CalculatorRow)instance).FontSize = FontSize;  ((CalculatorRow)instance).Ratios = Ratios;   ((CalculatorRow)instance).MinWidths = MinWidths; }, WiringMethod = (newInstance) => { _rows.WireTo(newInstance); _labelsConcatenator.WireTo(newInstance, "inputs");   newInstance.WireTo(labelsConcatenatorConnector, "labelsCommaSeparated");  testCalculatorRows.Add((ITestCalculatorRow)newInstance); }, CrossWiringMethod = (instance1, instance2) => { instance2.WireFrom(instance1, "operands"); }, PostWiringInitializeMethod = delegate(object instance) { _rows.AddRows();  ((CalculatorRow)instance).Initialize(); }
                };
                Space id_68d3e779ba0d4f78ad48db2ed468608c = new Space()
                {
                    InstanceName = "Default"
                };
                StringConcat labelsConcatenator = new StringConcat()
                {
                    InstanceName = "labelsConcatenator", Separator = ","
                };
                Text id_39a7a11c94da4b338a92b2235b8e96d1 = new Text("Units")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_6be1dbef5dd042ba88554b4482b16079 = new Text("Formula")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_93a237ff714b48748a4ba10ede42d2dc = new Text("Description")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_96b879e17b4346e4b98484224e65d582 = new Text("Label")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_a72464a6a1a8426887ca40b886b5567e = new Text("Textbook")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_ccc54bcd38e14c10a5ba59d851191cc4 = new Text("Result")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_f9b8d9329de5407b93a1834afeaf5de6 = new Text("Fmt")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                Text id_fc0b8f38b3c14f799f605cd54214b503 = new Text("Reactive Calculator")
                {
                    InstanceName = "Default", FontSize = FontSize
                };
                TextBox id_b84a8eee3a554afaad9fa90ac6b594f9 = new TextBox()
                {
                    InstanceName = "Default", Text = "Title your calculation here", FontSize = 15
                };
                Vertical id_b02d2caea938499b997b9bfcb80fb0e9 = new Vertical()
                {
                    InstanceName = "Default"
                };
                Vertical rows = new Vertical()
                {
                    InstanceName = "rows"
                };

                // END AUTO-GENERATED INSTANTIATIONS FOR CalculatorNRows.xmind

                // BEGIN AUTO-GENERATED WIRING FOR CalculatorNRows.xmind
                mainWindow.WireTo(id_b02d2caea938499b997b9bfcb80fb0e9, "iuiStructure");                      // (MainWindow (mainWindow).iuiStructure) -- [IUI] --> (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).child)
                labelsConcatenator.WireTo(labelsConcatenatorConnector, "output");                            // (StringConcat (labelsConcatenator).output) -- [iDataFlow<string>] --> (DataFlowConnector<string> (labelsConcatenatorConnector).input)
                id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_fc0b8f38b3c14f799f605cd54214b503, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Text (id_fc0b8f38b3c14f799f605cd54214b503).child)
                id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_b84a8eee3a554afaad9fa90ac6b594f9, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (TextBox (id_b84a8eee3a554afaad9fa90ac6b594f9).child)
                id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_24914ab245484fe1b70af8020ca2e831, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Horizontal (id_24914ab245484fe1b70af8020ca2e831).child)
                id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(rows, "children");                                // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Vertical (rows).Child)
                id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_aa2f23f75c79479e88ccf7ed0ed6c2cc, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Horizontal (id_aa2f23f75c79479e88ccf7ed0ed6c2cc).Child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_96b879e17b4346e4b98484224e65d582, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_96b879e17b4346e4b98484224e65d582).child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_6be1dbef5dd042ba88554b4482b16079, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_6be1dbef5dd042ba88554b4482b16079).child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_a72464a6a1a8426887ca40b886b5567e, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_a72464a6a1a8426887ca40b886b5567e).child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_ccc54bcd38e14c10a5ba59d851191cc4, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_ccc54bcd38e14c10a5ba59d851191cc4).child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_39a7a11c94da4b338a92b2235b8e96d1, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_39a7a11c94da4b338a92b2235b8e96d1).child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_93a237ff714b48748a4ba10ede42d2dc, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_93a237ff714b48748a4ba10ede42d2dc).child)
                id_24914ab245484fe1b70af8020ca2e831.WireTo(id_f9b8d9329de5407b93a1834afeaf5de6, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_f9b8d9329de5407b93a1834afeaf5de6).child)
                id_aa2f23f75c79479e88ccf7ed0ed6c2cc.WireTo(id_803db86064414b379608f65bc07098bc, "children"); // (Horizontal (id_aa2f23f75c79479e88ccf7ed0ed6c2cc).children) -- [List<IUI>] --> (Button (id_803db86064414b379608f65bc07098bc).child)
                id_aa2f23f75c79479e88ccf7ed0ed6c2cc.WireTo(id_68d3e779ba0d4f78ad48db2ed468608c, "children"); // (Horizontal (id_aa2f23f75c79479e88ccf7ed0ed6c2cc).children) -- [List<IUI>] --> (Space (id_68d3e779ba0d4f78ad48db2ed468608c).child)
                id_803db86064414b379608f65bc07098bc.WireTo(MultipleRow, "eventButtonClicked");               // (Button (id_803db86064414b379608f65bc07098bc).eventButtonClicked) -- [IEvent] --> (Multiple (MultipleRow).addRow)
                MultipleRow.WireTo(id_012306911dbe485c91ecd24bd35b2420, "factory");                          // (Multiple (MultipleRow).factory) -- [IFactoryMethod] --> (CalculatorRowFactory (id_012306911dbe485c91ecd24bd35b2420).factory)
                // END AUTO-GENERATED WIRING FOR CalculatorNRows.xmind

                // These are used to solve compiler error "Cannot use local variable 'rows' before it is declared" in the lambda functions in the wiring code above if they reference 'rows' and 'labelsConcetenator' instead;
                _rows = rows;
                _labelsConcatenator = labelsConcatenator;  //

                // This tell MultipleRow object to go ahead an create calculator rows (each of which will use the lambdas above to wire into the rest of the application)
                MultipleRow.Generate();


                // these are used for testing the application to set the title and press the button
                title        = id_b84a8eee3a554afaad9fa90ac6b594f9;
                addRowButton = id_803db86064414b379608f65bc07098bc;

                mw = mainWindow;
            }
示例#15
0
 public void ConcatinizationExtensions_NullThrows_Test()
 {
     StringConcat.WithSeparator('/', null);
 }
示例#16
0
        private MainWindow Calculator2ARows()
        {
            var mainWindow = new MainWindow("Calculator");
            // BEGIN AUTO-GENERATED INSTANTIATIONS FOR Calculator2ARows.xmind
            CalculatorRow Row1 = new CalculatorRow()
            {
                InstanceName = "Row1"
            };
            CalculatorRow Row2 = new CalculatorRow()
            {
                InstanceName = "Row2"
            };
            DataFlowConnector <string> labelsConcatenatorConnector = new DataFlowConnector <string>()
            {
                InstanceName = "labelsConcatenatorConnector"
            };
            Horizontal id_24914ab245484fe1b70af8020ca2e831 = new Horizontal()
            {
                InstanceName = "Default", Ratios = new int[] { 1, 2, 2, 1, 3 }, MinWidths = new int[] { 50, 200, 520 }
            };
            StringConcat labelsConcatenator = new StringConcat()
            {
                InstanceName = "labelsConcatenator", Separator = ","
            };
            Text id_39a7a11c94da4b338a92b2235b8e96d1 = new Text("Units")
            {
                InstanceName = "Default", FontSize = 50
            };
            Text id_6be1dbef5dd042ba88554b4482b16079 = new Text("Formula")
            {
                InstanceName = "Default", FontSize = 50
            };
            Text id_93a237ff714b48748a4ba10ede42d2dc = new Text("Description")
            {
                InstanceName = "Default", FontSize = 50
            };
            Text id_96b879e17b4346e4b98484224e65d582 = new Text("Label")
            {
                InstanceName = "Default", FontSize = 50
            };
            Text id_ccc54bcd38e14c10a5ba59d851191cc4 = new Text("Result")
            {
                InstanceName = "Default", FontSize = 50
            };
            Text id_fc0b8f38b3c14f799f605cd54214b503 = new Text("Debug output")
            {
                InstanceName = "Default", FontSize = 50
            };
            Vertical rows = new Vertical()
            {
                InstanceName = "rows"
            };

            // END AUTO-GENERATED INSTANTIATIONS FOR Calculator2ARows.xmind

            // BEGIN AUTO-GENERATED WIRING FOR Calculator2ARows.xmind
            mainWindow.WireTo(rows, "iuiStructure");                                                     // (@MainWindow (mainWindow).iuiStructure) -- [IUI] --> (Vertical (rows).child)
            rows.WireTo(id_24914ab245484fe1b70af8020ca2e831, "children");                                // (Vertical (rows).children) -- [List<IUI>] --> (Horizontal (id_24914ab245484fe1b70af8020ca2e831).child)
            rows.WireTo(Row1, "children");                                                               // (Vertical (rows).children) -- [List<IUI>] --> (CalculatorRow (Row1).child)
            rows.WireTo(Row2, "children");                                                               // (Vertical (rows).children) -- [List<IUI>] --> (CalculatorRow (Row2).child)
            rows.WireTo(id_fc0b8f38b3c14f799f605cd54214b503, "children");                                // (Vertical (rows).children) -- [List<IUI>] --> (Text (id_fc0b8f38b3c14f799f605cd54214b503).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_96b879e17b4346e4b98484224e65d582, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_96b879e17b4346e4b98484224e65d582).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_6be1dbef5dd042ba88554b4482b16079, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_6be1dbef5dd042ba88554b4482b16079).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_ccc54bcd38e14c10a5ba59d851191cc4, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_ccc54bcd38e14c10a5ba59d851191cc4).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_39a7a11c94da4b338a92b2235b8e96d1, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_39a7a11c94da4b338a92b2235b8e96d1).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_93a237ff714b48748a4ba10ede42d2dc, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_93a237ff714b48748a4ba10ede42d2dc).child)
            labelsConcatenator.WireTo(Row1, "inputs");                                                   // (StringConcat (labelsConcatenator).inputs) -- [IDataFlowB<string>] --> (CalculatorRow (Row1).label)
            Row2.WireTo(Row1, "operands");                                                               // (CalculatorRow (Row2).operands) -- [IDataFlowB<double>] --> (CalculatorRow (Row1).result)
            Row1.WireTo(Row1, "operands");                                                               // (CalculatorRow (Row1).operands) -- [IDataFlowB<double>] --> (CalculatorRow (Row1).result)
            labelsConcatenator.WireTo(Row2, "inputs");                                                   // (StringConcat (labelsConcatenator).inputs) -- [IDataFlowB<string>] --> (CalculatorRow (Row2).label)
            Row2.WireTo(Row2, "operands");                                                               // (CalculatorRow (Row2).operands) -- [IDataFlowB<double>] --> (CalculatorRow (Row2).result)
            Row1.WireTo(Row2, "operands");                                                               // (CalculatorRow (Row1).operands) -- [IDataFlowB<double>] --> (CalculatorRow (Row2).result)
            labelsConcatenator.WireTo(labelsConcatenatorConnector, "output");                            // (StringConcat (labelsConcatenator).output) -- [iDataFlow<string>] --> (DataFlowConnector<string> (labelsConcatenatorConnector).input)
            Row2.WireTo(labelsConcatenatorConnector, "labelsCommaSeparated");                            // (CalculatorRow (Row2).labelsCommaSeparated) -- [IDataFlowB<string>] --> (DataFlowConnector<string> (labelsConcatenatorConnector).outputsB)
            Row1.WireTo(labelsConcatenatorConnector, "labelsCommaSeparated");                            // (CalculatorRow (Row1).labelsCommaSeparated) -- [IDataFlowB<string>] --> (DataFlowConnector<string> (labelsConcatenatorConnector).outputsB)
            // END AUTO-GENERATED WIRING FOR Calculator2ARows.xmind
            // Row1.WireInternals();
            // Row2.WireInternals();
            return(mainWindow);
        }
示例#17
0
        /*
         *
         *      public void CalculatorNRows()
         *      {
         *          Vertical rows = new Vertical() { InstanceName = "rows" };
         *          StringConcat labelsConcatenator = new StringConcat() { InstanceName = "labelsConcatenator", Separator = "," };
         *          // BEGIN AUTO-GENERATED INSTANTIATIONS FOR CalculatorNRows2.xmind
         *          Button id_803db86064414b379608f65bc07098bc = new Button("Add row") { InstanceName = "Default", FontSize = 25 };
         *          CalculatorRowFactory id_012306911dbe485c91ecd24bd35b2420 = new CalculatorRowFactory() { InstanceName = "Default" };
         *          DataFlowConnector<string> labelsConcatenatorConnector = new DataFlowConnector<string>() { InstanceName = "labelsConcatenatorConnector" };
         *          Horizontal id_24914ab245484fe1b70af8020ca2e831 = new Horizontal() { InstanceName = "Default", Ratios = new int[] { 1, 2, 2, 1, 3 }, MinWidths = new int[] { 50, 200, 520 } };
         *          Horizontal id_aa2f23f75c79479e88ccf7ed0ed6c2cc = new Horizontal() { InstanceName = "Default", Ratios = new int[] { 1, 8 }, MinWidths = new int[] { 50 } };
         *          Multiple MultipleRow = new Multiple(N: 4) { InstanceName = "MultipleRow", WiringMethod = (newInstance) => { rows.WireTo(newInstance); labelsConcatenator.WireTo(newInstance, "inputs"); newInstance.WireTo(labelsConcatenatorConnector, "labelsCommaSeparated"); }, CrossWiringMethod = (instance1, instance2) => { instance2.WireFrom(instance1, "operands"); }, PostWiringInitializeMethod = delegate (object instance) { rows.AddRows(); ((CalculatorRow)instance).Initialize(); } };
         *          Space id_68d3e779ba0d4f78ad48db2ed468608c = new Space() { InstanceName = "Default" };
         *          Text id_39a7a11c94da4b338a92b2235b8e96d1 = new Text("Units") { InstanceName = "Default", FontSize = 25 };
         *          Text id_6be1dbef5dd042ba88554b4482b16079 = new Text("Formula") { InstanceName = "Default", FontSize = 25 };
         *          Text id_93a237ff714b48748a4ba10ede42d2dc = new Text("Description") { InstanceName = "Default", FontSize = 25 };
         *          Text id_96b879e17b4346e4b98484224e65d582 = new Text("Label") { InstanceName = "Default", FontSize = 25 };
         *          Text id_ccc54bcd38e14c10a5ba59d851191cc4 = new Text("Result") { InstanceName = "Default", FontSize = 25 };
         *          Text id_fc0b8f38b3c14f799f605cd54214b503 = new Text("Reactive Calculator") { InstanceName = "Default", FontSize = 25 };
         *          TextBox id_b84a8eee3a554afaad9fa90ac6b594f9 = new TextBox() { InstanceName = "Default", Text = "Title your calculation here", FontSize = 15 };
         *          Vertical id_b02d2caea938499b997b9bfcb80fb0e9 = new Vertical() { InstanceName = "Default" };
         *          // END AUTO-GENERATED INSTANTIATIONS FOR CalculatorNRows2.xmind
         *          // ((CalculatorRow)newInstance).WireInternals();
         *
         *          // BEGIN AUTO-GENERATED WIRING FOR CalculatorNRows2.xmind
         *          mainWindow.WireTo(id_b02d2caea938499b997b9bfcb80fb0e9, "iuiStructure"); // (@MainWindow (mainWindow).iuiStructure) -- [IUI] --> (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).child)
         *          labelsConcatenator.WireTo(labelsConcatenatorConnector, "output"); // (@StringConcat (labelsConcatenator).output) -- [iDataFlow<string>] --> (DataFlowConnector<string> (labelsConcatenatorConnector).input)
         *          id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_fc0b8f38b3c14f799f605cd54214b503, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Text (id_fc0b8f38b3c14f799f605cd54214b503).child)
         *          id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_b84a8eee3a554afaad9fa90ac6b594f9, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (TextBox (id_b84a8eee3a554afaad9fa90ac6b594f9).child)
         *          id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_24914ab245484fe1b70af8020ca2e831, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Horizontal (id_24914ab245484fe1b70af8020ca2e831).child)
         *          id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(rows, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (@Vertical (rows).Child)
         *          id_b02d2caea938499b997b9bfcb80fb0e9.WireTo(id_aa2f23f75c79479e88ccf7ed0ed6c2cc, "children"); // (Vertical (id_b02d2caea938499b997b9bfcb80fb0e9).children) -- [List<IUI>] --> (Horizontal (id_aa2f23f75c79479e88ccf7ed0ed6c2cc).Child)
         *          id_24914ab245484fe1b70af8020ca2e831.WireTo(id_96b879e17b4346e4b98484224e65d582, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_96b879e17b4346e4b98484224e65d582).child)
         *          id_24914ab245484fe1b70af8020ca2e831.WireTo(id_6be1dbef5dd042ba88554b4482b16079, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_6be1dbef5dd042ba88554b4482b16079).child)
         *          id_24914ab245484fe1b70af8020ca2e831.WireTo(id_ccc54bcd38e14c10a5ba59d851191cc4, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_ccc54bcd38e14c10a5ba59d851191cc4).child)
         *          id_24914ab245484fe1b70af8020ca2e831.WireTo(id_39a7a11c94da4b338a92b2235b8e96d1, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_39a7a11c94da4b338a92b2235b8e96d1).child)
         *          id_24914ab245484fe1b70af8020ca2e831.WireTo(id_93a237ff714b48748a4ba10ede42d2dc, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_93a237ff714b48748a4ba10ede42d2dc).child)
         *          id_aa2f23f75c79479e88ccf7ed0ed6c2cc.WireTo(id_803db86064414b379608f65bc07098bc, "children"); // (Horizontal (id_aa2f23f75c79479e88ccf7ed0ed6c2cc).children) -- [List<IUI>] --> (Button (id_803db86064414b379608f65bc07098bc).child)
         *          id_aa2f23f75c79479e88ccf7ed0ed6c2cc.WireTo(id_68d3e779ba0d4f78ad48db2ed468608c, "children"); // (Horizontal (id_aa2f23f75c79479e88ccf7ed0ed6c2cc).children) -- [List<IUI>] --> (Space (id_68d3e779ba0d4f78ad48db2ed468608c).child)
         *          id_803db86064414b379608f65bc07098bc.WireTo(MultipleRow, "eventButtonClicked"); // (Button (id_803db86064414b379608f65bc07098bc).eventButtonClicked) -- [IEvent] --> (Multiple (MultipleRow).addRow)
         *          MultipleRow.WireTo(id_012306911dbe485c91ecd24bd35b2420, "factory"); // (Multiple (MultipleRow).factory) -- [IFactoryMethod] --> (CalculatorRowFactory (id_012306911dbe485c91ecd24bd35b2420).factory)
         *          // END AUTO-GENERATED WIRING FOR CalculatorNRows2.xmind
         *          MultipleRow.Generate();
         *      }
         */



        private MainWindow Calculator10Rows()
        {
            MainWindow mainWindow = new MainWindow("Calculator");
            Vertical   rows       = new Vertical()
            {
                InstanceName = "rows"
            };
            StringConcat labelsConcatenator = new StringConcat()
            {
                InstanceName = "labelsConcatenator", Separator = ","
            };
            // BEGIN AUTO-GENERATED INSTANTIATIONS FOR Calculator10Rows.xmind
            CalculatorRowFactory id_012306911dbe485c91ecd24bd35b2420 = new CalculatorRowFactory()
            {
                InstanceName = "Default"
            };
            DataFlowConnector <string> labelsConcatenatorConnector = new DataFlowConnector <string>()
            {
                InstanceName = "labelsConcatenatorConnector"
            };
            Horizontal id_24914ab245484fe1b70af8020ca2e831 = new Horizontal()
            {
                InstanceName = "Default", Ratios = new int[] { 1, 2, 2, 1, 3 }, MinWidths = new int[] { 50, 200, 520 }
            };
            Multiple MultipleRow = new Multiple(N: 10)
            {
                InstanceName = "MultipleRow", WiringMethod = (newInstance) => { rows.WireTo(newInstance); labelsConcatenator.WireTo(newInstance, "inputs"); newInstance.WireTo(labelsConcatenatorConnector, "labelsCommaSeparated"); }, CrossWiringMethod = (instance1, instance2) => { instance2.WireFrom(instance1, "operands"); }
            };
            Text id_39a7a11c94da4b338a92b2235b8e96d1 = new Text("Units")
            {
                InstanceName = "Default", FontSize = 25
            };
            Text id_6be1dbef5dd042ba88554b4482b16079 = new Text("Formula")
            {
                InstanceName = "Default", FontSize = 25
            };
            Text id_93a237ff714b48748a4ba10ede42d2dc = new Text("Description")
            {
                InstanceName = "Default", FontSize = 25
            };
            Text id_96b879e17b4346e4b98484224e65d582 = new Text("Label")
            {
                InstanceName = "Default", FontSize = 25
            };
            Text id_ccc54bcd38e14c10a5ba59d851191cc4 = new Text("Result")
            {
                InstanceName = "Default", FontSize = 25
            };
            Text id_fc0b8f38b3c14f799f605cd54214b503 = new Text("Reactive Calculator")
            {
                InstanceName = "Default", FontSize = 25
            };
            TextBox id_b84a8eee3a554afaad9fa90ac6b594f9 = new TextBox()
            {
                InstanceName = "Default", Text = "Title your calculation here", FontSize = 15
            };

            // END AUTO-GENERATED INSTANTIATIONS FOR Calculator10Rows.xmind

            // BEGIN AUTO-GENERATED WIRING FOR Calculator10Rows.xmind
            mainWindow.WireTo(rows, "iuiStructure");                                                     // (@MainWindow (mainWindow).iuiStructure) -- [IUI] --> (@Vertical (rows).child)
            labelsConcatenator.WireTo(labelsConcatenatorConnector, "output");                            // (@StringConcat (labelsConcatenator).output) -- [iDataFlow<string>] --> (DataFlowConnector<string> (labelsConcatenatorConnector).input)
            rows.WireTo(id_fc0b8f38b3c14f799f605cd54214b503, "children");                                // (@Vertical (rows).children) -- [List<IUI>] --> (Text (id_fc0b8f38b3c14f799f605cd54214b503).child)
            rows.WireTo(id_b84a8eee3a554afaad9fa90ac6b594f9, "children");                                // (@Vertical (rows).children) -- [List<IUI>] --> (TextBox (id_b84a8eee3a554afaad9fa90ac6b594f9).child)
            rows.WireTo(id_24914ab245484fe1b70af8020ca2e831, "children");                                // (@Vertical (rows).children) -- [List<IUI>] --> (Horizontal (id_24914ab245484fe1b70af8020ca2e831).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_96b879e17b4346e4b98484224e65d582, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_96b879e17b4346e4b98484224e65d582).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_6be1dbef5dd042ba88554b4482b16079, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_6be1dbef5dd042ba88554b4482b16079).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_ccc54bcd38e14c10a5ba59d851191cc4, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_ccc54bcd38e14c10a5ba59d851191cc4).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_39a7a11c94da4b338a92b2235b8e96d1, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_39a7a11c94da4b338a92b2235b8e96d1).child)
            id_24914ab245484fe1b70af8020ca2e831.WireTo(id_93a237ff714b48748a4ba10ede42d2dc, "children"); // (Horizontal (id_24914ab245484fe1b70af8020ca2e831).children) -- [List<IUI>] --> (Text (id_93a237ff714b48748a4ba10ede42d2dc).child)
            MultipleRow.WireTo(id_012306911dbe485c91ecd24bd35b2420, "factory");                          // (Multiple (MultipleRow).factory) -- [IFactoryMethod] --> (CalculatorRowFactory (id_012306911dbe485c91ecd24bd35b2420).factory)
            // END AUTO-GENERATED WIRING FOR Calculator10Rows.xmind
            MultipleRow.Generate();
            return(mainWindow);
        }
示例#18
0
 public void ConcatinizationExtensions_EmptyThrows_Test()
 {
     StringConcat.WithSeparator('/', new string[] { });
 }