本文整理汇总了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 );
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例9: Delete
public void Delete(Entity entity)
{
log.DebugFormat("{0} #{1} deleted.", entity.GetType(), entity.Id);
}
示例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);
}
}
示例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);
}
示例12: MarkEntityAsDeleted
protected override void MarkEntityAsDeleted(Entity entity)
{
AttachIfNeeded(entity);
_dbContext.Set(entity.GetType()).Remove(entity);
}
示例13: UpdateEntityDetails
private void UpdateEntityDetails(Entity entity)
{
this.updateMethods[entity.GetType()](entity);
}
示例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);
}
示例15: Insert
public void Insert(Entity entity)
{
log.DebugFormat("{0} #{1} inserted.", entity.GetType(), entity.Id);
}