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


C# Entity.GetType方法代码示例

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


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

示例1: doCollision

        public void doCollision(Entity ent)
        {
            if (ent.GetType() == typeof(FlyingEnemy) ||
                ent.GetType() == typeof(SpawnerEnemy) ||
                ent.GetType() == typeof(GuardEnemy))
            {

                    health -= 1.0f;
            }

            if (ent.GetType() == typeof(InfoPad))
            {
                String newPower = ((InfoPad)ent).power;

                if (!powers.isAvailable(newPower))
                {
                    powers.makeAvailable(newPower);
                    LogState.instance.catIntoLog("Discovered: " + newPower + "\n");
                    LogState.instance.catIntoAvailable(newPower);
                    LogState.instance.clearInput();
                    ent.health = 0;
                }
                else
                {
                    if (!justHit)
                    {
                        LogState.instance.catIntoLog("Already know " + newPower + "\n");
                        justHit = true;
                        ent.health = 0;
                    }
                }
            }
        }
开发者ID:tgashby,项目名称:RGJ-2012,代码行数:33,代码来源:Player.cs

示例2: Create

        public Guid Create( Entity entity )
        {
            // TODO: can the ID be assigned manually? I can't remember
            Guid id = Guid.NewGuid();
            entity.Id = id;

            string name = entity.GetType().Name;
            if( data.ContainsKey( name ) == false ) {
                data.Add( name, new EntityCollection() );
            }

            if( name == "Entity" ) {
                Entity de = ( Entity )entity;
                // We set name here to support DynamicEntity
                name = de.LogicalName;
                de[name + "id"] = id;
            }
            else {
                entity.GetType().GetProperty( name + "id" ).SetValue( entity, id, null );
            }

            if( !data.ContainsKey( name ) ) {
                data[ name ] = new EntityCollection();
            }
            data[ name ].Entities.Add( entity );

            if( m_persist ) {
                PersistToDisk( m_filename );
            }

            return id;
        }
开发者ID:modulexcite,项目名称:FakeCRM,代码行数:32,代码来源:MockCrmService.cs

示例3: AddEntity

        protected internal void AddEntity(Entity e)
        {
            //Automatically detect proxy types assembly if an early bound type was used.
            if (ProxyTypesAssembly == null &&
                e.GetType().IsSubclassOf(typeof(Entity)))
            {
                ProxyTypesAssembly = Assembly.GetAssembly(e.GetType());
            }

            ValidateEntity(e); //Entity must have a logical name and an Id

            //Add the entity collection
            if (!Data.ContainsKey(e.LogicalName))
            {
                Data.Add(e.LogicalName, new Dictionary<Guid, Entity>());
            }

            if (Data[e.LogicalName].ContainsKey(e.Id))
            {
                Data[e.LogicalName][e.Id] = e;
            }
            else
            {
                Data[e.LogicalName].Add(e.Id, e);
            }

            //Update metadata for that entity
            if (!AttributeMetadata.ContainsKey(e.LogicalName))
                AttributeMetadata.Add(e.LogicalName, new Dictionary<string, string>());

            //Update attribute metadata
            if (ProxyTypesAssembly != null)
            {
                //If the context is using a proxy types assembly then we can just guess the metadata from the generated attributes
                var type = FindReflectedType(e.LogicalName);
                if (type != null)
                {
                    var props = type.GetProperties();
                    foreach (var p in props)
                    {
                        if (!AttributeMetadata[e.LogicalName].ContainsKey(p.Name))
                            AttributeMetadata[e.LogicalName].Add(p.Name, p.Name);
                    }
                }
                else
                    throw new Exception(string.Format("Couldnt find reflected type for {0}", e.LogicalName));

            }
            else
            {
                //If dynamic entities are being used, then the only way of guessing if a property exists is just by checking
                //if the entity has the attribute in the dictionary
                foreach (var attKey in e.Attributes.Keys)
                {
                    if (!AttributeMetadata[e.LogicalName].ContainsKey(attKey))
                        AttributeMetadata[e.LogicalName].Add(attKey, attKey);
                }
            }
        }
