Stetic.ObjectWrapper.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public virtual void Dispose()
        {
            if (IsDisposed)
                return;

            if (Disposed != null)
                Disposed (this, EventArgs.Empty);
            disposed = true;
            if (frontend != null)
                frontend.Dispose ();
            frontend = null;
            if (wrapped != null)
                wrappers.Remove (GetIndentityObject (wrapped));
            System.Runtime.Remoting.RemotingServices.Disconnect (this);
        }

Usage Example

        internal void LoadDefaultValues()
        {
            // This is a hack because there is no managed way of getting
            // the default value of a GObject property.
            // This method creates an dummy instance of this class and
            // gets the values for their properties. Those values are
            // considered the default

            if (defaultValuesLoaded)
            {
                return;
            }
            defaultValuesLoaded = true;

            object ob = NewInstance(null, false);

            foreach (ItemGroup group in ItemGroups)
            {
                foreach (ItemDescriptor item in group)
                {
                    TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
                    if (prop == null)
                    {
                        continue;
                    }

                    if (!prop.HasDefault)
                    {
                        prop.SetDefault(null);
                    }
                    else
                    {
                        object val = prop.GetValue(ob);
                        prop.SetDefault(val);
                    }
                }
            }
            ObjectWrapper ww = ObjectWrapper.Lookup(ob);

            ww.Dispose();
        }