public void Test7(string context)
 {
     using (var db = GetDataContext(context))
         AreEqual(
             from c in    Child select new { Count = GrandChild.Where(g => g.ChildID == c.ChildID).Count() },
             from c in db.Child select new { Count = db.GrandChild.Where(g => g.ChildID == c.ChildID).Count() });
 }
Exemplo n.º 2
0
        public void Initialize_InvalidGrandChildObject_ExceptionRaised()
        {
            // Arrange
            IDataPortal <Root> dataPortal = _testDIContext.CreateDataPortal <Root>();
            Root  rootObject  = dataPortal.Create(new Root.Criteria("Test Data"));
            Child childObject = rootObject.Children.AddNew();

            childObject.Data = "Test child data";
            GrandChild              grandChildObject   = childObject.GrandChildren.AddNew();
            ApplicationContext      applicationContext = _testDIContext.CreateTestApplicationContext();
            RevalidatingInterceptor sut  = new RevalidatingInterceptor(applicationContext);
            InterceptArgs           args = new InterceptArgs()
            {
                ObjectType = typeof(Root),
                Operation  = DataPortalOperations.Update,
                Parameter  = rootObject,
                IsSync     = true
            };

            applicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server);
            applicationContext.LocalContext["__logicalExecutionLocation"] = ApplicationContext.LogicalExecutionLocations.Server;

            // Act and Assert
            Assert.ThrowsException <Rules.ValidationException>(() => sut.Initialize(args));
        }
Exemplo n.º 3
0
    static void Main(string[] args)
    {
        Parent obj1 = new Parent();
        Parent obj2 = new Child();
        // Child obj2 = new Child();
        // GrandChild obj3 = new GrandChild();
        Parent obj3 = new GrandChild();

        obj1.Name();
        obj2.Name();
        obj3.Name();
        Console.WriteLine();

        Parent[] Array = new Parent[]   // new Parent[]에서 3개를 선언했으니 []안의 숫자를 생략해도 상관없다.
        {
            new Parent(),
            new Child(),
            new GrandChild()
        };
        for (int i = 0; i < Array.Length; ++i)
        {
            Array[i].Name();
        }


        // 배열을 만든 구문과 obj.Name()으로 선언한 구문의 결과값은 같다.
        // 만약 100개의 코드를 짠다고 가정해보자.
        // 배열코드는 배열 100개만 선언해주면 for문은 그대로 써도 상관이없지만,
        // obj.Name()코드는 1부터 100까지 객체선언도 해줘야하고 .Name()도 100개를 선언해줘야한다.

        // virtual을 안쓰면 참조변수의 타입기반으로 돌아간다.
        // 객체지향이기때문에 객체기반으로 돌릴꺼다.
    }
Exemplo n.º 4
0
        public void InsertUnion1(string context)
        {
            Child.Count();

            using (var db = GetDataContext(context))
            {
                try
                {
                    db.Parent.Delete(p => p.ParentID > 1000);

                    var q =
                        db.Child.Select(c => new Parent {
                        ParentID = c.ParentID, Value1 = (int)Math.Floor(c.ChildID / 10.0)
                    }).Union(
                            db.GrandChild.Select(c => new Parent {
                        ParentID = c.ParentID ?? 0, Value1 = (int?)Math.Floor((c.GrandChildID ?? 0) / 100.0)
                    }));

                    q.Insert(db.Parent, p => new Parent
                    {
                        ParentID = p.ParentID + 1000,
                        Value1   = p.Value1
                    });

                    Assert.AreEqual(
                        Child.Select(c => new { ParentID = c.ParentID }).Union(
                            GrandChild.Select(c => new { ParentID = c.ParentID ?? 0 })).Count(),
                        db.Parent.Count(c => c.ParentID > 1000));
                }
                finally
                {
                    db.Parent.Delete(p => p.ParentID > 1000);
                }
            }
        }
