Exemplo n.º 1
0
 public IOMaping(MyInterface mControl, PinMapStruct PinMap)
 {
     InitializeComponent();
     this.mControl = mControl;
     this.PinMap   = PinMap;
     DisplayPinMap(PinMap);
 }
Exemplo n.º 2
0
    public void Call <T>(MyInterface <T> thingDoer)
    {
        T something = thingDoer.GetSomething();

        thingDoer.DoSomething(something);
        thingDoer.DoSomething(something);
    }
Exemplo n.º 3
0
        public void Run()
        {
            MyClass c = new MyClass();
            MyInterface[] arr = new MyClass[4];
            arr[0] = c;

            MyBase[] arr2 = new MyClass[1];
            arr[0] = c;

            object[] arr3 = (object[])arr;
            arr3[1] = c;

            MyBaseInterface[] arr4 = new MyDerivedInterface[1];
            arr4[0] = c;

            object[] arr5 = new MyInterface[1];
            arr5[0] = c;

            MyClass[] arr6 = new MyClass[1];
            arr6[0] = c;
            PassClassAsInterface(arr6);

            MyClass[][] arr7 = new MyClass[1][];
            arr7[0] = new MyClass[1];
            arr7[0][0] = c;
            PassArrayOfArray(arr7);
        }
Exemplo n.º 4
0
    private static int TestMultipleInterfaces()
    {
        TestClass <int> testInt = new TestClass <int>(5);

        MyInterface myInterface = testInt as MyInterface;

        if (!myInterface.GetAString().Equals("TestClass"))
        {
            Console.Write("On type TestClass, MyInterface.GetAString() returned ");
            Console.Write(myInterface.GetAString());
            Console.WriteLine(" Expected: TestClass");
            return(Fail);
        }


        if (myInterface.GetAnInt() != 1)
        {
            Console.Write("On type TestClass, MyInterface.GetAnInt() returned ");
            Console.Write(myInterface.GetAnInt());
            Console.WriteLine(" Expected: 1");
            return(Fail);
        }

        Interface <int> itf = testInt as Interface <int>;

        if (itf.GetT() != 5)
        {
            Console.Write("On type TestClass, Interface<int>::GetT() returned ");
            Console.Write(itf.GetT());
            Console.WriteLine(" Expected: 5");
            return(Fail);
        }

        return(Pass);
    }
Exemplo n.º 5
0
        static void Class2()
        {
            var ints = new List <MyStruct>();
            var objs = new List <MyClass>();

            for (int i = 0; i < 70000; i++)
            {
                ints.Add(new MyStruct());
                objs.Add(new MyClass());
            }

            sw.Start();
            for (int i = 0; i < 70000; i++)
            {
                MyInterface a = ints[i];
            }
            sw.Stop();
            Console.WriteLine($"Interface struct write time => {sw.ElapsedTicks}");
            sw.Reset();

            sw.Start();
            for (int i = 0; i < 70000; i++)
            {
                MyInterface a = objs[i];
            }
            sw.Stop();
            Console.WriteLine($"Interface class write time => {sw.ElapsedTicks}");
            sw.Reset();
        }
    static void Main(string[] args)
    {
        BasePartViewModel <Plug> derived = new BasePartViewModel <Plug>();
        MyInterface <Part>       b       = derived;

        b.OpenFile();
    }
Exemplo n.º 7
0
 /// <summary>
 /// IO 제허 함수를 생성한다.
 /// </summary>
 /// <param name="mControl"></param>
 public IOControl(MyInterface mControl)
 {
     this.mControl   = mControl;
     timer1.Interval = 10;
     timer1.Tick    += new EventHandler(Timer1_Tick);
     timer1.Enabled  = true;
     return;
 }
Exemplo n.º 8
0
    public void InstanceReturnsTypesThatImplementAnInterface()
    {
        TestableGetInstanceForm form        = new TestableGetInstanceForm(typeof(IInterface));
        MyInterface             implementor = new MyInterface();

        form.OnObjectCreated(implementor);
        Assert.AreSame(implementor, form.Instance);
    }
