Inheritance: Company.Person, IEmployee
示例#1
0
 /// <summary>
 /// Serialize XML
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 private static String SerializeXML(Company.Employee emp)
 {
     try
     {
         String        XmlizedString = null;
         XmlSerializer xs            = new XmlSerializer(typeof(Company.Employee));
         //create an instance of the MemoryStream class since we intend to keep the XML string
         //in memory instead of saving it to a file.
         MemoryStream memoryStream = new MemoryStream();
         //XmlTextWriter - fast, non-cached, forward-only way of generating streams or files
         //containing XML data
         XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
         //Serialize emp in the xmlTextWriter
         xs.Serialize(xmlTextWriter, emp);
         //Get the BaseStream of the xmlTextWriter in the Memory Stream
         memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
         //Convert to array
         XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray());
         return(XmlizedString);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#2
0
        public void AddEmployee(Employee employee)
        {
            if (employee == null)
            {
                throw new ArgumentNullException("employee", "Employee cannot be null.");
            }

            if (this.employees.ContainsKey(employee.Id))
            {
                throw new ArgumentException("This employee is already in the list.");
            }

            this.employees.Add(employee.Id, employee);
        }
示例#3
0
        public int CompareTo(Employee other)
        {
            if (this.Id == other.Id)
            {
                return 0;
            }

            if (this.Id < other.Id)
            {
                return -1;
            }

            return 1;
        }
示例#4
0
文件: Manager.cs 项目: ImarKelam/OOP
 public void AddEmployee(Employee emp)
 {
     this.employees.Add(emp);
 }
示例#5
0
        public string Hire(Employee employeeName)
        {
            currentEmployees.Add(employeeName);
            return ($"hired {employeeName.firstName} ");

        }