コード例 #1
0
        internal override float MeasureSubtreeCost()
        {
            Vector3 offset;

            Vector3.Subtract(ref BoundingBox.Max, ref BoundingBox.Min, out offset);
            return(offset.X * offset.Y * offset.Z + ChildA.MeasureSubtreeCost() + childB.MeasureSubtreeCost());
        }
コード例 #2
0
        public static void DoTest()
        {
            // Create a list with parents and children
            List <GrandParent> gList = new List <GrandParent>()
            {
                new Parent()
                {
                    ThisDouble = 1.1, ThisInt = 1
                },
                new Parent()
                {
                    ThisDouble = 2.2, ThisInt = 2
                },
                new ChildA()
                {
                    ThisDouble = 100.1, ThisInt = 101, ThisString = "first child A"
                },
                new ChildB()
                {
                    ThisDouble = 200.2, ThisInt = 202
                },
            };


            // Test if can return child lists to parent list holders
            var query3 = new Parent().GetSpecificList(gList);
            var query4 = new Parent().GetSpecificList_TraditionalWay(gList);

            query3 = new ChildA().GetSpecificList(gList);
            query4 = new ChildA().GetSpecificList_TraditionalWay(gList);
            query3 = new ChildB().GetSpecificList(gList);
            query4 = new ChildB().GetSpecificList_TraditionalWay(gList);
        }
コード例 #3
0
        internal override Fix64 MeasureSubtreeCost()
        {
            Vector3 offset;

            Vector3.Subtract(ref BoundingBox.Max, ref BoundingBox.Min, out offset);
            return(Fix64.SafeMul(Fix64.SafeMul(offset.X, offset.Y), offset.Z) + ChildA.MeasureSubtreeCost() + childB.MeasureSubtreeCost());
        }
コード例 #4
0
 public Rectangle GetRoom()
 {
     if (Room != null)
     {
         return(Room);
     }
     else
     {
         if (ChildA != null && ChildB == null)
         {
             return(ChildA.GetRoom());
         }
         else if (ChildA == null && ChildB != null)
         {
             return(ChildB.GetRoom());
         }
         else
         {
             if (Program.Game.Random.Next(2) == 0)
             {
                 return(ChildA.GetRoom());
             }
             else
             {
                 return(ChildB.GetRoom());
             }
         }
     }
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: ASPePeX/SWDevAufgaben
 private static void Main(string[] args)
 {
     ParentA a = new ChildA();
     a.DoSomething();
     ParentB b = new ChildB();
     b.DoSomething();
 }
コード例 #6
0
 public void SerializeUnmarkedChildShouldFail()
 {
     Program.ExpectFailure <InvalidOperationException>(() =>
     {
         var obj = new ChildA();
         Serializer.Serialize(Stream.Null, obj);
     }, "Unexpected sub-type: Examples.Issues.SO6505590+ChildA");
 }
コード例 #7
0
ファイル: SO6505590.cs プロジェクト: GeorchW/protobuf-net
 public void SerializeUnmarkedChildShouldFail()
 {
     Program.ExpectFailure<InvalidOperationException>(() =>
     {
         var obj = new ChildA();
         Serializer.Serialize(Stream.Null, obj);
     }, "Type is not expected, and no contract can be inferred: Examples.Issues.SO6505590+ChildA");
 }
コード例 #8
0
 public void SerializeUnmarkedChildShouldFail()
 {
     Program.ExpectFailure <InvalidOperationException>(() =>
     {
         var obj = new ChildA();
         Serializer.Serialize(Stream.Null, obj);
     }, "Type is not expected, and no contract can be inferred: Examples.Issues.SO6505590+ChildA");
 }
コード例 #9
0
 public static ChildAVM Map(this ChildA model)
 {
     return(new ChildAVM()
     {
         ParentIdVM = model.ParentId,
         ParentNameVM = model.ParentName,
         ChildPropertyAVM = model.ChildPropertyA,
     });
 }
コード例 #10
0
ファイル: ManageChildren.cs プロジェクト: yuurule/OkitaUnity
 void Start()
 {
     // in Start() we instantiate ChildA() and ChildB() and assign them to the BaseClass[]. This is valid because they both derive BaseClass.
     // B/C BaseClass had the abstract functions MoveForward() and ChildUpdate() they can be called in the Update() in the Manager.
     children     = new BaseClass[2];
     children [0] = new ChildA();
     children [0].Initialize(ChildMesh, ChildMaterial);
     children [1] = new ChildB();
     children [1].Initialize(ChildMesh, ChildMaterial);
 }
コード例 #11
0
	// Use this for initialization
	void Start()
	{
		children = new BaseClass[2];
		
		children [0] = new ChildA();
		children [0].Initialize(ChildMesh, ChildMaterial);
		
		children [1] = new ChildB();
		ChildB cb = new ChildB();
		Debug.Log(cb.MyColor);
		children [1].Initialize(ChildMesh, ChildMaterial);
	}
コード例 #12
0
        private static void Subclass()
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var parentA = new ParentA()
                    {
                        Name = "Chris"
                    };

                    var childA = new ChildA()
                    {
                        Name = "Mary",
                        AnotherProperty = "Likes dogs"
                    }; 

                    var parentB = new ParentB()
                    {
                        Name = "Chris"
                    };

                    var childB = new ChildB()
                    {
                        Name = "Mary",
                        AnotherProperty = "Likes dogs"
                    }; 
                    
                    var parentC = new ParentC()
                    {
                        Name = "Chris"
                    };

                    var childC = new ChildC()
                    {
                        Name = "Mary",
                        AnotherProperty = "Likes dogs"
                    }; 

                    session.Save(parentA);
                    session.Save(parentB);
                    session.Save(parentC);
                    session.Save(childA);
                    session.Save(childB);
                    session.Save(childC);
                    
                    transaction.Commit();

                    Console.WriteLine("Done!");
                }
            }
        }
