Ejemplo n.º 1
0
 public void SetInViewState(string key, object value, object defaultValue)
 {
     if (value == null)
     {
         if (defaultValue != null)
         {
             _viewState[key] = value;
         }
         else
         {
             _viewState.Remove(key);
         }
     }
     else
     {
         if (!value.Equals(defaultValue))
         {
             _viewState[key] = value;
         }
         else
         {
             _viewState.Remove(key);
         }
     }
     _lastKey   = key;
     _lastValue = value;
 }
Ejemplo n.º 2
0
 public static void RemoveFrom(StateBag viewState)
 {
     if (IsIn(viewState))
     {
         viewState.Remove(Key);
     }
 }
Ejemplo n.º 3
0
 public static void RemoveFrom(StateBag viewState)
 {
   if (IsIn(viewState))
   {
     viewState.Remove(Key);
   }
 }
Ejemplo n.º 4
0
        /*
         * internal void Print ()
         * {
         *      Console.WriteLine ("BackColor: {0}", BackColor);
         *      Console.WriteLine ("BorderColor: {0}", BorderColor);
         *      Console.WriteLine ("BorderStyle: {0}", BorderStyle);
         *      Console.WriteLine ("BorderWidth: {0}", BorderWidth);
         *      Console.WriteLine ("CssClass: {0}", CssClass);
         *      Console.WriteLine ("ForeColor: {0}", ForeColor);
         *      Console.WriteLine ("Height: {0}", Height);
         *      Console.WriteLine ("Width: {0}", Width);
         * }
         */

        public virtual void Reset()
        {
            viewstate.Remove("BackColor");
            viewstate.Remove("BorderColor");
            viewstate.Remove("BorderStyle");
            viewstate.Remove("BorderWidth");
            viewstate.Remove("CssClass");
            viewstate.Remove("ForeColor");
            viewstate.Remove("Height");
            viewstate.Remove("Width");
            if (fontinfo != null)
            {
                fontinfo.Reset();
            }
            styles = 0;
            viewstate.Remove(BitStateKey);
            stylesTraked = 0;
        }
 internal void Reset()
 {
     bag.Remove("Font_Bold");
     bag.Remove("Font_Italic");
     bag.Remove("Font_Names");
     bag.Remove("Font_Overline");
     bag.Remove("Font_Size");
     bag.Remove("Font_Strikeout");
     bag.Remove("Font_Underline");
     _owner.RemoveBit((int)Style.Styles.FontAll);
 }
Ejemplo n.º 6
0
        public void StateBag()
        {
            object x = "a";
            x+="a";
            var sb = new StateBag();
            sb.Set(x,"p1",20);
            sb.Set("aa", "p1", 50);
            Assert.AreEqual(20,sb.Get(x,"p1",null));

            // Aa is interned
            Assert.IsTrue(string.IsInterned("aa")!=null);
            Assert.AreEqual(50, sb.Get("aa", "p1", null));

            sb.Remove("aa","p1");
            Assert.IsNull(sb.Get("aa", "p1", null));
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public void StateBag()
        {
            object x = "a";

            x += "a";
            var sb = new StateBag();

            sb.Set(x, "p1", 20);
            sb.Set("aa", "p1", 50);
            Assert.AreEqual(20, sb.Get(x, "p1", null));

            // Aa is interned
            Assert.IsTrue(string.IsInterned("aa") != null);
            Assert.AreEqual(50, sb.Get("aa", "p1", null));

            sb.Remove("aa", "p1");
            Assert.IsNull(sb.Get("aa", "p1", null));
        }
Ejemplo n.º 9
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");
        }
        public void LoadAlreadyIncludedBlocks(StateBag viewState)
        {
            if (OSPage.IsAjaxRequest)
            {
                ArrayList jsKeys = (ArrayList)viewState["JSKeys"];

                if (jsKeys != null)
                {
                    foreach (string key in jsKeys)
                    {
                        GetJavascriptNode(key).AlreadyIncluded = true;
                    }
                }
            }
            else
            {
                viewState.Remove("JSKeys");
            }
        }
Ejemplo n.º 11
0
 public static void Message_Load(Label lbl, StateBag ViewState, String Key)
 {
     if (ViewState[Key] != null)
     {
       lbl.Text = (String)ViewState[Key];
     }
     ViewState.Remove(Key);
 }
 public void Remove(string key)
 {
     viewState.Remove(key);
 }