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


C# BaseEntity.GetType方法代码示例

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


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

示例1: CommitLinks

        public virtual void CommitLinks(BaseEntity entity)
        {
            if (Settings.IsVerbose)
                Console.WriteLine ("  Committing all links for '"  + entity.GetType().Name + "'.");

            var previousEntity = Reader.Read(entity.GetType(), entity.Id);

            FindAndFixDifferences (previousEntity, entity);
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:9,代码来源:DataLinker.cs

示例2: FindAndFixDifferences

        public virtual void FindAndFixDifferences(BaseEntity previousEntity, BaseEntity updatedEntity)
        {
            if (Settings.IsVerbose)
                Console.WriteLine ("    Finding and fixing all differences between previous and updated '" + updatedEntity.GetType().Name + "' entity.");

            foreach (var property in updatedEntity.GetType().GetProperties()) {
                if (Linker.IsLinkProperty (updatedEntity, property)) {
                    FindAndFixDifferences (previousEntity, updatedEntity, property);
                }
            }
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:11,代码来源:DataLinker.cs

示例3: AddReturnLink

        public void AddReturnLink(BaseEntity entity, PropertyInfo property, BaseEntity targetEntity, string targetEntityPropertyName)
        {
            var targetEntityType = targetEntity.GetType ();

            var targetEntityProperty = targetEntityType.GetProperty (targetEntityPropertyName);

            if (targetEntityProperty == null)
                throw new ArgumentException ("The property '" + targetEntityPropertyName + "' was not found on the '" + targetEntity.GetType ().Name + "' entity.");
            var existingReturnLinksObject = targetEntityProperty.GetValue (targetEntity);

            var newReturnLinksObject = AddEntityToObject (entity, existingReturnLinksObject, targetEntityProperty);

            targetEntityProperty.SetValue (targetEntity, newReturnLinksObject);

            entity.IsPendingLinkCommit = true;
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:16,代码来源:EntityLinker.cs

示例4: Equals

        public virtual bool Equals(BaseEntity obj)
        {
            if (obj == null) return false;
            if (ReferenceEquals(this, obj)) return true;

            if(!IsTransient(this) && !IsTransient(obj) && Equals(this.Id, obj.Id))
            {
                var thisType = this.GetType(); //// Khác ở đây
                var otherType = obj.GetType();
                return thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType);
            }
            return false;
        }
开发者ID:sounj142,项目名称:aaabbb,代码行数:13,代码来源:BaseEntity.cs

示例5: CommitNewReverseLinks

        public virtual void CommitNewReverseLinks(BaseEntity entity, PropertyInfo property, BaseEntity[] newLinkedEntities)
        {
            if (Settings.IsVerbose)
                Console.WriteLine ("    Committing new reverse links for '" + entity.GetType ().Name + "' entity on '" + property.Name + "'.");

            var otherPropertyName = Linker.GetOtherPropertyName (property);

            if (!String.IsNullOrEmpty (otherPropertyName)) {
                foreach (var newLinkedEntity in newLinkedEntities) {
                    if (!Saver.PendingSave.Contains (newLinkedEntity)
                        && !Updater.PendingUpdate.Contains(newLinkedEntity)) {
                        Linker.AddReturnLink (entity, property, newLinkedEntity, otherPropertyName);

                        Updater.DelayUpdate (newLinkedEntity);
                    }
                }
            }
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:18,代码来源:DataLinker.cs

示例6: AddLink

        public void AddLink(BaseEntity entity, string propertyName, BaseEntity linkedEntity)
        {
            var otherPropertyName = "";

            var property = entity.GetType ().GetProperty (propertyName);

            if (PropertyHasLinkAttribute (property, out otherPropertyName)
                || IsLinkProperty(entity, property)) {
                var value = property.GetValue (entity);
                var newValue = AddEntityToObject (linkedEntity, value, property);
                property.SetValue (entity, newValue);

                entity.IsPendingLinkCommit = true;

                if (!String.IsNullOrEmpty(otherPropertyName))
                    AddReturnLink (entity, property, linkedEntity, otherPropertyName);
            } else
                throw new Exception ("Invalid property. It needs to have the type BaseEntity.");
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:19,代码来源:EntityLinker.cs

示例7: AddEntityToObject

        public object AddEntityToObject(BaseEntity entityToAdd, object linksObject, PropertyInfo property)
        {
            if (IsEntityProperty(property)) {
                return entityToAdd;
            }
            else if (IsEntityArrayProperty(property)) {

                var list = new ArrayList ();

                if (linksObject != null)
                    list.AddRange ((BaseEntity[])linksObject);

                // TODO: Should this check that it's not already in the list? Check via id, not via object comparison
                if (!EntityExists((BaseEntity[])list.ToArray(typeof(BaseEntity)), entityToAdd))
                    list.Add (entityToAdd);

                return list.ToArray (entityToAdd.GetType ());
            } else
                throw new Exception ("Invalid return link object. Must be subclass of BaseEntity or BaseEntity[] array.");
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:20,代码来源:EntityLinker.cs

示例8: RemoveReturnLink

        public void RemoveReturnLink(BaseEntity entity, PropertyInfo property, BaseEntity targetEntity, string targetEntityPropertyName)
        {
            if (entity == null)
                throw new ArgumentNullException ("entity");

            if (property == null)
                throw new ArgumentNullException ("property");

            if (targetEntity == null)
                throw new ArgumentNullException ("targetEntity", "Entity '" + entity.GetType().FullName + "', property '" + property.Name + "'.");

            var targetEntityProperty = targetEntity.GetType ().GetProperty (targetEntityPropertyName);

            if (targetEntityProperty == null)
                throw new Exception ("Property '" + targetEntityPropertyName + "' not found on type '" + targetEntity.GetType().FullName + "'.");
            else {
                var existingReturnLinksObject = targetEntityProperty.GetValue (targetEntity);

                var newReturnLinksObject = RemoveEntityFromObject (entity, existingReturnLinksObject, targetEntityProperty);

                targetEntityProperty.SetValue (targetEntity, newReturnLinksObject);
            }
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:23,代码来源:EntityLinker.cs

示例9: RemoveEntityFromObject

        public object RemoveEntityFromObject(BaseEntity entityToRemove, object linksObject, PropertyInfo property)
        {
            if (IsEntityProperty(property)) {
                return null;
            }
            else if (IsEntityArrayProperty(property)) {
                var list = new ArrayList ();

                if (linksObject != null)
                    list.AddRange ((BaseEntity[])linksObject);

                for (int i = 0; i < list.Count; i++) {
                    if (((BaseEntity)list [i]).Id == entityToRemove.Id) {
                        list.RemoveAt (i);
                        break;
                    }
                }

                return list.ToArray (entityToRemove.GetType());
            } else
                throw new Exception ("Invalid return link object. Must be subclass of BaseEntity or BaseEntity[] array.");
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:22,代码来源:EntityLinker.cs

示例10: OnDeployItem

 public void OnDeployItem(Deployer deployer, BaseEntity baseEntity)
 {
     var player = deployer.ownerPlayer;
     var item = deployer.GetItem();
     var itemDef = item.info;
     var type = baseEntity.GetType();
     if (type != typeof (BaseOven) || !itemDef.displayName.translated.ToLower().Equals("furnace")) return;
     var baseOven = (BaseOven)baseEntity;
     var instanceId = RPGHelper.OvenId(baseOven);
     if (PlayersFurnaces.ContainsKey(instanceId))
     {
         ChatMessage(player, "Contact the developer, tell him wrong Id usage for furnace.");
         return;
     }
     PlayersFurnaces.Add(instanceId, RPGHelper.SteamId(player));
 }
开发者ID:Zloplay,项目名称:hunt,代码行数:16,代码来源:HuntRPG.cs

示例11: MappingNotImplementedException

 public MappingNotImplementedException(BaseEntity entity)
     : base (message: "Mapper for provided entity model of type" + entity.GetType() + "not found")
 {
     Entity = entity;
 }
开发者ID:m-wilczynski,项目名称:Graphinder,代码行数:5,代码来源:MappingNotImplementedException.cs

示例12: UnsavedLinksException

 public UnsavedLinksException(BaseEntity entity)
     : base("Some of the entities linked to '" + entity.GetType().Name + " have not been saved. Use the Data.SaveLinkedEntities(entity) function.")
 {
 }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:4,代码来源:UnsavedLinksException.cs

示例13: UpdateLinkedEntities

        public virtual void UpdateLinkedEntities(BaseEntity entity)
        {
            if (Settings.IsVerbose)
                Console.WriteLine ("Updating all entities linked to '"  + entity.GetType().Name + "'.");

            foreach (var property in entity.GetType().GetProperties()) {
                if (Linker.IsLinkProperty (entity, property)) {
                    UpdateLinkedEntities (entity, property);
                }
            }
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:11,代码来源:DataLinker.cs

示例14: RemoveLinks

        public virtual void RemoveLinks(BaseEntity entity)
        {
            if (Settings.IsVerbose)
            {
                Console.WriteLine ("  Removing links between '" + entity.GetType().Name + "' and other entities");
            }

            foreach (var property in entity.GetType().GetProperties()) {
                var otherPropertyName = "";

                // TODO: Clean up if statement
                if ((Linker.PropertyHasLinkAttribute(property, out otherPropertyName)
                    || Linker.IsLinkProperty(entity, property))
                    && !String.IsNullOrEmpty(otherPropertyName))
                {
                    RemoveLinks (entity, property, otherPropertyName);
                }
            }
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:19,代码来源:DataLinker.cs

示例15: EntityExists

        public bool EntityExists(BaseEntity[] entities, BaseEntity entityToFind)
        {
            if (entities == null)
                return false;

            if (entityToFind == null)
                throw new ArgumentNullException ("entityToFind");

            return (from entity in entities
                where entity != null
                    && entity.GetType() == entityToFind.GetType()
                    && entity.Id == entityToFind.Id
                select entity).Count() > 0;
        }
开发者ID:CompulsiveCoder,项目名称:gitdb-cs,代码行数:14,代码来源:EntityLinker.cs


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