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


C# IEntityBase.GetType方法代码示例

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


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

示例1: Destroy

        /// <summary>
        /// Destroy the block
        /// </summary>
        /// <param name="entity">entity who destroyed the block</param>
        /// <param name="block">block that has been destroyed</param>
        public virtual void Destroy(IEntityBase entity, IStructBlock iBlock)
        {
            StructBlock block = (StructBlock)iBlock;
            BlockDestroyEventArgs eventArgs = RaiseDestroyEvent(entity, block);
            if (eventArgs.EventCanceled)
                return;

            PlaySoundOnDestroy(entity, block);

            UpdateWorld(block, true);

            // Check if the entity is a player
            if ((entity != null) && (entity.GetType() == typeof(Player)))
            {
                // Check if the player is in creative mode
                if (((Player)entity).GameMode == System.Convert.ToByte(1))
                {
                    // Don't drop any items as the player is in creative mode
                    goto skipDrop;
                }
            }

            DropItems(entity as EntityBase, block);

            skipDrop:
            DamageItem(entity);

            NotifyNearbyBlocks((EntityBase)entity, block);
        }
开发者ID:keneo,项目名称:c-raft,代码行数:34,代码来源:BlockBase.cs

示例2: ControlToEntity

        public static void ControlToEntity(Control ctl, IEntityBase entity, string attributeName)
        {
            Type typ = entity.GetType();

            PropertyInfo pi = typ.GetProperty(attributeName, BindingFlags.Public | BindingFlags.Instance);
            object objValue = null;

            while (true)
            {

                if (ctl is DropDownList)
                {
                    objValue = ((DropDownList)ctl).SelectedItem.Value;
                    break;
                }

                if (ctl is HiddenField)
                {
                    objValue = ((HiddenField)ctl).Value;
                    break;
                }

                if (ctl is esdTextBox)
                {
                    objValue = ((TextBox)ctl).Text;
                    break;
                }

                if (ctl is CheckBox)
                {
                    CheckBox objCtl = (CheckBox)ctl;
                    objValue = objCtl.Checked ? ConstFlagEstado.ACTIVADO : ConstFlagEstado.DESACTIVADO;
                    break;
                }

                if (ctl is esdMaskedTextBox)
                {
                    objValue = ((esdMaskedTextBox)ctl).Text;
                    break;
                }

                if (ctl is esdNumericTextBox)
                {
                    objValue = ((esdNumericTextBox)ctl).Value;
                    break;
                }

                if (ctl is esdDateTextBox)
                {
                    objValue = DateTime.Parse(((esdDateTextBox)ctl).Text);
                    break;
                }

                break;
            }

            object objDefVal = pi.GetValue(entity, null);
            object objNewValue = DataHelper.ChangeType(objValue, pi.PropertyType, objDefVal);

            pi.SetValue(entity, objNewValue, null);
        }
开发者ID:ArquitecturaSoftware,项目名称:texfinadev,代码行数:61,代码来源:WebHelper.cs