Exemplo n.º 5
0
    static void Main(string[] args)
    {
        Parent obj1 = new Parent();
        Parent obj2 = new Child();
        // Child obj2 = new Child();
        // GrandChild obj3 = new GrandChild();
        Parent obj3 = new GrandChild();

        obj1.Name();
        obj2.Name();
        obj3.Name();
        Console.WriteLine();

        Parent[] Array = new Parent[]   // new Parent[]에서 3개를 선언했으니 []안의 숫자를 생략해도 상관없다.
        {
            new Parent(),
            new Child(),
            new GrandChild()
        };
        for (int i = 0; i < Array.Length; ++i)
        {
            Array[i].Name();
        }
//부모한테 Name(), 자식한테 Name()인 똑같은 메서드를 만들어서 사용하는 기법을 메서드 오버라이딩이라고한다. 라이딩을 라이트라고보고 덮어쓰는것을 생각해보자
//오버라이딩은 상속에서만 쓸 수 있다, 인자가 일치하는 경우
//오버로딩은 메서드이름은 똑같은데 인자가 다른것임. 생성자도 메서드이므로 생성자가 같은데 인자가 다르면 생성자 오버로딩이다.
//오버로딩은 인자만 다르면 쓸 수 있으므로 상속했을때(클래스가 다를때), 같은 클래스일때도 쓸 수 있다.
//
//버츄얼을 쓰면 type을 체크하지않고 객체를 체크해서 객체에 맞춰서 호출된다.
//일단은! 버츄얼은 좋다.라고 생각하자..
//
    }
Exemplo n.º 6
0
        public void Initialize_ValidRootObjectWithChildAndGrandChild_NoExceptionRaised()
        {
            // Arrange
            bool executed = false;
            IDataPortal <Root> dataPortal = _testDIContext.CreateDataPortal <Root>();
            Root  rootObject  = dataPortal.Fetch(new Root.Criteria("Test Data"));
            Child childObject = rootObject.Children.AddNew();

            childObject.Data = "Test child data";
            GrandChild grandChildObject = childObject.GrandChildren.AddNew();

            grandChildObject.Data = "Test grandchild data";
            ApplicationContext      applicationContext = _testDIContext.CreateTestApplicationContext();
            RevalidatingInterceptor sut  = new RevalidatingInterceptor(applicationContext);
            InterceptArgs           args = new InterceptArgs()
            {
                ObjectType = typeof(Root),
                Operation  = DataPortalOperations.Update,
                Parameter  = rootObject,
                IsSync     = true
            };

            applicationContext.SetExecutionLocation(ApplicationContext.ExecutionLocations.Server);
            applicationContext.LocalContext["__logicalExecutionLocation"] = ApplicationContext.LogicalExecutionLocations.Server;

            // Act
            sut.Initialize(args);
            executed = true;

            // Assert
            Assert.IsTrue(executed);
        }
Exemplo n.º 7
0
        public static void test_grand_grand_children_finalize()
        {
            GrandChild obj = new GrandChild();

            Test.AssertEquals(-42, obj.receivedValue);
            obj.Dispose();
        }
