public static StateBag DeserializeStateBag(SerializationReader reader)
        {
            var flags = reader.ReadOptimizedBitVector32();
            var stateBag = new StateBag(flags[StateBagIsIgnoreCase]);

            if (flags[StateBagHasDirtyEntries])
            {
                var count = reader.ReadOptimizedInt32();

                for(var i = 0; i < count; i++)
                {
                    var key = reader.ReadOptimizedString();
                    var value = reader.ReadObject();

            // ReSharper disable PossibleNullReferenceException
                    stateBag.Add(key, value).IsDirty = true;
            // ReSharper restore PossibleNullReferenceException
                }
            }

            if (flags[StateBagHasCleanEntries])
            {
                var count = reader.ReadOptimizedInt32();

                for(var i = 0; i < count; i++)
                {
                    var key = reader.ReadOptimizedString();
                    var value = reader.ReadObject();

                    stateBag.Add(key, value);
                }
            }
            return stateBag;
        }
        public static StateBag DeserializeStateBag(SerializationReader reader)
        {
            var flags    = reader.ReadOptimizedBitVector32();
            var stateBag = new StateBag(flags[StateBagIsIgnoreCase]);

            if (flags[StateBagHasDirtyEntries])
            {
                var count = reader.ReadOptimizedInt32();

                for (var i = 0; i < count; i++)
                {
                    var key   = reader.ReadOptimizedString();
                    var value = reader.ReadObject();

// ReSharper disable PossibleNullReferenceException
                    stateBag.Add(key, value).IsDirty = true;
// ReSharper restore PossibleNullReferenceException
                }
            }

            if (flags[StateBagHasCleanEntries])
            {
                var count = reader.ReadOptimizedInt32();

                for (var i = 0; i < count; i++)
                {
                    var key   = reader.ReadOptimizedString();
                    var value = reader.ReadObject();

                    stateBag.Add(key, value);
                }
            }
            return(stateBag);
        }
Exemplo n.º 3
0
        public static StateBag DeserializeStateBag(SerializationReader reader)
        {
            BitVector32 flags    = reader.ReadOptimizedBitVector32();
            StateBag    stateBag = new StateBag(flags[StateBagIsIgnoreCase]);

            if (flags[StateBagHasDirtyEntries])
            {
                int count = reader.ReadOptimizedInt32();
                for (int i = 0; i < count; i++)
                {
                    string key   = reader.ReadOptimizedString();
                    object value = reader.ReadObject();
                    stateBag.Add(key, value).IsDirty = true;
                }
            }

            if (flags[StateBagHasCleanEntries])
            {
                int count = reader.ReadOptimizedInt32();
                for (int i = 0; i < count; i++)
                {
                    string key   = reader.ReadOptimizedString();
                    object value = reader.ReadObject();
                    stateBag.Add(key, value);
                }
            }
            return(stateBag);
        }
Exemplo n.º 4
0
 public WebPartVerb(string id, WebPartEventHandler serverClickHandler, string clientClickHandler)
 {
     this.id = id;
     this.serverClickHandler = serverClickHandler;
     this.clientClickHandler = clientClickHandler;
     stateBag = new StateBag();
     stateBag.Add("serverClickHandler", serverClickHandler);
     stateBag.Add("clientClickHandler", clientClickHandler);
 }
        public void BtnCopy_Click_Success()
        {
            // Arrange
            InitilizeTestObjects();
            ShimFilter.GetByGroupIDInt32BooleanUserString = (p1, p2, p3, p4) => new List <Filter> {
                new Filter {
                    CreatedDate = new DateTime(), GroupID = 1
                }
            };
            var viewState = new StateBag();

            viewState.Add("SortField", "GroupID");
            viewState.Add("SortDirection", "asc");
            ShimControl.AllInstances.ViewStateGet = (p) => viewState;
            QueryString.Add("GroupID", "1");
            ShimGroupDataFields.GetByGroupIDInt32UserBoolean = (p1, p2, p3) => new List <GroupDataFields> {
                new GroupDataFields {
                }
            };
            var gvFilters = privateObject.GetFieldOrProperty("gvFilters") as GridView;

            gvFilters.DataKeyNames = new string[] { "id" };
            gvFilters.DataSource   = new DataTable {
                Columns = { "id" }, Rows = { { "1" } }
            };
            gvFilters.DataBind();
            gvFilters.Rows[0].Cells[0].Controls.Add(new CheckBox {
                ID = "chkCopyFilter", Checked = true
            });
            ShimFilter.GetByFilterIDInt32User = (p1, p2) => new Filter {
                WhereClause     = "[test]",
                FilterGroupList = new List <FilterGroup> {
                    new FilterGroup {
                        FilterConditionList = new List <FilterCondition> {
                            new FilterCondition {
                            }
                        }
                    }
                }
            };
            ShimGroupDataFields.ExistsStringNullableOfInt32Int32Int32 = (p1, p2, p3, p4) => true;
            var filterSaved = false;

            ShimFilter.SaveFilterUser = (p1, p2) => { filterSaved = true; return(0); };

            // Act
            privateObject.Invoke("btnCopy_Click", new object[] { null, null });

            // Assert
            filterSaved.ShouldBeTrue();
        }
