Esempio n. 1
0
        static void Main()
        {
            var b = new Base("A");
            var d = new Derived("B", "C");

            TestLogger.Log("Static method calls...");
            TestLogger.Log(Base.S("D")); // "DBS"
            TestLogger.Log(Derived.S("E")); // "EDS"
            TestLogger.Log("Instance method calls...");
            TestLogger.Log(b.I("F")); // "AFBI";
            TestLogger.Log(d.I("G")); // "BCGDI";
            TestLogger.Log("Virtual method calls...");
            TestLogger.Log(b.V("H")); // "AHBV";
            TestLogger.Log(((Base)d).V("I")); // "BCIDV";
            TestLogger.Log("Interface method calls...");
            TestLogger.Log(((IMN)b).M("J")); // "AJBM";
            TestLogger.Log(((IMN)d).M("K")); // "BCKDM";
            TestLogger.Log(((IOP)b).O("L")); // "ALBO";
            TestLogger.Log(((IOP)d).O("M")); // "BMBO";
            TestLogger.Log("Virtual interface method calls...");
            TestLogger.Log(((IMN)b).N("N")); // "ANBN";
            TestLogger.Log(((IMN)d).N("O")); // "BCODN";
            TestLogger.Log(((IOP)b).P("P")); // "APBP";
            TestLogger.Log(((IOP)d).P("Q")); // "BCQDP";
        }
  void run()
  {
    if (director_primitives.PrintDebug) Console.WriteLine("------------ Start ------------ ");

    Caller myCaller = new Caller();

    // test C++ base class
    using (Base myBase = new Base(100.0))
    {
      makeCalls(myCaller, myBase);
    }

    if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");

    // test vanilla C++ wrapped derived class
    using (Base myBase = new Derived(200.0))
    {
      makeCalls(myCaller, myBase);
    }

    if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");

    // test director / C# derived class
    using (Base myBase = new CSharpDerived(300.0))
    {
      makeCalls(myCaller, myBase);
    }

    if (director_primitives.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
  }
        public void Execute()
        {
            var assembly = Assembly.LoadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "protobuf-net.dll"));
            var derived = new Derived()
            {
                BaseFirstProperty = "BaseFirst",
                BaseSecProperty = "BaseSec",
                DerivedFirstProperty = "DerivedFirst"
            };

            var reflectionSerializer = assembly.GetType("ProtoBuf.Serializer");
            var getTypeSerializer = typeof(Serializer);

            var reflectionMethods = reflectionSerializer.GetMethods(BindingFlags.Static | BindingFlags.Public);
            var reflectionGenericMethodInfo = reflectionMethods.First<MethodInfo>(method => method.Name == "SerializeWithLengthPrefix");
            var reflectionSpecificMethodInfo = reflectionGenericMethodInfo.MakeGenericMethod(new Type[] { derived.GetType() });

            var getTypeMethods = getTypeSerializer.GetMethods(BindingFlags.Static | BindingFlags.Public);
            var getTypeGenericMethodInfo = getTypeMethods.First<MethodInfo>(method => method.Name == "SerializeWithLengthPrefix");
            var getTypeSpecificMethodInfo = getTypeGenericMethodInfo.MakeGenericMethod(new Type[] { derived.GetType() });

            var reflectionStream = new MemoryStream();
            var getTypeStream = new MemoryStream();
            reflectionSpecificMethodInfo.Invoke(null, new object[] { reflectionStream, derived, PrefixStyle.Base128 });
            getTypeSpecificMethodInfo.Invoke(null, new object[] { getTypeStream, derived, PrefixStyle.Base128 });

            Assert.AreEqual(37, (int)reflectionStream.Length, "loaded dynamically");
            Assert.AreEqual(37, (int)getTypeStream.Length, "loaded statically");
            
        }
 public void Run()
 {
     var b = new Base();
     b.Execute();
     b = new Derived();
     b.Execute();
 }
 static void Main()
 {
     Base B = new Base();
     Derived D = new Derived();
     B.Message();
     D.Message();
 }
