当前位置: 首页>>代码示例>>C#>>正文


C# Facade类代码示例

本文整理汇总了C#中Facade的典型用法代码示例。如果您正苦于以下问题:C# Facade类的具体用法?C# Facade怎么用?C# Facade使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Facade类属于命名空间,在下文中一共展示了Facade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: User_should_be_able_to_delete_an_widget_from_page

        public void User_should_be_able_to_delete_an_widget_from_page()
        {
            var facade = default(Facade);
            var profile = default(UserProfile);
            var wiId = default(int);
            var userSetup = default(UserSetup);
            
            "Given a new user".Context(() =>
            {
                profile = MembershipHelper.CreateNewAnonUser();
                facade = new Facade(new AppContext(string.Empty, profile.UserName));

                userSetup = facade.FirstVisitHomeTab(profile.UserName, string.Empty, true, false);
            });

            "When user adds a new page".Do(() =>
            {
                var widgets = facade.GetWidgetInstancesInZoneWithWidget(
                    facade.GetColumnsInTab(userSetup.CurrentTab.ID).First().WidgetZone.ID);

                wiId = widgets.First().Id;
                facade.DeleteWidgetInstance(wiId);
            });

            "It should add a new blank page as current page".Assert(() =>
            {
                var userTabSetup = facade.RepeatVisitHomeTab(profile.UserName, string.Empty, true, false);

                var widgets = facade.GetWidgetInstancesInZoneWithWidget(
                    facade.GetColumnsInTab(userSetup.CurrentTab.ID).First().WidgetZone.ID);

                Assert.Equal(0, widgets.Where(wi => wi.Id == wiId).Count());
            });
        }
开发者ID:modulexcite,项目名称:dropthings,代码行数:34,代码来源:TestWidgetStuff.cs

示例2: AddToShoppingCart

        public ActionResult AddToShoppingCart(int movieId, int amount)
        {
            MakeShoppingCart();
            HttpCookie myCookie = Request.Cookies.Get(CART_NAME);

            ShoppingCart cart = JsonConvert.DeserializeObject<ShoppingCart>(myCookie.Value);

            if (lookInCart(cart,movieId))
            {
                var orderline = cart.Orderline.First(c => c.Movie.Id == movieId);
                orderline.Amount += amount;
            }
            else
            {
                var mov = new Facade().GetMovieGateway().Get(movieId);
                cart.Orderline.Add(new Orderline() { Amount = amount, Movie = mov });
            }

            myCookie.Value = JsonConvert.SerializeObject(cart);

            myCookie.Expires = DateTime.Now.AddDays(PERSISTANCE_TIME); // this will make the cart persist longer.

            this.HttpContext.Response.Cookies.Set(myCookie);
            return RedirectToAction("Index","Home");
            //this should allow you to return nothing, I imagine that this could be useful
            //for JavaScript
            // return null
        }
开发者ID:Xorthos,项目名称:MovieStoreAssignment,代码行数:28,代码来源:CartController.cs

示例3: User_should_be_able_change_page_title

        public void User_should_be_able_change_page_title()
        {
            var facade = default(Facade);
            var profile = default(UserProfile);
            var userSetup = default(UserSetup);
            var newName = Guid.NewGuid().ToString();
            "Given a new user".Context(() =>
            {
                profile = MembershipHelper.CreateNewAnonUser();
                facade = new Facade(new AppContext(string.Empty, profile.UserName));

                userSetup = facade.FirstVisitHomeTab(profile.UserName, string.Empty, true, false);
            });

            "When user changes title of current page".Do(() =>
            {
                facade.ChangeTabName(newName);
            });

            "It should persist and on next visit the new page title should reflect".Assert(() =>
            {
                var userTabSetup = facade.RepeatVisitHomeTab(profile.UserName, string.Empty, true, false);
                Assert.Equal(newName, userTabSetup.CurrentTab.Title);
            });
        }
开发者ID:modulexcite,项目名称:dropthings,代码行数:25,代码来源:TestPageStuff.cs

示例4: Main

        static void Main()
        {
            Facade facade = new Facade();

            facade.MethodA();
            facade.MethodB();
        }
开发者ID:kiko81,项目名称:Teleric-Academy-Homeworks,代码行数:7,代码来源:Program.cs

