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
ファイル: Manager.cs プロジェクト: tormibg/SoftUni-1
        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
ファイル: Employee.cs プロジェクト: tormibg/SoftUni-1
        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} ");

        }