Exemplo n.º 9
0
    public static void Main()
    {
        Derived der = new Derived();

        der.MyMethodInInterface();
        MyInterface helper = (MyInterface)der;

        helper.MyMethodInInterface();
    }
        static void Main(string[] args)
        {
            var         assembly = Assembly.LoadFrom("GetString.Library.dll");
            Type        type     = assembly.GetType("GetString.Library.MyLibrary");
            MyInterface instance = (MyInterface)Activator.CreateInstance(type);

            Console.WriteLine(instance.GetString());
            Console.ReadKey();
        }
Exemplo n.º 11
0
        public MES_Control(MyInterface mControl, __TcpIP__ ServerIp, __TcpIP__ ClientIp)
        {
            this.mControl     = mControl;
            this.ServerIpAddr = ServerIp;
            this.ClientIpAddr = ClientIp;

            timer1.Interval = 1000;
            timer1.Tick    += Timer1_Tick;
        }
Exemplo n.º 12
0
 public IOControl(MyInterface mControl, __TcpIP__ Board, __TcpIP__ PC)
 {
     this.PC         = PC;
     this.Board      = Board;
     timer1.Interval = 10;
     timer1.Tick    += timer1_tick;
     this.mControl   = mControl;
     //timer1.Enabled = true;
 }
Exemplo n.º 13
0
    static void Main(string[] args)
    {
        MyInterface iface = CreateInstance();

        Console.WriteLine(iface.GetValue());
        try { iface.ThrowError(); }
        catch (Exception ex) { Console.WriteLine(ex); }
        Console.ReadKey(true);
    }
Exemplo n.º 14
0
        private ClassWithInterface CreateModel(MyInterface implementation)
        {
            var c = new ClassWithInterface
            {
                name        = "Test",
                myInterface = implementation
            };

            return(c);
        }
        static void Main(string[] args)
        {
            IMyInterface MyInterface;
            MyClass      myClassObject = new MyClass();

            MyInterface = myClassObject;

            MyInterface.SomeMethod();
            MyInterface.AnotherMethod("hello");
        }
Exemplo n.º 16
0
 private static MyInterface[] MakeInterfaceArray()
 {
     MyInterface[] itfs = new MyInterface[50];
     itfs[0]  = new Foo0();
     itfs[1]  = new Foo1();
     itfs[2]  = new Foo2();
     itfs[3]  = new Foo3();
     itfs[4]  = new Foo4();
     itfs[5]  = new Foo5();
     itfs[6]  = new Foo6();
     itfs[7]  = new Foo7();
     itfs[8]  = new Foo8();
     itfs[9]  = new Foo9();
     itfs[10] = new Foo10();
     itfs[11] = new Foo11();
     itfs[12] = new Foo12();
     itfs[13] = new Foo13();
     itfs[14] = new Foo14();
     itfs[15] = new Foo15();
     itfs[16] = new Foo16();
     itfs[17] = new Foo17();
     itfs[18] = new Foo18();
     itfs[19] = new Foo19();
     itfs[20] = new Foo20();
     itfs[21] = new Foo21();
     itfs[22] = new Foo22();
     itfs[23] = new Foo23();
     itfs[24] = new Foo24();
     itfs[25] = new Foo25();
     itfs[26] = new Foo26();
     itfs[27] = new Foo27();
     itfs[28] = new Foo28();
     itfs[29] = new Foo29();
     itfs[30] = new Foo30();
     itfs[31] = new Foo31();
     itfs[32] = new Foo32();
     itfs[33] = new Foo33();
     itfs[34] = new Foo34();
     itfs[35] = new Foo35();
     itfs[36] = new Foo36();
     itfs[37] = new Foo37();
     itfs[38] = new Foo38();
     itfs[39] = new Foo39();
     itfs[40] = new Foo40();
     itfs[41] = new Foo41();
     itfs[42] = new Foo42();
     itfs[43] = new Foo43();
     itfs[44] = new Foo44();
     itfs[45] = new Foo45();
     itfs[46] = new Foo46();
     itfs[47] = new Foo47();
     itfs[48] = new Foo48();
     itfs[49] = new Foo49();
     return(itfs);
 }
Exemplo n.º 17
0
        public void GrandChildClass_AsInterface()
        {
            MyInterface source = GrandChildClassHelper.Generate();

            var dest = GetClone(source, 1);

            Assert.NotNull(dest);
            Assert.NotSame(dest, source);
            Assert.Equal(source.Parent_Public_GetSet_AutoProp, dest.Parent_Public_GetSet_AutoProp);
            Assert.Equal(source.Parent_Public_Get_AutoProp, dest.Parent_Public_Get_AutoProp);
        }
