Пример #1
0
		public void GettingAndSettingIndex()
		{
			var mgr = new VariableManager();
			mgr["Test1"] = 1;
			mgr["Test2"] = "two";
			mgr["Test3"] = mgr["Test1"] + 2;
			mgr["Test4"] = mgr["Test2"] + 2;

			Assert.Equal(1, mgr["Test1"]);
			Assert.Equal("two", mgr["Test2"]);
			Assert.Equal(3, mgr["Test3"]);
			Assert.Equal("two2", mgr["Test4"]);
		}
Пример #2
0
		public void GettingAndSettingFields()
		{
			dynamic mgr = new VariableManager();
			mgr.Test1 = 1;
			mgr.Test2 = "two";
			mgr.Test3 = mgr.Test1 + 2;
			mgr.Test4 = mgr.Test2 + 2;

			Assert.Equal(1, mgr.Test1);
			Assert.Equal("two", mgr.Test2);
			Assert.Equal(3, mgr.Test3);
			Assert.Equal("two2", mgr.Test4);
		}
Пример #3
0
		public void InitializingVariables()
		{
			dynamic mgr = new VariableManager();
			mgr.Test1 = 1;
			mgr.Test2 = "two";
			mgr.Test3 = mgr.Test1 + 2;
			mgr.Test4 = mgr.Test2 + 2;

			var mgr2 = new VariableManager(mgr.GetList());

			Assert.Equal(1, mgr["Test1"]);
			Assert.Equal("two", mgr["Test2"]);
			Assert.Equal(3, mgr["Test3"]);
			Assert.Equal("two2", mgr["Test4"]);
		}
Пример #4
0
        public void Assign()
        {
            dynamic mgr = new VariableManager();
            mgr.Test1 = (byte)1;
            mgr.Test2 = "two";
            mgr.Test3 = 3;

            byte test1 = mgr["Test1"];
            string test2 = mgr["Test2"];
            int test3 = mgr["Test3"];

            Assert.Equal((byte)1, test1);
            Assert.Equal("two", test2);
            Assert.Equal(3, test3);

            Assert.Throws<RuntimeBinderException>(() => { int test4 = mgr["Test4"]; });
        }
Пример #5
0
		/// <summary>
		/// Initializes class.
		/// </summary>
		/// <param name="regionId"></param>
		protected Region(int regionId)
		{
			_creaturesRWLS = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
			_propsRWLS = new ReaderWriterLockSlim();
			_clientEventsRWLS = new ReaderWriterLockSlim();
			_itemsRWLS = new ReaderWriterLockSlim();

			_propIds = new Dictionary<int, int>();

			this.Id = regionId;

			_creatures = new Dictionary<long, Creature>();
			_props = new Dictionary<long, Prop>();
			_clientEvents = new Dictionary<long, ClientEvent>();
			_items = new Dictionary<long, Item>();

			_clients = new HashSet<ChannelClient>();

			this.Collisions = new RegionCollision();

			this.Properties = new VariableManager();
		}
Пример #6
0
        public void Get()
        {
            dynamic mgr = new VariableManager();
            mgr.Test1 = (byte)1;
            mgr.Test2 = "two";
            mgr.Test3 = 3;

            Assert.Equal(1, mgr.Get<byte>("Test1", 0));
            Assert.Equal("two", mgr.Get<string>("Test2", ""));
            Assert.Equal(3, mgr.Get<int>("Test3", 0));

            Assert.Equal(127, mgr.Get<byte>("Test4", 127));

            Assert.Throws<InvalidCastException>(() => { Assert.Equal(1, mgr.Get<int>("Test1", 0)); });
        }