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


C# Entity.GetProperty方法代码示例

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


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

示例1: CanShow

        /// <summary>
        /// 子类重写以实现过滤逻辑
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        protected virtual bool CanShow(Entity entity, string input)
        {
            if (this.IgnoreCase) input = input.ToLower();

            foreach (var filterProperty in this.GetFilterProperty(entity))
            {
                var value = entity.GetProperty(filterProperty) as string;
                if (value != null)
                {
                    if (this.IgnoreCase) value = value.ToLower();
                    if(value.Contains(input)) return true;
                }
            }
            return false;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:21,代码来源:FilterCommand.cs

示例2: ClearDataCore

        /// <summary>
        /// 删除不必要的对象,只留下需要保存的“脏”数据
        /// </summary>
        /// <param name="diffEntity">The difference entity.</param>
        /// <param name="entityInfo">The entity information.</param>
        protected virtual void ClearDataCore(Entity diffEntity, EntityMeta entityInfo)
        {
            foreach (var item in entityInfo.ChildrenProperties)
            {
                var mp = item.ManagedProperty;

                //如果是懒加载属性,并且没有加载数据时,不需要遍历此属性值
                if (!diffEntity.FieldExists(mp)) continue;
                var children = diffEntity.GetProperty(mp) as EntityList;
                if (children == null) continue;

                for (int i = children.Count - 1; i >= 0; i--)
                {
                    var child = children[i];
                    if (!child.IsDirty)
                    {
                        children.Remove(child);
                        children.DeletedList.Remove(child);
                    }
                    else
                    {
                        this.ClearData(child);
                    }
                }
            }
        }
开发者ID:569550384,项目名称:Rafy,代码行数:31,代码来源:DiffSaveService.cs

示例3: MakeSavedCore

        /// <summary>
        /// 清除子对象集合
        /// </summary>
        /// <param name="oldEntity">The old entity.</param>
        /// <param name="entityInfo">The entity information.</param>
        protected virtual void MakeSavedCore(Entity oldEntity, EntityMeta entityInfo)
        {
            foreach (var item in entityInfo.ChildrenProperties)
            {
                var mp = item.ManagedProperty as IListProperty;

                //如果是懒加载属性,并且没有加载数据时,不需要遍历此属性值
                if (!oldEntity.FieldExists(mp)) continue;

                var children = oldEntity.GetProperty(mp) as EntityList;
                if (children == null) continue;

                //清除已删除数据
                children.CastTo<EntityList>().DeletedList.Clear();

                //所有子对象,都标记为已保存
                for (int i = children.Count - 1; i >= 0; i--)
                {
                    var child = children[i] as Entity;
                    if (child.IsDirty || child.IsNew) MakeSaved(child);
                }
            }

            oldEntity.MarkSaved();
        }
开发者ID:569550384,项目名称:Rafy,代码行数:30,代码来源:DiffSaveService.cs

示例4: ReadChildren

        /// <summary>
        /// 递归读取根对象的所有子对象
        /// </summary>
        /// <param name="entity"></param>
        private void ReadChildren(Entity entity)
        {
            var allProperties = entity.PropertiesContainer.GetNonReadOnlyCompiledProperties();

            var childrenList = new List<IList<Entity>>();

            //遍历所有子属性,读取孩子列表
            for (int i = 0, c = allProperties.Count; i < c; i++)
            {
                var property = allProperties[i];
                if (property is IListProperty)
                {
                    var children = entity.GetProperty(property) as IList<Entity>;
                    if (children != null && children.Count > 0)
                    {
                        //所有孩子列表中的实体,都加入到对应的实体列表中。
                        //并递归读取孩子的孩子实体。
                        var entityType = children[0].GetType();
                        var list = this.FindAggregateList(entityType);
                        childrenList.Add(list);
                        for (int j = 0, c2 = children.Count; j < c2; j++)
                        {
                            var child = children[j];

                            list.Add(child);
                            this.ReadChildren(child);
                        }
                    }
                }
            }
        }
开发者ID:hardCTE,项目名称:Rafy,代码行数:35,代码来源:EntityChldrenBatchReader.cs

示例5: CheckIsReadOnly

        /// <summary>
        /// 检测某个实体对象的某个实体属性是否可以只读。
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        internal static bool CheckIsReadOnly(Entity entity, WPFEntityPropertyViewMeta property)
        {
            //类指明为只读
            var indicator = property.ReadonlyIndicator;
            if (indicator.Status == ReadOnlyStatus.ReadOnly || property.Owner.NotAllowEdit) { return true; }

            //检测动态属性
            if (indicator.Status == ReadOnlyStatus.Dynamic && entity != null)
            {
                return (bool)entity.GetProperty(indicator.Property);
            }

            return false;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:20,代码来源:ReadOnlyMatrix.cs

示例6: GetSelectedValue

        /// <summary>
        /// 根据SelectedValuePath指定的值,获取目标属性值
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static object GetSelectedValue(this SelectionViewMeta rvi, Entity entity)
        {
            var selectedValuePath = rvi.SelectedValuePath ?? Entity.IdProperty;

            //如果是一个引用属性,则返回引用属性的 Id
            var refProperty = selectedValuePath as IRefProperty;
            if (refProperty != null)
            {
                var meta = refProperty.GetMeta(entity);
                return refProperty.Nullable ?
                    entity.GetRefNullableId(refProperty.RefIdProperty) :
                    entity.GetRefId(refProperty.RefIdProperty);
            }

            return entity.GetProperty(selectedValuePath);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:21,代码来源:Helper.cs

示例7: CalculateCollectValue

 private static void CalculateCollectValue(Entity entity, IManagedProperty property, ManagedPropertyChangedEventArgs args)
 {
     var distance = Convert.ToDouble(args.NewValue) - Convert.ToDouble(args.OldValue);
     var oldValue = Convert.ToDouble(entity.GetProperty(property));
     entity.SetProperty(property, oldValue + distance);
 }
开发者ID:569550384,项目名称:Rafy,代码行数:6,代码来源:AutoCollectHelper.cs

示例8: EntityToJson

        internal static void EntityToJson(EntityViewMeta evm, Entity entity, EntityJson entityJson)
        {
            var isTree = evm.EntityMeta.IsTreeEntity;

            foreach (var propertyVM in evm.EntityProperties)
            {
                var property = propertyVM.PropertyMeta;
                var mp = property.ManagedProperty;
                if (mp != null)
                {
                    //如果非树型实体,则需要排除树型实体的两个属性。
                    if (!isTree && (mp == Entity.TreeIndexProperty || mp == Entity.TreePIdProperty)) { continue; }

                    //引用属性
                    if (propertyVM.IsReference)
                    {
                        var refMp = mp as IRefProperty;
                        object value = string.Empty;
                        var id = entity.GetRefNullableId(refMp.RefIdProperty);
                        if (id != null) { value = id; }

                        var idName = refMp.RefIdProperty.Name;
                        entityJson.SetProperty(idName, value);

                        //同时写入引用属性的视图属性,如 BookCategoryId_Label
                        if (id != null && propertyVM.CanShowIn(ShowInWhere.List))
                        {
                            var titleProperty = propertyVM.SelectionViewMeta.RefTypeDefaultView.TitleProperty;
                            if (titleProperty != null)
                            {
                                var lazyRefEntity = entity.GetRefEntity(refMp.RefEntityProperty);
                                var titleMp = titleProperty.PropertyMeta.ManagedProperty;
                                if (titleMp != null)
                                {
                                    value = lazyRefEntity.GetProperty(titleMp);
                                }
                                else
                                {
                                    value = ObjectHelper.GetPropertyValue(lazyRefEntity, titleProperty.Name);
                                }

                                var name = EntityModelGenerator.LabeledRefProperty(idName);
                                entityJson.SetProperty(name, value);
                            }
                        }
                    }
                    //一般托管属性
                    else
                    {
                        var pRuntimeType = property.PropertyType;
                        var serverType = ServerTypeHelper.GetServerType(pRuntimeType);
                        if (serverType.Name != SupportedServerType.Unknown)
                        {
                            var value = entity.GetProperty(mp);
                            value = ToClientValue(pRuntimeType, value);
                            entityJson.SetProperty(mp.Name, value);
                        }
                    }
                }
                //一般 CLR 属性
                else
                {
                    var pRuntimeType = property.PropertyType;
                    var serverType = ServerTypeHelper.GetServerType(pRuntimeType);
                    if (serverType.Name != SupportedServerType.Unknown)
                    {
                        var value = ObjectHelper.GetPropertyValue(entity, property.Name);
                        value = ToClientValue(pRuntimeType, value);
                        entityJson.SetProperty(property.Name, value);
                    }
                }
            }
        }
开发者ID:569550384,项目名称:Rafy,代码行数:73,代码来源:EntityJsonConverter.cs

示例9: UpdateVisibility

        internal void UpdateVisibility(Entity currData)
        {
            if (this._meta != null)
            {
                bool isVisible = false;
                var visibilityIndicator = this._meta.VisibilityIndicator;

                //如果是动态计算,则尝试从数据中获取是否可见的值。
                if (visibilityIndicator.IsDynamic)
                {
                    if (currData != null)
                    {
                        isVisible = (bool)currData.GetProperty(visibilityIndicator.Property);
                    }
                    else
                    {
                        isVisible = true;
                    }
                }
                else
                {
                    isVisible = visibilityIndicator.VisiblityType == VisiblityType.AlwaysShow;
                }

                this.IsVisible = isVisible;
            }
        }
开发者ID:569550384,项目名称:Rafy,代码行数:27,代码来源:TreeColumn.cs

示例10: ApplyToBlock

 public void ApplyToBlock(Entity block)
 {
     block.GetProperty<string>("CollisionSoundCue").Value = this.RubbleCue;
     block.Get<PhysicsBlock>().Box.Mass = this.Density;
     this.ApplyToEffectBlock(block.Get<ModelInstance>());
 }
开发者ID:kernelbitch,项目名称:Lemma,代码行数:6,代码来源:Map.cs

示例11: UpdateRedundancies

        /// <summary>
        /// 尝试更新冗余属性值。
        /// </summary>
        internal void UpdateRedundancies(Entity entity)
        {
            //如果有一些在冗余属性路径中的属性的值改变了,则开始更新数据库的中的所有冗余字段的值。
            Entity dbEntity = null;
            var propertiesInPath = _repository.GetPropertiesInRedundancyPath();
            for (int i = 0, c = propertiesInPath.Count; i < c; i++)
            {
                var property = propertiesInPath[i];

                //如果只有一个属性,那么就是它变更引起的更新
                //否则,需要从数据库获取原始值来对比检测具体哪些属性值变更,然后再发起冗余更新。
                bool isChanged = c == 1;

                var refProperty = property as IRefIdProperty;
                if (refProperty != null)
                {
                    if (!isChanged)
                    {
                        if (dbEntity == null) { dbEntity = ForceGetById(entity); }
                        var dbId = dbEntity.GetRefId(refProperty);
                        var newId = entity.GetRefId(refProperty);
                        isChanged = !object.Equals(dbId, newId);
                    }

                    if (isChanged)
                    {
                        foreach (var path in property.InRedundantPathes)
                        {
                            //如果这条路径中是直接把引用属性的值作为值属性进行冗余,那么同样要进行值属性更新操作。
                            if (path.ValueProperty.Property == property)
                            {
                                this.UpdateRedundancyByRefValue(entity, path, refProperty);
                            }
                            //如果是引用变更了,并且只有一个 RefPath,则不需要处理。
                            //因为这个已经在属性刚变更时的处理函数中实时处理过了。
                            else if (path.RefPathes.Count > 1)
                            {
                                this.UpdateRedundancyByIntermidateRef(entity, path, refProperty);
                            }
                        }
                    }
                }
                else
                {
                    var newValue = entity.GetProperty(property);

                    if (!isChanged)
                    {
                        if (dbEntity == null) { dbEntity = ForceGetById(entity); }
                        var dbValue = dbEntity.GetProperty(property);
                        isChanged = !object.Equals(dbValue, newValue);
                    }

                    if (isChanged)
                    {
                        foreach (var path in property.InRedundantPathes)
                        {
                            UpdateRedundancyByValue(entity, path, newValue);
                        }
                    }
                }
            }

            entity.UpdateRedundancies = false;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:68,代码来源:RedundanciesUpdater.cs

示例12: UpdateRedundancyByRefValue

        /// <summary>
        /// 冗余路径中非首位的引用属的值作为值属性进行冗余,那么同样要进行值属性更新操作。
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="path">The path.</param>
        /// <param name="refChanged">该引用属性值变化了</param>
        private void UpdateRedundancyByRefValue(Entity entity, RedundantPath path, IRefIdProperty refChanged)
        {
            var newValue = entity.GetProperty(refChanged);

            this.UpdateRedundancy(entity, path.Redundancy, newValue, path.RefPathes, entity.Id);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:12,代码来源:RedundanciesUpdater.cs

示例13: TryModifyName

 /// <summary>
 /// 有必要的话,就修改Name
 /// </summary>
 /// <param name="newObject"></param>
 private void TryModifyName(Entity newObject, bool modifyName)
 {
     if (modifyName)
     {
         if (newObject is IHasHame)
         {
             var no = newObject as IHasHame;
             no.Name += "-新增";
         }
         else
         {
             var mp = newObject.PropertiesContainer.GetAvailableProperties().Find("Name");
             if (mp != null && !mp.IsReadOnly)
             {
                 string name = newObject.GetProperty(mp).ToString();
                 newObject.SetProperty(mp, name + "-新增");
             }
         }
     }
 }
开发者ID:569550384,项目名称:Rafy,代码行数:24,代码来源:CopyAndNewCommand.cs


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