当前位置: 首页>>代码示例>>C#>>正文


C# IEmployee.GetType方法代码示例

本文整理汇总了C#中IEmployee.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IEmployee.GetType方法的具体用法?C# IEmployee.GetType怎么用?C# IEmployee.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEmployee的用法示例。


在下文中一共展示了IEmployee.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getEmployee

        /// <summary>
        /// Checks the type of employee to get information on and queries from specific table.
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public IEmployee getEmployee(IEmployee employee)
        {
            if (employee.GetType() == typeof(Director))
                return getDirector(employee);
            if (employee.GetType() == typeof(GroupManager))
                return getManager(employee);

            return getUser(employee);
        }
开发者ID:tah182,项目名称:Comet,代码行数:14,代码来源:EmployeeSvcImplDB.cs

示例2: CheckEmployeeIsManager

 private static void CheckEmployeeIsManager(IEmployee employToCheck)
 {
     if (!(employToCheck is Manager))
     {
         string position = employToCheck.GetType().Name;
         string realPosition = position[0].ToString();
         for (int i = 1; i < position.Length; i++)
         {
             if (realPosition[i].ToString().ToUpper() == realPosition[i].ToString())
             {
                 realPosition = " " + position[i];
             }
             else
             {
                 realPosition += position[i];
             }
         }
         throw new ArgumentException(String.Format("{0} {1} is not a manager (real position: {2})", employToCheck.FirstName, employToCheck.LastName, realPosition));
     }
 }
开发者ID:bulgariamitko,项目名称:SoftUniHomeWordsAndMore,代码行数:20,代码来源:CapitalismCommandExecutor.cs

示例3: CheckEmployeeIsManager

        private static void CheckEmployeeIsManager(IEmployee employeeToCheck)
        {
            if (!(employeeToCheck is Manager))
            {
                //string position = string.Empty;
                //switch (employeeToCheck.GetType().Name)
                //{
                //    case "ChiefTelephoneOfficer":
                //        position = "chief telephone officer";
                //        break;
                //    case "CleaningLady":
                //        position = "cleaning lady";
                //        break;
                //    case "RegularEmployee":
                //        position = "regular employee";
                //        break;
                //    default:
                //        position = employeeToCheck.GetType().Name;
                //        break;
                //}
                string position = employeeToCheck.GetType().Name;
                string realPosition = position[0].ToString();
                for (int i = 1; i < position.Length; i++)
                {
                    if (realPosition[i].ToString().ToUpper() == realPosition[i].ToString())
                    {
                        realPosition += " " + position[i];
                    }
                    else
                    {
                        realPosition += position[i];
                    }
                }

                throw new ArgumentNullException($"{employeeToCheck.FirstName} {employeeToCheck.LastName} is not a manager (real position: {position})");
            }
        }
开发者ID:ivailojordanov,项目名称:Fundamental-Level,代码行数:37,代码来源:CapitalismCommandExecutor.cs

示例4: updateEmployee

        public bool updateEmployee(IEmployee employee)
        {
            if (employee.GetType() == typeof(Director)) {
                if (!isValidDirectorId(employee.ID))
                    throw new ArgumentException("Director does not exist. Did you mean to add a new Director instead?");
            }

            throw new System.NotImplementedException();
        }
开发者ID:tah182,项目名称:Comet,代码行数:9,代码来源:EmployeeSvcImplDB.cs

示例5: saveEmployee

        public IEmployee saveEmployee(IEmployee employee)
        {
            if (!employee.isValid())
                throw new ArgumentException("Please fill out all necessary information.");

            if (employee.GetType() == typeof(Director)) {
                Director d = (Director)employee;
                DIRECTOR director = new DIRECTOR {
                    DIRECTOR_ID = d.ID,
                    START_DATE = d.StartDate,
                    END_DATE = null
                };
                return saveDirector(director);
            }
            if (employee.GetType() == typeof(GroupManager)) {
                GroupManager m = (GroupManager)employee;
                GROUP_MANAGER manager = new GROUP_MANAGER {
                    MANAGER_ID = m.ID,
                    GROUP_ID = (Int16)m.GroupID,
                    DIRECTOR_ID = m.DirectorID,
                    START_DATE = m.StartDate,
                    END_DATE = null
                };
                return saveManager(manager);
            } else {
                Employee e = (Employee)employee;
                EMPLOYEE emp = new EMPLOYEE {
                    EMPLOYEE_ID = e.ID,
                    GROUP_MANAGER_START = e.GroupManagerID,
                    START_DATE = e.StartDate,
                    END_DATE = null
                };
                return saveUser(emp);
            }
        }
开发者ID:tah182,项目名称:Comet,代码行数:35,代码来源:EmployeeSvcImplDB.cs

示例6: Visit

 //通过反射和预定好饿方法命令规则动态执行
 public void Visit(IEmployee employee)
 {
     string typeName = employee.GetType().Name;//获取employee的类型名
     string methodName = "Visit" + typeName;//使用Visit+类型名拼接关联的方法名
     MethodInfo method = this.GetType().GetMethod(methodName);//获取反射Visitor类的关联employee的方法
     method.Invoke(this, new object[] { employee });//调用这个关联的方法,并把employee作为参数传入,这里实现了一个动态的调用
 }
开发者ID:miaodl,项目名称:DesignPattern,代码行数:8,代码来源:Program.cs


注:本文中的IEmployee.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。