示例#1
0
        public void Should_FailEqualityForDifferentNumericValues()
        {
            var numericItem  = new I2(1);
            var numericItem2 = new I2(2);

            Assert.IsFalse(numericItem.Equals(numericItem2));
        }
示例#2
0
        public ServiceC(
            I2 service2,
            I3 service3,
            I4 service4,
            I5 service5)
        {
            if (service2 is null)
            {
                throw new ArgumentNullException(nameof(service2));
            }

            if (service3 is null)
            {
                throw new ArgumentNullException(nameof(service3));
            }

            if (service4 is null)
            {
                throw new ArgumentNullException(nameof(service4));
            }

            if (service5 is null)
            {
                throw new ArgumentNullException(nameof(service5));
            }
        }
示例#3
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var query = from a in db.Locations
                        from b in db.Events
                        where b.Id == id && a.ID == b.LocationId
                        join c in db.Monsters on b.MonsterId equals c.Id into C
                        from m in C.DefaultIfEmpty()
                        join i1 in db.Images on a.ImageId equals i1.ID into I1
                        from ia in I1.DefaultIfEmpty()
                        join i2 in db.Images on m.ImageId equals i2.ID into I2
                        from im in I2.DefaultIfEmpty()
                        select new DetailsEventViewModel
            {
                Event         = b,
                Location      = a,
                LocationImage = ia != null ? ia : null,
                Monster       = m != null ? m : null,
                MonsterImage  = im != null ? im : null
            };

            var oneEvent = query.FirstOrDefault();

            if (oneEvent == null)
            {
                return(HttpNotFound());
            }

            return(View(oneEvent));
        }
示例#4
0
        public void InitClojureFnMappingsWorks()
        {
            //SanityCheck.PrintMethods(_obj.GetType());

            Impl1 impl1 = _obj as Impl1;

            Expect(impl1.m1(21), EqualTo(100));

            MethodInfo m1Method = _proxyType.GetMethod("m1", new Type[] { typeof(int) });

            Expect(m1Method, Not.Null);
            Expect(m1Method.Invoke(_obj, new object[] { 21 }), EqualTo(100));

            I1 i1 = _obj as I1;

            Expect(i1, Not.Null);
            Expect(i1.m1(42), EqualTo(100));
            Expect(i1.m2("help"), EqualTo(200));
            // just hoping the next one doesn't blow up
            // We set a flag to test
            Fn2V._called = false;
            i1.m2v("abcd");
            Expect(Fn2V._called);

            Expect(i1.m2s("job"), EqualTo("nice job"));

            I2 i2 = _obj as I2;

            Expect(i2, Not.Null);
            Expect(i2.m1(25), EqualTo(100));
            Expect(i2.m3(60), EqualTo(300));
            Expect(i2.m3("test"), EqualTo(300));
            Expect(i2.m4("junk"), EqualTo(400));
        }
示例#5
0
    static void Main()
    {
        Customer C1 = new Customer();

        C1.Customer2Print();
        C1.Customer3Print();
        C1.Customer1Print();

        ICustomer2 IC2 = new Customer();

        IC2.Customer2Print(); // Only ICustomer2 member available.

        Program P = new Program();

        ((I1)P).InterfaceMethod(); //As the method names in both the interface us same. InterfaceMethod() cannot be called on Program object.
        ((I2)P).InterfaceMethod();

        /* OR */
        I1 i1 = new Program();
        I2 i2 = new Program();

        i1.InterfaceMethod();
        i2.InterfaceMethod();

        /* OR */
        I1 ii1 = new Program();
        I2 ii2 = (Program)ii1; //may not be a good practice in actual, but depends.

        ii1.InterfaceMethod();
        ii2.InterfaceMethod();


        Console.ReadKey();
    }
示例#6
0
        public void Should_BeEqualIfNumericItemsEqual()
        {
            var numericItem  = new I2(1);
            var numericItem2 = new I2(1);

            Assert.IsTrue(numericItem.Equals(numericItem2));
        }