Esempio n. 6
0
    public static void Main(string[] args)
    {
        var br = new BaseResult();
        var dr = new DerivedResult();

        var bas = new Base();
        var derived = new Derived();

        bas.Method();
        bas.MethodWithParameter1(br);
        bas.MethodWithParameter1(dr);
        bas.MethodWithParameter2(dr);

        bas = derived;
        bas.Method();
        bas.MethodWithParameter1(br);
        bas.MethodWithParameter1(dr);
        bas.MethodWithParameter2(dr);

        derived.Method();
        derived.MethodWithParameter1(br);
        derived.MethodWithParameter1(dr);
        derived.MethodWithParameter2(br);
        derived.MethodWithParameter2(dr);
    }
        public void Run()
        {
            // Array Covariance
            // http://msdn.microsoft.com/en-us/library/aa664572(v=vs.71).aspx
            /*
             * For any two reference-types A and B, if an implicit reference conversion (Section 6.1.4) or explicit reference conversion (Section 6.2.3)
             * exists from A to B, then the same reference conversion also exists from the array type A[R] to the array type B[R],
             * where R is any given rank-specifier (but the same for both array types).
             * This relationship is known as array covariance.
             * Array covariance in particular means that a value of an array type A[R] may actually be a reference to an instance of an array type B[R],
             * provided an implicit reference conversion exists from B to A.
             *
             * Because of array covariance, assignments to elements of reference type arrays include a run-time check that ensures that the value
             * being assigned to the array element is actually of a permitted type (Section 7.13.1).
             * */

            Base[] baseArray = new Base[1];
            Derived[] derivedArray = new Derived[] { new Derived() };

            // array element assignment is covariant
            baseArray[0] = new Derived();
            baseArray[0] = new OtherDerived();

            // This assignment is not type safe but it is allowed
            baseArray = derivedArray;
            baseArray[0] = new Derived();
            // ArrayTypeMismatchException at RUNTIME
            baseArray[0] = new OtherDerived();

            populate(derivedArray);
        }
Esempio n. 8
0
        public void DoIt()
        {
            var stringArray1 = new string[] {"A", "B", "C"};
            Array.Reverse(stringArray1);

            string[] stringArray2 = {"Hello", "World"};
            Array.Sort(stringArray2);

            var r = stringArray2.Concat(stringArray1);
            foreach(var i in r)
            {
                Console.Out.WriteLine(">>> " + i);
            }

            var d = new Derived();
            Console.Out.WriteLine("Value: " + d.Value);

            var list = new List<string>
                           {
                               "ghi",
                               "abc",
                               "rhj"
                           };
            list.Sort((s, s1) => string.Compare(s, s1) * -1);

            foreach (var i in list)
            {
                Console.Out.WriteLine("> " + i);
            }
        }
Esempio n. 9
0
        public void DemoVanInterface()
        {
            IBankAccount account = new Derived();
            account.Withdraw(10m);

            Console.WriteLine($"Balance: {((Base)account).Balance}");
        }
Esempio n. 10
0
        public void RefreshingEntityDerivedFromAbstractClass()
        {
            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    var d = new Derived();
                    session.Store(d);
                    session.SaveChanges();

                    using (var seperateSession = store.OpenSession())
                    {
                        var loaded = seperateSession.Load<Derived>(d.Id);
                        Assert.NotNull(loaded);
                        Assert.Empty(loaded.Foos);

                        loaded.AddFoo(new Foo() { Name = "a" });
                        seperateSession.SaveChanges();
                    }

                    session.Advanced.Refresh(d);
                    Assert.Single(d.Foos);
                }
            }
        }
    public static void Main ()
    	{	    
	    //Base[] derivedArray = new Base [10];
    	    //Base[] baseArray = new Derived [10];
	    Derived[] derivedArray = new Derived [10];
	    test (derivedArray);
    	}
 public static int MainMethod(string[] args)
 {
     dynamic d = new Derived();
     short x = d;
     if (x == short.MaxValue)
         return 0;
     return 1;
 }
