Export (0) Print
Expand All

Equals Method

IIS 7.0

Determines whether the specified object is equal to the current ModulePageInfo.

Namespace:  Microsoft.Web.Management.Client
Assembly:  Microsoft.Web.Management (in Microsoft.Web.Management.dll)

public override bool Equals(
	Object obj
)

Parameters

obj
Type: System..::..Object
The object to compare with the current ModulePageInfo object.

Return Value

Type: System..::..Boolean
true if the objects are both ModulePageInfo objects and have some fields with equal values; otherwise, false.

For the objects to be equal, the specified object must be assignable to a ModulePageInfo object and must have the same PageType and Title.

    ModulePageInfo getModPage(string title, string sDesc, Image imgSm,
        Image ImLg, string longDes) 
    {
        return new ModulePageInfo(
        this, typeof(DemoPage), title, sDesc, imgSm, ImLg, longDes);
    }

    ModulePageInfo getModPage(string title) 
    {
        return new ModulePageInfo(this, typeof(DemoPage), title);
    }

    bool imageMatch(object o1, object o2) 
    {
        Image i1 = (Image)o1;
        Image i2 = (Image)o2;

        if (i1 == null && i2 != null ||
            i1 != null && i2 == null
            )
            return false;

        if (i1 != null && i2 != null) 
        {
            bool b = true;
            b = i1.GetHashCode() == i1.GetHashCode();
            if (b == false)
                return b;
        }

        // Both images NULL -> equality.
        return true;
    }

    bool myCompare(ModulePageInfo m1, ModulePageInfo m2) 
    {
        bool b = m1.Equals(m2);
        if (b == false)
            return b;

        b = m1.Description == m2.Description;
        if (b == false)
            return b;

        b = imageMatch(m1.SmallImage, m2.SmallImage);
        if (b == false)
            return b;

        b = imageMatch(m1.LargeImage, m2.LargeImage);
        if (b == false)
            return b;

        b = m1.LongDescription == m2.LongDescription;
        if (b == false)
            return b;

        return b;
    }

    void testModPageEq() 
    {
        string strFirst = "First Title";

        ModulePageInfo modPgInfo1 = getModPage(strFirst);
        ModulePageInfo modPgInfo2 = getModPage(strFirst, "Descrip", 
            rLoadImg.loadImgs("rSmall.bmp"),
            rLoadImg.loadImgs("rLarge.bmp"), "Long Descript");

        // The two show equality here.
        bool bEQ = modPgInfo1.Equals(modPgInfo2);
        Trace.WriteLine("modPgInfo1.Equals(modPgInfo2) : " 
            + bEQ.ToString());

        // A better compare shows they differ.
        bEQ = myCompare(modPgInfo1, modPgInfo2);
        Trace.WriteLine("myCompare(Mod1, Mod2) : " + bEQ.ToString());

    }
}


Community Additions

ADD
Show:
© 2015 Microsoft