示例#7
0
        public void Should_FailEqualityForDifferetObjectTypes()
        {
            var numericItem = new I2(1);
            var obj         = "test";

            Assert.IsFalse(numericItem.Equals(obj));
        }
 public static void Test()
 {
             #pragma warning disable 219
     Derived <Derived <int> >       d   = new Derived <Derived <int> >();
     I2 <Derived <Derived <int> > > idi = d;
             #pragma warning restore 219
 }
示例#9
0
        public void Should_CreateCorrectI2Item()
        {
            var numericItem = new I2(1);

            Assert.IsTrue(numericItem.Value == 1);
            Assert.IsTrue(numericItem.Type == Format.I2);
        }
示例#10
0
        public void Should_FailEqualityForDifferentDataTypes()
        {
            var numericItem  = new U8(1);
            var numericItem2 = new I2(1);

            Assert.IsFalse(numericItem.Equals(numericItem2));
        }
示例#11
0
 public SomeClass(I1 i1, I2 i2, I3 i3, int i, int?nullableI, string s)
 {
     _i1 = i1 ?? throw new ArgumentNullException(nameof(i1));
     _i2 = i2 ?? throw new ArgumentNullException(nameof(i2));
     _i3 = i3 ?? throw new ArgumentNullException(nameof(i3));
     _s  = s ?? throw new ArgumentNullException(nameof(s));
 }
示例#12
0
    void Run(I2 i)
    {
        // Viable callables: C18.M1()
        i.M1();

        // Viable callables: I2.M2()
        i.M2();
    }
示例#13
0
 public ServiceA(I2 service2)
 {
     if (service2 is null)
     {
         throw new ArgumentNullException(nameof(service2));
     }
     Service2 = service2;
 }
 int I1.GF1 <TF> (I2 i2, long counter, long initial_stack, long current_stack)
 {
     if (counter > 0)
     {
         return(i2.GF2 <TF> (this, counter - 1, initial_stack, (long)&counter));
     }
     return(check((long)&counter, current_stack));
 }
示例#15
0
        int z = 0; //flag


        private void recountBtn_Click(object sender, EventArgs e)
        {
            I1 -= 0.09;
            I2 -= 0.09;
            I3 -= 0.09;
            I4 -= 0.09;
            I5 -= 0.09;
            I6 -= 0.09;

            I1tb.Text = I1.ToString();
            I2tb.Text = I2.ToString();
            I3tb.Text = I3.ToString();
            I4tb.Text = I4.ToString();
            I5tb.Text = I5.ToString();
            I6tb.Text = I6.ToString();

            U2 = I2 * EU * IV / ((IV + I2 + I1) * (I2 + I3 + I4 + I5 - Math.Pow(I2, 2) / (IV + I2 + I1) - Math.Pow((I4 + I5), 2) / (I4 + I5 + I6)));
            U1 = U2 * I2 / (IV + I2 + I1) + EU * IV / (IV + I2 + I1);
            U3 = U2 * (I4 + I5) / (I4 + I5 + I6);
            U1 = Math.Round(U1, 3);
            U2 = Math.Round(U2, 3);
            U3 = Math.Round(U3, 3);

            U1label.Text = "U1 = " + U1.ToString();
            U2label.Text = "U2 = " + U2.ToString();
            U3label.Text = "U3 = " + U3.ToString();

            if (z == 1)
            {
                F1 = Math.Round(Math.Pow(U11 - U1, 2), 3);
            }
            if (z == 2)
            {
                F1 = Math.Round(Math.Pow(U22 - U2, 2), 3);
            }
            if (z == 3)
            {
                F1 = Math.Round(Math.Pow(U33 - U3, 2), 3);
            }

            if (F1 < F)
            {
                FTB.Text = F1.ToString();
                F        = F1;
                logsRTB.AppendText("Целевая функция уменьшается F=" + F1.ToString() + "\n");
                logsRTB.ScrollToCaret();
            }
            else
            {
                logsRTB.AppendText("Целевая функция увеличилась F=" + F1.ToString() + "\n");
                logsRTB.ScrollToCaret();
                recountBtn.Enabled = false;
            }
            Fz = 0;

            calculateGrad();
            calculateHessian();
        }