Esempio n. 13
0
        protected override void Given()
        {
            _result = new Derived();

            _calculation = new Calculation(new Variable("Grasp", "Output", typeof(Base)), Expression.Constant(_result));

            _schema = new GraspSchema(Enumerable.Empty<Variable>(), new[] { _calculation });
        }
Esempio n. 14
0
        public void DemoVanOverrideVanMethod()
        {
            Base b = new Base();
            Derived d = new Derived();

            Console.WriteLine(b.CalculateInterest(100m));

            Console.WriteLine(d.CalculateInterest(100m));
        }
Esempio n. 15
0
 static void Oops(Derived d)
 {
     Console.WriteLine(d);
     Console.WriteLine(d.i);
     Console.WriteLine(d.j);
     Console.WriteLine(d.k);
     d.i = 0x77777777;
     d.j = 0x77777777;
 }
 void Factory(out Base b)
 {
     // covariant assignment
     if (DateTime.Now.Year > 2013) {
         b = new Derived();
     } else {
         b = new OtherDerived();
     }
 }
Esempio n. 17
0
        static void Main(string[] args)
        {
            Base d = new Derived();     //создаем экземпляр производного класса - в переменную БАЗОВОГО КЛАССА !!

            d.DoSomething();            //вызываем метод производного класса - (он переопределен)

            Console.WriteLine( d.MyProperty );  //доступ к свойству производного класса - (переопределено)
            Console.ReadKey();
        }
Esempio n. 18
0
 static void Main()
 {
     Base B = new Base();
     Derived D = new Derived();
     B.a = 1234;
     D.a = 5.678;
     Console.WriteLine(B.a);
     Console.WriteLine(D.a);
 }
        static void Main()
        {
            Derived d = new Derived();

                Base b = d as Base;
                if (b != null)
                {
                    Console.WriteLine(b.ToString());
                }
        }
Esempio n. 20
0
		public void ConversionToLessSpecificType2()
		{
			Derived derived = new Derived();

			Expression<Base> expr = new Expression<Base>("Test");
			expr.Parameters.Add("Test", typeof(Base), derived);
			Base result = expr.Evaluate();

			Assert.AreSame(derived, result);
		}
        public void Can_deserialize_private_set_in_base_class()
        {
            var derived = new Derived();
            derived.Set("test");

            string serialized = derived.ToJson();
            var deserialized = serialized.FromJson<Derived>();

            Assert.That(deserialized.Value, Is.EqualTo("test"));
        }
Esempio n. 22
0
        public void Thing()
        {
            Console.WriteLine("Creating base");
            var @base = new Base();
            Assert.NotNull(@base);

            Console.WriteLine("Creating derived");
            var derived = new Derived();
            Assert.NotNull(derived);
        }
Esempio n. 23
0
	public static int Main ()
	{
		var d = new Derived ();
		d.Print ();

		if (d.i != 90)
			return 1;

		return 0;
	}
        public void GivenNonCompatibleDecoratorType_ThrowsException()
        {
            // arrange
            var decoratee = new Derived();

            // act
            Action nonCompatibleDecoratorType = () => decoratee.DecoratedWith(typeof(NonCompatible));

            // assert
            Assert.Throws<ArgumentException>(nonCompatibleDecoratorType);
        }
        public void HierarchyCast()
        {
            Base myBaseType;
            myBaseType = new Derived(33); // Implicit cast between derived to base.
            Console.WriteLine("base.p1: {0}", myBaseType.p1);
            //myBaseType.p2; //--> compile error because Base is narrower than Derived!

            Derived myDerivedType = (Derived)myBaseType; // Must explicitly cast to store Base reference in Derived type.
            Console.WriteLine("derivate.p1: {0}", myDerivedType.p1);
            Console.WriteLine("derivate.p2: {0}", myDerivedType.p2);
        }
        public void GivenOneDecorator_ReturnsCorrectResult()
        {
            // arrange
            var decoratee = new Derived();

            // act
            var decorated = ((IBase) decoratee).DecoratedWith(typeof(Decorator1));

            // assert
            Assert.Equal("_decorator1_derived", decorated.Do());
        }
