static void tstHiding() { //The differences in behavior between Overrider and Hider are demonstrated in the following code: Overrider over = new Overrider(); BaseClass b1 = over; over.Foo(); // Overrider.Foo b1.Foo(); // Overrider.Foo Hider h = new Hider(); BaseClass b2 = h; h.Foo(); // Hider.Foo b2.Foo(); // BaseClass.Foo }
public static void exception_raised_from_inherited_virtual() { var obj = new Overrider(); Test.AssertRaises <Efl.EflException>(obj.CallChildrenRaiseError); }
public Delete OverrideCanDelete(Overrider <Func <T, string> > overrider) { this.CanDelete = overrider(this.CanDelete ?? (t => null)); return(this); }
public void OverrideDelete(Overrider <Action <T, object[]> > overrider) { this.Delete = overrider(this.Delete); }
public void OverrideExecute(Overrider <Action <T, object[]> > overrider) { this.Execute = overrider(this.Execute); }
public void OverrideConstruct(Overrider <Func <object[], T> > overrider) { this.Construct = overrider(this.Construct); }
public ConstructFrom <F> OverrideCanConstruct(Overrider <Func <F, string> > overrider) { this.CanConstruct = overrider(this.CanConstruct ?? (f => null)); return(this); }
public void OverrideConstruct(Overrider <Func <List <Lite <F> >, object[], T> > overrider) { this.Construct = overrider(this.Construct); }
public void OverrideConstruct(Overrider <Func <F, object?[]?, T?> > overrider) { this.Construct = overrider(this.Construct); }
public Execute OverrideCanExecute(Overrider <Func <T, string?> > overrider) { this.CanExecute = overrider(this.CanExecute ?? (t => null)); return(this); }
public static void Override <T>(T Data, T On) where T : ISerializeData { Overrider.Override(Data, On); }
static void Main(string[] args) { Stock msft = new Stock { Name = "MSFT", SharesOwned = 1000L }; Console.WriteLine(msft.Name); Console.WriteLine(msft.SharesOwned); Console.WriteLine(msft); House mansion = new House { Name = "Mansion", Mortgage = 250000M }; Console.WriteLine(mansion); Console.WriteLine(mansion.Name); Console.WriteLine(mansion.Mortgage); Console.WriteLine(mansion.Liability); // polymorphism Display(msft); Display(mansion); // Upcast : implicitly upcast to a base class reference Asset a = msft; // True : Console.WriteLine(a == msft); // OK : Console.WriteLine(a.Name); // Error: SharesOwned undefined // Console.WriteLine(a.SharesOwned); // Downcast : explicitly downcast to a subclass reference Stock s = (Stock)a; // <No error> Console.WriteLine(s.SharesOwned); // True : Console.WriteLine(s == a); // True : Console.WriteLine(s == msft); // as operator performs a downcast that evaluates to null (rather than throwing // an exception) if the downcast fails Asset asserNull = new Asset(); Stock t = asserNull as Stock; // t is null; no exception thrown Console.WriteLine(t?.SharesOwned); // new versus override Overrider over = new Overrider(); BaseClass b1 = over; over.Foo(); // Overrider.Foo b1.Foo(); // Overrider.Foo Hider h = new Hider(); BaseClass b2 = h; h.Foo(); // Hider.Foo b2.Foo(); // BaseClass.Foo // Boxing : convert a value-type instance to a reference-type instance int x = 9; // box the int into an object object obj = x; // Unboxing : cast the object back to the original value type // Unboxing : requires an explicit cast int y = (int)obj; x = 5; // changing the value of x doesn’t change its previously boxed copy Console.WriteLine(obj); // 9 }
public Default() { _Overrider = new Overrider(); }
public Default(IList <object> qiContent) { _Overrider = new Overrider(); }
private void OverrideErrorMessage() { Overrider overrider = new Overrider(); overrider.OverrideError(this, "BirthDate", "Date should be in format dd-MM-yyyy"); }