Exemplo n.º 8
0
            public static void CallDelegateFromGrandChild()
            {
                GrandChild child = new GrandChild();

                Assert.AreEqual("Child.AbstractFinal", new TestMethod(child.AbstractFinal));
                Assert.AreEqual("GrandChild.AbstractOverrideFinal", new TestMethod(child.AbstractOverrideFinal));
                Assert.AreEqual("Child.VirtualFinal", new TestMethod(child.VirtualFinal));
                Assert.AreEqual("GrandChild.VirtualNilFinal", new TestMethod(child.VirtualNilFinal));
                Assert.AreEqual("GrandChild.VirtualOverrideFinal", new TestMethod(child.VirtualOverrideFinal));
            }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            /* Child c = new Child();
             * c.ParentMethod();*/
            /*Parent p = new Child(); //Up-casting
             * p.ParentMethod();*/
            Parent p = new GrandChild();

            p.ParentMethod();
        }
        public Child1()
        {
            var id = Interlocked.Increment(ref _id);

            Name = this.GetType().Name + id;

            for (int i = 0; i < 2; i++)
            {
                GrandChild.Add(new GrandChild1());
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var p = new Parent();
            var c = new Child();
            var t = new GrandChild();
            var b = new a.yes();

            var d = new Dog();

            d.name = "Rocky";
            p.TakeForWalk(d);
        }
Exemplo n.º 12
0
 public void Test7()
 {
     ForEachProvider(db => AreEqual(
                         from c in Child select new
     {
         Count = GrandChild.Where(g => g.ChildID == c.ChildID).Count(),
     },
                         from c in db.Child select new
     {
         Count = db.GrandChild.Where(g => g.ChildID == c.ChildID).Count(),
     }));
 }
Exemplo n.º 13
0
        public void should_get_instances_with_same_name_as_requested_instance_or_fall_back_to_default_instance()
        {
            var @default = "default";
            var name1 = "name1";
            var name2 = "name2";
            var defaultGrandChild = new GrandChild();
            var namedGrandChild = new GrandChild();
            var container = new Container(x =>
            {
                x.For<ParentWithSingleChild>().Use<ParentWithSingleChild>().Set(y => y.Tag, @default);
                x.For<ParentWithSingleChild>(name1).Use<ParentWithSingleChild>().Set(y => y.Tag, name1);
                x.For<ParentWithMultipleChildren>().Use<ParentWithMultipleChildren>().Set(y => y.Tag, @default);
                x.For<ParentWithMultipleChildren>(name1).Use<ParentWithMultipleChildren>().Set(y => y.Tag, name1);
                x.For<Child>().Use<Child>().Set(y => y.Tag, @default);
                x.For<Child>(name2).Use<Child>().Set(y => y.Tag, name2);
                x.For<GrandChild>().Use(defaultGrandChild);
                x.For<GrandChild>(name1).Use(namedGrandChild);
            });

            {
                var singleParent = container.Get<ParentWithSingleChild>();
                singleParent.Tag.Should().Be(@default);
                singleParent.Child.Tag.Should().Be(@default);
                singleParent.Child.GrandChild.Should().Be(defaultGrandChild);

                var singleParent1 = container.Get<ParentWithSingleChild>(name1);
                singleParent1.Tag.Should().Be(name1);
                singleParent1.Child.Tag.Should().Be(@default);
                singleParent1.Child.GrandChild.Should().Be(namedGrandChild);

                var singleParent2 = container.Get<ParentWithSingleChild>(name2);
                singleParent2.Tag.Should().Be(@default);
                singleParent2.Child.Tag.Should().Be(name2);
                singleParent2.Child.GrandChild.Should().Be(@defaultGrandChild);
            }

            {
                var multiParent = container.Get<ParentWithMultipleChildren>();
                multiParent.Tag.Should().Be(@default);
                multiParent.Children.Should().HaveCount(2);
                multiParent.Children.Should().OnlyContain(x => x.GrandChild == defaultGrandChild);

                var multiParent1 = container.Get<ParentWithMultipleChildren>(name1);
                multiParent1.Tag.Should().Be(name1);
                multiParent1.Children.Should().HaveCount(2);
                multiParent1.Children.Should().OnlyContain(x => x.GrandChild == namedGrandChild);

                var multiParent2 = container.Get<ParentWithMultipleChildren>(name2);
                multiParent2.Tag.Should().Be(@default);
                multiParent2.Children.Should().HaveCount(2);
                multiParent2.Children.Should().OnlyContain(x => x.GrandChild == defaultGrandChild);
            }
        }
        public void GetChildWithReferencedGrandChild()
        {
            var child = container.GetInstance(typeof(Child), "Marsha") as Child;

            Assert.IsNotNull(child);
            Assert.AreEqual("Marsha", child.Name);

            GrandChild grandChild = child.MyGrandChild;

            Assert.IsNotNull(grandChild);
            Assert.AreEqual(1972, grandChild.BirthYear, "Has correct BirthYear");
            Assert.AreEqual(true, grandChild.RightHanded, "Is Right-Handed?");
        }
        public void GetChildWithDefinedGrandChild()
        {
            var child = container.GetInstance(typeof(Child), "Tom") as Child;

            Assert.IsNotNull(child);
            Assert.AreEqual("Tom", child.Name);


            GrandChild grandChild = child.MyGrandChild;

            Assert.IsNotNull(grandChild);
            Assert.AreEqual(1984, grandChild.BirthYear, "Has correct BirthYear");
            Assert.IsTrue(grandChild is LeftieGrandChild, "Correct type?");
        }
        public void GetParentWithReferenceToDefaultGrandChild()
        {
            container.Configure(x => x.ForRequestedType <GrandChild>().TheDefault.Is.TheInstanceNamed("Trevor"));
            var child = container.GetInstance(typeof(Child), "Jessica") as Child;

            Assert.IsNotNull(child);
            Assert.AreEqual("Jessica", child.Name);


            GrandChild grandChild = child.MyGrandChild;

            Assert.IsNotNull(grandChild);
            Assert.AreEqual(1979, grandChild.BirthYear, "Has correct BirthYear");
            Assert.IsTrue(grandChild is LeftieGrandChild, "Is a Leftie?");
        }
Exemplo n.º 17
0
        public void Contains8()
        {
            var arr = new[] { GrandChild.ElementAt(0), GrandChild.ElementAt(1) };

            ForEachProvider(db => AreEqual(
                                from p in Parent
                                join ch in Child on p.ParentID equals ch.ParentID
                                join gc in GrandChild on ch.ChildID equals gc.ChildID
                                where arr.Contains(gc)
                                select p,
                                from p in db.Parent
                                join ch in db.Child on p.ParentID equals ch.ParentID
                                join gc in db.GrandChild on ch.ChildID equals gc.ChildID
                                where arr.Contains(gc)
                                select p));
        }
Exemplo n.º 18
0
        public void should_get_dependencies_with_same_name_as_top_instance_or_fall_back_to_default_instance()
        {
            var name1 = "abc";
            var name2 = "xyz";
            var grandChild = new GrandChild();
            var grandChild1 = new GrandChild();
            var container = new Container(x =>
            {
                x.For<ParentWithSingleChild>().Use<ParentWithSingleChild>().Set(y => y.Tag, grandChild);
                x.For<ParentWithSingleChild>(name1).Use<ParentWithSingleChild>().Set(y => y.Tag, grandChild1);
                x.For<ParentWithSingleChild>(name2).Use<ParentWithSingleChild>().Set(y => y.Tag, grandChild);
                x.For<GrandChild>().Use(grandChild);
                x.For<GrandChild>(name1).Use(grandChild1);
            });

            container.GetAll<ParentWithSingleChild>().Should().OnlyContain(x => x.Tag == x.Child.GrandChild);
        }
Exemplo n.º 19
0
        public void Simple11()
        {
            ForEachProvider(db =>
            {
                var q1 = GrandChild
                         .GroupBy(ch => new { ParentID = ch.ParentID + 1, ch.ChildID }, ch => ch.ChildID);

                var q2 = db.GrandChild
                         .GroupBy(ch => new { ParentID = ch.ParentID + 1, ch.ChildID }, ch => ch.ChildID);

                var list1 = q1.AsEnumerable().OrderBy(_ => _.Key.ChildID).ToList();
                var list2 = q2.AsEnumerable().OrderBy(_ => _.Key.ChildID).ToList();

                Assert.AreEqual(list1.Count, list2.Count);
                Assert.AreEqual(list1[0].ToList(), list2[0].ToList());
            });
        }
Exemplo n.º 20
0
        public void NotContains8([DataSources] string context)
        {
            var arr = new[] { GrandChild.ElementAt(0), GrandChild.ElementAt(1) };

            using (var db = GetDataContext(context))
                AreEqual(
                    from p in Parent
                    join ch in Child on p.ParentID equals ch.ParentID
                    join gc in GrandChild on ch.ChildID equals gc.ChildID
                    where !arr.Contains(gc)
                    select p
                    ,
                    from p in db.Parent
                    join ch in db.Child on p.ParentID equals ch.ParentID
                    join gc in db.GrandChild on ch.ChildID equals gc.ChildID
                    where !arr.Contains(gc)
                    select p);
        }
        public void GetParentWithReferencedChild()
        {
            var parent = container.GetInstance(typeof(Parent), "Jerry") as Parent;

            Assert.IsNotNull(parent);
            Assert.AreEqual(72, parent.Age, "Age = 72");
            Assert.AreEqual("Blue", parent.EyeColor);

            Child child = parent.MyChild;

            Assert.IsNotNull(child);
            Assert.AreEqual("Marsha", child.Name);

            GrandChild grandChild = child.MyGrandChild;

            Assert.IsNotNull(grandChild);
            Assert.AreEqual(1972, grandChild.BirthYear, "Has correct BirthYear");
            Assert.AreEqual(true, grandChild.RightHanded, "Is Right-Handed?");
        }
        public void GetParentWithDefinedChild()
        {
            var parent = container.GetInstance(typeof(Parent), "Jackie") as Parent;

            Assert.IsNotNull(parent);
            Assert.AreEqual(70, parent.Age, "Age = 70");
            Assert.AreEqual("Green", parent.EyeColor);

            Child child = parent.MyChild;

            Assert.IsNotNull(child);
            Assert.AreEqual("Elizabeth", child.Name);

            GrandChild grandChild = child.MyGrandChild;

            Assert.IsNotNull(grandChild);
            Assert.AreEqual(1992, grandChild.BirthYear, "Has correct BirthYear");
            Assert.IsTrue(grandChild is LeftieGrandChild, "Is a Leftie?");
        }
Exemplo n.º 23
0
        public void Contains803(string context)
        {
            var arr = new[] { GrandChild.ElementAt(0), GrandChild.ElementAt(1) };

            using (var db = GetDataContext(context))
                AreEqual(
                    from p in Parent
                    join ch in Child on p.ParentID equals ch.ParentID
                    join gc in GrandChild on ch.ChildID equals gc.ChildID
                    where arr.Contains(new GrandChild {
                    ParentID = 1, ChildID = ch.ChildID, GrandChildID = gc.GrandChildID
                })
                    select p
                    ,
                    from p in db.Parent
                    join ch in db.Child on p.ParentID equals ch.ParentID
                    join gc in db.GrandChild on ch.ChildID equals gc.ChildID
                    where arr.Contains(new GrandChild {
                    ParentID = 1, ChildID = ch.ChildID, GrandChildID = gc.GrandChildID
                })
                    select p);
        }
Exemplo n.º 24
0
        public void Contains801()
        {
            var arr = new[] { GrandChild.ElementAt(0), GrandChild.ElementAt(1) };

            ForEachProvider(db => AreEqual(
                                from p in Parent
                                join ch in Child on p.ParentID equals ch.ParentID
                                join gc in GrandChild on ch.ChildID equals gc.ChildID
                                select new GrandChild {
                ParentID = 2, ChildID = ch.ChildID, GrandChildID = gc.GrandChildID
            } into gc
                                where arr.Contains(gc)
                                select gc,
                                from p in db.Parent
                                join ch in db.Child on p.ParentID equals ch.ParentID
                                join gc in db.GrandChild on ch.ChildID equals gc.ChildID
                                select new GrandChild {
                ParentID = 2, ChildID = ch.ChildID, GrandChildID = gc.GrandChildID
            } into gc
                                where arr.Contains(gc)
                                select gc));
        }
Exemplo n.º 25
0
        public void Stratabase_TESTFAIL_InheritedData()
        {
            Base v = new GrandChild
            {
                Id          = Guid.NewGuid(),
                IntValue    = 5,
                StringValue = "55",
                BoolValue   = true,
            };

            Stratabase sb = new Stratabase(2);

            sb.SetBaselineFromPropertiesOf(v);

            GrandChild gc = new GrandChild {
                Id = v.Id
            };

            sb.SetObjectWithProperties(gc);

            Assert.AreEqual(((GrandChild)v).IntValue, gc.IntValue);
            Assert.AreEqual(((GrandChild)v).StringValue, gc.StringValue);
            Assert.AreEqual(((GrandChild)v).BoolValue, gc.BoolValue);
        }
Exemplo n.º 26
0
        public void Contains801([DataSources] string context)
        {
            var arr = new[] { GrandChild.ElementAt(0), GrandChild.ElementAt(1) };

            using (var db = GetDataContext(context))
                AreEqual(
                    from p in Parent
                    join ch in Child on p.ParentID equals ch.ParentID
                    join gc in GrandChild on ch.ChildID equals gc.ChildID
                    select new GrandChild {
                    ParentID = 2, ChildID = ch.ChildID, GrandChildID = gc.GrandChildID
                } into gc
                    where arr.Contains(gc)
                    select gc
                    ,
                    from p in db.Parent
                    join ch in db.Child on p.ParentID equals ch.ParentID
                    join gc in db.GrandChild on ch.ChildID equals gc.ChildID
                    select new GrandChild {
                    ParentID = 2, ChildID = ch.ChildID, GrandChildID = gc.GrandChildID
                } into gc
                    where arr.Contains(gc)
                    select gc);
        }
Exemplo n.º 27
0
        public void InsertUnion1()
        {
            Child.Count();

            ForEachProvider(
                db =>
            {
                try
                {
                    db.Parent.Delete(p => p.ParentID > 1000);

                    var q =
                        db.Child.Select(c => new Parent {
                        ParentID = c.ParentID, Value1 = (int)Math.Floor(c.ChildID / 10.0)
                    }).Union(
                            db.GrandChild.Select(c => new Parent {
                        ParentID = c.ParentID ?? 0, Value1 = (int?)Math.Floor((c.GrandChildID ?? 0) / 100.0)
                    }));

                    q.Insert(db.Parent, p => new Parent
                    {
                        ParentID = p.ParentID + 1000,
                        Value1   = p.Value1
                    });

                    Assert.AreEqual(
                        Child.Select(c => new { ParentID = c.ParentID }).Union(
                            GrandChild.Select(c => new { ParentID = c.ParentID ?? 0 })).Count(),
                        db.Parent.Count(c => c.ParentID > 1000));
                }
                finally
                {
                    db.Parent.Delete(p => p.ParentID > 1000);
                }
            });
        }
Exemplo n.º 28
0
 public Child(GrandChild child)
 {
 }
  static void Main() 
  {
    { 
      Person person = new Person();
      check(person, "Person");
      person.Dispose();
    }
    { 
      Person person = new Child();
      check(person, "Child");
      person.Dispose();
    }
    { 
      Person person = new GrandChild();
      check(person, "GrandChild"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangPerson();
      check(person, "TargetLangPerson"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangChild();
      check(person, "TargetLangChild"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangGrandChild();
      check(person, "TargetLangGrandChild"); 
      person.Dispose();
    }

    // Semis - don't override id() in target language
    { 
      Person person = new TargetLangSemiPerson();
      check(person, "Person"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangSemiChild();
      check(person, "Child"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangSemiGrandChild();
      check(person, "GrandChild"); 
      person.Dispose();
    }

    // Orphans - don't override id() in C++
    { 
      Person person = new OrphanPerson();
      check(person, "Person"); 
      person.Dispose();
    }
    { 
      Person person = new OrphanChild();
      check(person, "Child"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangOrphanPerson();
      check(person, "TargetLangOrphanPerson"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangOrphanChild();
      check(person, "TargetLangOrphanChild"); 
      person.Dispose();
    }

    // Duals - id() makes an upcall to the base id()
    { 
      Person person = new TargetLangDualPerson();
      check(person, "TargetLangDualPerson + Person"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangDualChild();
      check(person, "TargetLangDualChild + Child"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangDualGrandChild();
      check(person, "TargetLangDualGrandChild + GrandChild"); 
      person.Dispose();
    }

    // Mix Orphans and Duals
    { 
      Person person = new TargetLangDualOrphanPerson();
      check(person, "TargetLangDualOrphanPerson + Person"); 
      person.Dispose();
    }
    { 
      Person person = new TargetLangDualOrphanChild();
      check(person, "TargetLangDualOrphanChild + Child"); 
      person.Dispose();
    }
  }
Exemplo n.º 30
0
 public Child(GrandChild grandChild)
 {
     GrandChild = grandChild;
 }
 public void Initialize()
 {
     _parent = new Parent();
       _child = new Child();
       _grandChild = new GrandChild();
 }
Exemplo n.º 32
0
            public static void CallFromInsideGrandChild()
            {
                GrandChild child = new GrandChild();

                child.TestGrandChild();
            }
Exemplo n.º 33
0
 public Child(string Name, GrandChild MyGrandChild)
 {
     _Name = Name;
     _MyGrandChild = MyGrandChild;
 }
Exemplo n.º 34
0
        static void Main()
        {
            {
                Person person = new Person();
                check(person, "Person");
                person.Dispose();
            }
            {
                Person person = new Child();
                check(person, "Child");
                person.Dispose();
            }
            {
                Person person = new GrandChild();
                check(person, "GrandChild");
                person.Dispose();
            }
            {
                Person person = new TargetLangPerson();
                check(person, "TargetLangPerson");
                person.Dispose();
            }
            {
                Person person = new TargetLangChild();
                check(person, "TargetLangChild");
                person.Dispose();
            }
            {
                Person person = new TargetLangGrandChild();
                check(person, "TargetLangGrandChild");
                person.Dispose();
            }

            // Semis - don't override id() in target language
            {
                Person person = new TargetLangSemiPerson();
                check(person, "Person");
                person.Dispose();
            }
            {
                Person person = new TargetLangSemiChild();
                check(person, "Child");
                person.Dispose();
            }
            {
                Person person = new TargetLangSemiGrandChild();
                check(person, "GrandChild");
                person.Dispose();
            }

            // Orphans - don't override id() in C++
            {
                Person person = new OrphanPerson();
                check(person, "Person");
                person.Dispose();
            }
            {
                Person person = new OrphanChild();
                check(person, "Child");
                person.Dispose();
            }
            {
                Person person = new TargetLangOrphanPerson();
                check(person, "TargetLangOrphanPerson");
                person.Dispose();
            }
            {
                Person person = new TargetLangOrphanChild();
                check(person, "TargetLangOrphanChild");
                person.Dispose();
            }

            // Duals - id() makes an upcall to the base id()
            {
                Person person = new TargetLangDualPerson();
                check(person, "TargetLangDualPerson + Person");
                person.Dispose();
            }
            {
                Person person = new TargetLangDualChild();
                check(person, "TargetLangDualChild + Child");
                person.Dispose();
            }
            {
                Person person = new TargetLangDualGrandChild();
                check(person, "TargetLangDualGrandChild + GrandChild");
                person.Dispose();
            }

            // Mix Orphans and Duals
            {
                Person person = new TargetLangDualOrphanPerson();
                check(person, "TargetLangDualOrphanPerson + Person");
                person.Dispose();
            }
            {
                Person person = new TargetLangDualOrphanChild();
                check(person, "TargetLangDualOrphanChild + Child");
                person.Dispose();
            }
        }
Exemplo n.º 35
0
        public void Changeset_GetAssociatedChanges_Singleton()
        {
            DomainServiceDescription dsd = DomainServiceDescription.GetDescription(typeof(CompositionScenarios_Explicit));

            // verify singleton change of None
            GreatGrandChild unmodifiedGgc  = new GreatGrandChild();
            GrandChild      currGrandChild = new GrandChild
            {
                Child = unmodifiedGgc
            };
            GrandChild origGrandChild = new GrandChild
            {
                Child = unmodifiedGgc
            };
            ChangeSetEntry gcOperation = new ChangeSetEntry(1, currGrandChild, origGrandChild, DomainOperation.Update);

            gcOperation.Associations = new Dictionary <string, int[]> {
                { "Child", new int[] { 2 } }
            };
            ChangeSetEntry  ggcOperation = new ChangeSetEntry(2, unmodifiedGgc, null, DomainOperation.None);
            ChangeSet       cs           = new ChangeSet(new ChangeSetEntry[] { gcOperation, ggcOperation });
            GreatGrandChild ggcChange    = cs.GetAssociatedChanges(currGrandChild, p => p.Child, ChangeOperation.None).Cast <GreatGrandChild>().SingleOrDefault();

            Assert.AreSame(unmodifiedGgc, ggcChange);

            // verify singleton insert
            GreatGrandChild newGgc = new GreatGrandChild();

            currGrandChild = new GrandChild
            {
                Child = newGgc
            };
            origGrandChild = new GrandChild
            {
                Child = null
            };
            gcOperation = new ChangeSetEntry(1, currGrandChild, origGrandChild, DomainOperation.Update);
            gcOperation.Associations = new Dictionary <string, int[]> {
                { "Child", new int[] { 2 } }
            };
            ggcOperation = new ChangeSetEntry(2, newGgc, null, DomainOperation.Insert);
            cs           = new ChangeSet(new ChangeSetEntry[] { gcOperation, ggcOperation });
            ggcChange    = cs.GetAssociatedChanges(currGrandChild, p => p.Child, ChangeOperation.Insert).Cast <GreatGrandChild>().SingleOrDefault();
            Assert.AreSame(newGgc, ggcChange);
            Assert.AreEqual(ChangeOperation.Insert, cs.GetChangeOperation(newGgc));

            // verify singleton update
            GreatGrandChild modifiedGgc = new GreatGrandChild();

            currGrandChild = new GrandChild
            {
                Child = modifiedGgc
            };
            origGrandChild = new GrandChild
            {
                Child = modifiedGgc
            };
            gcOperation = new ChangeSetEntry(1, currGrandChild, origGrandChild, DomainOperation.Update);
            gcOperation.Associations = new Dictionary <string, int[]> {
                { "Child", new int[] { 2 } }
            };
            ggcOperation = new ChangeSetEntry(2, modifiedGgc, unmodifiedGgc, DomainOperation.Update);
            cs           = new ChangeSet(new ChangeSetEntry[] { gcOperation, ggcOperation });
            ggcChange    = cs.GetAssociatedChanges(currGrandChild, p => p.Child, ChangeOperation.Update).Cast <GreatGrandChild>().SingleOrDefault();
            Assert.AreSame(modifiedGgc, ggcChange);
            Assert.AreSame(unmodifiedGgc, cs.GetOriginal(modifiedGgc));
            Assert.AreEqual(ChangeOperation.Update, cs.GetChangeOperation(modifiedGgc));

            // verify singleton delete
            GreatGrandChild deletedGgc = new GreatGrandChild();

            currGrandChild = new GrandChild
            {
                Child = null
            };
            origGrandChild = new GrandChild
            {
                Child = deletedGgc
            };
            gcOperation = new ChangeSetEntry(1, currGrandChild, null, DomainOperation.Update);
            gcOperation.OriginalAssociations = new Dictionary <string, int[]>()
            {
                { "Child", new int[] { 2 } }
            };
            ggcOperation = new ChangeSetEntry(2, deletedGgc, null, DomainOperation.Delete);
            gcOperation.OriginalAssociations = new Dictionary <string, int[]>()
            {
                { "Child", new int[] { 2 } }
            };
            cs        = new ChangeSet(new ChangeSetEntry[] { gcOperation, ggcOperation });
            ggcChange = cs.GetAssociatedChanges(currGrandChild, p => p.Child, ChangeOperation.Delete).Cast <GreatGrandChild>().SingleOrDefault();
            Assert.AreSame(deletedGgc, ggcChange);
            Assert.AreSame(null, cs.GetOriginal(deletedGgc));
            Assert.AreEqual(ChangeOperation.Delete, cs.GetChangeOperation(deletedGgc));
        }
 public Child(string name, GrandChild grandChild)
 {
     _name       = name;
     _grandChild = grandChild;
 }
Exemplo n.º 37
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string strMessage = "No Matches";

            listBox1.Items.Clear();
            if ((textBox1.Text == "") && (comboBox1.Text == ""))
            {
                MessageBox.Show("Select the drive and Enter the file type to be searched!");
            }
            else if (textBox1.Text == "")
            {
                MessageBox.Show("Enter the file type to be searched!");
            }
            else if (comboBox1.Text == "")
            {
                MessageBox.Show("Select the drive to search the files!");
            }
            else
            {
                try
                {
                    int             i = 0;
                    int             iVal;
                    DirectoryInfo[] ChildDirs = this.getDirectories(comboBox1.Text);
                    //If the Search file type has no extention then add one.
                    iVal = textBox1.Text.IndexOf(".");
                    if (iVal == -1)
                    {
                        textBox1.Text += ".*";
                    }
                    //Get the Child Directories.
                    foreach (DirectoryInfo ChildDir1 in ChildDirs)
                    {
                        //recurse through the child directories.
                        while (ChildDir1.GetDirectories().Length > 0)
                        {
                            DirectoryInfo[] GrandChilds = ChildDir1.GetDirectories();
                            foreach (DirectoryInfo GrandChild in GrandChilds)
                            {
                                FileInfo[] Files = GrandChild.GetFiles(textBox1.Text);
                                if (Files.Length == 0)
                                {
                                    // Do nothing.
                                }
                                else
                                {
                                    foreach (FileInfo DirFile in Files)
                                    {
                                        listBox1.Items.Insert(i, DirFile.Name);
                                        i++;
                                    }
                                }
                                //ChildDir1 = GrandChild;
                            }
                        }
                    }
                }
                catch (IOException E)
                {
                    strMessage = E.Message;
                    listBox1.Items.Insert(0, strMessage);
                    strMessage = "";
                }
                if (listBox1.Items.Count == 0)
                {
                    listBox1.Items.Insert(0, strMessage);
                }
            }
        }