示例3: GetFullXml

        /// <summary>
        /// 获取填充xml
        /// </summary>
        /// <param name="obj">要填充的实体</param>
        /// <param name="modelCode">实体名称</param>
        /// <returns>返回xml</returns>
        public XElement GetFullXml(IEntityBase obj, string modelCode, SubmitData submitData)
        {
            XElement element = null;
            Metadata meta = new Metadata();
            string modelType = string.Empty;
            if (!string.IsNullOrEmpty(modelCode))
            {
                modelType = modelCode.ToUpper();
            }
            else
            {
                modelType = obj.GetType().Name;
            }
            List<AutoDictionary> listAutoDic = new List<AutoDictionary>();
            string strMainKey = string.Empty;
            string strMainValue = string.Empty;
            CommonBLL bll = new CommonBLL("");
            #region 处理元数据

            #region "   T_HR_EMPLOYEEOVERTIMERECORD  "

            if (modelType.ToUpper() == Constants.T_HR_EMPLOYEEOVERTIMERECORD)
            {
                strMainKey = "OVERTIMERECORDID";
                strMainValue = string.Empty;
                Type objtype = obj.GetType();
                PropertyInfo[] propinfos = objtype.GetProperties();
                foreach (PropertyInfo propinfo in propinfos)
                {
                    string keyValue = propinfo.GetValue(obj, null) != null ? propinfo.GetValue(obj, null).ToString() : string.Empty;
                    if (propinfo.Name == strMainKey)
                    {
                        strMainValue = keyValue;
                    }
                }

                if (obj is T_HR_EMPLOYEEOVERTIMERECORD)
                {
                    T_HR_EMPLOYEEOVERTIMERECORD entity = obj as T_HR_EMPLOYEEOVERTIMERECORD;
                    if (submitData.SubmitFlag != SubmitFlag.New && submitData.ApprovalResult == ApprovalResult.NoPass)
                    {
                        var overtimeDetail = bll.Query<T_HR_EMPLOYEEOVERTIMERECORD>().Where(w => w.OVERTIMERECORDID == strMainValue).ToList();
                        //Dictionary<object, object> detail = new Dictionary<object, object>();
                        //detail.Add(overtimeDetail, null);//normItemConfigList 是2级从表列表

                        Dictionary<object, object> detail = new Dictionary<object, object>();
                        detail.Add(entity.T_HR_EMPLOYEEOVERTIMEDETAILRD, null);

                        listAutoDic.Add(new AutoDictionary
                        {
                            TableName = modelType,
                            KeyValue = "CREATEUSERID",
                            DataValue = submitData.ApprovalUser.UserID,
                            DataText = submitData.ApprovalUser.UserName,
                            Name = "CREATEUSERID"
                        });
                        listAutoDic.Add(new AutoDictionary
                        {
                            TableName = modelType,
                            KeyValue = "CREATEPOSTID",
                            DataValue = submitData.ApprovalUser.PostID,
                            DataText = submitData.ApprovalUser.PostName,
                            Name = "CREATEPOSTID"
                        });
                        listAutoDic.Add(new AutoDictionary
                        {
                            TableName = modelType,
                            KeyValue = "CREATEDEPARTMENTID",
                            DataValue = submitData.ApprovalUser.DepartmentID,
                            DataText = submitData.ApprovalUser.DepartmentName,
                            Name = "CREATEDEPARTMENTID"
                        });
                        listAutoDic.Add(new AutoDictionary
                        {
                            TableName = modelType,
                            KeyValue = "CREATECOMPANYID",
                            DataValue = submitData.ApprovalUser.CompanyID,
                            DataText = submitData.ApprovalUser.CompanyName,
                            Name = "CREATECOMPANYID"
                        });
                    }
                }
            }
            #endregion




            #endregion
            //auditInfo.ObjXml = metaData.TableToXml(yearNormDraft, null, auditInfo.SystemCode, auditInfo.ModelCode, listAutoDic);//  将Detail设置成了null
            string xml = meta.TableToXml(obj, null, "HR", modelType, listAutoDic);
            element = XElement.Parse(xml);
            //SMT.Portal.Common.MetaData metaData = new MetaData();
            return element;
//.........这里部分代码省略.........
开发者ID:JuRogn,项目名称:OA,代码行数:101,代码来源:AuditBLL.cs

示例4: GetValueFromAttribute

        public static object GetValueFromAttribute(IEntityBase entity, string attributeName)
        {
            Type typ = entity.GetType();

            PropertyInfo pi = typ.GetProperty(attributeName, BindingFlags.Public | BindingFlags.Instance);
            object objValue = pi.GetValue(entity, null);

            return objValue;
        }
开发者ID:ArquitecturaSoftware,项目名称:texfinadev,代码行数:9,代码来源:WebHelper.cs


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