static void Main(string[] args) { Child2 ch2_1 = new Child2(2, 2, 2, 2); Console.WriteLine(ch2_1.Product()); Child1 ch1_1 = ch2_1; Console.WriteLine(ch1_1.Product()); Parent p1 = ch1_1; Console.WriteLine(p1.Product()); ///////////////////////////////////////////////// Child1 ch2_2 = new Child1(2, 2, 2); Console.WriteLine(ch2_2.Product()); Parent p2 = ch2_2; Console.WriteLine(p2.Product()); ///////////////////////////////////////////////// Parent p3 = new Parent(2, 2, false); Console.WriteLine(p3.Product()); GC.Collect(); dynamic s1 = p1; Console.WriteLine(s1.Product()); s1 = p2; Console.WriteLine(s1.Product()); s1 = p3; Console.WriteLine(s1.Product()); }
public void PopulateFilterIndex(Type type, IDictionary <string, IList <QueryFilterCondition> > index) { if (Operator != and) { return; } if (Argument1 != null) { Argument1.PopulateFilterIndex(type, index); } else if (Child1 != null) { Child1.PopulateFilterIndex(type, index); } if (Argument2 != null) { Argument2.PopulateFilterIndex(type, index); } else if (Child2 != null) { Child2.PopulateFilterIndex(type, index); } }
// Convert node to string public override string ToString() { return(String.Format(Grouped ? "({0} {1} {2})" : "{0} {1} {2}", Child1.ToString(), Conjunction.ToString().ToUpper(), Child2.ToString())); }
public void NoLinqByGeneric() { Child2 result = null; Measure.Method(() => { result = GetListOfSubTypeByGeneric <Child2>(list1); if (result != null) { return; } result = GetListOfSubTypeByGeneric <Child2>(list2); if (result != null) { return; } result = GetListOfSubTypeByGeneric <Child2>(list3); if (result != null) { return; } result = GetListOfSubTypeByGeneric <Child2>(list4); if (result != null) { return; } }).WarmupCount(10) .MeasurementCount(10) .IterationsPerMeasurement(5) .GC() .Run(); }
/// <exclude/> protected override Size ArrangeOverride(Size finalSize) { UIElement licenseErrorElement = null; CheckLicense(ref licenseErrorElement); if (licenseErrorElement != null) { licenseErrorElement.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); return(finalSize); } Rect splitterRect; GetRects(finalSize, out _child1Rect, out splitterRect, out _child2Rect); if (Child1 != null) { Child1.Arrange(_child1Rect); } if (SplitterPresenter != null) { SplitterPresenter.Arrange(splitterRect); } if (Child2 != null) { Child2.Arrange(_child2Rect); } return(finalSize); }
/// <summary> /// Method to query all the ids of features in this node that intersect the box defined /// by <paramref name="minx"/>, <paramref name="miny"/>, <paramref name="maxx"/> /// and <paramref name="maxy"/> /// </summary> /// <param name="minx">The lower x-ordinate</param> /// <param name="miny">The lower y-ordinate</param> /// <param name="maxx">The upper x-ordinate</param> /// <param name="maxy">The upper y-ordinate</param> /// <param name="fidList">A list of feature ids to add to</param> /// <returns>An enumeration of feature ids</returns> internal void QueryFids(byte minx, byte miny, byte maxx, byte maxy, List <uint> fidList) { if (ContainedBy(minx, miny, maxx, maxy)) { AddAllFidsInNode(fidList); return; } foreach (var feature in this) { if (feature.Intersects(minx, maxx, miny, maxy)) { fidList.Add(feature.Fid); } } if (Nid < _tree.FirstLeafNodeId) { if (Child1.Intersects(minx, miny, maxx, maxy)) { Child1.QueryFids(minx, miny, maxx, maxy, fidList); } if (Child2.Intersects(minx, miny, maxx, maxy)) { Child2.QueryFids(minx, miny, maxx, maxy, fidList); } } }
public override string asString() { string b = Child1.asString(); string c = Child2.asString(); return("(" + b + "~" + c + ")"); }
public override Node differentiate() { Add_Operator a1 = new Add_Operator(); Multiply_Operator m1 = new Multiply_Operator(); Multiply_Operator m2 = new Multiply_Operator(); Node c1 = Child1; Node c2 = Child2.differentiate(); Node c3 = Child1.differentiate(); Node c4 = Child2; a1.Child1 = m1; m1.Parent = a1; a1.Child2 = m2; m2.Parent = a1; m1.Child1 = c1; c1.Parent = m1; m1.Child2 = c2; c2.Parent = m1; m2.Child1 = c3; c3.Parent = m2; m2.Child2 = c4; c4.Parent = m2; return(a1); }
public override float Solve(float n) { float Left = Child1.Solve(n); float Right = Child2.Solve(Left - n); if (Child1.evaluate(Left) - Child2.evaluate(Left) != n) { if (Child1.evaluate(Right) - Child2.evaluate(Right) != n) { Right = Child2.Solve(n); Left = Child1.Solve(Right - n); if (Child1.evaluate(Left) - Child2.evaluate(Left) != n) { if (Child1.evaluate(Right) - Child2.evaluate(Right) != n) { return(float.PositiveInfinity); } return(Right); } return(Left); } return(Right); } return(Left); }
/// <summary> /// Method to remove a feature from a bin /// </summary> /// <param name="searchFeature"></param> /// <returns></returns> internal bool Remove(SbnFeature searchFeature) { if (!Intersects(searchFeature.MinX, searchFeature.MinY, searchFeature.MaxX, searchFeature.MaxY)) { return(false); } if (FeatureCount > 0) { var searchBin = FirstBin; for (var i = 0; i < FeatureCount; i++) { var j = i % 100; if (i > 100 && j == 0) { searchBin = searchBin.Next; } if (searchBin[j].Fid == searchFeature.Fid) { searchBin.RemoveAt(j); return(true); } } } if (Nid < _tree.FirstLeafNodeId) { return(Child1.Remove(searchFeature) || Child2.Remove(searchFeature)); } return(false); }
static void Main(string[] args) { Program p = new Program(); //获取对象的三种方法 Type t = p.GetType(); Type t1 = typeof(Program); Type t2 = Type.GetType("_1.反射1.Program"); Console.WriteLine(t); Console.WriteLine(t1); Console.WriteLine(t2); //调用无参构造函数,动态创建对象 //动态创建类,类必须有public且无参构造函数 //使用无参数构造方法创建此类的对象(如果没有无参构造函数会报异常) object obj = Activator.CreateInstance(t);//动态创建t1指向的类的对象,相当于new Person(); Console.WriteLine("对象:" + obj); Child c = new Child(); c.Hello(); Child2 c1 = new Child2(); c1.Hello(); Console.ReadKey(); }
public void TestCastFromInterface() { ITestInt intProp = new Child1(22); ITestInt strProp = new Child2(33); Trace.WriteLine(string.Format("Child1 cast id:{0} - int prop:{1}", ((Child1)intProp).Id, ((Child1)intProp).IntProperty)); Trace.WriteLine(string.Format("Child2 cast id:{0} - str prop:{1}", ((Child2)strProp).Id, ((Child2)strProp).StringProperty)); }
protected override void OnSizeRequested(ref Gtk.Requisition requisition) { var size1 = Child1.SizeRequest(); var size2 = Child2.SizeRequest(); requisition.Height = Math.Max(size1.Height, size2.Height); requisition.Width = Handler.GetPreferredPanelSize(size1.Width, size2.Width); }
public override ResponseVotes Evaluate(IAiContext context) { var votes = new ResponseVotes(); var matchingResponses = context.AvailableResponses.OfType<TRESPONSE>().Where(r => Child1.Evaluate(context).IsMatch(r)); matchingResponses.ForEach(response => context.VoteFor(response, Child2.Evaluate(context))); return votes; }
protected override void OnGetPreferredWidthForHeight(int height, out int minimum_width, out int natural_width) { int min1, width1, min2, width2, sw = Handler.SplitterWidth; Child1.GetPreferredWidthForHeight(height, out min1, out width1); Child2.GetPreferredWidthForHeight(height, out min2, out width2); minimum_width = Handler.GetPreferredPanelSize(min1, min2); natural_width = Handler.GetPreferredPanelSize(width1, width2); }
protected override void OnGetPreferredHeightForWidth(int width, out int minimum_height, out int natural_height) { int min1, height1, min2, height2, sw = Handler.SplitterWidth; Child1.GetPreferredHeightForWidth(width, out min1, out height1); Child2.GetPreferredHeightForWidth(width, out min2, out height2); minimum_height = Handler.GetPreferredPanelSize(min1, min2); natural_height = Handler.GetPreferredPanelSize(height1, height2); }
public override ResponseVotes Evaluate(IAiContext context) { var vote = context.AvailableResponses .OfType <BuyCardResponse>() .FirstOrDefault(response => (response.Item.Equals(Child1.Evaluate(context)))); return(vote == null ? new ResponseVotes() : new ResponseVotes().VoteFor(vote, Child2.Evaluate(context))); }
public static void Main(string[] args) { Kid KidObject = new Kid(); Child child = new Child(); Child2 child2 = new Child2(); Console.WriteLine(KidObject.PrintMessage()); Console.WriteLine(child.PrintMessage()); Console.WriteLine(child2.PrintMessage()); }
/// <summary> /// function to count all features in this node and all child nodes /// </summary> /// <returns>The number of features in all this and all child nodes</returns> public int CountAllFeatures() { var res = FeatureCount; if (Nid < _tree.FirstLeafNodeId) { res += Child1.CountAllFeatures() + Child2.CountAllFeatures(); } return(res); }
public static void Main() { var c1 = new Child1(); var c2 = new Child2(); Test.SetBaseClassValue(c1); Test.SetBaseClassValue(c2); Console.WriteLine(c1.CreateUser); Console.WriteLine(c2.CreateUser); Console.ReadLine(); }
public override Node differentiate() { Node n = this; Node c1 = Child1.differentiate(); Node c2 = Child2.differentiate(); n.Child1 = c1; n.Child2 = c2; c1.Parent = n; c2.Parent = n; return(this); }
public override bool Evaluate(IAiContext context) { var cardSet = Child1.Evaluate(context); var card = Child2.Evaluate(context); if (cardSet == null || card == null) { return(false); } return(cardSet.Contains(card)); }
/// <summary> /// Called from AuDockPanel.OnPaint, for its _firstSplit. /// Paints all descendants. /// </summary> internal override void Paint(Graphics g) { if (IsSplitterVisible) { var t = _manager._paintTools; g.FillRectangle(t.brushSplitter, this.SplitterBounds); } if (Child1.IsDocked) { Child1.Paint(g); } if (Child2.IsDocked) { Child2.Paint(g); } }
public override bool Evaluate(IAiContext context) { if (Child1 == null || Child2 == null) { return(false); } var cardSet1 = Child1.Evaluate(context); var cardSet2 = Child2.Evaluate(context); if (cardSet1 == null || cardSet2 == null) { return(false); } return(Child1.Evaluate(context).IsSupersetOf(Child2.Evaluate(context))); }
void Start() { PublicChild child1 = new PublicChild(); Child2 child2 = new Child2(); // 9、理所当然地可以两个并存 child1.ParentPrivate(); child2.ParentPrivate(); //PublicChild child2 = new PublicChild(1); // 3、protected构造函数不可访问 //PrivateParent parent = new PrivateParent(); // 5、不可以在类外面创建protected构造函数的类 //PublicChild child2 = new PublicChild(""); }
/// <summary> /// Add the child nodes /// </summary> public void AddChildren() { if (Nid >= _tree.FirstLeafNodeId) { return; } var splitBounds = GetSplitBounds(1); var childId = Nid * 2; _tree.Nodes[childId] = new SbnNode(_tree, childId++, splitBounds[0], splitBounds[1], splitBounds[2], splitBounds[3]); Child1.AddChildren(); splitBounds = GetSplitBounds(2); _tree.Nodes[childId] = new SbnNode(_tree, childId, splitBounds[0], splitBounds[1], splitBounds[2], splitBounds[3]); Child2.AddChildren(); }
public static void InheritanceTest10() { List<Parent> list = new List<Parent>(); Child2 c1 = new Child2(); SubParent c2 = new Child3(); list.Add(new Child2()); list.Add(new Child3()); list.RemoveAll((c) => c is Child2); if (list.Count != 1) throw new Exception("Error"); c1 = (Child2)c2; Console.WriteLine(c1.ToString()); c1 = c2 as Child2; Console.WriteLine(c1 == null); }
/// <summary> /// Helper method to add all the ids of features in this node and its descendants /// </summary> /// <returns>An enumeration of feature ids</returns> private void AddAllFidsInNode(List <uint> fidList) { if (FeatureCount > 0) { var bin = FirstBin; while (bin != null) { fidList.AddRange(bin.GetAllFidsInBin()); bin = bin.Next; } } if (Nid < _tree.FirstLeafNodeId) { Child1.AddAllFidsInNode(fidList); Child2.AddAllFidsInNode(fidList); } }
static void Main(string[] args) { //Abstraction //Only DoIt is visible to me Abstraction abs = new Abstraction(); abs.DoIt(); //Inheritance Parent p = new Parent(); p.ParentMethod_1(); Child1 ch1 = new Child1(); ch1.ParentMethod_1(); //using over-ride //Child1 o/p // Child1 ch1_1 = new Parent(); // ch1_1.ParentMethod_1(); - Error Parent ch1_2 = new Child1(); ch1_2.ParentMethod_1(); //using over-ride Child2 ch2 = new Child2(); ch2.ParentMethod_1(); //using New //Parent o/p //important!! Parent ch2_1 = new Child2(); ch2_1.ParentMethod_1(); //Output // ParentMethod // ParentMethod_1 in child1 // ParentMethod_1 in child1 // ParentMethod_1 in Child2 as new // ParentMethod }
public override Node differentiate() { Minus_Operator a = new Minus_Operator(); Multiply_Operator m1 = new Multiply_Operator(); Multiply_Operator m2 = new Multiply_Operator(); Node c1 = Child1.differentiate(); Node c2 = Child2; Node c3 = Child1; Node c4 = Child2.differentiate(); Divide_Operator d = new Divide_Operator(); Exponent_Operator e = new Exponent_Operator(); Node c5 = Child2; Operand o = new Operand(2); a.Child1 = m1; a.Child2 = m2; m1.Parent = a; m2.Parent = a; m1.Child1 = c1; c1.Parent = m1; m1.Child2 = c2; c2.Parent = m1; m2.Child1 = c3; m2.Child2 = c4; c3.Parent = m2; c4.Parent = m2; e.Child1 = c5; e.Child2 = o; o.Parent = e; c5.Parent = e; d.Child1 = a; d.Child2 = e; a.Parent = d; e.Parent = e; return(d); }
static void Main(string[] args) { Base b1 = new Base(); Child1 c1 = new Child1(); Child2 c2 = new Child2(); Base b2 = c1; Base b3 = c2; b1.Virtual(); b1.NonVirtual(); b2.Virtual(); b2.NonVirtual(); b3.Virtual(); b3.NonVirtual(); c1.Virtual(); c1.NonVirtual(); c2.Virtual(); c2.NonVirtual(); }
public void Sketch_ToString_At_Instance_Level() { var obj = new Child2(); var str = obj.Sketch(); Assert.AreEqual("Child2String", str); }
public void TestCastFromInterface() { ITestInt intProp = new Child1(22); ITestInt strProp = new Child2(33); Console.WriteLine("Child1 cast id:{0} - int prop:{1}", ((Child1)intProp).Id, ((Child1)intProp).IntProperty); Console.WriteLine("Child2 cast id:{0} - str prop:{1}", ((Child2)strProp).Id, ((Child2)strProp).StringProperty); }