Exemplo n.º 6
0
        public void AddNoIndexAndNoFollowMetaTag()
        {
            if (MetaIncludesPlaceHolder == null)
            {
                return;
            }

            StateBag bag = new StateBag();

            bag.Add("name", "robots");
            bag.Add("content", "noindex, nofollow");

            WebFormHelper.AddMetaTag(new AttributeCollection(bag), MetaIncludesPlaceHolder);
        }
Exemplo n.º 7
0
        internal static int NextTempRecId(StateBag viewState)
        {
            if (viewState["TempRecId"] != null)
            {
                int RecId = Convert.ToInt32(viewState["TempRecId"]) + 1;

                viewState.Add("TempRecId", RecId);
                return(RecId);
            }
            else
            {
                viewState.Add("TempRecId", 1);
                return(1);
            }
        }
        protected void SetUp(String param)
        {
            _shims = ShimsContext.Create();
            var bag = new StateBag();

            bag.Add("_type", ToolButtonType.Checkbox);
            ShimToolButton.AllInstances.GroupNameGet = (x) => "name";
            ShimControl.AllInstances.PageGet         = (x) => new Page();
            ShimControl.AllInstances.ViewStateGet    = (x) => bag;
            if (param.Equals("low"))
            {
                ShimToolBase.AllInstances.BorderWidthGet = (x) => new Unit("4");
            }
            else if (param.Equals("high"))
            {
                ShimToolBase.AllInstances.BorderWidthGet = (x) => new Unit("6");
            }
            else if (param.Equals("equal"))
            {
                ShimToolBase.AllInstances.BorderWidthGet = (x) => new Unit("5");
            }
            ShimToolBase.AllInstances.BorderWidthRollOverGet   = (x) => new Unit("5");
            ShimWebControl.AllInstances.BackColorGet           = (x) => Color.AliceBlue;
            ShimWebControl.AllInstances.BorderColorGet         = (x) => Color.AliceBlue;
            ShimToolBase.AllInstances.BackColorClickedGet      = (x) => Color.AntiqueWhite;
            ShimToolButton.AllInstances.BorderColorRollOverGet = (x) => Color.Aqua;
            ShimToolBase.AllInstances.BackImageGet             = (x) => Image;
            ShimCoreWebControl.AllInstances.ImagesDirectoryGet = (x) => "http://image";
            ShimToolBase.AllInstances.BackImageClickedGet      = (x) => "backImage";
            ShimToolBase.AllInstances.AllowRollOverGet         = (x) => true;
            ShimToolButton.AllInstances.BackImageRollOverGet   = (x) => "roll";
            ShimToolBase.AllInstances.BackColorRollOverGet     = (x) => Color.AliceBlue;
        }
Exemplo n.º 9
0
        public void LoadContentGrid_Success([Values(true, false)] bool isAllFolders)
        {
            // Arrange
            var ContentUserID = _testObject.GetFieldOrProperty("ContentUserID") as DropDownList;

            ContentUserID.Items.Add("1");
            ContentUserID.SelectedValue = "1";
            var cbxAllFoldersContent = _testObject.GetFieldOrProperty("cbxAllFoldersContent") as CheckBox;

            cbxAllFoldersContent.Checked = isAllFolders;
            var ds = new DataSet();

            ds.Tables.Add(new DataTable {
                Columns = { "ContentTitle", "CreatedDate", "UpdatedDate", "ContentTypeCode", "DESC" }, Rows = { { 1, 1 } }
            });
            ShimContent.GetByContentTitleStringNullableOfInt32NullableOfInt32NullableOfInt32NullableOfDateTimeNullableOfDateTimeUserInt32Int32StringStringString =
                (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) => ds;
            var lblTotalNumberOfPagesGroup = _testObject.GetFieldOrProperty("lblTotalNumberOfPagesGroup") as Label;
            var lblTotalRecords            = _testObject.GetFieldOrProperty("lblTotalRecords") as Label;

            lblTotalRecords.Text = "1";
            _stateBag.Add("contentGridPageIndex", "1");

            // Act, Assert
            Should.NotThrow(() => _testObject.Invoke("loadContentGrid", new object[] { 1, 1 }));
            lblTotalNumberOfPagesGroup.Text.ShouldBe("1");
        }