开发者ID:DigitalFlow,项目名称:fake-xrm-easy,代码行数:59,代码来源:XrmFakedContext.Crud.cs

示例4: GetRoundtripEntity

        internal static Entity GetRoundtripEntity(Entity entity)
        {
            Entity roundtripEntity = (Entity)Activator.CreateInstance(entity.GetType());
            IDictionary<string, object> roundtripState = ObjectStateUtility.ExtractRoundtripState(entity.GetType(), entity.OriginalValues);
            roundtripEntity.ApplyState(roundtripState);

            return roundtripEntity;
        }
开发者ID:kouweizhong,项目名称:openair,代码行数:8,代码来源:ChangeSetBuilder.cs

示例5: Format

        public string Format(Entity entity)
        {
            var key = entity.GetType();
            if (!htmlTags.ContainsKey(key))
                throw new Exception(string.Format("HtmlFormatter got unknown Entity: {0}", entity.GetType()));

            var strToFormat = htmlTags[key];
            var entityContent = entity.GetSubEntitiesFormat(this);
            return string.Format(strToFormat, entityContent);
        }
开发者ID:xackill,项目名称:01-quality,代码行数:10,代码来源:HtmlFormatter.cs

示例6: Add

        public void Add(Entity entity)
        {
            if (entity.Self.Id == null)
                session.Save(entity);

            var existingObject = ((IList<CachedEntity>)Find(entity.GetType(), entity.Self.Id)).FirstOrDefault();
            if (existingObject == null)
            {
                entities.Add(new CachedEntity {Id = entity.Self.Id, Type = entity.GetType(), Value = entity});
            }
            else
            {
                existingObject.Value = entity;
            }
        }
开发者ID:AndyStewart,项目名称:Dynamo,代码行数:15,代码来源:EntityCache.cs