示例#16
0
    int I1.F1(I2 i2, int counter, long initial_stack, long current_stack)
    {
        int local;

        if (counter > 0)
        {
            return(i2.F2(this, counter - 1, initial_stack, (long)&local));
        }
        return(check((long)&local, current_stack));
    }
示例#17
0
        static void Main(string[] args)
        {
            MyClass myClass = new MyClass();

            myClass.X = 10;

            I2 i2 = myClass;

            Console.WriteLine("I1.X => " + myClass.X);
            Console.WriteLine("I2.X() => " + i2.X());
        }
示例#18
0
        public static void Main()
        {
            MultipleInheritance Obj1 = new MultipleInheritance();
            I1 Interface1            = Obj1;

            Interface1.myMethod();
            I2 Interface2 = Obj1;

            Interface2.myMethod();
            Console.ReadLine();
        }
示例#19
0
 public void InformationLevel1()
 {
     if (totalFunds >= 500)
     {
         gameObject.GetComponent <Plague>().insideChance  *= 0.8f;
         gameObject.GetComponent <Plague>().outsideChance *= 0.8f;
         totalFunds -= 500;
         I2.SetActive(true);
         MT2.SetActive(true);
     }
 }
示例#20
0
        public static void TestC2()
        {
            var c2 = new C2();
            I1  i1 = c2;
            I2  i2 = c2;

            i1.Prop1 = 10;
            Assert.AreEqual(9, i1.Prop1);

            i2.Prop1 = 10;
            Assert.AreEqual(11, i2.Prop1);
        }
示例#21
0
文件: Program.cs 项目: alincak/CSharp
        static void Main(string[] args)
        {
            MyClass myClass = new MyClass();

            I1 i1 = myClass;
            I2 i2 = myClass;

            i1.Write();
            i2.Write();

            Write(myClass);
        }
示例#22
0
        /// <summary>
        /// Given three of the four current channels, calculates the
        /// missing channel based on the relationship IR = IA + IB + IC.
        /// </summary>
        /// <param name="meterInfo">Data context for accessing configuration tables in the database.</param>
        public DataSeries CalculateMissingCurrentChannel()
        {
            Meter      meter;
            DataSeries missingSeries;

            // If the data group does not have exactly 3 channels,
            // then there is no missing channel or there is not
            // enough data to calculate the missing channel
            if (DefinedCurrents != 3)
            {
                return(null);
            }

            // Get the meter associated with the channels in this data group
            meter = (I1 ?? I2).SeriesInfo.Channel.Meter;

            if (m_i1Index == -1)
            {
                // Calculate I1 = IR - I2 - I3
                missingSeries            = IR.Add(I2.Negate()).Add(I3.Negate());
                missingSeries.SeriesInfo = GetSeriesInfo(meter, m_dataGroup, "Current", "General1");
                m_i1Index = m_dataGroup.DataSeries.Count;
                m_dataGroup.Add(missingSeries);
            }
            else if (m_i2Index == -1)
            {
                // Calculate I2 = IR - I1 - I3
                missingSeries            = IR.Add(I1.Negate()).Add(I3.Negate());
                missingSeries.SeriesInfo = GetSeriesInfo(meter, m_dataGroup, "Current", "General2");
                m_i1Index = m_dataGroup.DataSeries.Count;
                m_dataGroup.Add(missingSeries);
            }
            else if (m_i3Index == -1)
            {
                // Calculate I3 = IR - I1 - I2
                missingSeries            = IR.Add(I1.Negate()).Add(I2.Negate());
                missingSeries.SeriesInfo = GetSeriesInfo(meter, m_dataGroup, "Current", "General3");
                m_i1Index = m_dataGroup.DataSeries.Count;
                m_dataGroup.Add(missingSeries);
            }
            else
            {
                // Calculate IR = I1 + I2 + I3
                missingSeries            = I1.Add(I2).Add(I3);
                missingSeries.SeriesInfo = GetSeriesInfo(meter, m_dataGroup, "Current", "RES");
                m_i1Index = m_dataGroup.DataSeries.Count;
                m_dataGroup.Add(missingSeries);
            }

            return(missingSeries);
        }
