示例#1
0
        public FtMetaField New(int dataType)
        {
            FtMetaField result = FieldFactory.CreateMetaField(dataType, HeadingCount);

            Add(result);
            return(result);
        }
示例#2
0
        private static FieldBase[] CreateCoreFields(ArrayList fields, TypedRecordAttribute recordAttribute)
        {
            FieldBase curField;
            var       arr          = new ArrayList();
            var       someOptional = false;

            for (var i = 0; i < fields.Count; i++)
            {
                var fieldInfo = (FieldInfo)fields[i];

                curField = FieldFactory.CreateField(fieldInfo, recordAttribute, someOptional);

                if (curField != null)
                {
                    someOptional = curField.mIsOptional;

                    arr.Add(curField);
                    if (arr.Count > 1)
                    {
                        ((FieldBase)arr[arr.Count - 2]).mNextIsOptional = ((FieldBase)arr[arr.Count - 1]).mIsOptional;
                    }
                }
            }

            if (arr.Count > 0)
            {
                ((FieldBase)arr[0]).mIsFirst            = true;
                ((FieldBase)arr[arr.Count - 1]).mIsLast = true;
            }

            return((FieldBase[])arr.ToArray(typeof(FieldBase)));
        }
示例#3
0
        public void Create_CorrectArg_ShouldReturnAField()
        {
            var factory = new FieldFactory();
            var result  = factory.Create(new Mock <IContest>().Object, "name");

            Assert.IsInstanceOf <Field>(result);
        }
示例#4
0
        static void Main()
        {
            try
            {
                var bots = new List <IBot>
                {
                    new MediumBot(),
                    new EasyBot()
                };

                var fieldFactory = new FieldFactory();
                var board        = new Board(7, 6, fieldFactory);
                var gameFactory  = new GameFactory(board, bots.ToArray());

                var playerFactory = new PlayerFactory();
                var proxy         = new GameProxy();

                var logger = new Log4netAdapter("GameAPI");
                var api    = new GameAPI(gameFactory, playerFactory, logger, proxy);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1(api));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MessageBox.Show(e.ToString());
                Application.Exit();
            }
        }
示例#5
0
        void UpdateExposedParameters()
        {
            parameters.Clear();

            if (graph.exposedParameters.Count != 0)
            {
                parameters.Add(new Label("Exposed Parameters:"));
            }

            foreach (var param in graph.exposedParameters)
            {
                if (param.settings.isHidden)
                {
                    continue;
                }

                VisualElement prop = new VisualElement();
                prop.style.display = DisplayStyle.Flex;
                Type paramType = Type.GetType(param.type);
                var  field     = FieldFactory.CreateField(paramType, param.serializedValue.value, (newValue) => {
                    Undo.RegisterCompleteObjectUndo(graph, "Changed Parameter " + param.name + " to " + newValue);
                    param.serializedValue.value = newValue;
                }, param.name);
                prop.Add(field);
                parameters.Add(prop);
            }
        }
示例#6
0
        internal FtFieldDefinition New(int dataType)
        {
            FtFieldDefinition definition = FieldFactory.CreateFieldDefinition(Count, dataType);

            list.Add(definition);
            return(definition);
        }
示例#7
0
        private object GetFormValues(Type typeOfModel, string prefix)
        {
            var vm = Activator.CreateInstance(typeOfModel);

            foreach (var property in vm.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                var propertyName = string.IsNullOrEmpty(prefix)
                    ? property.Name
                    : string.Format("{0}.{1}", prefix, property.Name);

                if (property.IsReadonly())
                {
                    continue;
                }

                if (!property.PropertyType.IsValueType && property.PropertyType != typeof(string) && !typeof(IEnumerable).IsAssignableFrom(property.PropertyType))
                {
                    var childValue = GetFormValues(property.PropertyType, propertyName);
                    property.SetValue(vm, childValue, null);
                    continue;
                }

                var elements = ((RemoteWebDriver)Browser).FindElementsByName(propertyName);
                var format   = GetFormatStringForProperty(property);
                property.SetValue(vm, FieldFactory.Create(elements).Get(new ModelFieldType(property.PropertyType, format)), null);
            }
            return(vm);
        }