示例7: Collider

        public bool Collider(Entity entity_a, Entity entity_b)
        {
            float entity_a_LH = entity_a.X - entity_a.Width/2; 	                //LH
            float entity_a_RH = entity_a.X + entity_a.Width/2;	//RH
            float entity_a_T = entity_a.Y - entity_a.Height/2;	                    //Top
            float entity_a_B = entity_a.Y +entity_a.Height/2;	//Btm

            //Let's get centre of entity_b for a little more realism/accuracy
            float entity_b_X = entity_b.X;// +(entity_b.Width * 0.5f);
            float entity_b_Y = entity_b.Y;// +(entity_b.Height * 0.5f);

            if (entity_b_X >= entity_a_LH && entity_b_X <= entity_a_RH && entity_b_Y <= entity_a_B && entity_b_Y >= entity_a_T)
            {
                //On enemy collission with tower increase capacity of tower - or this can be ran in main game loop
                if (entity_a.GetType() == typeof(Tower))
                {
                    //Temporary for testing - set object to inactive for list clean up - Pass responsibility to enemy directly
                    entity_b.Active = false;
                }
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:jeremy-e,项目名称:Spell-Slinger-AIE,代码行数:26,代码来源:ColliderHandler.cs

示例8: OnBoxCollision

        public override void OnBoxCollision(Entity collided, Rectangle intersect)
        {
            // Collides with another Hero
            if (collided.GetType() == typeof (Hero)) _tint = Color.Red;

            base.OnBoxCollision(collided, intersect);
        }
开发者ID:GarethIW,项目名称:LD29,代码行数:7,代码来源:Hero.cs

示例9: ScoreKill

 public void ScoreKill(Entity entity)
 {
     if ((entity.GetType() == typeof(Alien)) && (entity.PlayerNumber != PlayerNumber))
     {
         Match.GetInstance().GetPlayer(PlayerNumber).Kills++;
     }
     else if ((entity.GetType() == typeof(Ship)) && (entity.PlayerNumber != PlayerNumber))
     {
         Match.GetInstance().GetPlayer(PlayerNumber).Kills++;
     }
     else if (((entity.GetType() == typeof(AlienFactory)) || (entity.GetType() == typeof(MissileController))) &&
              (entity.PlayerNumber != PlayerNumber))
     {
         Match.GetInstance().GetPlayer(PlayerNumber).Kills++;
     }
 }
开发者ID:rm2k,项目名称:space-invaders,代码行数:16,代码来源:Missile.cs

示例10: CheckCollision

        /// <summary>
        /// Generic collision detection function.
        /// Checks collisions between two Entities.
        /// </summary>
        /// <param name="a">the first Entity.</param>
        /// <param name="b">the second Entity.</param>
        /// <returns>True if the two Entities are colliding; false otherwise.</returns>
        public static bool CheckCollision(Entity a, Entity b)
        {
            if (b.GetType() == typeof(MysteryBox))
            {
                return CheckCollision(a, (MysteryBox)b);
            }
            else
            {
                if (a.myModel != null && b.myModel != null)
                {
                    for (int i = 0; i < a.myModel.Meshes.Count; i++)
                    {
                        BoundingSphere HeroSphere = a.myModel.Meshes[i].BoundingSphere;
                        HeroSphere.Center += a.getPOSITION();

                        for (int j = 0; j < b.myModel.Meshes.Count; j++)
                        {
                            BoundingSphere EnemySphere = b.myModel.Meshes[j].BoundingSphere;
                            EnemySphere.Center += b.getPOSITION();

                            if (HeroSphere.Intersects(EnemySphere))
                            {
                                //collision!
                                return true;
                            }
                        }
                    }
                }
                return false;
            }
        }
开发者ID:CaKlassen,项目名称:Titanium,代码行数:38,代码来源:PhysicsUtils.cs

示例11: CreateSerializer

        /// <summary>
        /// 为指定的实体创建一个 DataContractSerializer。
        /// 此过程会通过引用属性、列表属性,递归搜索实体类中所涉及到的其它所有实体类型,
        /// 并传递给 DataContractSerializer 作为已知类型,否则,将无法序列化。
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static DataContractSerializer CreateSerializer(Entity entity)
        {
            var graph = new SerializationEntityGraph();
            graph.DeepSearch(entity);

            return new DataContractSerializer(entity.GetType(), graph._knownTypes);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:14,代码来源:SerializationEntityGraph.cs

示例12: addEntity

        public void addEntity(Entity type, Vector2 position, Game game)
        {
            Type t = type.GetType();

            if (t == typeof(InfoPad))
            {
                entities.Add(new InfoPad(position, ((InfoPad)type).power));
            }
            else if (t == typeof(FlyingEnemy))
            {
                entities.Add(new FlyingEnemy(position));
            }
            else if (t == typeof(SpawnerEnemy))
            {
                entities.Add(new SpawnerEnemy(position));
            }
            else if (t == typeof(GuardEnemy))
            {
                entities.Add(new GuardEnemy(position));
            }
            else
            { }

            entities.Last<Entity>().LoadContent(game);
        }
开发者ID:tgashby,项目名称:RGJ-2012,代码行数:25,代码来源:Entities.cs

示例13: OnCollision

 public override bool OnCollision(Entity ent, byte collide)
 {
     if (ent.GetType() == typeof(TheGame.Models.Player.Player)) {
         TheGame.Models.Player.Player player = (TheGame.Models.Player.Player) ent;
         player.Finished = true;
     }
     return false;
 }
开发者ID:Railec,项目名称:SE1cKBS,代码行数:8,代码来源:EntityGoal.cs

示例14: GetId

        internal static object GetId(Entity entity)
        {
            if (entity == null)
              {
            return null;
              }

              return entity.GetType().InvokeMember("Id", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public, null, entity, null, CultureInfo.InvariantCulture);
        }
开发者ID:MiddleTommy,项目名称:LightSpeed-Ria-Services,代码行数:9,代码来源:TypeUtils.cs

示例15: DieAHorribleDeath

 //Aka Kill (Sam)
 public void DieAHorribleDeath(Entity murderer = null)
 {
     game.entities_toremove.Add (this);
     if (murderer == null) { return; }
     string name = murderer.GetType ().FullName;
     if (name == "NoMoreClones.FriendlyBullet") {
         game.score += score_worth;
     }
 }
开发者ID:ChelmsfordMakerspace,项目名称:gamedev-workshops,代码行数:10,代码来源:Entity.cs


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