示例#23
0
        static void Main(string[] args)
        {
            C obj = new C();

            I1 ir1 = obj;

            I2 ir2 = obj;

            obj.f();
            ir1.f();
            ir2.f();

            Console.ReadKey();
        }
示例#24
0
 public MainViewModel()
 {
     SelectionViewModel
     .WhenAnyValue(a => a.SelectedValue)
     .Where(a => a != null)
     .Select(method => (a: method, method.GetParameters().Count()))
     .CombineLatest(I1.WhenAnyValue(_ => _.Output), I2.WhenAnyValue(a => a.Output), (a, b, c) => NewMethod(b, c, v => a.a.Invoke(null, v), a.Item2))
     .SelectMany(a => a.ToObservable())
     .ObserveOnDispatcher()
     .Subscribe(normal =>
     {
         O.Mean = normal.Mean;
         O.StandardDeviation = normal.StdDev;
     });
示例#25
0
        public void UpdateClojureFnMappingsWorks()
        {
            IProxy ip = _obj as IProxy;

            ip.__updateClojureFnMappings(
                PersistentHashMap.create("m3", new Fn3(500), "m4", new Fn4(600)));

            I2 i2 = _obj as I2;

            Expect(i2, Not.Null);
            Expect(i2.m1(25), EqualTo(100));
            Expect(i2.m3(60), EqualTo(500));
            Expect(i2.m3("test"), EqualTo(500));
            Expect(i2.m4("junk"), EqualTo(600));
        }
示例#26
0
    static void Main()
    {
        A a = new A();

        a.Foo();

        // I1 i1 = a;
        // i1.Bar();
        ((I1)a).Bar();

        I2 i2 = a;

        i2.Bar();

        a.Bar(); // TPC !!!!
    }
示例#27
0
 static void Test6()
 {
     Console.WriteLine("--- Test5: I2[] to I1[]");
     try
     {
         I2[] arr1 = new I2[] { new B(), new B(), new B() };
         I1[] arr2 = (I1[])arr1;
         for (int i = 0; i < arr2.Length; ++i)
         {
             Console.WriteLine(arr2[i]);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.GetType());
     }
 }
        public void Call(ItemObj item)
        {
            switch (Last)
            {
            case 1:
                I1.ChangeItem(item);
                break;

            case 2:
                I2.ChangeItem(item);
                break;

            case 3:
                I3.ChangeItem(item);
                break;

            case 4:
                I4.ChangeItem(item);
                break;

            case 5:
                I5.ChangeItem(item);
                break;

            case 6:
                I6.ChangeItem(item);
                break;

            case 7:
                I7.ChangeItem(item);
                break;

            case 8:
                I8.ChangeItem(item);
                break;

            case 9:
                I9.ChangeItem(item);
                break;

            case 10:
                O.ChangeItem(item);
                break;
            }
        }
示例#29
0
        protected override void Check()
        {
            var c = new C();
            I2  i = c;

            Component.Bind(nameof(i.R1), nameof(i.P1));
            Component.Bind(nameof(i.R2), nameof(i.P2));
            Component.Bind <Action <int> >(nameof(i.R3), nameof(i.P3));
            Component.Bind <Func <int> >(nameof(i.R3), nameof(i.P3));

            c._x = 10;
            i.R1.ShouldBe(5);

            i.R2 = 12;
            c._x.ShouldBe(24);

            i.R3.ShouldBe(48);
            i.R3 = 12;
            c._x.ShouldBe(6);
        }
示例#30
0
        public static void TestC3()
        {
            var c3 = new C3();
            I1  i1 = c3;
            I2  i2 = c3;

            i1.Prop1 = 10;
            Assert.AreEqual(10, i1.Prop1);
            Assert.AreEqual(10, i2.Prop1);
            Assert.AreEqual(10, c3.Prop1);

            i2.Prop1 = 11;
            Assert.AreEqual(11, i1.Prop1);
            Assert.AreEqual(11, i2.Prop1);
            Assert.AreEqual(11, c3.Prop1);

            c3.Prop1 = 12;
            Assert.AreEqual(12, i1.Prop1);
            Assert.AreEqual(12, i2.Prop1);
            Assert.AreEqual(12, c3.Prop1);
        }