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


C# Entity.GetType方法代码示例

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


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

示例1: Equals

        /// <summary>
        /// Equalses the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns>A <see cref="System.Boolean"/></returns>
        public virtual bool Equals( Entity entity )
        {
            if ( ReferenceEquals ( null, entity ) )
            {
                return false;
            }
            if ( ReferenceEquals ( this, entity ) )
            {
                return true;
            }
            if ( GetType () != entity.GetType () )
            {
                return false;
            }

            var otherIsTransient = Equals ( entity.Key, ( long )0 );
            var thisIsTransient = Equals ( Key, ( long )0 );

            if ( otherIsTransient && thisIsTransient )
            {
                return ReferenceEquals ( entity, this );
            }

            return entity.Key.Equals ( Key );
        }
开发者ID:divyang4481,项目名称:REM,代码行数:30,代码来源:Entity.cs

示例2: OfflinableEntity

        /// <summary>
        /// Constructor referencing an <see cref="Entity"/>
        /// </summary>
        /// <param name="entity"><see cref="Entity"/> reference to be offlined</param>
        /// <param name="addedEntity">Conditional <see cref="Boolean"/> to specify whether or not the <see cref="Entity"/> is Added</param>
        public OfflinableEntity(Entity entity, bool addedEntity = false)
        {
            this.OriginalEntity = entity.GetOriginal();
            this.CurrentEntity = entity;

            if (addedEntity)
            {
                foreach (var collection in entity.GetType().GetProperties().Where(p => p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(EntityCollection<>)))
                {
                    List<Entity> entities = new List<Entity>();
                    foreach (var entityRef in collection.GetValue(entity, null) as IEnumerable<Entity>)
                    {
                       entities.Add(entityRef);
                    }
                    if (entities.Any())
                    {
                        if (EntityRefs == null)
                        {
                            EntityRefs = new Dictionary<string, List<Entity>>();
                        }
                        this.EntityRefs.Add(collection.Name, entities);
                    }
                }
            }
            this.EntityState = entity.EntityState;
            this.EntityActions = ConvertToOfflinableEntityActions(entity.EntityActions);
        }
开发者ID:JeanNguon,项目名称:Projet,代码行数:32,代码来源:OfflinableEntity.cs

示例3: NewBuildOrder

 private void NewBuildOrder(ActionType actionType, Entity target)
 {
     if (actionType == ActionType.Build)
     {
         if (target != null)
             if (target.GetType() == typeof(Building))
                 _buildingToBuild = target as Building;
     }
 }
开发者ID:mennolp098,项目名称:multiplayer-rts,代码行数:9,代码来源:Builder.cs

示例4: GetMethodList

    // returns callable methods, for triggers etc
    public static string[] GetMethodList(Entity ent)
    {
        string [] tempMethods =
            ent.GetType()
            .GetMethods(BindingFlags.Instance| BindingFlags.Public | BindingFlags.NonPublic |  BindingFlags.FlattenHierarchy)
            .Where(m => m.GetCustomAttributes(typeof(Callable), false).Length > 0)
            .Where(x => !ignoreMethods.Any(n => n == x.Name)) // Don't list methods in the ignoreMethods array (so we can exclude Unity specific methods, etc.)
            .Select(x => x.Name)
            .ToArray();

        if (tempMethods.Length > 0) {
            // sort the list
            Array.Sort<string> (tempMethods);
        }

        return tempMethods;
    }
开发者ID:JimWest,项目名称:UnityTestProject,代码行数:18,代码来源:EntityUtility.cs

示例5: TestLinqCount

        public void TestLinqCount()
        {
            var collection = Configuration.GetTestCollection<Entity>();
            if (collection.Exists()) { collection.Drop(); }

            for (int i = 0; i < 100; ++i)
            {
                var e = new Entity() { Name = "Name_" + i };
                collection.Insert(e.GetType(), e, WriteConcern.Acknowledged);
            }

            var query = (from e in collection.AsQueryable<Entity>()
                         where true || e.Name == "Name_22"
                         select e);
            var count = query.Count();

            Assert.AreEqual(100, count);
        }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CSharp653Tests.cs

示例6: SetEntity

    private void SetEntity(Entity entity)
    {
        this.entity = entity;

        switch (type)
        {
            case StatBarType.Health:
                entity.OnSelect += ShowStatBar;
                entity.OnDeselect += HideStatBar;
                entity.OnDamageReceive += UpdateStatBar;
                break;
            case StatBarType.BuildProgress:
                entity.OnConstructionProgress += UpdateStatBar;
                if (entity.GetType() == typeof(Building))
                    ((Building)entity).OnPlace += ShowStatBar;
                break;
        }
    }
开发者ID:mennolp098,项目名称:multiplayer-rts,代码行数:18,代码来源:EntityStatBar.cs

