protected void Page_Load(object sender, EventArgs e) { AutoFactory<Sponsor> spnFac = new AutoFactory<Sponsor>(); rptSponsors.DataSource = spnFac.GetAllEntities(); rptSponsors.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory <Company> companyFac = new AutoFactory <Company>(); rptLookingForPartner.DataSource = companyFac.GetAllEntities().FindAll(x => x.CompanyAcceptWork == true); rptLookingForPartner.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory <TeamMember> teamFac = new AutoFactory <TeamMember>(); rptTeam.DataSource = teamFac.GetAllEntities(); rptTeam.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory <Sponsor> spnFac = new AutoFactory <Sponsor>(); rptSponsors.DataSource = spnFac.GetAllEntities(); rptSponsors.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory<Company> companyFac = new AutoFactory<Company>(); rptLookingForPartner.DataSource = companyFac.GetAllEntities().FindAll(x => x.CompanyAcceptWork == true); rptLookingForPartner.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory<TeamMember> teamFac = new AutoFactory<TeamMember>(); rptTeam.DataSource = teamFac.GetAllEntities(); rptTeam.DataBind(); }
public void MyMemberDataTest(string carName, IAuto expectedCar) { var _service = new AutoFactory(); var actualCar = _service.GetInstance(carName); Assert.Equal(expectedCar, actualCar); }
/// <inheritdoc /> public IAmqpResourceManager CreateResourceManager() { this.InitializeIfRequired(); using var auto = new AutoFactory <ResourceManager>(() => new ResourceManager(this.CreateQueueManager(), this.CreateExchangeManager(), this.Logger.Create("ResourceManager"))); return(auto.Return()); }
/// <inheritdoc /> public IAmqpConsumerManager <IBasicConsumer> CreateConsumerManager() { this.InitializeIfRequired(); using var auto = new AutoFactory <ConsumerManager>(() => new ConsumerManager(this.defaultChannelConfiguration, this.rabbitMQConnection.CreateModel(), this.Logger.Create("ConsumerManager"))); return(auto.Return()); }
/// <inheritdoc /> public IAmqpPublisher CreatePublishManager(ChannelConfiguration channelConfiguration) { this.InitializeIfRequired(); using var auto = new AutoFactory <RabbitPublisher>(() => new RabbitPublisher(channelConfiguration, this.rabbitMQConnection.CreateModel(), this.Logger.Create("PublishManager"))); return(auto.Return()); }
public void Create_BMW() { var factory = new AutoFactory(); var auto = factory.CreateInstance("bmw"); Assert.Equal("BMW On", auto.TurnOn); Assert.Equal("BMW Off", auto.TurnOff); }
public void Create_Mini() { var factory = new AutoFactory(); var auto = factory.CreateInstance("mini"); Assert.Equal("Mini On", auto.TurnOn); Assert.Equal("Mini Off", auto.TurnOff); }
/// <inheritdoc /> public IAmqpQueueManager CreateQueueManager() { this.InitializeIfRequired(); using var auto = new AutoFactory <QueueManager>(() => new QueueManager(this.defaultChannelConfiguration, this.rabbitMQConnection.CreateModel(), this.Logger.Create("Channel"))); return(auto.Return()); }
public void LoadTypes_LoadsAllAvailableIAutos() { //arrange && act AutoFactory autoFactory = new AutoFactory(); //assert autoFactory.Automobiles.Should().HaveCount(7); }
public void Create_NullAuto_For_Missing_Auto() { var factory = new AutoFactory(); var auto = factory.CreateInstance("foo"); Assert.Empty(auto.TurnOn); Assert.Empty(auto.TurnOff); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory<Company> companyFac = new AutoFactory<Company>(); List<Company> allCompanies = companyFac.GetAllEntities(); rptCompanies.DataSource = allCompanies; rptCompanies.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory <Company> companyFac = new AutoFactory <Company>(); List <Company> allCompanies = companyFac.GetAllEntities(); rptCompanies.DataSource = allCompanies; rptCompanies.DataBind(); }
public void TestVersion02(string carName) { AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); }
public void Init() { var inventories = new Inventory(GetJObjectByPath(Config.InventoryPath)); Logger.Log($"Inventory loaded: {inventories.Stocks.Count} unique components"); var recipes = new Recipe(GetJObjectByPath(Config.RecipesPath)); Logger.Log($"Recipes loaded: {recipes.Recipes.Count} total"); AutoFactory = new AutoFactory(inventories, recipes, Logger); }
static void Main(string[] args) { string carName = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); Console.ReadLine(); }
public void CreateInstance_GivenASpecificCarName_ReturnsTheAppropriateIAutoInstance(string carName, Type expectedCarType) { //arrange AutoFactory autoFactory = new AutoFactory(); //act IAuto actualCar = autoFactory.CreateInstance(carName); //assert actualCar.Should().BeOfType(expectedCarType); }
public static void InitializeReflectionDemo() { string carCommand = Console.ReadLine(); AutoFactory factory = new AutoFactory(); IAuto car = factory.CreateInstance(carCommand); car.TurnOn(); car.TurnOff(); }
static void Main(string[] args) { string carName = args[0]; var factory = new AutoFactory(); IAuto car = factory.CreateInstance(carName); car.TurnOn(); car.TurnOff(); }
public Member Login(string email, string password) { string SQL = $"SELECT * FROM Member WHERE Email='{email}'"; Member member = SqlQuery(SQL); if (member?.Password == AutoFactory.GenerateSaltedPassword(member.Token, password)) { return(member); } return(new Member()); }
public ActionResult CreateUser(Member member) { if (!context.MemberFactory.ExistsBy("Email", member.Email)) { member.MemberRoleID = 1; member = context.MemberFactory.Insert(member); member.Password = AutoFactory.GenerateSaltedPassword(member.Token, member.Password); context.MemberFactory.Update(member); return(RedirectToAction("Login")); } ViewBag.CreateMemberError = true; return(View(member)); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory <Facility> facilityFac = new AutoFactory <Facility>(); Facility f = facilityFac.GetLatest("FacilityID", AutoFactory <Facility> .OrderBy.ASC); imgFacImage1.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageOne); imgFacImage2.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageTwo); imgFacImage3.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageThree); imgFacImage4.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageFour); litFacText.Text = f.Text; litFacAddress.Text = f.Address; }
protected void Page_Load(object sender, EventArgs e) { AutoFactory<Facility> facilityFac = new AutoFactory<Facility>(); Facility f = facilityFac.GetLatest("FacilityID", AutoFactory<Facility>.OrderBy.ASC); imgFacImage1.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageOne); imgFacImage2.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageTwo); imgFacImage3.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageThree); imgFacImage4.ImageUrl = string.Format("~/Images/Facilities/{0}", f.ImageFour); litFacText.Text = f.Text; litFacAddress.Text = f.Address; }
// The idea behind the abstract factory pattern is to delegate the creation of a family of objects // to another class so that the client does not need to deal with that responsibility. // A family of objects can be books and publishers or motorbikes and scooters //Client //This is a class which use AbstractFactory and AbstractProduct interfaces to create a family of related objects. //AbstractFactory //This is an interface which is used to create abstract product //ConcreteFactory //This is a class which implements the AbstractFactory interface to create concrete products. //AbstractProduct //This is an interface which declares a type of product. //ConcreteProduct //This is a class which implements the AbstractProduct interface to create product. // First we need to create the abstract product and concrete products // Then we create the abstract factory and concrete factories. // And finally implement everything into the client. static void Main(string[] args) { // Not always necessary to create a producer/client. #region Game Example // Alternative to this would be to create a factory for flying and walking. NPCFactory enemyFactory = NPCFactoryProducer.Producer("EmenyFactory"); var flyingEnemy = enemyFactory.GetEnemy(EnemyTypes.Flying); NPCFactory friendlyFactory = NPCFactoryProducer.Producer("FriendlyFactory"); var walkingFriendly = friendlyFactory.GetFriendly(FriendlyTypes.Walking); flyingEnemy.Attack(); walkingFriendly.Move(); #endregion #region Car Example // Class can be configured in the config file or property settings. var fordFactory = CarProducer.ProduceFactory(); var fordSedan = fordFactory.CreateSedan(); var fordCoupe = fordFactory.CreateCoupe(); #endregion #region Auto IAutoFactory fac = AutoFactory.ProduceFactory(); var car = fac.CreateSportsCar(); car.TurnOn(); car.TurnOff(); car = fac.CreateLuxuryCar(); car.TurnOn(); car.TurnOff(); car = fac.CreateEconomyCar(); car.TurnOn(); car.TurnOff(); #endregion Console.ReadKey(); }
protected void btnLogin_Click(object sender, EventArgs e) { string email = txbEmail.Text; string password = txbPassword.Text; AutoFactory <User> userFac = new AutoFactory <User>(); User u = userFac.GetEntity(string.Format("SELECT * FROM tblUser WHERE fldUserEmail='{0}' AND fldUserPassword='******'", email, password)); if (u == null || u.UserRole == 0) { lblErrorMessage.Text = "Wrong username or password"; } else { Session["user"] = u; Response.Redirect("Default.aspx"); } }
protected void btnLogin_Click(object sender, EventArgs e) { string email = txbEmail.Text; string password = txbPassword.Text; AutoFactory<User> userFac = new AutoFactory<User>(); User u = userFac.GetEntity(string.Format("SELECT * FROM tblUser WHERE fldUserEmail='{0}' AND fldUserPassword='******'", email, password)); if (u == null || u.UserRole == 0) { lblErrorMessage.Text = "Wrong username or password"; } else { Session["user"] = u; Response.Redirect("Default.aspx"); } }
void PopulateDropDownLists() { if (!IsPostBack) { AutoFactory<UserRole> roleFac = new AutoFactory<UserRole>(); ddlUserRole.DataSource = roleFac.GetAllEntities(); ddlUserRole.DataTextField = "RoleName"; ddlUserRole.DataValueField = "UserRoleID"; ddlUserRole.DataBind(); ddlUserRole.Items.Insert(0, "Select"); AutoFactory<Company> companyFac = new AutoFactory<Company>(); ddlAssignedCompany.DataSource = companyFac.GetAllEntities(); ddlAssignedCompany.DataTextField = "CompanyName"; ddlAssignedCompany.DataValueField = "CompanyID"; ddlAssignedCompany.DataBind(); ddlAssignedCompany.Items.Insert(0, "Select"); } }
void PopulateDropDownLists() { if (!IsPostBack) { AutoFactory <UserRole> roleFac = new AutoFactory <UserRole>(); ddlUserRole.DataSource = roleFac.GetAllEntities(); ddlUserRole.DataTextField = "RoleName"; ddlUserRole.DataValueField = "UserRoleID"; ddlUserRole.DataBind(); ddlUserRole.Items.Insert(0, "Select"); AutoFactory <Company> companyFac = new AutoFactory <Company>(); ddlAssignedCompany.DataSource = companyFac.GetAllEntities(); ddlAssignedCompany.DataTextField = "CompanyName"; ddlAssignedCompany.DataValueField = "CompanyID"; ddlAssignedCompany.DataBind(); ddlAssignedCompany.Items.Insert(0, "Select"); } }
protected void Page_Load(object sender, EventArgs e) { AutoFactory<News> newsFac = new AutoFactory<News>(); AutoFactory<Home> homeFac = new AutoFactory<Home>(); AutoFactory<Company> companyFac = new AutoFactory<Company>(); List<News> allNews = newsFac.GetAllEntities(); rptNewsSlider.DataSource = allNews; rptNewsSlider.DataBind(); Home h = homeFac.GetEntityByID(1); litHomeText.Text = h.HomeText; List<Company> allCompanies = companyFac.GetAllEntities(); Random rnd = new Random(); rptRandom3Companies.DataSource = allCompanies.OrderBy(x => rnd.Next()).Take(3); rptRandom3Companies.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AutoFactory <News> newsFac = new AutoFactory <News>(); AutoFactory <Home> homeFac = new AutoFactory <Home>(); AutoFactory <Company> companyFac = new AutoFactory <Company>(); List <News> allNews = newsFac.GetAllEntities(); rptNewsSlider.DataSource = allNews; rptNewsSlider.DataBind(); Home h = homeFac.GetEntityByID(1); litHomeText.Text = h.HomeText; List <Company> allCompanies = companyFac.GetAllEntities(); Random rnd = new Random(); rptRandom3Companies.DataSource = allCompanies.OrderBy(x => rnd.Next()).Take(3); rptRandom3Companies.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int companyID = Convert.ToInt32(Request.QueryString["CompanyID"]); if (companyID < 1) { Response.Redirect("ErrorSite.aspx"); return; } AutoFactory<Company> companyFac = new AutoFactory<Company>(); Company c = companyFac.GetEntityByID(companyID); CompaniesINDHeader.Style.Add("background-image", string.Format("./Images/Company/{0}/{1}", c.CompanyName, c.CompanyImageBannerURL)); imgCompanyImageURL.ImageUrl = string.Format("./Images/Company/{0}/{1}", c.CompanyName, c.CompanyImageURL); lblCompanyName.Text = c.CompanyName; lblCompanyDescription.Text = c.CompanyDescription.Replace("\n", "<br />"); AutoFactory<Product> productFac = new AutoFactory<Product>(); List<Product> companyProducts = new List<Product>(productFac.GetAllEntities().FindAll(x => x.CompanyID == c.CompanyID)); rptOurProducts.DataSource = companyProducts; rptOurProducts.DataBind(); }
public ActionResult Get(string carName) { try { AutoFactory autoFactory = new AutoFactory(); ApiResult result = new ApiResult(); IAutoFactory factory = autoFactory.LoadFactory(carName); if (factory is UnknownCarFactory) { return(NotFound()); } Creational.FactoryMethod.After.Autos.IAuto car = factory.CreateAutomobile(); result.CarName = car.Name; result.Color = car.GetColor(); result.Year = car.GetYear(); return(Ok(result)); } catch (Exception ex) { _logger.LogError(ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
static void Main(string[] args) { CocoLib.Logging.Functions.Directory = "C:\\Users\\Zach\\Desktop\\Log.txt"; AutoInstruction instruction = new AutoInstruction(); Scalar command1 = new Scalar() { Distance = new Distance() { Amount = 10, Unit = LinearUnit.Feet }, Type = CommandType.Drive }; instruction.Commands.Add(command1); instruction.Save("C:\\Users\\Zach\\Desktop\\Auto\\AutoRed1.json"); string prefix = "C:\\Users\\Zach\\Desktop\\Auto\\"; DirectoryListing listing = new DirectoryListing() { AutoBlue1 = prefix + "AutoBlue1.json", AutoBlue2 = prefix + "AutoBlue2.json", AutoBlue3 = prefix + "AutoBlue3.json", AutoBlue4 = prefix + "AutoBlue4.json", AutoRed1 = prefix + "AutoRed1.json", AutoRed2 = prefix + "AutoRed2.json", AutoRed3 = prefix + "AutoRed3.json", AutoRed4 = prefix + "AutoRed4.json", Test = prefix + "Test.json" }; AutoFactory autoFactory = new AutoFactory(listing); autoFactory.RunAuto(AutoFactory.AutoModes.Red1); }
protected void Page_Load(object sender, EventArgs e) { int companyID = Convert.ToInt32(Request.QueryString["CompanyID"]); if (companyID < 1) { Response.Redirect("ErrorSite.aspx"); return; } AutoFactory <Company> companyFac = new AutoFactory <Company>(); Company c = companyFac.GetEntityByID(companyID); CompaniesINDHeader.Style.Add("background-image", string.Format("./Images/Company/{0}/{1}", c.CompanyName, c.CompanyImageBannerURL)); imgCompanyImageURL.ImageUrl = string.Format("./Images/Company/{0}/{1}", c.CompanyName, c.CompanyImageURL); lblCompanyName.Text = c.CompanyName; lblCompanyDescription.Text = c.CompanyDescription.Replace("\n", "<br />"); AutoFactory <Product> productFac = new AutoFactory <Product>(); List <Product> companyProducts = new List <Product>(productFac.GetAllEntities().FindAll(x => x.CompanyID == c.CompanyID)); rptOurProducts.DataSource = companyProducts; rptOurProducts.DataBind(); }
public void Build(string recipe, int qty) { AutoFactory.Build(recipe, qty); }