public ItemFactory(IMetadataProvider metadataProvider, IFieldFactory fieldFactory, AppSettings appSettings, IDestMasterRepository destMasterRepository) { _metadataProvider = metadataProvider; _fieldFactory = fieldFactory; _appSettings = appSettings; _destMasterRepository = destMasterRepository; }
public Roulette(IRandom randomizer, IFieldFactory factory) { _randomizer = randomizer; _factory = factory; _fields = _factory.CreateFields(); _result = _fields[0]; }
public Roulette(IRouletteNumberGenerator rouletteNumberGenerator, IFieldFactory fieldFactory) { _rouletteNumberGenerator = rouletteNumberGenerator; _fieldFactory = fieldFactory; _fields = _fieldFactory.CreateFields("USA"); _result = _fields[0]; }
public Board(int width, int height, IFieldFactory fieldFactory) { Width = width; Height = height; FieldFactory = fieldFactory; Reset(); }
public void Setup() { _fieldFactory = new FakeFieldFactory(); _randomizer = Substitute.For <IRandomizer>(); _randomizer.GetNext().Returns((uint)2); _uut = new Roulette(_fieldFactory, _randomizer); }
public Board(int width, int height, IFieldFactory fieldFactory) { Width = width; Height = height; this.fieldFactory = fieldFactory; Reset(); }
public Engine(INinjaFactory ninjaFactory, IData data, IFieldFactory fieldFactory, IInputReader reader, IOutputWriter writer) { this.ninjaFactory = ninjaFactory; this.data = data; this.fieldFactory = fieldFactory; this.reader = reader; this.writer = writer; }
//private IFieldFactory _fieldFactory; public Roulette(IFieldFactory fieldFactory, IRandomizer randomizer) { _fields = fieldFactory.GetFields(); _result = _fields[0]; _randomizer = randomizer; }
public Roulette(IRandomizer randompar, IFieldFactory FieldFactorypar) { _random = randompar; _fieldFactory = FieldFactorypar; _fields = _fieldFactory.getFields(); _result = _fields[0]; }
public override FrameworkElementFactory GenerateField(IFactoryContext context, ItemsControlDescription fieldDescription) { FrameworkElementFactory element = new FrameworkElementFactory(typeof(ItemsControl)); element.SetValue(Grid.IsSharedSizeScopeProperty, true); if (fieldDescription.ItemTemplate != null) { element.SetValue(ItemsControl.ItemTemplateProperty, fieldDescription.ItemTemplate); } else { DataTemplate dt = new DataTemplate(); if (fieldDescription.ItemDefinition != null) { IFieldFactory factory = context.Mapping.Context.GetFactory(fieldDescription.ItemDefinition.GetType()); dt.VisualTree = factory.CreateField(context, fieldDescription.ItemDefinition); } else { var lbl = new FrameworkElementFactory(typeof(TextBlock)); lbl.SetBinding(TextBlock.TextProperty, new Binding()); dt.VisualTree = lbl; } element.SetValue(ItemsControl.ItemTemplateProperty, dt); } element.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(fieldDescription.ItemsSource)); if (fieldDescription.Rows != null || fieldDescription.Columns != null) { FrameworkElementFactory uniformPanel = new FrameworkElementFactory(typeof(UniformGrid)); if (fieldDescription.Rows != null) { uniformPanel.SetValue(UniformGrid.RowsProperty, fieldDescription.Rows.Value); } if (fieldDescription.Columns != null) { uniformPanel.SetValue(UniformGrid.ColumnsProperty, fieldDescription.Columns.Value); } element.SetValue(ItemsControl.ItemsPanelProperty, new ItemsPanelTemplate(uniformPanel)); } FrameworkElementFactory scrollviewer = new FrameworkElementFactory(typeof(ScrollViewer)); scrollviewer.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); scrollviewer.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto); scrollviewer.AppendChild(element); return(scrollviewer); }
public void If_no_field_is_filled_Then_return_false() { IFieldFactory fieldFactory = Substitute.For <IFieldFactory>(); fieldFactory.Create().Returns(new Field()); var match = new Match(fieldFactory); match.IsFinished.Should().BeFalse(); }
public ItemConverter(IFieldFactory fieldFactory, AppSettings appSettings, IMetadataProvider metadataProvider, IItemFactory itemFactory, IDestMasterRepository destMasterRepository, IReporter conversionReporter) { _fieldFactory = fieldFactory; _appSettings = appSettings; _metadataProvider = metadataProvider; _itemFactory = itemFactory; _destMasterRepository = destMasterRepository; _conversionReporter = conversionReporter; }
public GameEngine(IDisplay display, IConsoleFacade facade, IHerbivoreManager herbivore, ICarnivoreManager carnivore, IAnimalFactory animalfactory, IFieldFactory fieldFactory, IGenericAnimalManager genericAnimal) { _display = display; _facade = facade; _herbivore = herbivore; _carnivore = carnivore; _animalFactory = animalfactory; _fieldFactory = fieldFactory; _genericAnimal = genericAnimal; }
public SqlServerProvider(string connectionString, string table, IFieldFactory cellFactory) { ConnectionString = connectionString; var tableParts = table.Split('.'); Schema = tableParts[0]; Table = tableParts[1]; TableIdentifier = table; CellFactory = cellFactory; }
public GameSetUpFasade(IUserService userService, IUserSessionService userSessionService, IGameFactory gameFactory, IInterfaceService interfaceService, IWriterService writerService, IAsciiFactoriesFactory asciiFactoriesFactory, IFieldFactory fieldFactory, IButtonFactory buttonFactory) { this.userSessionService = userSessionService; this.userService = userService; this.gameFactory = gameFactory; this.interfaceService = interfaceService; this.writerService = writerService; this.asciiFactoriesFactory = asciiFactoriesFactory; this.fieldFactory = fieldFactory; this.buttonFactory = buttonFactory; }
public FieldBuilder CreateField(SchemaBuilder schemaBuilder, PropertyInfo propertyInfo) { IFieldFactory fieldFactory = null; var fieldType = propertyInfo.PropertyType; /* Check whether fieldType is generic or not. * Only IList<> and IDictionary are supported. */ if (fieldType.IsGenericType) { foreach (var interfaceType in fieldType.GetInterfaces()) { if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IList <>)) { fieldFactory = new ArrayFieldCreator(); break; } else if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IDictionary <,>)) { fieldFactory = new MapFieldCreator(); break; } } /* * if (fieldType.GetGenericTypeDefinition() == typeof(IList<>)) * { * fieldFactory = new ArrayFieldCreator(); * } * else if (fieldType.GetGenericTypeDefinition() == typeof(IDictionary<,>)) * { * fieldFactory = new MapFieldCreator(); * } * else */ if (fieldFactory == null) { var sb = new StringBuilder(); sb.AppendLine(string.Format("Type {0} does not supported.", fieldType)); sb.AppendLine("Only IList<T> and IDictionary<TKey, TValue> generic types are supproted"); throw new NotSupportedException(sb.ToString()); } } else { fieldFactory = new SimpleFieldCreator(); } return(fieldFactory.CreateField(schemaBuilder, propertyInfo)); }
public Roulette(IFieldFactory factory, IRandomizer random) { _factory = factory; _random = random; _fields = _factory.CreateFields(); //_fields = new List<Field> //{ // new Field(0, Field.Green), // new Field(1, Field.Red), // new Field(2, Field.Black), // new Field(3, Field.Red), // new Field(4, Field.Black), // new Field(5, Field.Red), // new Field(6, Field.Black), // new Field(7, Field.Red), // new Field(8, Field.Black), // new Field(9, Field.Red), // new Field(10, Field.Black), // new Field(11, Field.Black), // new Field(12, Field.Red), // new Field(13, Field.Black), // new Field(14, Field.Red), // new Field(15, Field.Black), // new Field(16, Field.Red), // new Field(17, Field.Black), // new Field(18, Field.Red), // new Field(19, Field.Red), // new Field(20, Field.Black), // new Field(21, Field.Red), // new Field(22, Field.Black), // new Field(23, Field.Red), // new Field(24, Field.Black), // new Field(25, Field.Red), // new Field(26, Field.Black), // new Field(27, Field.Red), // new Field(28, Field.Black), // new Field(29, Field.Black), // new Field(30, Field.Red), // new Field(31, Field.Black), // new Field(32, Field.Red), // new Field(33, Field.Black), // new Field(34, Field.Red), // new Field(35, Field.Black), // new Field(36, Field.Red) //}; _result = _fields[0]; }
public void If_some_fields_are_filled_Then_return_false() { IFieldFactory fieldFactory = Substitute.For <IFieldFactory>(); fieldFactory.Create().Returns( new Field() { State = FieldState.O }, new Field() { State = null }, new Field() { State = FieldState.O }, new Field() { State = FieldState.X }, new Field() { State = null }, new Field() { State = null }, new Field() { State = FieldState.O }, new Field() { State = FieldState.X }, new Field() { State = null }); var match = new Match(fieldFactory); match.IsFinished.Should().BeFalse(); }
public Fields( TType declaringType, IFieldFactory <TField, TConstant, TType> fieldFactory) { List <TField> fields = new List <TField>(); List <TConstant> constants = new List <TConstant>(); foreach (FieldDefinition fieldDefinition in declaringType.TypeDefinition.Fields.Where(field => !field.IsDefined(declaringType.Assembly, typeof(CompilerGeneratedAttribute)))) { if (fieldDefinition.HasConstant) { constants.Add(fieldFactory.CreateConstant(declaringType, fieldDefinition)); } else { fields.Add(fieldFactory.CreateField(declaringType, fieldDefinition)); } } FieldsWithMonoCecil = fields; ConstantsWithMonoCecil = constants; }
public Fields( TType declaringType, IFieldFactory <TField, TConstant, TType> fieldFactory) { List <TField> fields = new List <TField>(); List <TConstant> constants = new List <TConstant>(); foreach (FieldInfo fieldDefinition in declaringType.Type.GetAllFields().Where(field => !field.IsDefined(typeof(CompilerGeneratedAttribute)))) { if (fieldDefinition.IsLiteral) { constants.Add(fieldFactory.CreateConstant(declaringType, fieldDefinition)); } else { fields.Add(fieldFactory.CreateField(declaringType, fieldDefinition)); } } FieldsWithReflection = fields; ConstantsWithReflection = constants; }
public void FixtureSetup() { fakeList = new List <IField> { Substitute.For <IField>(), Substitute.For <IField>(), Substitute.For <IField>() }; fakeList[0].Number.Returns(0U); fakeList[1].Number.Returns(1U); fakeList[2].Number.Returns(6U); fakeList[0].Color.Returns(FieldColor.Green); fakeList[1].Color.Returns(FieldColor.Red); fakeList[2].Color.Returns(FieldColor.Black); fakeList[0].Parity.Returns(Parity.Neither); fakeList[1].Parity.Returns(Parity.Odd); fakeList[2].Parity.Returns(Parity.Even); fakeFieldFactory = Substitute.For <IFieldFactory>(); fakeFieldFactory.CreateFields().Returns(fakeList); }
public DataTemplate CreateTemplate(FormState formState, DataFormMapperRegion region = DataFormMapperRegion.MainContent) { DataTemplate template = new DataTemplate(); DataFormMappingItem <T> form = new DataFormMappingItem <T>(); switch (region) { case DataFormMapperRegion.MainContent: form = MainContent; break; case DataFormMapperRegion.Header: form = TopContent; break; case DataFormMapperRegion.Footer: form = BottomContent; break; } if (form.GroupCollection.Groups.Any() == false) { return(template); } IFieldFactory collectionFactory = Context.GetFactory <GroupCollectionDescription>(); FactoryContext factoryContext = new FactoryContext(this, formState); FrameworkElementFactory mainGrid = collectionFactory.CreateField(factoryContext, form.GroupCollection); template.VisualTree = mainGrid; return(template); }
public MovesController(GamesRepo gamesRepo, IMapper mapper, IFieldFactory factory) { this.mapper = mapper; this.gamesRepo = gamesRepo; this.factory = factory; }
public void TearDown() { this.factory = null; }
public override FrameworkElementFactory GenerateField(IFactoryContext context, GroupDescription fieldDescription) { FrameworkElementFactory root; root = new FrameworkElementFactory(typeof(DockPanel)); if (fieldDescription.RowSpan != null) { root.SetValue(Grid.RowSpanProperty, fieldDescription.RowSpan.Value); } if (fieldDescription.ColumnSpan != null) { root.SetValue(Grid.ColumnSpanProperty, fieldDescription.ColumnSpan.Value); } if (fieldDescription.DataContext != null) { root.SetBinding(Grid.DataContextProperty, new Binding(fieldDescription.DataContext)); } //group label if (!String.IsNullOrEmpty(fieldDescription.DisplayName)) { FrameworkElementFactory labelGroup = new FrameworkElementFactory(typeof(TextBlock)); labelGroup.SetValue(TextBlock.TextProperty, fieldDescription.DisplayName); labelGroup.SetValue(Control.FontWeightProperty, FontWeights.Bold); labelGroup.SetValue(FrameworkElement.MarginProperty, new Thickness(2)); labelGroup.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center); FrameworkElementFactory borderForLabelGroup = new FrameworkElementFactory(typeof(Grid)); borderForLabelGroup.SetValue(Grid.ColumnProperty, 0); borderForLabelGroup.SetValue(Grid.ColumnSpanProperty, 2); borderForLabelGroup.SetValue(Grid.RowProperty, 0); borderForLabelGroup.SetValue(DockPanel.DockProperty, Dock.Top); borderForLabelGroup.SetValue(Control.HorizontalAlignmentProperty, HorizontalAlignment.Left); borderForLabelGroup.SetValue(Control.VerticalAlignmentProperty, VerticalAlignment.Top); borderForLabelGroup.AppendChild(labelGroup); root.AppendChild(borderForLabelGroup); } int row = 1; FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid)); grid.SetValue(FrameworkElement.MarginProperty, new Thickness(4, 0, 4, 4)); //columns FrameworkElementFactory groupColumnLabel = new FrameworkElementFactory(typeof(ColumnDefinition)); FrameworkElementFactory groupColumnContent = new FrameworkElementFactory(typeof(ColumnDefinition)); groupColumnLabel.SetValue(ColumnDefinition.WidthProperty, GridLength.Auto); grid.AppendChild(groupColumnLabel); grid.AppendChild(groupColumnContent); //group row FrameworkElementFactory rowGroupDefinition = new FrameworkElementFactory(typeof(RowDefinition)); rowGroupDefinition.SetValue(RowDefinition.HeightProperty, GridLength.Auto); grid.AppendChild(rowGroupDefinition); //Properties foreach (FieldDescription property in fieldDescription.FieldDescriptions) { FrameworkElementFactory rowDefinition = new FrameworkElementFactory(typeof(RowDefinition)); if (!property.IsVerticalStretched) { rowDefinition.SetValue(RowDefinition.HeightProperty, GridLength.Auto); } else { } grid.AppendChild(rowDefinition); if (property.DisplayName != null) { //label FrameworkElementFactory label = new FrameworkElementFactory(typeof(TextBlock)); label.SetValue(Grid.ColumnProperty, 0); label.SetValue(Grid.RowProperty, row); label.SetValue(TextBlock.TextProperty, property.DisplayName); label.SetValue(FrameworkElement.MarginProperty, new Thickness(2, 1, 4, 1)); label.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Top); if (property.Visibiliy != null) { IValueConverter converter = property.VisibilityConverter; if (converter == null) { converter = new NotBoolToVisibilityConverter(); } label.SetBinding(FrameworkElement.VisibilityProperty, new Binding(property.Visibiliy) { Converter = converter }); } grid.AppendChild(label); } IFieldFactory factory = context.Mapping.Context.GetFactory(property.GetType()); //PropertyDefinitions FrameworkElementFactory element = factory.CreateField(context, property); element.SetValue(Grid.ColumnProperty, 1); element.SetValue(Grid.RowProperty, row); element.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 0, 0, 1)); if (property.IsEnabled != null) { element.SetValue(FrameworkElement.IsEnabledProperty, property.IsEnabled.Value); } if (property.Visibiliy != null) { IValueConverter converter = property.VisibilityConverter; if (converter == null) { converter = new NotBoolToVisibilityConverter(); } element.SetBinding(FrameworkElement.VisibilityProperty, new Binding(property.Visibiliy) { Converter = converter }); } if (property.DisplayName == null) { element.SetValue(Grid.ColumnProperty, 0); element.SetValue(Grid.ColumnSpanProperty, 2); } element.SetValue(FrameworkElement.HorizontalAlignmentProperty, property.HorizontalAlignment); if (property.Width != null) { element.SetValue(FrameworkElement.WidthProperty, property.Width.Value); element.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left); } if (property.Style != null) { element.SetValue(Control.StyleProperty, property.Style); } grid.AppendChild(element); row++; } root.AppendChild(grid); return(root); }
public BalloonsGameEngine FieldFactory(IFieldFactory fieldFactory) { this.engineContext.FieldFactory = fieldFactory; return this; }
private void PrepareNewGameRound(IFieldFactory fieldFactory, GameDifficulty gameDifficulty) { this.field = fieldFactory.CreateGameField(gameDifficulty); this.field.Filler = this.engineContext.GameFieldFiller; this.field.Fill(); }
public GamesController(IFieldFactory fieldFactory, GamesRepo gamesRepo) { this.fieldFactory = fieldFactory; this.gamesRepo = gamesRepo; }
public FieldModelBinder(IFieldFactory fieldFactory) { this.fieldFactory = fieldFactory; }
public IndexFactory(IFieldFactory fieldFactory) { _fieldFactory = fieldFactory; }
public void SetUp() { this.factory = this.GetFactory(); }
public void SetUp() { _fakeFieldFactory = Substitute.For <IFieldFactory>(); _fakeNumberGen = Substitute.For <IRouletteNumberGenerator>(); }
public Roulette(IFieldFactory fieldFactory, IRandomizer randomizer) { Fields = fieldFactory.CreateFields(); _result = null; _randomizer = randomizer; }
public override FrameworkElementFactory GenerateField(IFactoryContext context, GroupCollectionDescription fieldDescription) { //main control FrameworkElementFactory mainGrid = new FrameworkElementFactory(typeof(Grid)); mainGrid.SetValue(FrameworkElement.MarginProperty, new Thickness(4)); int maxMainColumnIndex = fieldDescription.Groups.Max(x => x.Column); int maxMainRowIndex = fieldDescription.Groups.Max(x => x.Row); //create columns for (int i = 0; i <= maxMainColumnIndex; i++) { FrameworkElementFactory column = new FrameworkElementFactory(typeof(ColumnDefinition)); GroupDescription foundGroup = fieldDescription.Groups.First(x => x.Column == i); if (foundGroup.Width != null) { column.SetValue(ColumnDefinition.WidthProperty, new GridLength(foundGroup.Width.Value)); } else { column.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star)); } mainGrid.AppendChild(column); } //create rows for (int i = 0; i <= maxMainRowIndex; i++) { FrameworkElementFactory row = new FrameworkElementFactory(typeof(RowDefinition)); if (!fieldDescription.Groups.Any(x => x.Row == i && x.FieldDescriptions.Any(p => p.IsVerticalStretched))) { row.SetValue(RowDefinition.HeightProperty, GridLength.Auto); } else { } mainGrid.AppendChild(row); } //Groups by column foreach (var groupsByColumn in fieldDescription.Groups .GroupBy(x => x.Column) .OrderBy(x => x.Key)) { //Groups foreach (var groups in groupsByColumn .GroupBy(x => x.Row) .OrderBy(x => x.Key)) { FrameworkElementFactory stackpanel = null; if (groups.Count() > 1) { stackpanel = new FrameworkElementFactory(typeof(StackPanel)); stackpanel.SetValue(Grid.ColumnProperty, groupsByColumn.Key); stackpanel.SetValue(Grid.RowProperty, groups.Key); stackpanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical); mainGrid.AppendChild(stackpanel); } IFieldFactory groupFactory = context.Mapping.Context.GetFactory <GroupDescription>(); foreach (var group in groups) { FrameworkElementFactory g = groupFactory.CreateField(context, group); g.SetValue(Grid.RowProperty, group.Row); g.SetValue(Grid.ColumnProperty, group.Column); if (group.ColumnSpan.HasValue) { g.SetValue(Grid.ColumnSpanProperty, group.ColumnSpan.Value); } if (groups.Count() > 1) { stackpanel.AppendChild(g); } else { g.SetValue(Grid.ColumnProperty, groupsByColumn.Key); g.SetValue(Grid.RowProperty, groups.Key); mainGrid.AppendChild(g); } } } } return(mainGrid); }
public Roulette(IFieldFactory fieldFactory, IRandom randomizer) { _fields = fieldFactory.CreateFields(); _result = _fields[0]; _random = randomizer; }