コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AutoFactory<Sponsor> spnFac = new AutoFactory<Sponsor>();

        rptSponsors.DataSource = spnFac.GetAllEntities();
        rptSponsors.DataBind();
    }
コード例 #2
0
    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();
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AutoFactory <TeamMember> teamFac = new AutoFactory <TeamMember>();

        rptTeam.DataSource = teamFac.GetAllEntities();
        rptTeam.DataBind();
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AutoFactory <Sponsor> spnFac = new AutoFactory <Sponsor>();

        rptSponsors.DataSource = spnFac.GetAllEntities();
        rptSponsors.DataBind();
    }
コード例 #5
0
    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();
    }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AutoFactory<TeamMember> teamFac = new AutoFactory<TeamMember>();

        rptTeam.DataSource = teamFac.GetAllEntities();
        rptTeam.DataBind();
    }
コード例 #7
0
        public void MyMemberDataTest(string carName, IAuto expectedCar)
        {
            var _service  = new AutoFactory();
            var actualCar = _service.GetInstance(carName);

            Assert.Equal(expectedCar, actualCar);
        }
コード例 #8
0
        /// <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());
        }
コード例 #9
0
        /// <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());
        }
コード例 #10
0
        /// <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());
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        /// <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());
        }
コード例 #14
0
        public void LoadTypes_LoadsAllAvailableIAutos()
        {
            //arrange && act
            AutoFactory autoFactory = new AutoFactory();

            //assert
            autoFactory.Automobiles.Should().HaveCount(7);
        }
コード例 #15
0
        public void Create_NullAuto_For_Missing_Auto()
        {
            var factory = new AutoFactory();
            var auto    = factory.CreateInstance("foo");

            Assert.Empty(auto.TurnOn);
            Assert.Empty(auto.TurnOff);
        }
コード例 #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AutoFactory<Company> companyFac = new AutoFactory<Company>();

        List<Company> allCompanies = companyFac.GetAllEntities();

        rptCompanies.DataSource = allCompanies;
        rptCompanies.DataBind();
    }
コード例 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AutoFactory <Company> companyFac = new AutoFactory <Company>();

        List <Company> allCompanies = companyFac.GetAllEntities();

        rptCompanies.DataSource = allCompanies;
        rptCompanies.DataBind();
    }
コード例 #18
0
        public void TestVersion02(string carName)
        {
            AutoFactory factory = new AutoFactory();

            IAuto car = factory.CreateInstance(carName);

            car.TurnOn();
            car.TurnOff();
        }
コード例 #19
0
ファイル: App.cs プロジェクト: hyan36/FactoryCoding
        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);
        }
コード例 #20
0
        static void Main(string[] args)
        {
            string      carName = Console.ReadLine();
            AutoFactory factory = new AutoFactory();
            IAuto       car     = factory.CreateInstance(carName);

            car.TurnOn();
            car.TurnOff();
            Console.ReadLine();
        }
コード例 #21
0
        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();
        }
コード例 #23
0
        static void Main(string[] args)
        {
            string carName = args[0];

            var factory = new AutoFactory();

            IAuto car = factory.CreateInstance(carName);

            car.TurnOn();

            car.TurnOff();
        }
コード例 #24
0
        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());
        }
コード例 #25
0
 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));
 }
コード例 #26
0
    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;
    }
コード例 #27
0
    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;
    }
コード例 #28
0
        // 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();
        }
コード例 #29
0
    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");
        }
    }
コード例 #30
0
    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");
        }
    }
コード例 #31
0
 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");
     }
 }
コード例 #32
0
 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");
     }
 }
コード例 #33
0
    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();
    }
コード例 #34
0
    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();
    }
コード例 #35
0
    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();

    }
コード例 #36
0
 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));
     }
 }
コード例 #37
0
        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);
        }
コード例 #38
0
    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();
    }
コード例 #39
0
ファイル: App.cs プロジェクト: hyan36/FactoryCoding
 public void Build(string recipe, int qty)
 {
     AutoFactory.Build(recipe, qty);
 }