Ejemplo n.º 1
0
        public void TestStaticTypeWithLambdas()
        {
            MyStaticClass.Reset();
            BoundPropertyDescriptor test;

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticStringProperty, "StaticStringProperty", "", "");
            Assert.IsFalse(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals("uninitialized"));
            test.SetValue(null, "xxx");
            Assert.IsTrue(test.GetValue(null).Equals("xxx"));
            Assert.IsTrue(MyStaticClass.StaticStringProperty == "xxx");

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticIntProperty, "StaticIntProperty", "", "");
            Assert.IsFalse(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals(5));
            test.SetValue(null, 10);
            Assert.IsTrue(test.GetValue(null).Equals(10));
            Assert.IsTrue(MyStaticClass.StaticIntProperty == 10);

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticStringAsymmetricalAccessProperty, "StaticStringAsymmetricalAccessProperty", "", "");
            Assert.IsTrue(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals("uninitialized"));
            test.SetValue(null, "xxx");
            Assert.IsTrue(test.GetValue(null).Equals("xxx"));
            Assert.IsTrue(MyStaticClass.StaticStringAsymmetricalAccessProperty == "xxx");

            test = new BoundPropertyDescriptor(typeof(MyStaticClass), () => MyStaticClass.StaticIntAsymmetricalProperty, "StaticIntAsymmetricalProperty", "", "");
            Assert.IsTrue(test.IsReadOnly);
            Assert.IsTrue(test.GetValue(null).Equals(5));
            test.SetValue(null, 10);
            Assert.IsTrue(test.GetValue(null).Equals(10));
            Assert.IsTrue(MyStaticClass.StaticIntAsymmetricalProperty == 10);
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            System.Console.WriteLine("C#: Starting the application.");

            // Initialize the OCaml engine.
            System.Console.WriteLine("C#: Start the OCaml engine.");
            LexiFi.Interop.Csml.Init();
            // Export local C# code to OCaml.
            System.Console.WriteLine("C#: Export components to OCaml.");
            LexiFi.Interop.CsmlGettingStarted.Init();

            // The same implementation supports the two linking mode.
            // If the OCaml code of the application is linked statically together with
            // the OCaml runtime, then the OCaml stub CsmlGettingStarted has already
            // been evaluated and we can immediatly play with the OCaml code.
            // Otherwise, we need to load the OCaml addin that contains all the OCaml code
            // of our application now.
            if (!LexiFi.Interop.Csml.MLStubAvailable("CsmlGettingStarted"))
            {
                // The method below changes the .cma to .cmxs if the OCaml runtime
                // linked with this application is in native code.
                System.Console.WriteLine("C#: Loading addin with OCaml code.");
                LexiFi.Interop.Csml.LoadFile("getting_started.cma");
            }

            System.Console.WriteLine("C#: Now calling OCaml code.");
            string s = MyStaticClass.DoSomething("foo");

            System.Console.WriteLine("C#: Returning from OCaml code with s = " + s);
        }
Ejemplo n.º 3
0
        public override string MyAction()
        {
            string appendToStory = "";

            int weaponDamage = weapon.Damage;

            enemy.Hp      -= weaponDamage;
            appendToStory += string.Format("You hit the {0} with {1} and did {2} damage. The {0} has {3} hp remaining" + Environment.NewLine, enemy.Name, weapon.Name, weaponDamage, enemy.Hp);

            if (enemy.Hp > 0)
            {
                int damageToPlayer = enemy.DamageToPlayer;

                player.CurrentHealth -= damageToPlayer;
                appendToStory        += string.Format("The {0} hit you and did {1} damage" + MyStaticClass.WhiteLine(), enemy.Name, damageToPlayer);
            }

            if (enemy.Hp <= 0)
            {
                enemy.IsDead   = true;
                appendToStory += string.Format("You deaded the {0}", enemy.Name + MyStaticClass.WhiteLine());

                MyStaticClass.EnemiesRemaining--;
                player.Kills++;
                player.InBattle = false;
            }

            return(appendToStory);
        }
 static void Main(string[] args)
 {
     MyStaticClass.MyInt = 9017;
     Console.WriteLine("1) My Int: " + MyStaticClass.MyInt.ToString());
     // or using the function
     Console.WriteLine("2) My Int: " + MyStaticClass.MyIntValue().ToString());
 }