Exemplo n.º 18
0
        public PanelMeter(MyInterface mControl)
        {
            this.mControl = mControl;

            SerialPort1.DataReceived += new SerialDataReceivedEventHandler(DataCatch1);
            SerialPort2.DataReceived += new SerialDataReceivedEventHandler(DataCatch2);
            timer1.Interval           = 10;
            timer1.Tick   += new EventHandler(timer1_tick);
            timer1.Enabled = true;
            return;
        }
Exemplo n.º 19
0
        public string GetStringTest()
        {
            //显示实现接口和直接实现接口的区别,
            //在于显示实现接口强制用户使用接口引用对象
            InterfaceTest        it       = new InterfaceTest();
            MyInterface          mit      = it;
            int                  index    = it.GetInumer("this", end: 200, start: 0);
            List <InterfaceTest> listTest = new List <InterfaceTest>();

            return("Tea pot...");
        }
        private static void ReferenceMethod(int[] array, ref MyInterface myInterface, ref Object thing, ref String word)
        {
            int j = 10;

            for (int i = 0; i < array.Length; i++)
            {
                array[i] = j;
                j--;
            }
            myInterface = new MyClass();
            thing       = null;
            word        = "dog";
        }
Exemplo n.º 21
0
    public Class()
    {
        if (condition == true)
        {
            control = new UserControl1();
        }
        else
        {
            control = new UserControl2();
        }

        control.LoadXML();
    }
Exemplo n.º 22
0
    private static int TestAVInInterfaceCache()
    {
        MyInterface[] itfs = MakeInterfaceArray();

        MyInterface[] testArray = new MyInterface[itfs.Length * 2];

        for (int i = 0; i < itfs.Length; i++)
        {
            testArray[i * 2 + 1] = itfs[i];
        }

        int numExceptions = 0;

        // Make sure AV in dispatch helpers is translated to NullRef
        for (int i = 0; i < testArray.Length; i++)
        {
            try
            {
                testArray[i].GetAnInt();
            }
            catch (NullReferenceException)
            {
                numExceptions++;
            }
        }

        // Make sure there's no trouble with unwinding out of the dispatch helper
        InterfaceWithManyParameters testInstance = null;

        for (int i = 0; i < 3; i++)
        {
            try
            {
                testInstance.ManyParameters(0, 0, 0, 0, 0, 0, 0, 0);
            }
            catch (NullReferenceException)
            {
                numExceptions++;
            }
            if (testInstance == null)
            {
                testInstance = new ClassWithManyParameters();
            }
            else
            {
                testInstance = null;
            }
        }

        return(numExceptions == itfs.Length + 2 ? Pass : Fail);
    }
Exemplo n.º 23
0
        public IndexModel(MyInterface _i)
        {
            _interface = _i;
            List <Type> types = new List <Type> {
                typeof(int), typeof(string)
            };                                                                 //определение типов свойств

            _i.SetTypes(types);

            _obj          = new MyObject();
            vm            = new ViewModel();
            vm.Name       = _obj.GetType().Name;
            vm.Properties = _interface.MyGetProperties(_obj);
        }
        static void Main(string[] args)
        {
            //value types
            bool   valType1 = true;
            byte   valType2 = 127;
            char   valType3 = 'a';
            double valType4 = 3.14159265359;
            float  valType5 = 3.14f;
            int    valType6 = 42;
            long   valType7 = 999999999;
            short  valType8 = 9999;

            ValueMethod(valType1, valType2, valType3, valType4, valType5, valType6, valType7, valType8);
            Console.WriteLine(valType1);
            Console.WriteLine(valType2);
            Console.WriteLine(valType3);
            Console.WriteLine(valType4);
            Console.WriteLine(valType5);
            Console.WriteLine(valType6);
            Console.WriteLine(valType7);
            Console.WriteLine(valType8);

            //reference types
            int[]       array       = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            MyInterface myInterface = null;
            Object      thing       = new Object();
            String      word        = "cat";

            ReferenceMethod(array, ref myInterface, ref thing, ref word);
            Console.WriteLine("\n[" + string.Join(", ", array) + "]");
            if (myInterface == null)
            {
                Console.WriteLine("It doesn't work: null");
            }
            else
            {
                myInterface.Method();
            }
            if (thing == null)
            {
                Console.WriteLine("null");
            }
            else
            {
                Console.WriteLine(thing);
            }
            Console.WriteLine(word + "\n");
        }
