本文整理匯總了C#中Bar.HasEqualParameters方法的典型用法代碼示例。如果您正苦於以下問題:C# Bar.HasEqualParameters方法的具體用法?C# Bar.HasEqualParameters怎麽用?C# Bar.HasEqualParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bar
的用法示例。
在下文中一共展示了Bar.HasEqualParameters方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Run
public static void Run()
{
// test config panel
var bar = new Bar() { C = "sub" };
var foo = new Foo() { C = "c", D = true, E = 2.0, F = 2, G = bar };
var config = new ConfigurationPanel(foo);
var copy = config.GetConfiguredObject() as Foo;
if (!bar.HasEqualParameters(copy.G))
throw new Exception("Sub-object comparison failed!");
foo.G = copy.G = null;
if (!foo.HasEqualParameters(copy))
throw new Exception("Main object comparison failed!");
var fprop = typeof(Foo).GetProperty("F");
config.SetterFor(fprop)(200);
if ((int)config.GetterFor(fprop)() != 200)
throw new Exception("Getter or setter failed!");
config.PropertyChanged += (args) =>
{
if (args.Property != fprop)
return;
if ((int)args.Getter() > 150)
args.Setter((int)args.Getter() - 2);
};
config.SetterFor(fprop)(190);
if ((int)config.GetterFor(fprop)() != 150)
throw new Exception("PropertyChanged failed!");
// test derived type panel
var derivedConfig = new DerivedTypeConfigurationPanel(typeof(Interface), bar);
if (!new Bar() { C = "sub" }.HasEqualParameters((Bar)derivedConfig.GetConfiguredObject()))
throw new Exception("DerivedTypeConfigurationPanel failed!");
var diffBar = new Bar() { C = "different" };
derivedConfig.SetConfiguredObject(diffBar);
if (!diffBar.HasEqualParameters((Bar)derivedConfig.GetConfiguredObject()))
throw new Exception("SetConfiguredObject failed!");
}