示例5: Admin_user_can_add_new_widget_and_assign_roles_to_widget

        public void Admin_user_can_add_new_widget_and_assign_roles_to_widget()
        {
            var facade = default(Facade);
            var newWidget = default(Widget);

            "Given an admin user".Context(() =>
                {
                    facade = new Facade(new AppContext(string.Empty, ADMIN_USER));
                });

            "When user adds a new widget and assigns roles to it".Do(() =>
                {
                    newWidget = facade.AddWidget("Test Widget", 
                        "omaralzabir.com", string.Empty, "Test widget", 
                        string.Empty, false, false, 0, "guest", 
                        (int)Enumerations.WidgetType.PersonalTab);
                    facade.AssignWidgetRoles(newWidget.ID, new string[] { GUEST_ROLE });
                });

            "It should be available to the users of that role".Assert(() =>
                {
                    var newUserProfile = MembershipHelper.CreateNewAnonUser();
                    facade.SetUserRoles(newUserProfile.UserName, new string[] { GUEST_ROLE });
                    var widgetsAvailable = facade.GetWidgetList(newUserProfile.UserName, Enumerations.WidgetType.PersonalTab);
                    Assert.Equal(1, widgetsAvailable.Where(w => w.ID == newWidget.ID).Count());
                });
        }
开发者ID:modulexcite,项目名称:dropthings,代码行数:27,代码来源:TestAdminStuff.cs

示例6: Button1_Click

        protected void Button1_Click(object sender, EventArgs e)
        {
            Employee uIEmployee = new Employee();

            uIEmployee.EmployeeFirstName = this.FirstNameTextBox.Text;
            uIEmployee.EmployeeLastName = this.LastNameTextBox.Text;
            uIEmployee.Employeetype = this.EmployeeTypeTextBox.Text;
            uIEmployee.EmployeePhone = this.PhoneTextBox.Text;

            object Class = uIEmployee;
            int ActionType = 1;

            //Facade newFacade = new Facade(uIEmployee, ActionType);
            Facade newFacade = new Facade(Class, ActionType);
            newFacade.ProcessRequest();

            if (Page.IsValid)
            {
                SuccessLabel.Text = "You have successfully registered on the FFR's website";
            }
            else
            {
                SuccessLabel.Text = "Failed to registers on FFR's website, please verify you have entered all necessary information.";
            }
            //deploy project
            //CustomerManager cm = new CustomerManager();
            //cm.Insert(uICustomer);
            /*XmlWriterSettings xmlSetting = new XmlWriterSettings();
            xmlSetting.Indent = true;

            string xmlFileName = "CustomerTest.xml";
            //XmlWriter xmlWriter = XmlWriter.Create("@C:, xmlSetting);

            XmlWriter xmlWriter = XmlWriter..Create(xmlFileName, xmlSetting);

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteComment("This Xml is generated when a customer registers on FFR's site");
            xmlWriter.WriteStartElement("Customer");
            xmlWriter.WriteElementString("ObjectType", "Customer");
            xmlWriter.WriteElementString("ActionType", "1");
            xmlWriter.WriteElementString("FirstName", this.FirstNameTextBox.Text);
            xmlWriter.WriteElementString("LastName", this.LastNameTextBox.Text);
            xmlWriter.WriteElementString("City", this.CityTextBox.Text);
            xmlWriter.WriteElementString("State", this.StateTextBox.Text);
            xmlWriter.WriteElementString("Street", this.StreetTextBox.Text);
            xmlWriter.WriteElementString("Zip", this.StateTextBox.Text);
            xmlWriter.WriteElementString("Phone", this.PhoneTextBox.Text);
            xmlWriter.WriteElementString("Email", this.EmailTextBox.Text);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();

            xmlWriter.Flush();
            xmlWriter.Close();

            Facade newFacade = new Facade(xmlWriter, xmlFileName);
            newFacade.ProcessRequest();
            xmlWriter.Dispose();
            xmlFileName = "";*/
        }
开发者ID:nolsen7187,项目名称:MSSE680_Week8,代码行数:59,代码来源:EmployeeRegistration.aspx.cs

示例7: Movie_add_will_create_new_genre_test

        public void Movie_add_will_create_new_genre_test()
        {
            Facade facade = new Facade();
            Movie temp = new Movie() { Genres = new List<Genre>() { new Genre() {Name = "test" } }, Name = "test", Price = 120d, TrailerURL = "test" };
            temp = facade.GetMovieRepo().Add(temp);

            Assert.AreEqual(facade.GetMovieRepo().Get(temp.Id).Genres.FirstOrDefault().Name, "test");
        }
开发者ID:nordtorp95,项目名称:MovieWebApi,代码行数:8,代码来源:MovieRepositoryTest.cs

示例8: Facade

 static Facade()
 {
     Singleton = new Facade ();
     Singleton.Lies = new Dictionary<Facet, HashSet<Lie>> ();
     foreach (Facet f in Enum.GetValues(typeof(Facet)).Cast<Facet>()) {
         Singleton.Lies[f] = new HashSet<Lie> ();
     }
 }