コード例 #13
0
    // Use this for initialization
    void Start()
    {
        children = new BaseClass[2];

        children [0] = new ChildA();
        children [0].Initialize(ChildMesh, ChildMaterial);

        children [1] = new ChildB();
        ChildB cb = new ChildB();

        Debug.Log(cb.MyColor);
        children [1].Initialize(ChildMesh, ChildMaterial);
    }
コード例 #14
0
        private static void Main(string[] args)
        {
            //Child in a Parent container!

            ParentA a = new ChildA();

            a.DoSomething();

            ParentB b = new ChildB();

            b.DoSomething();

            Console.ReadKey();
        }
コード例 #15
0
        private void GrowAsParent(float feed)
        {
            var passRatio = GetPassRatio();

            _crossSectionArea += passRatio * feed / Length;
            feed *= 1 - passRatio;

            if (!HasEnoughFeedForChildren(feed))
            {
                return;
            }

            ChildA?.Grow(feed * _growthModel.NutritionRatio);
            ChildB?.Grow(feed * (1 - _growthModel.NutritionRatio));
        }
コード例 #16
0
            public Spot Insert(char ID, Vec Rect)
            {
                if (ChildA != null && ChildB != null)
                {
                    Spot NewNode;
                    if ((NewNode = ChildA.Insert(ID, Rect)) != null)
                    {
                        return(NewNode);
                    }
                    return(ChildB.Insert(ID, Rect));
                }

                if (Rect.X > Area.W || Rect.Y > Area.H)
                {
                    return(null);
                }

                ChildA = new Spot();
                ChildB = new Spot();

                int WidthDelta  = (int)Area.W - (int)Rect.X;
                int HeightDelta = (int)Area.H - (int)Rect.Y;

                if (WidthDelta <= HeightDelta)
                {
                    ChildA.Area.SetPos(Area.X + (int)Rect.X, Area.Y);
                    ChildA.Area.SetSize(WidthDelta, (int)Rect.Y);
                    ChildB.Area.SetPos(Area.X, Area.Y + (int)Rect.Y);
                    ChildB.Area.SetSize(Area.W, HeightDelta);
                }
                else
                {
                    ChildA.Area.SetPos(Area.X, Area.Y + (int)Rect.Y);
                    ChildA.Area.SetSize((int)Rect.X, HeightDelta);
                    ChildB.Area.SetPos(Area.X + (int)Rect.X, Area.Y);
                    ChildB.Area.SetSize(WidthDelta, Area.H);
                }

                Area.SetSize((int)Rect.X, (int)Rect.Y);
                this.ID = ID;

                return(this);
            }