Esempio n. 27
0
    public static void Main(string[] args)
    {
        Action<Derived> dDerived = Method;
        Action<Base> dBase = Method;
        Action<IInterface> dIInterface = Method;

        var obj = new Derived();
        dIInterface(obj);
        dBase(obj);
        dDerived(obj);
    }
        public void GivenTwoDecorators_ReturnsCorrectResult()
        {
            // arrange
            IBase decoratee = new Derived();

            // act
            var decorated = decoratee.DecoratedWith(typeof(Decorator1)).DecoratedWith(typeof(Decorator2));

            // assert
            Assert.Equal("_decorator2_decorator1_derived", decorated.Do());
        }
        public void Run()
        {
            // simple assignment is covariant
            Base _base = new Derived();

            // as is function return
            _base = foo();

            // and value passed to function
            bar(new Derived());
        }
Esempio n. 30
0
        public void RunProgram()
        {
            var d1 = new Derived();
            Derived.number = 20;

            var d2 = new D();
            Console.WriteLine(D.number); //20
            Base.number = 30;

            Console.WriteLine(Derived.number); //30
            Console.WriteLine(D.number); //30
        }
Esempio n. 31
0
 public void ICall(Derived d)
 {
     d.ImplementMe(20);
 }
Esempio n. 32
0
 public static void Static(Derived d)
 {
     d.BaseMethod(10);
 }
Esempio n. 33
0
 public void StoreStaticField(Derived d)
 {
     ms_b = d;
     d.BaseMethod(10);
 }
        static void Main()
        {
            Derived d = new Derived();       // Create class object

            d.PrintOut("object.");           // Call method
        }
Esempio n. 35
0
 public void DCall(Derived d)
 {
     d.DerivedMethod(10);
 }
Esempio n. 36
0
 public virtual void Process(Derived obj)
 {
 }
Esempio n. 37
0
        public static void Entry()
        {
            Base <int, int> b = new Derived();

            b.CallT(123);
        }
Esempio n. 38
0
        static void Main(string[] args)
        {
            //Use Of GetType method
            object  obj  = new object();
            string  str1 = "Marvellous Infosystem";
            Derived dobj = new Derived();

            Type type1 = obj.GetType();
            Type type2 = str1.GetType();
            Type type3 = dobj.GetType();

            Console.WriteLine("Demonstration of GetType method..");

            //Object Class Output
            Console.WriteLine("Information of object class:");
            Console.WriteLine(type1.BaseType);
            Console.WriteLine(type1.Name);
            Console.WriteLine(type1.Namespace);
            Console.WriteLine(type1.FullName);
            Console.WriteLine(type1.DeclaringType);
            Console.WriteLine(type1.CustomAttributes);
            Console.WriteLine(type1.Attributes);

            //string output
            Console.WriteLine("Information of string class:");
            Console.WriteLine(type2.BaseType);
            Console.WriteLine(type2.Name);
            Console.WriteLine(type2.FullName);
            Console.WriteLine(type2.Namespace);
            Console.WriteLine(type2.ReflectedType);
            Console.WriteLine(type2.StructLayoutAttribute);
            Console.WriteLine(type2.TypeHandle);
            Console.WriteLine(type2.TypeInitializer);

            //Derived Output
            Console.WriteLine("Information of Derived class:");
            Console.WriteLine(type3.BaseType);
            Console.WriteLine(type3.Name);
            Console.WriteLine(type3.Namespace);
            Console.WriteLine(type3.FullName);
            Console.WriteLine(type3.IsClass);

            //Demonstration of Equals and ReferenceEqulas method

            Base bobj1 = new Base();
            Base bobj2 = new Derived();
            Base bobj3 = new Base();

            string str2 = "String";
            string str3 = "String";
            string str4 = "New String";

            Console.WriteLine("Comparison of 2 Objects:");
            Console.WriteLine(Object.Equals(bobj1, bobj2));
            Console.WriteLine(Object.Equals(str2, str3));

            Console.WriteLine(Object.ReferenceEquals(bobj1, bobj2));
            Console.WriteLine(Object.ReferenceEquals(bobj2, bobj2));
            Console.WriteLine(Object.ReferenceEquals(bobj1, bobj3));
            Console.WriteLine(Object.ReferenceEquals(str2, str3));
            Console.WriteLine(Object.ReferenceEquals(str2, str4));

            Console.WriteLine(str2.GetHashCode());
            Console.WriteLine(str3.GetHashCode());
            Console.WriteLine(str4.GetHashCode());

            Console.WriteLine("Demonstration of toString method:");
            int   salary     = 12000000;
            float percentage = 89.20f;

            string str5 = salary.ToString();
            string str6 = percentage.ToString();

            Console.WriteLine(str5);
            Console.WriteLine(str6);
        }