Ejemplo n.º 5
0
        public override string MyAction()
        {
            //TODO implement run command
            player.InBattle = false;

            return("You succesfully ran away" + MyStaticClass.WhiteLine());
        }
Ejemplo n.º 6
0
 public object Convert(
     object value,
     Type targetType,
     object parameter,
     System.Globalization.CultureInfo culture)
 {
     return(MyStaticClass.MyStaticMethod(value as MyItem));
 }
Ejemplo n.º 7
0
 public void ProveSingleInstanceOfStaticClass_Test()
 {
     // We have inovked the method twice but the constructor will fire once
     MyStaticClass.SomeMethod();
     MyStaticClass.iCount++;
     MyStaticClass.iCount++;
     MyStaticClass.SomeMethod();
 }
Ejemplo n.º 8
0
        public void TestGetClassForStatic()
        {
            var cn = ReflectionUtility.GetClass().Name;

            Assert.AreEqual(cn, "TestMetaData");

            cn = MyStaticClass.MyType().Name;
            Assert.AreEqual(cn, "MyStaticClass");
        }
        public void TestMethodFullNameReturnParametertypes()
        {
            var mn = (new MyClass()).MethodFullNameReturnParametertypes2();

            Assert.AreEqual(mn, "System.Void TestCompulsoryCat.TestReflectionUtility.TestMethodFullNameReturnParametertypes ()");

            mn = MyStaticClass.MethodFullNameReturnParametertypes3();
            Assert.AreEqual(mn, "System.Void TestCompulsoryCat.TestReflectionUtility.TestMethodFullNameReturnParametertypes ()");
        }
Ejemplo n.º 10
0
        public void TestMethodFullName()
        {
            var mn = (new MyClass()).MethodFullName2();

            Assert.AreEqual(mn, "TestCompulsoryCat.TestReflectionUtility.TestMethodFullName");

            mn = MyStaticClass.MethodFullname3();
            Assert.AreEqual(mn, "TestCompulsoryCat.TestReflectionUtility.TestMethodFullName");
        }
Ejemplo n.º 11
0
        public void TestGetCallingMethodFullNameReturnParametertypes()
        {
            var o  = new MyClass();
            var mn = o.GetCallingMethodFullNameReturnParametertypes();

            Assert.AreEqual(mn, "System.Void TestCompulsoryCat.TestReflectionUtility.TestGetCallingMethodFullNameReturnParametertypes ()");

            mn = MyStaticClass.GetCallingMethodFullNameReturnParametertypes();
            Assert.AreEqual(mn, "System.Void TestCompulsoryCat.TestReflectionUtility.TestGetCallingMethodFullNameReturnParametertypes ()");
        }
Ejemplo n.º 12
0
        public void TestGetCallingMethod()
        {
            var o  = new MyClass();
            var mn = o.GetCallingMethodNameMethod().Name;

            Assert.AreEqual(mn, "TestGetCallingMethod");

            mn = MyStaticClass.GetCallingMethodNameMethod().Name;
            Assert.AreEqual(mn, "TestGetCallingMethod");
        }
Ejemplo n.º 13
0
        public void TestGetClassVoid()
        {
            var cn = ReflectionUtility.GetClass().Name;

            Assert.AreEqual(cn, "TestReflectionUtility");

            cn = (new MyClass()).GetClassMethod().Name;
            Assert.AreEqual(cn, "MyClass");

            cn = MyStaticClass.StaticGetClassMethod().Name;
            Assert.AreEqual(cn, "MyStaticClass");
        }
