Пример #1
0
		public void RemoveEmployee(Employee employee)
		{
			if(employee == null)
				return;

			_employees.Remove(employee);
		}
Пример #2
0
		public void AddEmployee(Employee employee)
		{
			if(employee == null)
				throw new ArgumentNullException("employee");

			_employees.Add(employee);
		}
Пример #3
0
		public void GetValueTest()
		{
			var emp1 = new Employee()
			{
				Name = "Popeye Zhong",
				Gender = Gender.Male,
				Salary = 10000.01m,
				HomeAddress = new Address
				{
					CountryId = 123,
					City = "Wuhan",
					Detail = "****",
				},
			};

			Assert.Equal("Popeye Zhong", Zongsoft.Common.Convert.GetValue(emp1, "Name"));
			Assert.Equal("Wuhan", Zongsoft.Common.Convert.GetValue(emp1, "HomeAddress.City"));

			Zongsoft.Common.Convert.SetValue(emp1, "Name", "Popeye");
			Assert.Equal("Popeye", Zongsoft.Common.Convert.GetValue(emp1, "Name"));

			Zongsoft.Common.Convert.SetValue(emp1, "HomeAddress.City", "Shenzhen");
			Assert.Equal("Shenzhen", Zongsoft.Common.Convert.GetValue(emp1, "HomeAddress.City"));

			var department = new Department("Develop");
			department.AddEmployee(emp1);

			var empX = department[0];
			Assert.NotNull(empX);
			var empY = department["Popeye"];
			Assert.NotNull(empY);

			empX = (Employee)Zongsoft.Common.Convert.GetValue(department, "[0]");
			Assert.NotNull(empX);

			empY = (Employee)Zongsoft.Common.Convert.GetValue(department, "['Popeye']");
			Assert.NotNull(empX);

			var type = Zongsoft.Common.Convert.GetMemberType(department, "[0]");
			Assert.NotNull(type);
			Assert.Same(typeof(Employee), type);
		}