示例#8
0
        protected internal override FtMetaField CreateCopy()
        {
            FtMetaField field = FieldFactory.CreateMetaField(DataType, HeadingCount);

            field.Assign(this);
            return(field);
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GroupBoxController"/> class.
        /// </summary>
        /// <param name="element">The element representig the related <see cref="GroupBox"/></param>
        /// <param name="enabled">True if the <see cref="GroupBox"/> is modifiable, false otherwise</param>
        public GroupBoxController(GroupBox element, bool enabled)
            : base(enabled)
        {
            groupPanel = new EnhancedGroupBox
            {
                HeaderText   = element.Name,
                HeaderFont   = new Font("Tahoma", 8, FontStyle.Italic),
                BorderColor  = Color.Black,
                CornerRadius = 5,
                BorderSize   = 1
            };
            this.element = element;
            controllers  = new List <FieldController>();

            if (!String.IsNullOrEmpty(element.Description))
            {
                groupPanel.AddElement(new Label()
                {
                    Text = element.Description, ForeColor = Color.FromArgb(90, 90, 90), Font = new Font("Tahoma", 8, FontStyle.Regular)
                });
            }

            foreach (Field field in element.Fields)
            {
                FieldController controller = FieldFactory.CreateController(field, enabled);
                controllers.Add(controller);
                controller.SeparatedEditingRequest += OnInnerSeparatedRequest;
                groupPanel.AddElement(controller as Control);
            }

            Content = groupPanel;
        }
示例#10
0
        public void Process_WordsAlreadyPopulated_DoesNothing()
        {
            // arrange
            var database = new Mock <Database>();

            database.Setup(x => x.Name).Returns("fake");

            var itemMock = ItemFactory.CreateItem(database: database.Object);

            database.Setup(x => x.GetItem("item")).Returns(itemMock.Object);

            var field = FieldFactory.CreateField(itemMock.Object, ID.NewID, Constants.Fields.WordList, "lorem\nipsum");

            ItemFactory.AddFields(itemMock, new[] { field });

            var sut = new GetProfanityListFromItem(database.Object);

            sut.ItemPath = "item";
            var args = new ProfanityFilterArgs();

            args.WordList = new[] { "dolor" };

            // act
            sut.Process(args);

            // assert
            Assert.That(args.WordList, Is.EquivalentTo(new[] { "dolor" }));
        }
示例#11
0
 public Display(ApplicationConfig config)
 {
     this.background  = (Field)FieldFactory.MakeField(config.BackgroundField);
     this.numberField = (FieldString)FieldFactory.MakeField(config.NumberField);
     this.trialField  = (FieldString)FieldFactory.MakeField(config.TrialField);
     this.recordField = (FieldString)FieldFactory.MakeField(config.RecordField);
     this.resultField = (FieldImage)FieldFactory.MakeField(config.ResultField);
 }
示例#12
0
        private Field CreateField(XmlSchemaElement schema)
        {
            XmlSchema onTheFlySchema = new XmlSchema();

            onTheFlySchema.Items.Add(schema);

            return(FieldFactory.CreateField("GroupBox", schema.Name, onTheFlySchema));
        }
示例#13
0
文件: ModelTest.cs 项目: lwliang/doc
 public TestModel() : base()
 {
     ModelName = "test.user";
     No        = FieldFactory.CreateIntegerField(this, nameof(No));
     Name      = FieldFactory.CreateStringField(this, nameof(Name), 100);
     Price     = FieldFactory.CreateDecimalField(this, nameof(Price), 10, 2);
     ParentId  = FieldFactory.CreateMany2OneField(this, nameof(ParentId), "test.parent");
 }
示例#14
0
        private Item CreateDictionaryEntryItem(string phrase)
        {
            var item  = ItemFactory.CreateItem();
            var field = FieldFactory.CreateField(item.Object, ID.NewID, "Phrase", phrase);

            ItemFactory.AddFields(item, new[] { field });
            return(item.Object);
        }
示例#15
0
        public void CheckIfThereIsOnlyOneInstance()
        {
            FieldFactory firstField = FieldFactory.Instance;

            FieldFactory secondField = FieldFactory.Instance;

            Assert.AreSame(firstField, secondField);
        }
示例#16
0
        private Mock <Item> CreateMockBlogItem(bool rssEnabled)
        {
            var itemMock        = ItemFactory.CreateItem();
            var rssEnabledField = FieldFactory.CreateField(itemMock.Object, ID.NewID, "Enable RSS", rssEnabled ? "1" : "0");

            ItemFactory.AddFields(itemMock, new[] { rssEnabledField });

            return(itemMock);
        }
示例#17
0
        public void GetFieldWithSession()
        {
            Session      session = new Session(5, 3);
            FieldFactory factory = new FieldFactory();

            for (int i = 1; i <= session.Levels; i++)
            {
                session.CurrentLevel = i;
                Field field = factory.MakeField(session.StartIndex, session.EndIndex);
            }
        }
示例#18
0
        static void Main(string[] args)
        {
            var    ninjaFactory = new NinjaFactory();
            var    data         = new Data();
            var    fieldFactory = new FieldFactory();
            var    inputReader  = new ConsoleReader();
            var    inputWriter  = new ConsoleWriter();
            Engine start        = new Engine(ninjaFactory, data, fieldFactory, inputReader, inputWriter);

            start.Run();
        }
示例#19
0
        private Field getitem(int index)
        {
            global::System.IntPtr cPtr = GmsecPINVOKE.FieldList_getitem(swigCPtr, index);
            Field ret = (cPtr == global::System.IntPtr.Zero) ? null : FieldFactory.BuildField(cPtr, false);

            if (GmsecPINVOKE.SWIGPendingException.Pending)
            {
                throw GmsecPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#20
0
        public Board Generate(int mineCount)
        {
            if (mineCount < 1 || this.ColumnCount * this.RowCount < mineCount)
            {
                throw new ArgumentException("invalid mine count");
            }

            FieldFactory fieldFactory      = new FieldFactory();
            int          countOfPlacedMine = 0;
            Random       chanceToMine      = new Random();

            while (mineCount > countOfPlacedMine)
            {
                for (int rowIndex = 0; rowIndex < this.RowCount; rowIndex++)
                {
                    if (countOfPlacedMine == mineCount)
                    {
                        break;
                    }

                    for (int columnIndex = 0; columnIndex < this.ColumnCount; columnIndex++)
                    {
                        if (countOfPlacedMine == mineCount)
                        {
                            break;
                        }

                        int randomNumber = chanceToMine.Next(0, 2);
                        if (randomNumber == 1)
                        {
                            this.Board[rowIndex, columnIndex] = fieldFactory.GetField(Field.Field.MINE_CONTENT);
                            countOfPlacedMine++;
                        }
                    }
                }
            }

            for (int rowIndex = 0; rowIndex < this.RowCount; rowIndex++)
            {
                for (int columnIndex = 0; columnIndex < this.ColumnCount; columnIndex++)
                {
                    if (this.Board[rowIndex, columnIndex] != null)
                    {
                        continue;
                    }

                    int neighbourMinesCount = GetNeighbourMinesCount(rowIndex, columnIndex);
                    this.Board[rowIndex, columnIndex] = fieldFactory.GetField(neighbourMinesCount);
                }
            }

            return(this.Board);
        }
示例#21
0
        public void GetField()
        {
            FieldFactory fieldFactory = new FieldFactory();
            Field        field        = fieldFactory.MakeField(0, 10);
            int          i            = 0;

            foreach (LexemLine line in field.LexemLines)
            {
                Assert.AreEqual(i * FieldSettings.PictureHeight, line.Y);
                i++;
            }
            Assert.AreEqual(FieldSettings.RowNumbers, field.LexemLines.Count);
        }
示例#22
0
        private NodeController CreateController(Node node, bool enabled)
        {
            List <FieldController> fieldControllers = new List <FieldController>();

            foreach (Field field in node.Fields)
            {
                fieldControllers.Add(FieldFactory.CreateController(field, enabled));
            }

            NodeController controller = new NodeController(node.ID, node.Name, fieldControllers.ToArray());

            return(controller);
        }
        private void CreateOutputPort(TypeInfo typeInfo)
        {
            var element = FieldFactory.CreateField(typeInfo.DataType, dataNode.outputValue, (newValue) =>
            {
                owner.RegisterCompleteObjectUndo("Create TestNodeView " + typeInfo.fullName);
                dataNode.outputValue = newValue;
                NotifyNodeChanged();
                valueChangeCallback?.Invoke();
            }, $"{typeInfo.fullName.Split('.').LastOrDefault()}Value");

            controlsContainer.Add(element);
            style.width = 200;
        }
示例#24
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
        protected void InputModel(T model)
        {
            foreach (var property in model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (property.IsReadonly())
                {
                    continue;
                }

                var elements = ((RemoteWebDriver)Browser).FindElementsByName(property.Name);
                var format   = GetFormatStringForProperty(property);
                FieldFactory.Create(elements).Set(new ModelFieldValue(property.GetValue(model, null), format));
            }
        }
示例#26
0
        private static void PopulateFields(ICollection <IField> schema, Type template, string parentName, int currentDepth, int maxDepth)
        {
            if (currentDepth >= maxDepth)
            {
                return;
            }
            string concat(params string[] args) => string.Join(".", args).TrimStart('.');

            foreach (MemberInfo member in GetPublicFieldsAndPropertiesFrom(template))
            {
                string temp;
                IField field;
                Type   valueType = GetValueType(member);
#if DEBUG
                System.Diagnostics.Debug.WriteLine($"{concat(parentName, member.Name)}: <{valueType.Name}>");
#endif
                switch (GetKindOfType(valueType, out Type collectionElementType))
                {
                case KindOfType.Primitive:
                    field      = FieldFactory.CreateInstance(valueType, template);
                    field.Name = concat(parentName, member.Name);
                    schema.Add(field);
                    break;

                case KindOfType.CollectionOfPrimitives:
                    field      = FieldFactory.CreateInstance(valueType);
                    field.Name = concat(parentName, member.Name);
                    schema.Add(field);

                    field      = FieldFactory.CreateInstance(collectionElementType);
                    field.Name = concat(parentName, member.Name, Item);
                    schema.Add(field);
                    break;

                case KindOfType.Object:
                    temp = concat(parentName, member.Name);
                    PopulateFields(schema, valueType, temp, (currentDepth + 1), maxDepth);
                    break;

                case KindOfType.CollectionOfObjects:
                    field      = FieldFactory.CreateInstance(valueType);
                    field.Name = concat(parentName, member.Name);
                    schema.Add(field);

                    temp = concat(parentName, member.Name, Item);
                    PopulateFields(schema, collectionElementType, temp, (currentDepth + 1), maxDepth);
                    break;
                }
            }
        }
        public LevelParser(XmlDocument xmlFile)
        {
            _xmlFile      = xmlFile;
            _fieldFactory = new FieldFactory();

            StartFieldsPlayerOne   = new List <StartField>();
            StartFieldsPlayerTwo   = new List <StartField>();
            StartFieldsPlayerThree = new List <StartField>();
            StartFieldsPlayerFour  = new List <StartField>();
            AllFields = new List <IField>();

            // Parse XML and connect the fields
            ParseXML();
        }
示例#28
0
        private CommentItem CreateCommentItem()
        {
            var itemMock = ItemFactory.CreateItem();

            ItemFactory.AddFields(itemMock, new[]
            {
                FieldFactory.CreateField(itemMock.Object, ID.NewID, "IP Address", "127.0.0.1"),
                FieldFactory.CreateField(itemMock.Object, ID.NewID, "Comment", "comment"),
                FieldFactory.CreateField(itemMock.Object, ID.NewID, "Name", "name"),
                FieldFactory.CreateField(itemMock.Object, ID.NewID, "Email", "email"),
                FieldFactory.CreateField(itemMock.Object, ID.NewID, "Website", "website")
            });

            return(new CommentItem(itemMock.Object));
        }
示例#29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChoiceBox"/> class.
        /// </summary>
        /// <param name="typeName">The name of the class that rapresents the generic type of the instance.</param>
        /// <param name="elementName">The name of the <see cref="ChoiceBox"/> instance in the presentation.xml file of the workflow.</param>
        /// <param name="schema">The schema xml that describe the <see cref="ChoiceBox"/> type.</param>
        public ChoiceBox(String typeName, String elementName, XmlSchemaSet schema)
            : base(typeName, elementName, schema)
        {
            fields = new List <Field>();

            //Instatiate all the possible fields
            XmlSchemaType   myType = (schema.GlobalElements[new XmlQualifiedName(elementName)] as XmlSchemaElement).SchemaType;
            XmlSchemaChoice choice = (myType as XmlSchemaComplexType).Particle as XmlSchemaChoice;

            foreach (XmlSchemaElement element in choice.Items)
            {
                Field subfield = FieldFactory.CreateField(element);
                fields.Add(subfield);
            }
        }
示例#30
0
        void UpdateExposedParameters()
        {
            parameters.Clear();

            bool header           = true;
            bool showUpdateButton = false;

            foreach (var param in graph.exposedParameters)
            {
                if (param.settings.isHidden)
                {
                    continue;
                }

                if (header)
                {
                    var headerLabel = new Label("Exposed Parameters");
                    headerLabel.AddToClassList("Header");
                    parameters.Add(headerLabel);
                    header           = false;
                    showUpdateButton = true;
                }
                VisualElement prop = new VisualElement();
                prop.AddToClassList("Indent");
                prop.style.display = DisplayStyle.Flex;
                Type paramType = Type.GetType(param.type);
                var  field     = FieldFactory.CreateField(paramType, param.serializedValue.value, (newValue) => {
                    Undo.RegisterCompleteObjectUndo(graph, "Changed Parameter " + param.name + " to " + newValue);
                    param.serializedValue.value = newValue;
                }, param.name);
                prop.Add(field);
                parameters.Add(prop);
            }

            if (showUpdateButton)
            {
                var updateButton = new Button(() => {
                    MixtureGraphProcessor.RunOnce(graph);
                    graph.SaveAllTextures(false);
                })
                {
                    text = "Update"
                };
                updateButton.AddToClassList("Indent");
                parameters.Add(updateButton);
            }
        }
示例#31
0
        /* This test will consume 117/200 of your daily request. Use with caution */
        public void FetchDataAsync_should_export_a_record_for_each_of_the_mockaroo_data_types()
        {
            // Arrange
            var records = Convert.ToInt32(TestContext.Properties[RecordsProperty] ?? 1);
            var endpoint = Gigobyte.Mockaroo.Mockaroo.Endpoint(ApiKey.GetValue(), records, Format.JSON);

            var dataType = (DataType)Enum.Parse(typeof(DataType), Convert.ToString(TestContext.DataRow[0]));
            var field = new FieldFactory().CreateInstance(dataType);
            field.Name = "name";

            // Act
            TestContext.WriteLine("Context: {0}", dataType);
            var data = MockarooClient.FetchDataAsync(endpoint, new Schema(field)).Result;
            var json = JArray.Parse(Encoding.Default.GetString(data));

            // Assert
            json.Count.ShouldBeGreaterThanOrEqualTo(1);
        }