开发者ID:foxor,项目名称:MorphiumCard,代码行数:8,代码来源:Facade.cs

示例9: Update

 public HttpResponseMessage Update(Identity id, Facade.GroupPut group)
 {
     return ProcessPut(() =>
                        {
                            var instance = group.ToModel();
                            updateGroupCommand.Execute(instance);
                        });
 }
开发者ID:jasondentler,项目名称:Hermes,代码行数:8,代码来源:GroupResource.cs

示例10: LoadWidgets

 private void LoadWidgets()
 {
     using (Facade facade = new Facade(AppContext.GetContext(Context)))
     {
         Widgets.DataSource = facade.GetAllWidgets();
         Widgets.DataBind();
     }
 }
开发者ID:modulexcite,项目名称:dropthings,代码行数:8,代码来源:ManageWidgets.aspx.cs

示例11: GetPdfFailsIdInvoiceIdIsNotValidInteger

        public void GetPdfFailsIdInvoiceIdIsNotValidInteger()
        {
            //Arrange
            var sut = new Facade{Session = SessionMock.Object};

            //Act
            sut.GetPdf("not an integer");
        }
开发者ID:v-kosyak,项目名称:Invoices,代码行数:8,代码来源:ApiFacadeTest.cs

示例12: SaveWidget_Clicked

    protected void SaveWidget_Clicked(object sender, EventArgs e)
    {
        try
        {
            var control = LoadControl(Field_Url.Value);
        }
        catch (Exception x)
        {
            Debug.WriteLine(x.ToString());
            Services.Get<ILogger>().LogException(x);
            Error.Text = x.Message;
            Error.Visible = true;
            return;
        }

        using (Facade facade = new Facade(AppContext.GetContext(Context)))
        {
            var widgetId = int.Parse(Field_ID.Value.Trim());
            if (widgetId == 0)
            {
                var newlyAddedWidget = facade.AddWidget(
                    Field_Name.Value,
                    Field_Url.Value,
                    Field_Icon.Value,
                    Field_Description.Value,
                    Field_DefaultState.Value,
                    Field_IsDefault.Checked,
                    Field_IsLocked.Checked,
                    int.Parse(Field_OrderNo.Value),
                    Field_RoleName.Value,
                    int.Parse(Field_WidgetType.Value));
                
                widgetId = newlyAddedWidget.ID;
                SetWidgetRoles(widgetId);   
                this.EditWidget(newlyAddedWidget);
            }
            else
            {
                facade.UpdateWidget(widgetId,
                    Field_Name.Value,
                    Field_Url.Value,
                    Field_Icon.Value,
                    Field_Description.Value,
                    Field_DefaultState.Value,
                    Field_IsDefault.Checked,
                    Field_IsLocked.Checked,
                    int.Parse(Field_OrderNo.Value),
                    Field_RoleName.Value,
                    int.Parse(Field_WidgetType.Value));

                SetWidgetRoles(widgetId);   
            }

            this.LoadWidgets();
            EditForm.Visible = false;
        }        
    }
开发者ID:modulexcite,项目名称:dropthings,代码行数:57,代码来源:ManageWidgets.aspx.cs

示例13: Create

 public HttpResponseMessage Create(Facade.SubscriptionPost subscription)
 {
     return ProcessPost(()  =>
                        {
                            var instance = subscription.ToModel();
                            createCommand.Execute(instance);
                            return ResourceLocation.OfSubscription(instance.Id.Value);
                        });
 }
开发者ID:jasondentler,项目名称:Hermes,代码行数:9,代码来源:SubscriptionsResource.cs

示例14: Movie_get_by_genre_return_empty_on_no_movies_test

        public void Movie_get_by_genre_return_empty_on_no_movies_test()
        {
            Facade facade = new Facade();
            Genre genre = new Genre() { Name = "test" };
            genre = facade.GetGenreRepo().Add(genre);

            facade = new Facade();
            Assert.AreEqual(facade.GetMovieRepo().GetMovieByGenre(genre).ToList().Count, 0);
        }
开发者ID:nordtorp95,项目名称:MovieWebApi,代码行数:9,代码来源:MovieRepositoryTest.cs

示例15: Create

 public HttpResponseMessage Create(Facade.GroupPost topic)
 {
     return  ProcessPost(() =>
                        {
                            var instance = topic.ToModel();
                            createGroupCommand.Execute(instance);
                            return ResourceLocation.OfGroup(instance.Id.Value);
                        });
 }
开发者ID:wook815,项目名称:Hermes,代码行数:9,代码来源:GroupsResource.cs


注:本文中的Facade类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。