Ejemplo n.º 14
0
        /*
         * ברגע שיש התייחסות לשדה סטטי כלומר בפעם הראשונה שיש התייחסות לשדה סטטי
         * מתרחש אתחול לכל השדות הסטטיים.
         *
         * */


        static void Main(string[] args)
        {
            //Console.WriteLine(MyClass.StaticField);
            //MyClass.Foo();
            Console.WriteLine("First...");

            for (int i = 0; i < 11; i++)
            {
                new MyClass(i);
            }
            MyStaticClass.Foo();
            Console.ReadLine();
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter number of color: ");
            int n = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter string: ");
            string str = Console.ReadLine();

            MyStaticClass.Print(str, n);


            Console.ReadLine();
        }
Ejemplo n.º 16
0
        public static void Main2(string[] args)
        {
            GenericArgumentBinder binder = new GenericArgumentBinder(new FallbackToFirstCandidateMethodSelector(new BinderMethodSelector(Type.DefaultBinder)));

            MethodInfo[] methods;
            MethodInfo   method;

            binder.TryBind(typeof(MyClass).GetMethod("MyMethod4"),
                           new Type[] { typeof(MyClass3) },
                           out methods);

            int[] array = { };
            MyStaticClass.NewTest <object>(array);
        }
Ejemplo n.º 17
0
        public string GetCommandText(string input)
        {
            var i = input.Trim();

            if (Commands.ContainsKey(i))
            {
                var c = Commands[i];
                return(MyStaticClass.WhiteLine() + "<" + i + ">" + Environment.NewLine + c + MyStaticClass.WhiteLine());
            }
            else
            {
                return(MyStaticClass.WhiteLine() + "<" + i + ">" + Environment.NewLine + "This is not a command, for all commands see the Help page" + MyStaticClass.WhiteLine());
            }
        }
Ejemplo n.º 18
0
        public override string MyAction()
        {
            string appendToStory = "";

            if (!player.CurrentLocation.IsLootable)
            {
                return("You can't loot here" + MyStaticClass.WhiteLine());
            }

            if (!player.CurrentLocation.HasLoot)
            {
                return("This place was already looted" + MyStaticClass.WhiteLine());
            }

            ILootList location = player.CurrentLocation as ILootList;

            location.CreateLootTables();

            if (location.LootList.Count == 0)
            {
                return("You searched the entire place, but everything you found was useless" + MyStaticClass.WhiteLine());
            }

            //TODO Aparte methode voor looten
            var pickedUp = new List <Item>();

            foreach (Item i in location.LootList)
            {
                if (Player.inventoryPlayer.NumberOfItems < MyStaticClass.MaximumItemsInInventory)
                {
                    Player.inventoryPlayer.AddItem(i);
                    pickedUp.Add(i);

                    appendToStory += String.Format("You found a {0}" + MyStaticClass.WhiteLine(), i.Name);
                }
            }

            RemoveFromLootList(location.LootList, pickedUp);

            if (location.LootList.Count > 0)
            {
                appendToStory += "Your inventory is full" + MyStaticClass.WhiteLine();
            }
            if (location.LootList.Count == 0)
            {
                player.CurrentLocation.HasLoot = false;
            }

            return(appendToStory);
        }
Ejemplo n.º 19
0
        public override string MyAction()
        {
            string appendToStory = "";

            appendToStory += string.Format("Health: {0}", player.CurrentHealth);
            appendToStory += Environment.NewLine;
            appendToStory += string.Format("Kills: {0}", player.Kills);
            appendToStory += Environment.NewLine;
            appendToStory += string.Format("Enemies remaining: {0}", MyStaticClass.EnemiesRemaining);
            appendToStory += Environment.NewLine;
            appendToStory += string.Format("Weapon Equiped: {0}", player.SelectedWeapon.Name);
            appendToStory += MyStaticClass.WhiteLine();

            return(appendToStory);
        }