Exemplo n.º 25
0
    static void Main(string[] args)
    {
        MyClass1    A = new MyClass1(5);
        MyInterface B = A;

        Console.WriteLine(A.Num());
        Console.WriteLine(B.Num());

        MyClass2    C = new MyClass2(5);
        MyInterface D = C;

        Console.WriteLine(C.Num());
        Console.WriteLine(D.Num());

        Console.ReadKey();
    }
Exemplo n.º 26
0
        public void TestMethod1()
        {
            A a = new A();

            a.a = 10;
            a.b = 12;

            MyInterface myInterface = MockRepository.Mock <MyInterface>();

            myInterface.Expect(x => x.retValue(Arg <A> .Matches(m => m.a == 10 && m.b == 12)))
            .Return(5);

            int ret = myInterface.retValue(a);

            Assert.True(ret == 5);
            myInterface.VerifyExpectations(true);
        }
Exemplo n.º 27
0
        public static int guess(MyInterface obj, int v)
        {
            if (obj == null)
            {
                return(-1);
            }

            obj.setValue(v);

            if (obj.getValue() == 10)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 28
0
        //@SetteRequiredStatementCoverage(value = 71)
        public static int guessImpossible(MyInterface obj, int v)
        {
            if (obj == null)
            {
                return(-1);
            }

            obj.setValue(v);

            if (obj.getValue() == v + 1)
            {
                // impossible, no such an implementation is present
                throw new Exception();
            }
            else
            {
                return(1);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// IO 제허 함수를 생성한다.
        /// </summary>
        /// <param name="mControl"></param>
        public IOControl(MyInterface mControl)
        {
            P32C32.OutData[0] = new byte[4];
            P32C32.OutData[1] = new byte[4];
            P32C32.OutData[2] = new byte[4];

            P32C32.InData[0] = new byte[4];
            P32C32.InData[1] = new byte[4];
            P32C32.InData[2] = new byte[4];

            C64.OutData[0] = new byte[8];
            C64.OutData[1] = new byte[8];
            C64.OutData[2] = new byte[8];

            this.mControl = mControl;
            timer1.Interval = 10;
            timer1.Tick += new EventHandler(Timer1_Tick);
            timer1.Enabled = true;
            return;
        }
Exemplo n.º 30
0
        public void TestMethod1()
        {
            MockRepository mock = new MockRepository();

            MyInterface myInterface = mock.StrictMock <MyInterface>();

            A a = new A();

            a.a = 10;
            a.b = 12;

            myInterface.retValue(a);
            LastCall.Return(5).Constraints(
                Property.Value("a", 10) && Property.Value("b", 12)
                );
            mock.ReplayAll();

            int ret = myInterface.retValue(a);

            mock.VerifyAll();
            Assert.True(ret == 5);
        }
Exemplo n.º 31
0
    public static void Main()
    {
        MyClass ob = new MyClass();
        bool    result;

        result = ob.MyMethodB(4);
        if (result)
        {
            Console.WriteLine("4 is even.");
        }

        // result = ob.MyMethodA(4); // Error, MyMethodA not directly accessible
        result = !((MyInterface)ob).MyMethodA(4); //

        MyInterface iRef = (MyInterface)ob;       //upcast ->MyInterface o = this

        result = iRef.MyMethodA(3);
        if (result)
        {
            Console.WriteLine("3 is odd.");
        }
    }
Exemplo n.º 32
0
 private void PassArrayOfArray(MyInterface[][] arr)
 {
     arr[0][0].Test();
 }
Exemplo n.º 33
0
 public void TestNotNullViaInterface2(MyInterface m)
 {
   var tmp = m.InterfaceMethod("ciao!");
   Contract.Assert(tmp != null);
 }
Exemplo n.º 34
0
 private void PassClassAsInterface(MyInterface[] arr)
 {
     arr[0].Test();
 }
Exemplo n.º 35
0
 public void TestGEQ_ZeroViaInterface(MyInterface i)
 {
   var value = i.Count;
   Contract.Assert(value >= 0);
 }