コード例 #17
0
        public static void Present()
        {
            ChildA objectA = new ChildA();

            objectA.name = "Value"; // Pomimo tego, że w klasie ChildA nie
                                    // zdeklarowano zmiennej name,
                                    // jest ona dziedziczona z klasy Parent
            objectA.intigerVaraible = 6;

            ChildB objectB = new ChildB();

            objectB.name           = "Funny Value";
            objectB.stringVariable = "Only my variable";

            List <Parent> list = new List <Parent>();

            list.Add(objectA);
            list.Add(objectB); // Dzięki temu, że ChildA oraz ChildB dziedziczą z tej samej klasy
                               // mogą być na nią rzutowane dzięki czemu możliwe jest umieszczenie
                               // obiektów różnych klas w jednej liście
                               // ogarniczeniem jedank jest to, że po rzutowaniu można używać tylko
                               // metod, zmiennych... itp wspólnych -- tzn. należąccych do klasy Parent

            Console.WriteLine("Nazwy obiektów: ");
            foreach (Parent item in list)
            {
                Console.WriteLine($"{item.GetType().Name}     name = {item.name}");
            }

            Console.WriteLine("\nWywołanie metody ParentMethod()\n");
            foreach (Parent item in list)
            {
                item.ParentMethod();
                Console.WriteLine();
            }

            Console.WriteLine("\nWywołanie metody ParentAbstractMethod()\n");
            foreach (Parent item in list)
            {
                item.ParentAbstractMethod();
                Console.WriteLine();
            }
        }
コード例 #18
0
        private static void SaveServices(ISession session, ITransaction transaction)
        {
            Container c    = new Container();
            ChildA    post = new ChildA
            {
                Name = "test"
            };

            c.AddService(post);

            ChildB b = new ChildB();

            b.Value = "10";

            c.AddMiscellaneous(b);

            session.SaveOrUpdate(c);
            transaction.Commit();
        }
コード例 #19
0
ファイル: SO6505590.cs プロジェクト: XewTurquish/vsminecraft
 public void SerializeUnmarkedChildShouldFail()
 {
     var obj = new ChildA();
     Serializer.Serialize(Stream.Null, obj);
 }
コード例 #20
0
ファイル: SO6505590.cs プロジェクト: whut/protobuf-net
        public void SerializeUnmarkedChildShouldFail()
        {
            var obj = new ChildA();

            Serializer.Serialize(Stream.Null, obj);
        }
コード例 #21
0
 static void Main()
 {
     ChildA.Do();      //42
     ChildB.Do();      //12
     Console.ReadKey();
 }
コード例 #22
0
 protected override Operator DuplicateInternal(Dictionary <Operator, Operator> mapping) => new PrioritizedChoice(ChildA.Duplicate(mapping), ChildB.Duplicate(mapping));
コード例 #23
0
 public void RefreshBindings()
 {
     ChildA.Notify(nameof(ChildA.Check));
     ChildB.Notify(nameof(ChildB.Check));
 }
コード例 #24
0
 protected override Operator DuplicateInternal(Dictionary <Operator, Operator> mapping) => new Sequence(ChildA.Duplicate(mapping), ChildB.Duplicate(mapping));
コード例 #25
0
 public void Dispose()
 {
     ChildA?.Dispose();
     ChildB?.Dispose();
 }