示例7: TestLinqCount

        public void TestLinqCount()
        {
            var collection = LegacyTestConfiguration.GetCollection<Entity>();
            if (collection.Exists()) { collection.Drop(); }

            for (int i = 0; i < 100; ++i)
            {
                var e = new Entity() { Name = "Name_" + i };
                collection.Insert(e.GetType(), e, WriteConcern.Acknowledged);
            }

#pragma warning disable 429 // unreachable code
            var query = (from e in collection.AsQueryable<Entity>()
                         where true || e.Name == "Name_22"
                         select e);
#pragma warning restore
            var count = query.Count();

            Assert.Equal(100, count);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:20,代码来源:CSharp653Tests.cs

示例8: CanShootEntity

 public override bool CanShootEntity(Entity e)
 {
     System.Type entityType = e.GetType();
     if (entityType == typeof(PlayerControl))
     {
         // return reactions[PlayerControl] == HOSTILE
         return false;
     }
     else if (entityType == typeof(Enemy))
     {
         // return reactions[PlayerControl] == HOSTILE
         return true;
     }
     else if (entityType == typeof(NPC))
     {
         // return reactions[PlayerControl] == HOSTILE
         return false;
     }
     return false;
 }
开发者ID:wildrabbit,项目名称:ld33,代码行数:20,代码来源:NPC.cs

示例9: Delete

 public void Delete(Entity entity)
 {
     log.DebugFormat("{0} #{1} deleted.", entity.GetType(), entity.Id);
 }
开发者ID:akhuang,项目名称:NHibernate,代码行数:4,代码来源:AuditLogger.cs

示例10: setInitialEntity

	public void setInitialEntity(Entity entity) {
        removeEntity();
        entity.transform.parent = this.transform.parent;
        entity.transform.position = transform.position;
		this.entityPresent = entity;
		entity.setCurrentTile (this);
        if (entity.GetType() != typeof(Obstacle))
        {
            int type = (entity.getIsPlayer() ? 0 : 1);
            graphicTile = GetComponent<GraphicTile>();
            graphicTile.setAnim();
            setTileType(type);
        }
    }
开发者ID:ablbebxb,项目名称:demonGymnasium,代码行数:14,代码来源:Tile.cs

示例11: Populate

        public virtual void Populate(FieldMap fieldMap, Entity entity)
        {
            var fieldsWithNoValueOnEntity = new List<string>();

            var @class = new Class(GetType());
            @class.EachField(delegate(FieldInfo fieldInfo)
                                 {
                                     var uiItem = fieldInfo.GetValue(this) as UIItem;
                                     if (uiItem == null || !ControlDictionary.Instance.IsEditable(uiItem)) return;

                                     string fieldName = fieldMap.GetFieldNameFor(fieldInfo.Name, fieldInfo.FieldType);
                                     if (string.IsNullOrEmpty(fieldName)) return;

                                     try
                                     {
                                         EntityField entityField = entity.Field(fieldName);
                                         if (entityField == null)
                                             fieldsWithNoValueOnEntity.Add(fieldName);
                                         else
                                             entityField.SetValueOn(uiItem);
                                     }
                                     catch (TargetInvocationException e)
                                     {
                                         throw new AppScreenException(
                                             string.Format("Error assigning {0}.{1} to {2}.{3} ", entity.GetType(), fieldName, GetType(), fieldInfo.Name),
                                             e.InnerException);
                                     }
                                 });

            if (fieldsWithNoValueOnEntity.Count == 0) return;

            string message = string.Join(",", fieldsWithNoValueOnEntity.ToArray());
            WhiteLogger.Instance.WarnFormat("Mapping to screen: {0} with {1}, No value specified for fields {2}", this, entity.GetType(), message);
        }
开发者ID:hsteinhilber,项目名称:white-project,代码行数:34,代码来源:AppScreen.cs

示例12: MarkEntityAsDeleted

        protected override void MarkEntityAsDeleted(Entity entity)
        {
            AttachIfNeeded(entity);

            _dbContext.Set(entity.GetType()).Remove(entity);
        }
开发者ID:hudo,项目名称:Pragmatic,代码行数:6,代码来源:UnitOfWork.cs

示例13: UpdateEntityDetails

 private void UpdateEntityDetails(Entity entity)
 {
     this.updateMethods[entity.GetType()](entity);
 }
开发者ID:tupacko,项目名称:codingame,代码行数:4,代码来源:PokerChipRace.cs

示例14: SetIdOf

 public static void SetIdOf(Entity entity, int id)
 {
     PropertyInfo idProperty = entity.GetType().GetProperty("Id",
       BindingFlags.Public | BindingFlags.Instance);
       idProperty.SetValue(entity, id, null);
 }
开发者ID:pwideman,项目名称:ClubPool,代码行数:6,代码来源:EntityIdSetter.cs

示例15: Insert

 public void Insert(Entity entity)
 {
     log.DebugFormat("{0} #{1} inserted.", entity.GetType(), entity.Id);
 }
开发者ID:akhuang,项目名称:NHibernate,代码行数:4,代码来源:AuditLogger.cs


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