Ejemplo n.º 20
0
        public string SpawnEnemy()
        {
            Location location = player.CurrentLocation;

            int chanceToSpawnEnemy = Rng.Next(0, 100);

            if (MyStaticClass.EnemiesRemaining > 70) //If there are more than 70 enemies remaining
            {
                if (chanceToSpawnEnemy < 60)         //60% chance enemy is spawned
                {
                    player.CurrentLocation.Enemy = new CommonEnemy();
                    player.InBattle = true;
                    return(string.Format("You see {0} and ask for help. Than you remember you are in a game and these are your enemies so you engage in combat." + MyStaticClass.WhiteLine(), player.CurrentLocation.Enemy.Name));
                }
            }

            if (MyStaticClass.EnemiesRemaining > 40 && MyStaticClass.EnemiesRemaining <= 70) //if there are more than 40 enemies and less than 70
            {
                if (chanceToSpawnEnemy < 40)                                                 //40% chance enemy is spawned
                {
                    player.CurrentLocation.Enemy = new CommonEnemy();
                    player.InBattle = true;
                    return(string.Format("You see {0} and ask for help. Than you remember you are in a game and these are your enemies so you engage in combat." + MyStaticClass.WhiteLine(), player.CurrentLocation.Enemy.Name));
                }
            }

            if (MyStaticClass.EnemiesRemaining > 10 && MyStaticClass.EnemiesRemaining <= 40) //if there are more than 10 enemies and less than 40
            {
                if (chanceToSpawnEnemy < 20)                                                 //20% chance enemy is spawned
                {
                    player.CurrentLocation.Enemy = new CommonEnemy();
                    player.InBattle = true;
                    return(string.Format("You see {0} and ask for help. Than you remember you are in a game and these are your enemies so you engage in combat." + MyStaticClass.WhiteLine(), player.CurrentLocation.Enemy.Name));
                }
            }

            if (MyStaticClass.EnemiesRemaining > 0 && MyStaticClass.EnemiesRemaining <= 10) //if there are more than 10 enemies and less than 40
            {
                if (chanceToSpawnEnemy < 5)                                                 //5% chance enemy is spawned
                {
                    player.CurrentLocation.Enemy = new CommonEnemy();
                    player.InBattle = true;
                    return(string.Format("You see {0} and ask for help. Than you remember you are in a game and these are your enemies so you engage in combat." + MyStaticClass.WhiteLine(), player.CurrentLocation.Enemy.Name));
                }
            }

            return("No enemies in sight" + MyStaticClass.WhiteLine());
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            Console.WriteLine(MyStaticClass.myStaticVariable);

            MyStaticClass.MyStaticMethod();

            MyStaticClass.MyStaticProperty = 100;

            Console.WriteLine(MyStaticClass.MyStaticProperty);

            Console.WriteLine("Num of instances before levi = " + Cow.numOfInstances);

            Cow levi = new Cow();

            Console.WriteLine("Num of instances before jon = " + Cow.numOfInstances);
            Cow jon = new Cow();

            Console.WriteLine($"jon Id = {jon.id}\nNum of instances =  {Cow.numOfInstances}");
            Console.ReadLine();
        }
Ejemplo n.º 22
0
        public override string MyAction()
        {
            string appendToStory          = string.Format("You can have a maximum number of {0} inventory slots. {1}You've got:{1}", MyStaticClass.MaximumItemsInInventory, Environment.NewLine);
            int    ocupiedInventorySpaces = 1;

            if (Player.inventoryPlayer.Inventory.Count == 0)
            {
                appendToStory += Environment.NewLine + "Nothing... it's good practice to have some items before looking through your inventory";
            }

            var sortedList = Player.inventoryPlayer.Inventory.OrderBy(x => x.Name);

            foreach (Item i in sortedList)
            {
                appendToStory += Environment.NewLine + ocupiedInventorySpaces + ". " + i.Name;
                ocupiedInventorySpaces++;
            }

            appendToStory += MyStaticClass.WhiteLine();

            return(appendToStory);
        }