Exemplo n.º 10
0
 public WebPartVerb(string id, string clientHandler)
 {
     this.id = id;
     this.clientClickHandler = clientHandler;
     stateBag = new StateBag();
     stateBag.Add("clientClickHandler", clientHandler);
 }
Exemplo n.º 11
0
        protected void SetUp(String param)
        {
            _pagerBuilder  = new PagerBuilder();
            _privateObject = new PrivateObject(_pagerBuilder);
            var bag = new StateBag();

            bag.Add("_pageSizes", pageSizes);
            _shims = ShimsContext.Create();
            ShimPagerBuilder.AllInstances.RecordCountGet        = (x) => 0;
            ShimPagedControl.AllInstances.NavigationTemplateGet = (x) => navigation;
            ShimControl.AllInstances.ViewStateGet         = (x) => bag;
            ShimPagerBuilder.AllInstances.CurrentIndexGet = (x) => 1;
            if (param.Equals("x"))
            {
                ShimPagerBuilder.AllInstances.CurrentPageGet = (x) => 0;
            }
            else if (param.Equals("y"))
            {
                ShimPagerBuilder.AllInstances.CurrentPageGet = (x) => 5;
            }

            ShimPagerBuilder.AllInstances.PageCountGet           = (x) => 11;
            ShimPagerBuilder.AllInstances.CurrentGroupGet        = (x) => 2;
            ShimPagerBuilder.AllInstances.RecordCountGet         = (x) => 1;
            ShimPagerBuilder.AllInstances.PageSizeGet            = (x) => 0;
            ShimPagedControl.AllInstances.PageSelectorEnabledGet = (x) => true;
        }
        public void LoadLayoutGrid_Success([Values(true, false)] bool isAllFolders)
        {
            // Arrange
            var layoutUserID = _testObject.GetFieldOrProperty("LayoutUserID") as DropDownList;

            layoutUserID.Items.Add("1");
            layoutUserID.SelectedValue = "1";
            var cbxAllFoldersLayout = _testObject.GetFieldOrProperty("cbxAllFoldersLayout") as CheckBox;

            cbxAllFoldersLayout.Checked = isAllFolders;
            var ds = new DataSet();

            ds.Tables.Add(new DataTable {
                Columns = { "LayoutName", "CreatedDate", "UpdatedDate", "ContentTypeCode", "DESC" }, Rows = { { 1, 1 } }
            });
            ShimLayout.GetByLayoutNameStringNullableOfInt32NullableOfInt32Int32NullableOfDateTimeNullableOfDateTimeUserInt32Int32StringStringString =
                (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) => ds;
            var lblTotalNumberOfPagesGroup = _testObject.GetFieldOrProperty("lblTotalNumberOfPagesGroup") as Label;
            var lblTotalRecords            = _testObject.GetFieldOrProperty("lblTotalRecords") as Label;

            lblTotalRecords.Text = "1";
            ShimCustomer.HasProductFeatureInt32EnumsServicesEnumsServiceFeatures = (p1, p2, p3) => true;
            _testObject.SetFieldOrProperty("pnlMessage", new UpdatePanel {
                ID = "1", UpdateMode = UpdatePanelUpdateMode.Conditional
            });
            _stateBag.Add("layoutGridPageIndex", "1");

            // Act, Assert
            Should.NotThrow(() => _testObject.Invoke("loadLayoutsGrid", new object[] { 1, 1 }));
            lblTotalNumberOfPagesGroup.Text.ShouldBe("1");
        }
 /// <summary>
 /// Adds an item to the ViewState.
 /// </summary>
 /// <param name="viewState">ViewState.</param>
 /// <param name="key">Key of the ViewState item.</param>
 /// <param name="value">Value of the ViewState item.</param>
 public static void Add(this StateBag viewState, object key, object value)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     viewState.Add(key.ToString(), value);
 }
		public void CheckStateBagLarge()
		{
			var value = new StateBag();
			for(var i = 0; i < 1000; i++)
			{
				value.Add(i.ToString(), new Triplet(i, i.ToString(), i * i));
			}
			CheckValue(-2, 13734, value, new StateBagComparer());
		}
        private void InitTestSetSelectedGroup(int groupId, bool addMatchedGroupId = true)
        {
            InitCommonShimForTestGroupExplorer();
            ShimgroupExplorer.AllInstances.DataBindSelected = (p) => { };
            ShimGroup.GetByGroupID_NoAccessCheckInt32       = (id) => new CommunicatorEntites.Group()
            {
                GroupID   = groupId,
                GroupName = "groupName"
            };
            var groupList = new List <GroupObject>();

            _viewState.Add("SelectedTestGroups_List", groupList);
            groupList.Add(new GroupObject()
            {
                GroupID = addMatchedGroupId
                ? groupId
                : groupId + 10,
                filters = new List <CommunicatorEntites.CampaignItemBlastFilter>()
            });
        }
 // Implement the SaveViewState method. If the StateBag
 // that stores the MyItem class's view state contains
 // a value for the message property and if the value
 // has changed since the TrackViewState method was last
 // called, all view state for this class is deleted,
 // using the StateBag.Clear method,and the new value is added.
 object IStateManager.SaveViewState()
 {
     // Check whether the message property exists in
     // the ViewState property, and if it does, check
     // whether it has changed since the most recent
     // TrackViewState method call.
     if (!((IDictionary)_viewstate).Contains("message") || _viewstate.IsItemDirty("message"))
     {
         _viewstate.Clear();
         // Add the _message property to the StateBag.
         _viewstate.Add("message", _message);
     }
     return(((IStateManager)_viewstate).SaveViewState());
 }
