本文整理汇总了C#中System.Entity类的典型用法代码示例。如果您正苦于以下问题:C# Entity类的具体用法?C# Entity怎么用?C# Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于System命名空间,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Program
public Program()
{
m_service = new MockCrmService();
// test data for simple fetch
Entity de = new Entity();
de.LogicalName = "mydynamic";
de["prop1"] = "foo";
Guid deID = m_service.Create( de );
// test data for filters
de = new Entity();
de.LogicalName = "contact";
de[ "address1_name" ] = "Dan";
de[ "address1_city" ] = "Bethesda";
Guid deID2 = m_service.Create( de );
// data for testing links
Guid guid = Guid.NewGuid();
de = new Entity();
de.LogicalName = "subject";
de[ "subjectid" ] = guid;
Guid deID3 = m_service.Create( de );
de = new Entity();
de.LogicalName = "subject";
de[ "subjectid" ] = guid;
de[ "title" ] = "child";
de[ "parentsubject" ] = new EntityReference( "subject", deID3 );
Guid deID4 = m_service.Create( de );
}
示例2: ProcessEntities
protected override void ProcessEntities(Dictionary<int, Entity> entities)
{
float simultaneous = Environment.ProcessorCount * 2;
int perThread = (int)Math.Ceiling(((float)entities.Values.Count) / simultaneous);
Entity[] ents = new Entity[entities.Values.Count];
entities.Values.CopyTo(ents, 0);
int num = entities.Values.Count - 1;
List<Task> tasks = new List<Task>();
for (int j = 0; j < simultaneous; j++)
{
int initial = num;
tasks.Add(factory.StartNew(
() =>
{
for (int i = initial; i > initial - perThread && i >= 0; i--)
{
Process(ents[i]);
}
}
));
num -= perThread;
}
Task.WaitAll(tasks.ToArray());
}
示例3: TestAddRemoveListenerImpl
private void TestAddRemoveListenerImpl(Game game)
{
var audio = game.Audio;
var notAddedToEntityListener = new AudioListenerComponent();
var addedToEntityListener = new AudioListenerComponent();
// Add a listenerComponent not present in the entity system yet and check that it is correctly added to the AudioSystem internal data structures
Assert.DoesNotThrow(() => audio.AddListener(notAddedToEntityListener), "Adding a listener not present in the entity system failed");
Assert.IsTrue(audio.Listeners.ContainsKey(notAddedToEntityListener), "The list of listeners of AudioSystem does not contains the notAddedToEntityListener.");
// Add a listenerComponent already present in the entity system and check that it is correctly added to the AudioSystem internal data structures
var entity = new Entity("Test");
entity.Add(addedToEntityListener);
throw new NotImplementedException("TODO: UPDATE TO USE Scene and Graphics Composer");
//game.Entities.Add(entity);
Assert.DoesNotThrow(() => audio.AddListener(addedToEntityListener), "Adding a listener present in the entity system failed");
Assert.IsTrue(audio.Listeners.ContainsKey(addedToEntityListener), "The list of listeners of AudioSystem does not contains the addedToEntityListener.");
// Add a listenerComponent already added to audio System and check that it does not crash
Assert.DoesNotThrow(()=>audio.AddListener(addedToEntityListener), "Adding a listener already added to the audio system failed.");
// Remove the listeners from the AudioSystem and check that they are removed from internal data structures.
Assert.DoesNotThrow(() => audio.RemoveListener(notAddedToEntityListener), "Removing an listener not present in the entity system failed.");
Assert.IsFalse(audio.Listeners.ContainsKey(notAddedToEntityListener), "The list of listeners of AudioSystem still contains the notAddedToEntityListener.");
Assert.DoesNotThrow(() => audio.RemoveListener(addedToEntityListener), "Removing an listener present in the entity system fails");
Assert.IsFalse(audio.Listeners.ContainsKey(addedToEntityListener), "The list of listeners of AudioSystem still contains the addedToEntityListener.");
// Remove a listener not present in the AudioSystem anymore and check the thrown exception
Assert.Throws<ArgumentException>(() => audio.RemoveListener(addedToEntityListener), "Removing the a non-existing listener did not throw ArgumentException.");
}
示例4: KickPlayer
// Some functions below - Might move to seperate file? (functions.cs)
public void KickPlayer(Entity player)
{
player.AfterDelay(100, entity =>
{
Call("kick", player.Call<int>("getentitynumber"));
});
}
示例5: GetRecords
private PagedRecords GetRecords(
Entity entity,
NameValueCollection request,
TableInfo tableInfo,
Action<IList<BaseFilter>> filtersMutator)
{
var filterRecord = create_filter_record(entity, request);
var filters = _filterFactory.BuildFilters(filterRecord).ToList();
if (filtersMutator != null)
{
filtersMutator(filters);
}
var pagedRecords = _entitiesSource.GetRecords(
entity,
filters,
tableInfo.SearchQuery,
tableInfo.Order,
tableInfo.OrderDirection,
false,
tableInfo.Page,
tableInfo.PerPage);
pagedRecords.Filters = filters;
return pagedRecords;
}
示例6: OnUpdateSystem
private void OnUpdateSystem(ParticleEmitterComponent particleEmitterComponent)
{
if (dragonHead == null)
dragonHead = EntitySystem.Entities.FirstOrDefault(x => x.Name == "English DragonPelvis");
var desc = Description;
if (dragonHead != null)
{
var dragonTransform = dragonHead.Transformation;
if (dragonTransform != null)
{
desc.TargetOld = desc.Target;
desc.Target = (Vector3)dragonTransform.WorldMatrix.Row4;
}
}
var animationComponent = RootAnimation.GetOrCreate(AnimationComponent.Key);
if (animationComponent != null)
{
desc.AnimationTime = (float)animationComponent.CurrentTime.TotalSeconds;
// If we reset, reupload the particle buffer
if ((animationComponent.CurrentTime.Ticks - lastTime.Ticks) < 0)
particleEmitterComponent.UpdateNextBuffer = true;
lastTime = animationComponent.CurrentTime;
}
Description = desc;
}
示例7: DeleteUser
/// <summary>
/// 删除一个用户 业务角度来说 其实是不需要的
/// </summary>
/// <param name="entity">memberiship用户</param>
/// <returns>领域处理结果</returns>
public DomainResult DeleteUser(Entity.MemberShip.Membership entity)
{
if (IsExistUser(entity.Users.UserName).isSuccess)
{
var result = DomainResult.GetDefault();
try
{
Membership.DeleteUser(entity.Users.UserName);
using (var content = new SiteContext())
{
var other = content.OtherInformations
.Where(r => r.Email == entity.Users.UserName).FirstOrDefault();
if (other != null)
{
content.OtherInformations.Remove(other);
content.SaveChanges();
}
}
}
catch (Exception ex)
{
result.isSuccess = false;
result.error = ex;
result.ResultMsg = ex.Message;
}
return result;
}
else
{
return new DomainResult(false) { ResultMsg = "用户不存在" };
}
}
示例8: DeleteGalleryItemMeta
/// <summary>
/// Deletes the meta tag value from the specified gallery items.
/// </summary>
/// <param name="galleryItemMeta">An instance of <see cref="Entity.GalleryItemMeta" /> that defines
/// the tag value to be added and the gallery items it is to be added to.</param>
/// <exception cref="System.Web.Http.HttpResponseException"></exception>
public HttpResponseMessage DeleteGalleryItemMeta(Entity.GalleryItemMeta galleryItemMeta)
{
// /api/galleryitemmeta
try
{
var mType = (MetadataItemName)galleryItemMeta.MetaItem.MTypeId;
if (mType == MetadataItemName.Tags || mType == MetadataItemName.People)
{
MetadataController.DeleteTag(galleryItemMeta);
}
else
{
MetadataController.Delete(galleryItemMeta);
}
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent("Meta item deleted...")
};
}
catch (GallerySecurityException)
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
}
catch (Exception ex)
{
AppEventController.LogError(ex);
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
Content = Utils.GetExStringContent(ex),
ReasonPhrase = "Server Error"
});
}
}
示例9: SpriteRenderer
public SpriteRenderer(Entity parent)
: base(parent)
{
this.Color = Color.White;
this.Scale = 1;
this.SpriteEffects = SpriteEffects.None;
}
示例10: Listar
/// <summary>Método que representa la llamada al procedure 'Partida_Listar'</summary>
public static List<Entity.Partida.Listar> Listar(Entity.Partida Item, Cursor oCursor)
{
var ResultSet = new List<Entity.Partida.Listar>();
SqlCommand oComando = oCursor.ObtenerComando(Contexto.CnControlPresupuesto);
string Esquema = Galeria.Conexiones[(int)Contexto.CnControlPresupuesto].EsquemaDefecto;
oComando.CommandText = Esquema + "Partida_Listar";
try
{
using (SqlDataReader oLector = oComando.ExecuteReader())
{
while (oLector.Read())
{
var LItem = new Entity.Partida.Listar();
LItem.idPartida = (string)oLector["idPartida"];
LItem.Partida = (string)oLector["Partida"];
LItem.Estado = (string)oLector["Estado"];
ResultSet.Add(LItem);
}
}
return ResultSet;
}
catch (System.Exception)
{
throw;
}
}
示例11: RandomMoveBehaviour
public RandomMoveBehaviour(Entity entity)
{
_currentDirection = Vector3.up;
_distanceTraveledInThisDirection = 0;
_entity = entity;
}
示例12: Execute
public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx)
{
var assignRequest = (AssignRequest)request;
var target = assignRequest.Target;
var assignee = assignRequest.Assignee;
if (target == null)
{
throw new FaultException<OrganizationServiceFault>(new OrganizationServiceFault(), "Can not assign without target");
}
if (assignee == null)
{
throw new FaultException<OrganizationServiceFault>(new OrganizationServiceFault(), "Can not assign without assignee");
}
var service = ctx.GetFakedOrganizationService();
var assignment = new Entity
{
LogicalName = target.LogicalName,
Id = target.Id,
Attributes = new AttributeCollection
{
{ "ownerid", assignee }
}
};
service.Update(assignment);
return new AssignResponse();
}
示例13: Can_load_entity
public void Can_load_entity()
{
var specialId = "SHA1-UdVhzPmv0o+wUez+Jirt0OFBcUY=";
using (base.GetNewServer())
{
IDocumentStore documentStore = new DocumentStore
{
Url = "http://localhost:8080"
}.Initialize();
using(var store = documentStore)
{
store.Initialize();
using (var session = store.OpenSession())
{
var entity = new Entity() { Id = specialId };
session.Store(entity);
session.SaveChanges();
}
using (var session = store.OpenSession())
{
var entity1 = session.Load<object>(specialId);
Assert.NotNull(entity1);
}
}
}
}
示例14: WithSeries
public static void WithSeries(this IEnumerable<CFindResponse> cFinds, DICOMSCU scu, Entity daemon)
{
var iods = cFinds.Where(r => r.Status == (ushort)Status.PENDING)
.Where(r => r.HasData)
.Where(r => r.Data.Elements.Any(e => e.Tag == TagHelper.STUDY_INSTANCE_UID))
.Where(r => !string.IsNullOrEmpty(r.Data.Elements.First(e => e.Tag == TagHelper.STUDY_INSTANCE_UID).DData as string))
.Select(r => r.GetIOD())
.ToList();
iods.ForEach(i=>i.QueryLevel = QueryLevel.SERIES);
foreach (var iod in iods)
{
var req = new CFindRequest(iod, Root.STUDY);
var seriesUids = scu.GetResponse(req, daemon)
.Where(r => r.Status == (ushort)Status.PENDING)
.Where(r => r.HasData)
.Where(r => r.Data.Elements.Any(e => e.Tag == TagHelper.SERIES_INSTANCE_UID))
.Select(r => new
{
// Study = study,
Series = r.Data.GetSelector().SeriesInstanceUID.Data,
Modality = r.Data.GetSelector().Modality.Data
})
.ToList();
System.Console.Write("");
}
}
示例15: GenerateRandomAccountCollection
private EntityCollection GenerateRandomAccountCollection()
{
var collection = new List<Entity>();
for (var i = 0; i < 10; i++)
{
var rgn = new Random((int)DateTime.Now.Ticks);
var entity = new Entity("account");
entity["accountid"] = entity.Id = Guid.NewGuid();
entity["address1_addressid"] = Guid.NewGuid();
entity["modifiedon"] = DateTime.Now;
entity["lastusedincampaign"] = DateTime.Now;
entity["donotfax"] = rgn.NextBoolean();
entity["new_verybignumber"] = rgn.NextInt64();
entity["exchangerate"] = rgn.NextDecimal();
entity["address1_latitude"] = rgn.NextDouble();
entity["numberofemployees"] = rgn.NextInt32();
entity["primarycontactid"] = new EntityReference("contact", Guid.NewGuid());
entity["revenue"] = new Money(rgn.NextDecimal());
entity["ownerid"] = new EntityReference("systemuser", Guid.NewGuid());
entity["industrycode"] = new OptionSetValue(rgn.NextInt32());
entity["name"] = rgn.NextString(15);
entity["description"] = rgn.NextString(300);
entity["statecode"] = new OptionSetValue(rgn.NextInt32());
entity["statuscode"] = new OptionSetValue(rgn.NextInt32());
collection.Add(entity);
}
return new EntityCollection(collection);
}