public static void Main() { Anything @var = new Anything(); var c = new Container(); c.B.InstanceMethod(null); c.B.EncapsulatedStaticMethod(); c.B.EncapsulatedInstanceMethod(var); }
private static void ThreadMessages(Anything item, bool original) { if (original) { Console.WriteLine("[main method]:" + item.Text); } else { m_list.Add(item); } }
public override bool match(string s, World g) { List<Anything> f = g.FilterItems(s,room,inv); if (f.Count == 1) { itm = f[0]; return true; } else { return false; } }
public override bool match(string s, World g) { List <Anything> f = g.FilterItems(s, room, inv); if (f.Count == 1) { itm = f[0]; return(true); } else { return(false); } }
public void BehaviorsCanFilterVirtualMethods() { var alpha = ClayActivator.CreateInstance <Anything>(new IClayBehavior[] { new InterfaceProxyBehavior(), new AnythingModifier() }); dynamic dynamically = alpha; Anything statically = alpha; IClayPlus interfacially = alpha; Assert.That(dynamically.Hello, Is.EqualTo("[World]")); Assert.That(statically.Hello, Is.EqualTo("[World]")); Assert.That(interfacially.Hello, Is.EqualTo("[World]")); Assert.That(dynamically.Add(3, 4), Is.EqualTo(9)); Assert.That(statically.Add(3, 4), Is.EqualTo(9)); Assert.That(interfacially.Add(3, 4), Is.EqualTo(9)); Assert.That(interfacially.Add(3, 5), Is.EqualTo(10)); Assert.That(interfacially.Add(3, 6), Is.EqualTo(11)); }
public void SubclassFromAnythingMembersRemainAvailableStaticallyAndDynamicallyAndViaInterface() { var alpha = ClayActivator.CreateInstance <Anything>(new[] { new InterfaceProxyBehavior() }); var type = alpha.GetType(); Assert.That(type, Is.Not.EqualTo(typeof(Anything))); dynamic dynamically = alpha; Anything statically = alpha; IClayPlus interfacially = alpha; Assert.That(dynamically.Hello, Is.EqualTo("World")); Assert.That(statically.Hello, Is.EqualTo("World")); Assert.That(interfacially.Hello, Is.EqualTo("World")); Assert.That(dynamically.Add(3, 4), Is.EqualTo(7)); Assert.That(statically.Add(3, 4), Is.EqualTo(7)); Assert.That(interfacially.Add(3, 4), Is.EqualTo(7)); Assert.That(interfacially.Add(3, 5), Is.EqualTo(8)); Assert.That(interfacially.Add(3, 6), Is.EqualTo(9)); }
public bool DoEv(string ev, Dictionary <string, object> args, Role r, World g) { switch (ev) { case "quit": g.quit(); return(true); case "say": Console.WriteLine("you say " + args["name"].ToString()); return(true); case "go": direction i = (direction)args["direction"]; Dictionary <direction, Room> directions = ((Room)g.player.getParent()).directions; if (directions.ContainsKey(i)) { g.player.moveTo(directions[i]); Console.Write("you go "); Console.WriteLine(i); g.interpretLine("look"); return(true); } else { Console.WriteLine("you run into a wall"); return(true); } case "look_room": Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; IContainer v = g.player.getParent(); Util.centerText(v.getName(), Console.WindowWidth); Console.ResetColor(); Console.WriteLine(v.getDescription()); if (v.Length > 1) { Console.Write("there is a "); } int index = 0; foreach (Anything l in v) { if (l != g.player) { Console.Write(l); index += 1; if (index == v.Length - 2) { Console.Write(" and a "); } else if (index < v.Length - 2) { Console.Write(", a "); } } else { } } if (v.Length > 1) { Console.WriteLine(" here"); } return(true); case "take": Item t = (Item)args["item"]; t.moveTo(g.player); Console.WriteLine("you take the " + t.ToString() + "."); return(true); case "drop": Item n = (Item)args["item"]; n.moveTo(g.player.getParent()); Console.WriteLine("you drop the " + n.ToString() + "."); return(true); case "inventory": if (g.player.Length != 0) { Console.WriteLine("You are carying: "); foreach (Anything l in g.player) { Console.WriteLine("- a " + l.ToString()); } return(true); } else { Console.WriteLine("You arn't carying anything."); return(true); } case "examine": Anything o = (Anything)args["item"]; Console.WriteLine(o); Console.WriteLine(o.getDescription()); return(true); default: return(false); } }
public void Remove(Anything item) { items.Remove(item); }
public void Add(Anything item) { items.Add(item); item.setParent(this); }
public void Remove(Anything item) { inventory.Remove(item); }
public void Add(Anything item) { inventory.Add(item); }