Exemplo n.º 17
0
        public void Deny_Unrestricted()
        {
            StateBag bag = new StateBag(true);

            Assert.IsNotNull(bag.Add("key", "value"), "Add");
            Assert.AreEqual(1, bag.Count, "Count");
            Assert.IsNotNull(bag.GetEnumerator(), "GetEnumerator");
            bag.SetItemDirty("key", true);
            Assert.IsTrue(bag.IsItemDirty("key"), "IsItemDirty");
            bag.Remove("key");

            bag.Clear();
            bag["key"] = "value";
            Assert.IsNotNull(bag["key"], "this[string]");
            Assert.IsNotNull(bag.Keys, "Keys");
            Assert.IsNotNull(bag.Values, "Values");
            bag.SetDirty(true);
        }
Exemplo n.º 18
0
        void FillStyle(string s)
        {
            int mark = s.IndexOf(':');

            if (mark == -1)
            {
                return;
            }

            string key = s.Substring(0, mark).Trim();

            if (mark + 1 > s.Length)
            {
                return;
            }

            string fullValue = s.Substring(mark + 1);

            if (fullValue == "")
            {
                return;
            }

            mark = fullValue.IndexOf(';');

            string value;

            if (mark == -1)
            {
                value = fullValue.Trim();
            }
            else
            {
                value = fullValue.Substring(0, mark).Trim();
            }

            style.Add(key, value);
            if (mark + 1 > fullValue.Length)
            {
                return;
            }

            FillStyle(fullValue.Substring(mark + 1));
        }
Exemplo n.º 19
0
        public void IDictionary_Deny_Unrestricted()
        {
            IDictionary d = new StateBag();

            d.Add("key", "value");
            Assert.IsTrue(d.Contains("key"), "Contains");
            Assert.AreEqual(1, d.Count, "Count");
            d.Remove("key");
            d["key"] = "value";
            Assert.AreEqual("value", d["key"], "this[string]");
            d.Clear();
            Assert.IsFalse(d.IsFixedSize, "IsFixedSize");
            Assert.IsFalse(d.IsReadOnly, "IsReadOnly");

            ICollection c = (d as ICollection);

            Assert.IsFalse(c.IsSynchronized, "IsSynchronized");
            Assert.IsNotNull(c.SyncRoot, "SyncRoot");
        }
