void PlaceRopes() { GameObject staticContainer = new GameObject(); staticContainer.name = "Ropes"; staticContainer.transform.SetParent(world.transform); int ropenum = 1; foreach (SourceEntity ent in entities) { if (ent.GetStringValue("classname") != "keyframe_rope" && ent.GetStringValue("classname") != "move_rope") { continue; } SourceEntity next = GetSourceEntityByName(ent.GetStringValue("NextKey")); if (next == null) { continue; } GameObject ropeRoot = Instantiate(ropePrefab); RopeSim rope = ropeRoot.GetComponentInChildren <RopeSim> (); rope.start.position = SourceToUnityPosition(ent.GetVectorValue("origin")); rope.end.position = SourceToUnityPosition(next.GetVectorValue("origin")); ropeRoot.transform.SetParent(staticContainer.transform); ropeRoot.name = "Rope" + ropenum; ropenum++; } }
public void Example() { // Create our source object var sourceObj = new SourceEntity { Number = 10, NumberToString = -1000 }; var destObj = new DestEntity(); // Create the object mapper var mapper = new ResourceMapper <object>(); mapper.LoadStandardConverters(); // Load standard converters from System.Convert (e.g., int to string) mapper.RegisterOneWayMapping <SourceEntity, DestEntity>(mapping => { mapping.Set(to => to.DifferentlyNamedNumber, from => from.Number); // Directly assigns the source value to the destination value mapping.Set(to => to.DifferentlyNamedNumberToString, from => from.NumberToString); // There are many other variations of Set on the IMappingCollection<T> interface. Check these out on the API // Unspecified properties will be automapped after this point if not explicitly ignored using mapping.Ignore }); mapper.InitializeMap(); // Perform map destObj = mapper.Map(sourceObj, destObj, null); Assert.AreEqual(sourceObj.Id, destObj.Id); Assert.AreEqual(sourceObj.Number, destObj.DifferentlyNamedNumber); Assert.AreEqual(sourceObj.NumberToString.ToString(), destObj.DifferentlyNamedNumberToString); }
public void FeatureAvailabilityMix() { var Source_A = new SourceEntity(); Source_A.AddSourceItem(800, 1000, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability); var Source_B = new SourceEntity(); Source_B.AddSourceItem(90, 100, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability); var Indicators = new List <IndicatorEntity>() { new IndicatorEntity() { Id = 1, Source = Source_A }, new IndicatorEntity() { Id = 2, Source = Source_B } }; var entity = new FeatureEntity() { Id = 1, Name = "test", Indicators = Indicators }; var result = entity.Measure(); Assert.Equal(0.85m, result.Availability); }
private IEnumerable <SourceItemEntity> CreateFromPostRp(SourceEntity source, SourceItemPostRp model, DateTime on, string createdBy) { if (model is SourceItemAvailabilityPostRp ava) { return(SourceEntity.Factory.CreateItemsFromRange(source, model.Start, model.End, ava.Good, ava.Total, ava.Measure, on, createdBy, SourceGroupEnum.Availability)); } else if (model is SourceItemLatencyPostRp latency) { return(SourceEntity.Factory.CreateItemsFromRangeByMeasure(source, model.Start, model.End, latency.Measure, on, createdBy, SourceGroupEnum.Latency)); } else if (model is SourceItemExperiencePostRp experience) { return(SourceEntity.Factory.CreateItemsFromRange(source, model.Start, model.End, experience.Good, experience.Total, experience.Measure, on, createdBy, SourceGroupEnum.Experience)); } else { throw new ApplicationException("type is not valid"); } }
public void FeatureDateAvailabilityAggregateSuccess() { var sourceEntity = new SourceEntity() { }; sourceEntity.AddSourceItem(800, 1000, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability); var entity = new FeatureEntity() { Id = 1, Name = "test", Indicators = new List <IndicatorEntity>() { new IndicatorEntity() { Id = 1, Source = sourceEntity } } }; var result = entity.Measure(); Assert.Equal(0.8m, result.Availability); }
public async Task When_GenerateSource_Return_Bool_ThrowExceptionAsync() { try { SourceDomainService sourceDomainService = new Service.SourceDomainService(_sourceRepositoryMock.Object); List <SourceEntity> expectedSource = new List <SourceEntity>(); SourceDto sourceDto = new SourceDto { SourceID = 4, SourceName = "Press Trust of India", SourceURL = "https://www.presstrustofindia.com", RegistrationDate = DateTime.Now, SourceType = SourceType.External, IsActive = true }; SourceEntity source = new SourceEntity(sourceDto); expectedSource.Add(source); _sourceRepositoryMock.Setup(c => c.GetSourceAsync(source)).ReturnsAsync(expectedSource); //Act bool actualSourceList = await sourceDomainService.RegistrationAsync(sourceDto); //Assert. Assert.Equals(true, actualSourceList); } catch (Exception) { Assert.Fail(); throw; } }
public void When_Get_Generated_Source_Return_List_OF_Source() { try { SourceDomainService sourceDomainService = new Service.SourceDomainService(_sourceRepositoryMock.Object); List <SourceEntity> expectedSource = new List <SourceEntity>(); SourceDto sourceDto = new SourceDto(); SourceEntity source = new SourceEntity(sourceDto); expectedSource.Add(source); _sourceRepositoryMock.Setup(c => c.GetSourceAsync(source)).ReturnsAsync(expectedSource); //Act Task <List <SourceEntity> > actualSourceList = sourceDomainService.GetSoruceAsync(sourceDto); if (actualSourceList != null) { //Assert. Assert.AreEqual(expectedSource.Count, actualSourceList.Result.Count); } } catch (Exception) { Assert.Fail(); throw; } }
public void load_associated_when_target_is_null() { TargetEntity target = new TargetEntity { Id = 1, Name = "target", Associated = null }; SourceEntity source = new SourceEntity { Id = 1, Name = "source", Associated = new SourceAssociated { Id = 2, Name = "source_associated" } }; MapperContext context = new MapperContext(); var mapped = mapper.Map(source, target, context); Assert.NotNull(mapped.Associated); Assert.Null(mapped.Associated.Name); // properties are not mapped Assert.Equal(2, mapped.Associated.Id); // key is mapped // there is no tracking for disposed entity. Assert.False(context.TryGetEntry <TargetAssociated>(new EntityKey <int>(1), out MapperContextEntry entry)); // new entity is loaded. Assert.True(context.TryGetEntry <TargetAssociated>(new EntityKey <int>(2), out MapperContextEntry entry2)); Assert.Equal(MapperActionType.Attach, entry2.ActionType); }
protected async Task <SourceEntity> GetSourceEntity(CancellationToken cancellationToken) { Domain = Domain.Trim().Trim('/').ToLowerInvariant(); var sourceEntity = await _sourceRepo .Get(x => x.Url == Domain) .FirstOrDefaultAsync(cancellationToken) .ConfigureAwait(true); if (sourceEntity == null) { sourceEntity = new SourceEntity { Name = Name, Url = Domain, TimeSpent = TimeSpan.Zero, LastCrawledPostUrl = null }; _sourceRepo.Add(sourceEntity); await GoblinUnitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(true); } StopAtPostUrl = sourceEntity.LastCrawledPostUrl ?.Replace("http://", string.Empty) .Replace("https://", string.Empty).Trim('/'); return(sourceEntity); }
[U] public void FieldResolverRespectsDataMemberAttributes() { var client = TestClient.DefaultInMemoryClient; var document = new SourceEntity { Name = "name", DisplayName = "display name" }; var indexResponse = client.IndexDocument(document); var requestJson = Encoding.UTF8.GetString(indexResponse.ApiCall.RequestBodyInBytes); requestJson.Should().Contain("display_name"); var searchResponse = client.Search <SourceEntity>(s => s .Query(q => q .Terms(t => t .Field(f => f.DisplayName) .Terms("term") ) ) ); requestJson = Encoding.UTF8.GetString(searchResponse.ApiCall.RequestBodyInBytes); requestJson.Should().Contain("display_name"); }
/// <summary> /// 更新一条记录(异步方式) /// </summary> /// <param name="entity">实体模型</param> /// <returns></returns> public virtual async Task <bool> UpdateAsync(SourceEntity entity) { Dictionary <string, object> dict = new Dictionary <string, object>(); GetParameters(entity, dict); string strSQL = "Update Source SET " + "Type = @Type," + "Name = @Name," + "IsPassed = @IsPassed," + "IsTop = @IsTop," + "IsElite = @IsElite," + "Hits = @Hits," + "LastUseTime = @LastUseTime," + "Photo = @Photo," + "Intro = @Intro," + "Address = @Address," + "Tel = @Tel," + "Fax = @Fax," + "Mail = @Mail," + "Email = @Email," + "ZipCode = @ZipCode," + "HomePage = @HomePage," + "Im = @Im," + "Contacter = @Contacter" + " WHERE " + "ID = @ID"; return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict))); }
public override string Print(bool link = true, DwarfObject pov = null) { string eventString = GetYearTime(); eventString += DestEntity.ToLink(link, pov, this); eventString += " made a copy of "; if (FromOriginal) { eventString += "the original "; } eventString += Artifact.ToLink(link, pov, this); eventString += " from "; eventString += SourceStructure.ToLink(link, pov, this); eventString += " in "; eventString += SourceSite.ToLink(link, pov, this); eventString += " of "; eventString += SourceEntity.ToLink(link, pov, this); eventString += " keeping it within "; eventString += DestStructure.ToLink(link, pov, this); eventString += " in "; eventString += DestSite.ToLink(link, pov, this); eventString += PrintParentCollection(link, pov); eventString += "."; return(eventString); }
public async Task <ActionResult <ConnectParameters> > Get(string name) { ConnectParameters connector = new ConnectParameters(); try { CloudTable table = Common.GetTableConnect(connectionString, container); TableOperation retrieveOperation = TableOperation.Retrieve <SourceEntity>("PPDM", name); TableResult result = await table.ExecuteAsync(retrieveOperation); SourceEntity entity = result.Result as SourceEntity; if (entity == null) { return(NotFound()); } connector.SourceName = name; connector.Database = entity.DatabaseName; connector.DatabaseServer = entity.DatabaseServer; connector.DatabaseUser = entity.User; connector.DatabasePassword = entity.Password; connector.ConnectionString = entity.ConnectionString; } catch (Exception) { return(NotFound()); } return(connector); }
/// <summary> /// 通过数据读取器生成实体类 /// </summary> /// <param name="rdr"></param> /// <returns></returns> private static SourceEntity GetEntityFromrdr(NullableDataReader rdr) { SourceEntity info = new SourceEntity(); info.ID = rdr.GetInt32("ID"); info.Type = rdr.GetString("Type"); info.Name = rdr.GetString("Name"); info.IsPassed = rdr.GetBoolean("IsPassed"); info.IsTop = rdr.GetBoolean("IsTop"); info.IsElite = rdr.GetBoolean("IsElite"); info.Hits = rdr.GetInt32("Hits"); info.LastUseTime = rdr.GetNullableDateTime("LastUseTime"); info.Photo = rdr.GetString("Photo"); info.Intro = rdr.GetString("Intro"); info.Address = rdr.GetString("Address"); info.Tel = rdr.GetString("Tel"); info.Fax = rdr.GetString("Fax"); info.Mail = rdr.GetString("Mail"); info.Email = rdr.GetString("Email"); info.ZipCode = rdr.GetInt32("ZipCode"); info.HomePage = rdr.GetString("HomePage"); info.Im = rdr.GetString("Im"); info.Contacter = rdr.GetString("Contacter"); return(info); }
public async Task <ActionResult <string> > UpdateSource(ConnectParameters connectParameters) { if (connectParameters == null) { return(BadRequest()); } try { CloudTable table = Common.GetTableConnect(connectionString, container); string name = connectParameters.SourceName; if (String.IsNullOrEmpty(name)) { return(BadRequest()); } SourceEntity sourceEntity = new SourceEntity(name) { DatabaseName = connectParameters.Database, DatabaseServer = connectParameters.DatabaseServer, User = connectParameters.DatabaseUser, Password = connectParameters.DatabasePassword, ConnectionString = connectParameters.ConnectionString }; TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(sourceEntity); TableResult result = await table.ExecuteAsync(insertOrMergeOperation); } catch (Exception) { return(BadRequest()); } return(Ok($"OK")); }
public void Example() { // Create the object mapper var mapper = new ResourceMapper <SimpleDictionaryContext>(); mapper.RegisterOneWayMapping <SourceEntity, DestEntity>(mapping => { mapping.SetChildContext((from, to, context) => context.Set("ParentVariable", from.Id)); }); mapper.RegisterOneWayMapping <ChildEntity, ChildEntity>(mapping => { mapping.Set(to => to.ParentId, (from, to, context) => context.Get <int>("ParentVariable")); }); mapper.InitializeMap(); // Create source object var sourceObj = new SourceEntity { Id = 10, Child = new ChildEntity { Variable = 103 } }; var destObj = new DestEntity(); var mapContext = new SimpleDictionaryContext(); // Perform map mapper.Map(sourceObj, destObj, mapContext); Assert.Throws <KeyNotFoundException>(() => mapContext.Get <int>("ParentVariable")); Assert.AreEqual(sourceObj.Child.Variable, destObj.Child.Variable); Assert.AreEqual(sourceObj.Id, destObj.Child.ParentId); }
public override string SummarizeToString() { string Ret = "ComputedEntity(" + Name + ") [ " + SourceEntity.SummarizeToString() + " x { "; TargetEntities.ForEach(te => Ret += te.SummarizeToString() + " "); Ret += "}"; return(Ret); }
public static DestinationEntity CheckTrigger( this IContextOptionsFactory <DynamicDbContext> contextOptionsFactory, Expression <Func <SourceEntity, DestinationEntity> > triggerExpression, Action <DynamicDbContext> setupDbContext, Action <ModelBuilder> setupModelBuilder, SourceEntity source) { return(Assert.Single(contextOptionsFactory.CheckTrigger(triggerExpression, setupDbContext, setupModelBuilder, new[] { source }))); }
protected void GivenAValidSourceObject() { Source = new SourceEntity() { Name = "TestName", LastName = "TestLastname", Age = 35 }; }
public ActionResult Edit(string id) { var result = _provider.Find(id); SourceEntity se = new SourceEntity(); se.Source_id = result.ElementAt(0).Source_id; se.Title = result.ElementAt(0).Title; se.Type = result.ElementAt(0).Type; return(View(se)); }
public async Task <bool> RegistrationAsync(SourceDto sourceDto) { //if (sourceDto.SourceType == SourceType.External) // SourceEntity _sourceRepository = new SourceEntity(sourceDto); //else // SourceEntity registerSourceEntity = new SourceEntity(sourceDto); SourceEntity sourceEntity = new SourceEntity(sourceDto); return(await _sourceRepository.RegistrationAsync(sourceEntity)); }
public void map_owned_collection() { TargetEntity target = new TargetEntity { Id = 1, Name = "target_root", OwnedList = new List <TargetOwnedItem> { new TargetOwnedItem { Id = 1, Name = "Item 1" }, new TargetOwnedItem { Id = 2, Name = "Item 2" }, new TargetOwnedItem { Id = 3, Name = "Item 3" }, } }; SourceEntity source = new SourceEntity { Id = 1, Name = "target_root", OwnedList = new List <SourceOwnedItem> { new SourceOwnedItem { Id = 2, Name = "Item 2" }, new SourceOwnedItem { Id = 4, Name = "Item 4" }, } }; MapperContext context = new MapperContext(); TargetEntity mapped = mapper.Map(source, target, context); Assert.NotNull(mapped.OwnedList); Assert.Equal(2, mapped.OwnedList.Count); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(1), out MapperContextEntry entry1)); Assert.Equal(MapperActionType.Delete, entry1.ActionType); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(2), out MapperContextEntry entry2)); Assert.Equal(MapperActionType.Update, entry2.ActionType); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(3), out MapperContextEntry entry3)); Assert.Equal(MapperActionType.Delete, entry3.ActionType); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(4), out MapperContextEntry entry4)); Assert.Equal(MapperActionType.Create, entry4.ActionType); }
/// <summary> /// Обрабатывает конец директивы #region. Обновляет Location описания точки на вершине стека и переносит его в список для возврата /// </summary> private void ProcessRegionEnd() { SourceEntity pt = Regions.Pop(); if (pt == null) { return; } pt.Location.Merge(new LexLocation(tokLin, tokCol, tokELin, tokECol)); Pragmas.Add(pt); }
public void MeasureFeatureAvailability() { var entity = new SourceEntity(); entity.SourceItems.Add(SourceEntity.Factory.CreateItem(entity, DateTime.Now, 800, 1000, DateTime.Now, "test", SourceGroupEnum.Availability)); var proportion = entity.Measure(); Assert.Equal(0.8m, proportion.Availability); }
private TargetEntity ProcessEntity(SourceEntity sourceEntity) { return(new TargetEntity { Folder = sourceEntity.Folder, Id = sourceEntity.Id, Name = sourceEntity.Name, PasswordHash = HashHelper.Sha256(sourceEntity.Password), Created = sourceEntity.Created }); }
public void MeasureProportionAvailability() { var sourceEntity = new SourceEntity() { }; sourceEntity.AddSourceItem(800, 1000, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability); var a = sourceEntity.Measure(); Assert.Equal(0.8m, a.Availability); }
/// <summary> /// Обрабатывает начало директивы #region. Если данная директива содержит описание аспекта - сохраняет эту информацию в стеке /// </summary> /// <param name="region">текстовая часть директивы #region</param> private void ProcessRegion(string region) { List <string> RegionName = GetPragmaName(region); if (RegionName == null) { Regions.Push(null); return; } SourceEntity pt = new SourceEntity(RegionName, new LexLocation(tokLin, tokCol, tokELin, tokECol)); Regions.Push(pt); }
/// <summary> /// 获取实体 /// </summary> /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param> /// <param name="dict">参数的名/值集合</param> /// <returns></returns> public virtual SourceEntity GetEntity(string strWhere, Dictionary <string, object> dict = null) { SourceEntity obj = null; string strSQL = "select top 1 * from Source where 1=1 " + strWhere; using (NullableDataReader reader = _DB.GetDataReader(strSQL, dict)) { if (reader.Read()) { obj = GetEntityFromrdr(reader); } } return(obj); }
public async Task <bool> RegistrationAsync(SourceEntity sourceEntity) { if (sourceEntity == null) { throw new ArgumentNullException("Registration"); } // TO DO : Code to save record into database sourceEntity.SourceID = _nextId++; _context.Add(sourceEntity); _context.SaveChanges(); return(await Task.FromResult(true)); }
/// <summary> /// 获取实体(异步方式) /// </summary> /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param> /// <param name="dict">参数的名/值集合</param> /// <returns></returns> public virtual async Task <SourceEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null) { SourceEntity obj = null; string strSQL = "select top 1 * from Source where 1=1 " + strWhere; using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict))) { if (reader.Read()) { obj = GetEntityFromrdr(reader); } } return(obj); }
/// <summary> /// Преобразование дерева из парсера в рабочее дерево /// </summary> /// <param name="s">Корень аспектного дерева</param> /// <param name="FileName">относительный путь к файлу, содержащему данный подаспект</param> private PointOfInterest ConvertSourceEntityToPointOfInterest(SourceEntity s, string FileName) { if (s == null) return null; PointOfInterest res = new PointOfInterest(s.Location); res.Context.Add(new OuterContextNode(s.Value, s.GetType().Name)); if (s.Value != null && s.Value.Count != 0) res.Title = string.Join(" ", s.Value); res.FileName = FileName; res.ID = s.Name; foreach (SourceEntity se in s.Items) res.Items.Add(ConvertSourceEntityToPointOfInterest(se, FileName)); return res; }