Ejemplo n.º 23
0
        public override string MyAction()
        {
           helpText = "    Commands" + Environment.NewLine + 
                      "--------------------" + Environment.NewLine +
                      "    [Movement]"+ Environment.NewLine +
                      "--------------------" + Environment.NewLine + 
                      "North - Move North" + Environment.NewLine + 
                      "West - Move West" + Environment.NewLine + 
                      "South - Move South" + Environment.NewLine + 
                      "East - Move East" + Environment.NewLine + 
                      "--------------------" + Environment.NewLine + 
                      "  [Items / Actions]" + Environment.NewLine + 
                      "--------------------" + Environment.NewLine + 
                      " - Equip" + Environment.NewLine + 
                      " - Attack" + Environment.NewLine + 
                      "--------------------" + Environment.NewLine + 
                      "  [Fun commands]" + Environment.NewLine + 
                      "--------------------" + Environment.NewLine + 
                      " - Secret" + MyStaticClass.WhiteLine();

           return helpText;
        }
Ejemplo n.º 24
0
 public B(string x) : base(MyStaticClass.DoIntWork(x))
 {
 }
Ejemplo n.º 25
0
 public void MyMethod()
 {
     MyStaticClass.MyStaticMethod();
 }
Ejemplo n.º 26
0
        public override string MyAction() //TODO Haal de input == cijfer weg en zorg ervoor dat de speler dit niet kan invoegen als input (de cijfer staat voor de plek van de command in de enum van CommandFactory). Hetzelfde geldt voor de navigate method
        {
            if (input == "north" || input == "0")
            {
                Location locationNorth = Map.map[player.YCoord - 1, player.XCoord];
                return(Navigate(locationNorth, input));
            }
            else if (input == "east" || input == "1")
            {
                Location locationEast = Map.map[player.YCoord, player.XCoord + 1];
                return(Navigate(locationEast, input));
            }
            else if (input == "south" || input == "2")
            {
                Location locationSouth = Map.map[player.YCoord + 1, player.XCoord];
                return(Navigate(locationSouth, input));
            }
            else if (input == "west" || input == "3")
            {
                Location locationWest = Map.map[player.YCoord, player.XCoord - 1];
                return(Navigate(locationWest, input));
            }
            else
            {
                return("This is not a direction you can go to" + Environment.NewLine);
            }



            string Navigate(Location location, string input)
            {
                if (!location.IsPassable)
                {
                    return(location.LocationDescription + MyStaticClass.WhiteLine());
                }

                switch (input)
                {
                case "north":
                case "0":
                    player.YCoord--;
                    return(CurrentLocationDescription() + CurrentLocation());

                case "east":
                case "1":
                    player.XCoord++;
                    return(CurrentLocationDescription() + CurrentLocation());

                case "south":
                case "2":
                    player.YCoord++;
                    return(CurrentLocationDescription() + CurrentLocation());

                case "west":
                case "3":
                    player.XCoord--;
                    return(CurrentLocationDescription() + CurrentLocation());

                default: return("Something broke" + Environment.NewLine);
                }
            }

            string CurrentLocation()
            {
                string currentLocation = String.Format("You are now at [{0},{1}]" + MyStaticClass.WhiteLine(), player.YCoord, player.XCoord);

                return(currentLocation);
            }

            string CurrentLocationDescription()
            {
                return(player.CurrentLocation.LocationDescription + MyStaticClass.WhiteLine());
            }
        }
Ejemplo n.º 27
0
 public MyViewModel(MyStaticClass myStaticClass)
 {
     MyItems = ConvertMyStaticClassToObservableCollection(myStaticClass);
 }
Ejemplo n.º 28
0
 ObservableCollection <MyItem> ConvertMyStaticClassToObservabeCollection(MyStaticClass myStaticClass)
 {
Ejemplo n.º 29
0
 public static int MyStaticMethod()
 {
     return(MyStaticClass.MyStaticMethod());
 }
 public XmlModel( )
 {
     //Type Inference kicks in with other tests, but not this one T_T
     MyStaticClass.AddType <T>(ReadModel, WriteModel);
 }