Exemplo n.º 20
0
 private void Initialize()
 {
     _viewState = new StateBag();
     _viewState.Add("gSortField", DummyString);
     _viewState.Add("gSortDirection", DummyString);
     _viewState.Add("gCurrentPage", One);
     _viewState.Add("gTotalPages", One);
     _viewState.Add("gCurrentPage", One);
     _viewState.Add("gPageSize", One);
     ReflectionHelper.SetField(_testEntity, "Addresses", new TextBox {
         Text = DummyString
     });
     ReflectionHelper.SetField(_testEntity, "FormatTypeCode", new DropDownList
     {
         Items =
         {
             new ListItem
             {
                 Selected = true,
                 Value    = DummyString
             }
         }
     });
 }
 public StateItem Add(string key, object value)
 {
     return(viewState.Add(key, value));
 }
Exemplo n.º 22
0
        private void InitTestBtnSaveFilter(string suppressOrSelect, int groupId, string selectedFilterType, bool selectBlastId = true, bool addMatchedGroupId = true)
        {
            InitCommonShim();
            ShimgroupExplorer.AllInstances.SuppressOrSelectGet      = (p) => suppressOrSelect;
            ShimgroupExplorer.AllInstances.blastLicenseCount_Update = (p) => { };
            ShimgroupExplorer.AllInstances.DataBindSelected         = (p) => { };
            ShimgroupExplorer.AllInstances.DataBindSuppression      = (p) => { };
            _privateGroupExplorerObj.SetFieldOrProperty("_GroupID", BindingFlags.Static | BindingFlags.NonPublic, groupId);
            var rbFilterType = Get <RadioButtonList>(_privateGroupExplorerObj, RBlFilterTypeId);

            rbFilterType.Items.Add(new ListItem("smart", "smart"));
            rbFilterType.Items.Add(new ListItem("custom", "custom"));
            rbFilterType.SelectedValue = selectedFilterType;
            var ddlSmartSegment = Get <DropDownList>(_privateGroupExplorerObj, DDLSmartSegmentId);

            ddlSmartSegment.Items.Add(new ListItem("1000", "1000")
            {
                Selected = true
            });
            var lstBlast = Get <ListBox>(_privateGroupExplorerObj, LSTboxBlastId);

            lstBlast.Items.Add(new ListItem("1", "1")
            {
                Selected = selectBlastId
            });
            lstBlast.Items.Add(new ListItem("2", "2")
            {
                Selected = selectBlastId
            });
            var lstAvailableFilters = Get <ListBox>(_privateGroupExplorerObj, LSTboxAvailableFiltersId);

            lstAvailableFilters.Items.Add(new ListItem("1", "1")
            {
                Selected = true
            });
            lstAvailableFilters.Items.Add(new ListItem("2", "2")
            {
                Selected = true
            });
            var groupList = new List <GroupObject>()
            {
                new GroupObject()
                {
                    GroupID = addMatchedGroupId ?  groupId : 333,
                    filters = new List <CommunicatorEntites.CampaignItemBlastFilter>()
                    {
                        new CommunicatorEntites.CampaignItemBlastFilter()
                        {
                            FilterID       = 10,
                            SmartSegmentID = 10,
                            RefBlastIDs    = "RefBlastIDs"
                        }
                    }
                },
                new GroupObject()
                {
                    GroupID = 555,
                    filters = new List <CommunicatorEntites.CampaignItemBlastFilter>()
                    {
                        new CommunicatorEntites.CampaignItemBlastFilter()
                        {
                            FilterID       = 20,
                            SmartSegmentID = 20,
                            RefBlastIDs    = "RefBlastIDs"
                        }
                    }
                }
            };

            _viewState.Add("SelectedGroups_List", groupList);
            _viewState.Add("SupressionGroups_List", groupList);
            _viewState.Add("SelectedTestGroups_List", groupList);
        }
 // The constructor for the MyItem class.
 public MyItem(string mesg)
 {
     _message   = mesg;
     _viewstate = new StateBag();
     _viewstate.Add("message", _message);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="dataObjectTypeName">The data object type name.</param>
 public DataObjectColumnCollection(string dataObjectTypeName)
 {
     _dataObjectTypeName = dataObjectTypeName;
     _viewstate          = new StateBag();
     _viewstate.Add("dataObjectTypeName", dataObjectTypeName);
 }
Exemplo n.º 25
0
 private void SetSortingFields(string sortingField, string sortingDirection)
 {
     _viewState.Add("SortField", sortingField);
     _viewState.Add("SortDirection", sortingDirection);
 }