Beispiel #1
0
        // this is a wrapper around GetObject designed to
        // reduce the boxing hit
        public Padding GetPadding(int key, out bool found)
        {
            object storedObject = GetObject(key, out found);

            if (found)
            {
                PaddingWrapper wrapper = storedObject as PaddingWrapper;


                if (wrapper != null)
                {
                    return(wrapper.Padding);
                }
#if DEBUG
                else if (storedObject != null)
                {
                    Debug.Fail("Have non-null object that isnt a padding wrapper stored in a padding entry!\r\nDid someone SetObject instead of SetPadding?");
                }
#endif
            }

            // we didnt actually find a non-null padding wrapper.
            found = false;
            return(Padding.Empty);
        }
Beispiel #2
0
        public Padding GetPadding(int key, out bool found)
        {
            object obj2 = this.GetObject(key, out found);

            if (found)
            {
                PaddingWrapper wrapper = obj2 as PaddingWrapper;
                if (wrapper != null)
                {
                    return(wrapper.Padding);
                }
            }
            found = false;
            return(Padding.Empty);
        }
Beispiel #3
0
        public void SetPadding(int key, Padding value)
        {
            bool   flag;
            object obj2 = this.GetObject(key, out flag);

            if (!flag)
            {
                this.SetObject(key, new PaddingWrapper(value));
            }
            else
            {
                PaddingWrapper wrapper = obj2 as PaddingWrapper;
                if (wrapper != null)
                {
                    wrapper.Padding = value;
                }
                else
                {
                    this.SetObject(key, new PaddingWrapper(value));
                }
            }
        }
Beispiel #4
0
        public void SetPadding(int key, Padding value)
        {
            bool   found;
            object storedObject = GetObject(key, out found);

            if (!found)
            {
                SetObject(key, new PaddingWrapper(value));
            }
            else
            {
                PaddingWrapper wrapper = storedObject as PaddingWrapper;
                if (wrapper != null)
                {
                    // re-using the wrapper reduces the boxing hit.
                    wrapper.Padding = value;
                }
                else
                {
                    Debug.Assert(storedObject == null, "object should either be null or PaddingWrapper"); // could someone have SetObject to this key behind our backs?
                    SetObject(key, new PaddingWrapper(value));
                }
            }
        }