Esempio n. 39
0
 public override void Process(Derived obj)
 {
     Console.WriteLine("I got a Derived");
 }
Esempio n. 40
0
 public void TwoCalls(Derived d)
 {
     d.DerivedMethod(10);
     d.DerivedMethod(20);
 }
Esempio n. 41
0
        internal static ITestPrx Run(TestHelper helper)
        {
            Communicator communicator = helper.Communicator !;
            var          test         = ITestPrx.Parse(helper.GetTestProxy("test", 0), communicator);

            TextWriter output = helper.Output;

            output.Write("testing BitSequence and ReadOnlyBitSequence... ");

            Span <byte> span1       = stackalloc byte[7];
            Span <byte> span2       = stackalloc byte[3];
            var         bitSequence = new BitSequence(span1, span2);

            TestHelper.Assert(bitSequence.Length == 80);
            var onBits = new int[] { 0, 9, 35, 69, 70, 71, 79 };

            foreach (int i in onBits)
            {
                bitSequence[i] = true;
            }
            bitSequence[69] = true; // double true

            for (int i = 0; i < bitSequence.Length; ++i)
            {
                TestHelper.Assert(bitSequence[i] == onBits.Contains(i));
                bitSequence[i] = !bitSequence[i];
            }
            for (int i = 0; i < bitSequence.Length; ++i)
            {
                TestHelper.Assert(bitSequence[i] != onBits.Contains(i));
                bitSequence[i] = !bitSequence[i]; // back to original value
            }

            try
            {
                bitSequence[81] = true;
                TestHelper.Assert(false);
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            try
            {
                bitSequence[-5] = true;
                TestHelper.Assert(false);
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            Span <byte> span = stackalloc byte[10];

            span1.CopyTo(span);
            span2.CopyTo(span.Slice(7));
            var roBitSequence = new ReadOnlyBitSequence(span);

            TestHelper.Assert(roBitSequence.Length == 80);
            for (int i = 0; i < roBitSequence.Length; ++i)
            {
                TestHelper.Assert(roBitSequence[i] == onBits.Contains(i));
            }

            try
            {
                bool _ = roBitSequence[80];
                TestHelper.Assert(false);
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            try
            {
                bool _ = roBitSequence[-5];
                TestHelper.Assert(false);
            }
            catch (IndexOutOfRangeException)
            {
                // expected
            }

            output.Flush();
            output.WriteLine("ok");

            output.Write("testing basic operations with optional parameters... ");

            test.OpInt(null);
            test.OpInt(test.OpReturnInt());
            test.OpString(null);
            test.OpString(test.OpReturnString());

            test.OpBasic(17, 17, "test", "test");
            test.OpBasic(17, 17, null, "test");
            test.OpBasic(17, null, null, "test");

            (int?r, int o1, int?o2, string?o3) = test.OpBasicReturnTuple(5, 15, "test");
            TestHelper.Assert(r !.Value == 15 && o1 == 5 && o2 !.Value == 15 && o3 ! == "test");

            (r, o1, o2, o3) = test.OpBasicReturnTuple(6, null, null);
            TestHelper.Assert(r == null && o1 == 6 && o2 == null && o3 == null);
            output.WriteLine("ok");

            output.Write("testing operations with proxies and class parameters... ");
            TestHelper.Assert(test.OpObject(test, test) !.Equals(test));
            TestHelper.Assert(test.OpObject(test, null) == null);
            TestHelper.Assert(test.OpTest(test, test) !.Equals(test));
            TestHelper.Assert(test.OpTest(test, null) == null);

            var      classInstance = new C(42);
            AnyClass?anyClass      = test.OpAnyClass(classInstance, classInstance);

            TestHelper.Assert(anyClass != null && ((C)anyClass).X == 42);
            TestHelper.Assert(test.OpAnyClass(classInstance, null) == null);
            TestHelper.Assert(test.OpC(classInstance, classInstance) !.X == 42);
            TestHelper.Assert(test.OpC(classInstance, null) == null);

            try
            {
                test.OpObject(null !, null);
                TestHelper.Assert(false);
            }
            catch (NullReferenceException)
            {
            }

            try
            {
                test.OpTest(null !, null);
                TestHelper.Assert(false);
            }
            catch (NullReferenceException)
            {
            }

            // We detect null class instances through asserts during marshaling.

            output.WriteLine("ok");

            output.Write("testing operations with sequence<T?> parameters... ");
            int?[] intSeq = new int?[] { 1, -5, null, 19, -35000 };
            TestHelper.Assert(test.OpOptIntSeq(intSeq).SequenceEqual(intSeq));
            TestHelper.Assert(test.OpTaggedOptIntSeq(intSeq) !.SequenceEqual(intSeq));
            TestHelper.Assert(test.OpTaggedOptIntSeq(null) == null);

            string?[] stringSeq = new string?[] { "foo", "test", null, "", "bar" };
            TestHelper.Assert(test.OpOptStringSeq(stringSeq).SequenceEqual(stringSeq));
            TestHelper.Assert(test.OpTaggedOptStringSeq(stringSeq) !.SequenceEqual(stringSeq));
            TestHelper.Assert(test.OpTaggedOptStringSeq(null) == null);

            output.WriteLine("ok");

            output.Write("testing operations with dictionary<K, V?> parameters... ");
            Dictionary <int, int?> intIntDict = new Dictionary <int, int?> {
                { 1, -5 }, { 3, null }, { 5, 19 },
                { 7, -35000 }
            };

            TestHelper.Assert(test.OpIntOptIntDict(intIntDict).DictionaryEquals(intIntDict));
            TestHelper.Assert(test.OpTaggedIntOptIntDict(intIntDict) !.DictionaryEquals(intIntDict));
            TestHelper.Assert(test.OpTaggedIntOptIntDict(null) == null);

            Dictionary <int, string?> intStringDict = new Dictionary <int, string?> {
                { 1, "foo" }, { 3, "test" },
                { 5, null }, { 7, "bar" }
            };

            TestHelper.Assert(test.OpIntOptStringDict(intStringDict).DictionaryEquals(intStringDict));
            TestHelper.Assert(test.OpTaggedIntOptStringDict(intStringDict) !.DictionaryEquals(intStringDict));
            TestHelper.Assert(test.OpTaggedIntOptStringDict(null) == null);

            output.WriteLine("ok");

            output.Write("testing struct with optional data members... ");
            var      myStruct       = new MyStruct(test, null, new string?[] { "foo", null, "bar" });
            MyStruct myStructResult = test.OpMyStruct(myStruct);

            TestHelper.Assert(myStruct != myStructResult); // the proxies and arrays can't be identical
            TestHelper.Assert(myStructResult.Proxy !.Equals(myStruct.Proxy) &&
                              myStructResult.X == myStruct.X &&
                              myStructResult.StringSeq !.SequenceEqual(myStruct.StringSeq !));

            myStructResult = test.OpOptMyStruct(myStruct) !.Value;
            TestHelper.Assert(myStructResult.Proxy !.Equals(myStruct.Proxy) &&
                              myStructResult.X == myStruct.X &&
                              myStructResult.StringSeq !.SequenceEqual(myStruct.StringSeq !));

            TestHelper.Assert(test.OpOptMyStruct(null) == null);
            output.WriteLine("ok");

            output.Write("testing class with optional data members... ");
            var     derived       = new Derived(test, null, new string?[] { "foo", null, "bar" }, null, "test");
            Derived derivedResult = test.OpDerived(derived);

            TestHelper.Assert(derivedResult.Proxy !.Equals(derived.Proxy) &&
                              derivedResult.X == derived.X &&
                              derivedResult.StringSeq !.SequenceEqual(derived.StringSeq !) &&
                              derivedResult.SomeClass == null &&
                              derivedResult.S == derived.S);

            derivedResult = test.OpOptDerived(derived) !;
            TestHelper.Assert(derivedResult.Proxy !.Equals(derived.Proxy) &&
                              derivedResult.X == derived.X &&
                              derivedResult.StringSeq !.SequenceEqual(derived.StringSeq) &&
                              derivedResult.SomeClass == null &&
                              derivedResult.S == derived.S);

            TestHelper.Assert(test.OpOptDerived(null) == null);
            output.WriteLine("ok");

            output.Write("testing exception with optional data members... ");
            try
            {
                test.OpDerivedEx();
                TestHelper.Assert(false);
            }
            catch (DerivedEx ex)
            {
                TestHelper.Assert(ex.Proxy == null &&
                                  ex.X == 5 &&
                                  ex.StringSeq !.SequenceEqual(new string?[] { "foo", null, "bar" }) &&
                                  ex.SomeClass is C someClass && someClass.X == 42 &&
                                  ex.S == "test");
            }

            try
            {
                test.OpDerivedEx(context: new Dictionary <string, string> {
                    { "all null", "yes" }
                });
                TestHelper.Assert(false);
            }
            catch (DerivedEx ex)
            {
                TestHelper.Assert(ex.Proxy == null &&
                                  ex.X == null &&
                                  ex.StringSeq == null &&
                                  ex.SomeClass == null &&
                                  ex.S == null);
            }

            output.WriteLine("ok");
            return(test);
        }
Esempio n. 42
0
        static void Main(string[] args)
        {
            int a = 5;
            int b = a + 2;

            bool test = true;

            //int c = a + test;

            float   temperature;
            string  name;
            MyClass myClass = new MyClass();

            char firstLetter = 'C';
            var  limit       = 1;

            limit = 3333333;

            int[] source = { 1, 2, 3, 4, 5 };
            var   query  = from item in source where item <= item select item;

            myClass.MyProperty = 5;
            ChangeMyClass(myClass);
            Console.WriteLine(myClass.MyProperty);

            ChangeValue(a);
            Console.WriteLine(a);

            int aa = 123;

            System.Int32 bb = 123;

            var c      = aa + bb;
            var hexa   = 0x2A;
            var binary = 0b_0010_1010;

            string cadena = "test";
            char   letter = 'D';

            var characters = new[]
            {
                'j',
                '\u006A',
                '\x00A',
                (char)106
            };

            Console.WriteLine(string.Join(" ", characters));

            Console.WriteLine((int)Season.Autum);
            Console.WriteLine(Season.Autum.ToString());
            var error = ErrorCode.ConnectionLost;

            var test1 = ((ushort)ErrorCode.ConnectionLost == 100);
            var test2 = (ErrorCode.ConnectionLost == error);

            Coords coords = new Coords(1, 2, 3);

            (MyClass, string name, int, int, int, int, int)coord = (new MyClass(), "tr", 5, 4, 4, 4, 4);
            Console.WriteLine(coord.name);

            bool?   eval       = null;
            int?    num        = null;
            int     numNotNull = 0;
            string  cad        = null;
            MyClass myClass1   = null;

            //ChangeValue(num.Value);

            Dog dog = new Dog("Firulais", "5");

            Console.WriteLine(dog.ToString());

            int     numInt    = 1234563865;
            long    bigNumt   = numInt;
            Derived derivade  = new Derived();
            Base    baseClass = derivade;

            Giraffe g      = new Giraffe();
            Animal  animal = g;

            Giraffe g2 = (Giraffe)animal;

            int i = 3;

            Console.WriteLine($"i = {i}");
            Console.WriteLine($"++i = {++i}");
            Console.WriteLine($"i = {i}");

            if (!test && eval.Value)
            {
            }
            if (test)
            {
                a = 5;
            }
            else
            {
                a = 6;
            }

            a = (test ? 5 : (eval.Value ? 4 : 2));

            num = (num == null ? 5 : num);
            num = num ?? 5;

            string cadeNum = num?.ToString();

            List <int> nums = new List <int> {
                1, 2, 3, 4, 5, 6
            };

            nums.ForEach(num =>
            {
                Console.WriteLine(num);
                Console.WriteLine(num);
            });

            Employee employee = new Employee()
            {
                Name = "Erick"
            };
            //employee.Name = "Oscar";
        }
Esempio n. 43
0
 public void CrossCalls(Derived d)
 {
     d.BaseMethod(10);
     d.DerivedMethod(20);
 }
Esempio n. 44
0
 public static void Post(Derived model)
 {
 }
Esempio n. 45
0
        public static void Entry()
        {
            Inf i = new Derived();

            i.Foo();
        }
Esempio n. 46
0
 public static void GetParameterNotMatching([ApiConventionTypeMatch(ApiConventionTypeMatchBehavior.AssignableFrom)] Derived model)
 {
 }
Esempio n. 47
0
    static int Main()
    {
        Derived d = new Derived();

        return(d.Test());
    }
Esempio n. 48
0
 internal static void Object()
 {
     Base @base1 = new Base();
     Base @base2 = new Derived();
 }
Esempio n. 49
0
    public static int test_43_virtual()
    {
        Base b = new Derived();

        return(mono_test_marshal_virtual_delegate(b.get_del()));
    }
    public static void Main()
    {
        Derived d = new Derived();

        d.Access();
    }
Esempio n. 51
0
 public static void WriteLine(Derived d)
 {
     Console.WriteLine(d);
 }
Esempio n. 52
0
 public static void Main()
 {
     Derived d = new Derived(1);
 }
Esempio n. 53
0
 public void Call(Derived d)
 {
     DoBaseCall(d);
 }
 public static void Main(string[] args)
 {
     Derived d = new Derived();
 }
Esempio n. 55
0
 public void StoreField(Derived d)
 {
     m_b = d;
     d.BaseMethod(10);
 }
 public static void DoSomething(Derived obj)
 {
     Console.WriteLine("Test");
 }
Esempio n. 57
0
 public void CrossCalls(Derived d)
 {
     d.BaseMethod(10 + d.GetHashCode());
 }
Esempio n. 58
0
 public static int Main()
 {
     Derived.EndExecute <Derived> (null, "something");
     return(0);
 }
Esempio n. 59
0
 static void DerivedAsInputFunc(Derived x)
 {
 }
    static void Main()
    {
        Base x = new Derived();

        x.Foo(t);     // not allowed!
    }