ModulePropertiesPage.TargetObject Property

Definition

Gets or sets the object that uses configuration names and attributes.

protected:
 property System::Object ^ TargetObject { System::Object ^ get(); void set(System::Object ^ value); };
protected object TargetObject { get; set; }
member this.TargetObject : obj with get, set
Protected Property TargetObject As Object

Property Value

The object that accesses configuration names and attributes.

Examples

The following example uses the TargetObject propety to get and set a custom Microsoft.Web.Management.Client.PropertyGridObject object.

internal class CustomPropertiesInfo : PropertyGridObject {

    private PropertyBag _bag;

    public CustomPropertiesInfo(
        ModulePropertiesPage page,
        PropertyBag bag)
        : base(page) {

        Initialize(bag);
    }

    public CustomPropertiesInfo(
        ModulePropertiesPage page,
        PropertyBag bag,
        bool bRO)
        : base(page, bRO) {

        Initialize(bag);
    }

    internal void Initialize(PropertyBag bag) {
        _bag = bag;
        TrcData();
    }

    bool GetBoolProp(SH.PropInt pi) {

        object o = _bag[pi.Indx];
        if (o == null)
            return false;

        return (bool)o;
    }
//
protected override void ProcessProperties(
    PropertyBag properties) {

    _bag = properties;
    _clone = _bag.Clone(ReadOnly);
    CustomPropertiesInfo info =
        (CustomPropertiesInfo)TargetObject;

    if (info == null) {
        info = new CustomPropertiesInfo(this, _clone);
        TargetObject = info;
    } else {
        info.Initialize(_clone);
    }

    ClearDirty();
}
internal class CustomPropertiesInfo : PropertyGridObject {

    private PropertyBag _bag;

    public CustomPropertiesInfo(
        ModulePropertiesPage page,
        PropertyBag bag)
        : base(page) {

        Initialize(bag);
    }

    public CustomPropertiesInfo(
        ModulePropertiesPage page,
        PropertyBag bag,
        bool bRO)
        : base(page, bRO) {

        Initialize(bag);
    }

    internal void Initialize(PropertyBag bag) {
        _bag = bag;
        TrcData();
    }

    bool GetBoolProp(SH.PropInt pi) {

        object o = _bag[pi.Indx];
        if (o == null)
            return false;

        return (bool)o;
    }

    string GetStrProp(SH.PropInt pi) {

        object o = _bag[pi.Indx];
        if (o == null)
            return String.Empty;

        return (string)o;
    }

    int GetIntProp(SH.PropInt pi) {

        object o = _bag[pi.Indx];
        if (o == null)
            return -1234567;

        return (int)o;
    }

    System.TimeSpan GetTSProp(SH.PropInt pi) {

        object o = _bag[pi.Indx];
        if (o == null)
            return TimeSpan.MinValue;

        return (TimeSpan)o;
    }

    void SetProp(SH.PropInt pi, bool val) {
        _bag[pi.Indx] = val;
    }

    void SetProp(SH.PropInt pi, string val) {
        _bag[pi.Indx] = val;
    }

    void SetProp(SH.PropInt pi, int val) {
        _bag[pi.Indx] = val;
    }

    void SetProp(SH.PropInt pi, TimeSpan val) {
        _bag[pi.Indx] = val;
    }


    /* Add custom props here 
     * Property get/set name is not case sensitive
     * 
     * You can add the attribute [DefaultValue here 
     * but it's does nothing
     */

    public bool BoolProp {
        get {
            return GetBoolProp(SH.boolProp);
        }
        set {
            SetProp(SH.boolProp, value);
        }
    }

    public string strProp {
        get {
            return GetStrProp(SH.strProp);
        }
        set {
            SetProp(SH.strProp, value);
        }
    }

    public string strProp2 {
        get {
            return GetStrProp(SH.strProp2);
        }
        set {
            SetProp(SH.strProp2, value);
        }
    }

    public int intProp {
        get {
            return GetIntProp(SH.intProp);
        }
        set {
            SetProp(SH.intProp, value);
        }
    }

    public System.TimeSpan TSprop {
        get {
            return GetTSProp(SH.TSprop);
        }
        set {
            SetProp(SH.TSprop, value);
        }
    }

Remarks

The configuration object derives from the Microsoft.Web.Management.Client.PropertyGridObject class.

Applies to