protected void VisitEntityIdentity(EntityIdentity entityIdentity, TArgType arg) { DiscriminatedEntityIdentity entityIdentity1 = entityIdentity as DiscriminatedEntityIdentity; if (entityIdentity1 != null) { this.VisitEntityIdentity(entityIdentity1, arg); } else { this.VisitEntityIdentity((SimpleEntityIdentity)entityIdentity, arg); } }
internal override ColumnMap Visit( EntityColumnMap columnMap, ColumnMapTranslatorTranslationDelegate translationDelegate) { EntityIdentity entityIdentity = this.VisitEntityIdentity(columnMap.EntityIdentity, translationDelegate); this.VisitList <ColumnMap>(columnMap.Properties, translationDelegate); if (entityIdentity != columnMap.EntityIdentity) { columnMap = new EntityColumnMap(columnMap.Type, columnMap.Name, columnMap.Properties, entityIdentity); } return(translationDelegate((ColumnMap)columnMap)); }
protected void VisitEntityIdentity(EntityIdentity entityIdentity, TArgType arg) { var dei = entityIdentity as DiscriminatedEntityIdentity; if (null != dei) { VisitEntityIdentity(dei, arg); } else { VisitEntityIdentity((SimpleEntityIdentity)entityIdentity, arg); } }
private static GetItemRequest CreateGetLoanOfferRequest(EntityIdentity offerId) => new GetItemRequest { TableName = LoanOfferTableName, Key = GetDictionaryWithIdAttribute(offerId), AttributesToGet = new List <string> { IdDynamoFieldName, PeselNumberDynamoFieldName, EmailAddressDynamoFieldName, MaxLoanAmountDynamoFieldName } };
public void WhenAnEditorValueIsCreated_TheEditorIsTheProviderState() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyEditorPropertiesAvailableStatus(includeName: true); var context = IQueryExecutionContextFactory.Create(); var id = new EntityIdentity(key: "EditorKey", value: "bbb"); var editor = new ValueEditor { EditorType = "My.Editor.Type" }; var result = (UIPropertyEditorValue)UIPropertyEditorDataProducer.CreateEditorValue(context, id, editor, properties); Assert.Equal(expected: editor, actual: ((IEntityValueFromProvider)result).ProviderState); }
public void WhenPropertiesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyEditorPropertiesAvailableStatus(includeName: true); var context = IQueryExecutionContextFactory.Create(); var id = new EntityIdentity(key: "EditorKey", value: "bbb"); var editor = new ValueEditor { EditorType = "My.Editor.Type" }; var result = (UIPropertyEditorValue)UIPropertyEditorDataProducer.CreateEditorValue(context, id, editor, properties); Assert.Equal(expected: "My.Editor.Type", actual: result.Name); }
public async Task <IEnumerable <IEntityValue> > RetrieveAllLaunchProfileEntitiesAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, ILaunchProfilePropertiesAvailableStatus requestedProperties) { if (await _project.GetProjectLevelPropertyPagesCatalogAsync() is IPropertyPagesCatalog projectCatalog) { ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot(); return(createLaunchProfileValues(launchSettings)); } return(Enumerable.Empty <IEntityValue>()); IEnumerable <IEntityValue> createLaunchProfileValues(ILaunchSettings launchSettings) { Dictionary <string, Rule> debugRules = new(); foreach (Rule rule in DebugUtilities.GetDebugChildRules(projectCatalog)) { if (rule.Metadata.TryGetValue(s_commandNameMetadataName, out object?commandNameObj) && commandNameObj is string commandName) { debugRules[commandName] = rule; } } if (launchSettings is IVersionedLaunchSettings versionedLaunchSettings) { queryExecutionContext.ReportInputDataVersion(_launchSettingsTracker.VersionKey, versionedLaunchSettings.Version); } IProjectState projectState = new LaunchProfileProjectState(_project, _launchSettingsProvider, _launchSettingsTracker); foreach ((int index, ProjectSystem.Debug.ILaunchProfile profile) in launchSettings.Profiles.WithIndices()) { if (!Strings.IsNullOrEmpty(profile.Name) && !Strings.IsNullOrEmpty(profile.CommandName) && debugRules.TryGetValue(profile.CommandName, out Rule rule)) { QueryProjectPropertiesContext propertiesContext = new( isProjectFile : true, file : _project.FullPath, itemType : LaunchProfileProjectItemProvider.ItemType, itemName : profile.Name); EntityIdentity id = CreateLaunchProfileId(parent, profile.Name); IEntityValue launchProfileValue = CreateLaunchProfileValue(queryExecutionContext, id, propertiesContext, rule, index, projectState, requestedProperties); yield return(launchProfileValue); } } } }
public void WhenCategoryValueCreated_TheCategoryIsTheProviderState() { var properties = PropertiesAvailableStatusFactory.CreateCategoryPropertiesAvailableStatus(includeAllProperties: true); var entityRuntime = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "A", value: "B"); var category = new Category { DisplayName = "CategoryDisplayName", Name = "CategoryName" }; var order = 42; var result = (CategoryValue)CategoryDataProducer.CreateCategoryValue(entityRuntime, id, category, order, properties); Assert.Equal(expected: category, actual: ((IEntityValueFromProvider)result).ProviderState); }
public async Task <AddRefResponse> AddRefAsync(EntityIdentity refListIdentity, int refIndex, Ref refe) { var query = from l in _refsContext.RefLists.Include("Refs") where l.Id == refListIdentity.Id select l; var storedRefList = await query.SingleAsync(); BusinessContract.ValidateWritePermission(storedRefList.AuthorId); BusinessContract.ValidateRowVersion(storedRefList.RowVersion, refListIdentity.RowVersion); refe.RefListId = 0; refe.RefList = null; var refs = storedRefList.Refs.OrderBy(r => r.DisplayOrder).ToList(); refs.Insert(refIndex, refe); for (int i = 0; i < refs.Count; ++i) { refs[i].DisplayOrder = i; } storedRefList.Refs.Add(refe); /// update statistics if (refe.Kind == RefKind.Link) { var statisticsQuery = _refsContext.RefListStatistics.Where(s => s.RefListId == refListIdentity.Id); var storedStatistics = await statisticsQuery.SingleAsync(); storedStatistics.LinkCount = storedRefList.Refs.Count(r => r.Kind == RefKind.Link); } _refsContext.MarkAsModified(storedRefList); await _refsContext.SaveChangesAsync(); SendRefListUpdated(refListIdentity.Id); var ret = new AddRefResponse() { RefListIdentity = new EntityIdentity(storedRefList.Id, storedRefList.RowVersion), RefId = refe.Id, }; return(ret); }
public void WhenPropertiesAreRequested_PropertyValuesAreReturned() { var properties = PropertiesAvailableStatusFactory.CreateCategoryPropertiesAvailableStatus(includeAllProperties: true); var entityRuntime = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "A", value: "B"); var category = new Category { DisplayName = "CategoryDisplayName", Name = "CategoryName" }; var order = 42; var result = (CategoryValue)CategoryDataProducer.CreateCategoryValue(entityRuntime, id, category, order, properties); Assert.Equal(expected: "CategoryDisplayName", actual: result.DisplayName); Assert.Equal(expected: "CategoryName", actual: result.Name); Assert.Equal(expected: 42, actual: result.Order); }
public Service(IHttpContextAccessor httpContextAccessor, IMongoRepository <TIdentifiable> repository) : base(repository) { _httpContext = httpContextAccessor.HttpContext; // Get user logged in. var user = GetBeAuthIdentity(); // Create Entity Identity. _identity = new EntityIdentity { CreatedBy = user.FindFirst(SubscriptionClaimTypes.User).Value, OwnedBy = user.FindFirst(SubscriptionClaimTypes.Owner).Value }; // Check Owner _isOwner = _identity.CreatedBy == _identity.OwnedBy; }
public async Task RemoveTagUsesAsync(EntityIdentity identity) { SystemContract.RequireEntityIdentity(identity); var query = _refsContext.TagUses.Include("RefLists"). Where(t => t.Id == identity.Id); var storedTagUse = await query.SingleAsync(); BusinessContract.ValidateRowVersion(storedTagUse.RowVersion, identity.RowVersion); BusinessContract.ValidateWritePermission(storedTagUse.OwnerId); storedTagUse.RefLists.Clear(); _refsContext.TagUses.Remove(storedTagUse); await _refsContext.SaveChangesAsync(); }
public async Task <EntityIdentity> UpdateRefAsync(EntityIdentity identity, Ref updatedRef) { var query = from r in _refsContext.Refs.Include("RefList") where r.Id == updatedRef.Id select r; var storedRef = await query.SingleAsync(); if (storedRef.RefListId != identity.Id) { throw new ArgumentException("リストのIdが正しくありません"); } BusinessContract.ValidateWritePermission(storedRef.RefList.AuthorId); BusinessContract.ValidateRowVersion(storedRef.RefList.RowVersion, identity.RowVersion); switch (updatedRef.Kind) { case RefKind.Link: storedRef.Uri = updatedRef.Uri; storedRef.Title = updatedRef.Title; storedRef.Comment = updatedRef.Comment; break; case RefKind.Heading: storedRef.Title = updatedRef.Title; break; case RefKind.Text: storedRef.Comment = updatedRef.Comment; break; } if (_refsContext.IsModified(storedRef)) { _refsContext.MarkAsModified(storedRef.RefList); } await _refsContext.SaveChangesAsync(); SendRefListUpdated(identity.Id); identity.RowVersion = storedRef.RefList.RowVersion; return(identity); }
public async Task <ILoanOffer> GetAsync(EntityIdentity offerId) { var request = CreateGetLoanOfferRequest(offerId); var response = await _dynamoDbClient.GetItemAsync(request); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new FailedToGetLoanOfferFromDynamoDbException(response.HttpStatusCode); } var item = response.Item; return(_loanOfferFactory.Create( item[IdDynamoFieldName].S, item[PeselNumberDynamoFieldName].S, item[EmailAddressDynamoFieldName].S, Int32.Parse(item[MaxLoanAmountDynamoFieldName].N) )); }
private RefColumnMap CreateRefColumnMap(TypeInfo typeInfo, string name) { SimpleColumnMap entitySetIdColumnMap = (SimpleColumnMap)null; if (typeInfo.HasEntitySetIdProperty) { entitySetIdColumnMap = this.CreateSimpleColumnMap(Helper.GetModelTypeUsage((EdmMember)typeInfo.EntitySetIdProperty), "__EntitySetId"); } EntityType elementType = (EntityType)TypeHelpers.GetEdmType <RefType>(typeInfo.Type).ElementType; SimpleColumnMap[] keyColumnMaps = new SimpleColumnMap[elementType.KeyMembers.Count]; for (int index = 0; index < keyColumnMaps.Length; ++index) { EdmMember keyMember = elementType.KeyMembers[index]; keyColumnMaps[index] = this.CreateSimpleColumnMap(Helper.GetModelTypeUsage(keyMember), keyMember.Name); } EntityIdentity entityIdentity = this.CreateEntityIdentity(elementType, entitySetIdColumnMap, keyColumnMaps); return(new RefColumnMap(typeInfo.Type, name, entityIdentity)); }
//public async Task<RefList> CreateUnfiledRefListAsync(long userId) //{ // var user = await _userHandler.GetUserAsync(userId); // _refsContext.Users.Attach(user); // var refList = new RefList() // { // Kind = RefListKind.Unfiled, // Author = user, // Title = "unfiled", // Comment = "", // PublishingStatus = PublishingStatusKind.Private, // Refs = new Ref[0], // Statistics = null, // }; // _refsContext.RefLists.Add(refList); // await _refsContext.SaveChangesAsync(); // return refList; //} public async Task RemoveRefListAsync(EntityIdentity refListIdentity) { var query = _refsContext.RefLists.Include("TagUses").Where(l => l.Id == refListIdentity.Id); var storedRefList = await query.SingleAsync(); BusinessContract.ValidateWritePermission(storedRefList.AuthorId); BusinessContract.ValidateRowVersion(storedRefList.RowVersion, refListIdentity.RowVersion); storedRefList.TagUses.Clear(); foreach (var fav in storedRefList.FavoringFavorites.ToArray()) { _refsContext.Favorites.Remove(fav); } _refsContext.RefListStatistics.Remove(storedRefList.Statistics); _refsContext.RefLists.Remove(storedRefList); await _refsContext.SaveChangesAsync(); SendRefListUpdated(refListIdentity.Id); }
public async Task <EntityIdentity> RemoveRefAsync(EntityIdentity refListIdentity, int refIndex) { var query = from l in _refsContext.RefLists.Include("Refs") where l.Id == refListIdentity.Id select l; var storedRefList = await query.SingleOrDefaultAsync(); BusinessContract.ValidateWritePermission(storedRefList.AuthorId); BusinessContract.ValidateRowVersion(storedRefList.RowVersion, refListIdentity.RowVersion); var refs = storedRefList.Refs.OrderBy(r => r.DisplayOrder).ToList(); var removing = refs[refIndex]; refs.RemoveAt(refIndex); for (int i = 0; i < refs.Count; ++i) { refs[i].DisplayOrder = i; } _refsContext.Refs.Remove(removing); /// update statistics if (removing.Kind == RefKind.Link) { var statisticsQuery = _refsContext.RefListStatistics.Where(s => s.RefListId == refListIdentity.Id); var storedStatistics = await statisticsQuery.SingleAsync(); storedStatistics.LinkCount = storedRefList.Refs.Count(r => r.Kind == RefKind.Link); } _refsContext.MarkAsModified(storedRefList); await _refsContext.SaveChangesAsync(); SendRefListUpdated(refListIdentity.Id); refListIdentity.RowVersion = storedRefList.RowVersion; return(refListIdentity); }
public void StartNewGame(IGame game, EntityIdentity characterId, ICharacter character) { var personalAccountName = "Wallet"; var currencyType = new LookupItem <long> { Key = 1, Value = "GBP" }; var assetType = new LookupItem { Key = 1, Value = "Computer" }; "Given I have opened a game".x(async() => game = await this.OpenGame()); "And I have a created character".x(() => characterId = new EntityIdentity(new StateIdentity(1, Guid.NewGuid().ToString()))); "When I join the game" .x(async() => await this.JoinGameAsPlayer(game, characterId)); "Then I am notified my character has joined a game" .x(() => this.AmNotifiedOfEvent <PlayerHasJoinedGameEvent>()); "And a new Personal Account has opened called {personalAccountName} with a total funds of 0 creits" .x(() => this.AmNotifiedOfEvent <NewPersonalAccountOpenedEvent>((l) => this.AssertNewPersonalAccountOpened(l, personalAccountName, 0, currencyType))); "And I am notified of funds into my account of 100 credits" .x(() => this.AmNotifiedOfEvent <FundsAddedToAccount>((l) => this.AssertFundsAddedToAccount(l, personalAccountName, 100, currencyType))); "And I am notified of Assets received of the type {assetType}" .x(() => this.AmNotifiedOfEvent <AssetsReceived>((l) => this.AssertAssetReceived(l, assetType))); "And I am notified my current Net Worth has increased to 200C" .x(() => this.AmNotifiedOfEvent <NetWorthIncreased>((l) => this.AssertCharactersNetWorth(l, characterId, 200, currencyType))); "And I can view my character" .x(async() => await this.ICanViewMyCharacter(characterId)); "And I can view my characters Assets" .x(async() => await this.ICanViewMyAssets(character, game.GameType)); "And I can view my characters accounts" .x(async() => await this.ICanViewMyAccount(character)); }
public void WhenTheEntityIsCreated_TheProviderStateIsTheExpectedType() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyPropertiesAvailableStatus(); var runtimeModel = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "PropertyName", value: "A"); var cache = IPropertyPageQueryCacheFactory.Create(); var property = new TestProperty { Name = "A" }; var rule = new Rule(); rule.BeginInit(); rule.Properties.Add(property); rule.EndInit(); var result = (UIPropertyValue)UIPropertyDataProducer.CreateUIPropertyValue(runtimeModel, id, cache, property, order: 42, properties); Assert.IsType <PropertyProviderState>(((IEntityValueFromProvider)result).ProviderState); }
public void WhenTheEntityIsCreated_TheProviderStateIsTheExpectedType() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyPropertiesAvailableStatus(); var context = IQueryExecutionContextFactory.Create(); var id = new EntityIdentity(key: "PropertyName", value: "A"); var cache = IProjectStateFactory.Create(); var property = new TestProperty { Name = "A" }; var rule = new Rule(); rule.BeginInit(); rule.Properties.Add(property); rule.EndInit(); var result = (UIPropertyValue)UIPropertyDataProducer.CreateUIPropertyValue(context, id, cache, QueryProjectPropertiesContext.ProjectFile, property, order: 42, requestedProperties: properties); Assert.IsType <PropertyProviderState>(((IEntityValueFromProvider)result).ProviderState); }
public async Task WhenThePropertyIsAnIIntProperty_ThenTheEvaluatedValueIsAnInt() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyValuePropertiesAvailableStatus(includeEvaluatedValue: true); var mockIntProperty = new Mock <IIntProperty>(); mockIntProperty.Setup(m => m.GetValueAsIntAsync()).ReturnsAsync(42); var property = mockIntProperty.Object; var entityRuntime = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "A", value: "B"); var configuration = ProjectConfigurationFactory.Create(configuration: "Alpha|Beta|Gamma"); var result = (UIPropertyValueValue)await UIPropertyValueDataProducer.CreateUIPropertyValueValueAsync( entityRuntime, id, configuration, property, properties); Assert.Equal(expected: 42, actual: result.EvaluatedValue); }
private void Append(string prefix, EntityIdentity entityIdentity) { this.Append(prefix); this.Append("["); this.Append(",K", (IEnumerable <ColumnMap>)entityIdentity.Keys); SimpleEntityIdentity simpleEntityIdentity = entityIdentity as SimpleEntityIdentity; if (simpleEntityIdentity != null) { this.Append(",", simpleEntityIdentity.EntitySet); } else { DiscriminatedEntityIdentity discriminatedEntityIdentity = (DiscriminatedEntityIdentity)entityIdentity; this.Append("CM", (ColumnMap)discriminatedEntityIdentity.EntitySetColumnMap); foreach (EntitySet entitySet in discriminatedEntityIdentity.EntitySetMap) { this.Append(",E", entitySet); } } this.Append("]"); }
protected EntityIdentity GetIdByConvention <T>(T entity) where T : class { var entityType = typeof(TEntity); var name = entityType.Name; var possibles = new[] { "id", "key", $"{name}id", $"{name}key", $"{name}_id", $"{name}_key" }; var properties = entityType.GetProperties(); var property = properties.FirstOrDefault(p => possibles.Contains(p.Name.ToLowerInvariant())); var identiy = new EntityIdentity { Name = "Id" }; if (property != null) { identiy.Name = property.Name; identiy.Value = property.GetValue(entity); } return(identiy); }
public async Task WhenPropertyIsAnIEvaluatedProperty_GetUnevaluatedValueAsyncIsCalled() { var properties = PropertiesAvailableStatusFactory.CreateUIPropertyValuePropertiesAvailableStatus(includeUnevaluatedValue: true); var mockEvaluatedProperty = new Mock <IEvaluatedProperty>(); mockEvaluatedProperty.Setup(m => m.GetUnevaluatedValueAsync()).ReturnsAsync("unevaluated value"); var property = mockEvaluatedProperty.Object; var entityRuntime = IEntityRuntimeModelFactory.Create(); var id = new EntityIdentity(key: "A", value: "B"); var configuration = ProjectConfigurationFactory.Create(configuration: "Alpha|Beta|Gamma"); var result = (UIPropertyValueValue)await UIPropertyValueDataProducer.CreateUIPropertyValueValueAsync( entityRuntime, id, configuration, property, properties); Assert.Equal(expected: "unevaluated value", actual: result.UnevaluatedValue); mockEvaluatedProperty.Verify(m => m.GetUnevaluatedValueAsync()); }
protected override Task <IEntityValue?> TryCreateEntityOrNullAsync(IQueryExecutionContext queryExecutionContext, EntityIdentity id) { if (id.KeysCount == 4 && id.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string projectPath) && id.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName) && id.TryGetValue(ProjectModelIdentityKeys.UIPropertyName, out string propertyName) && id.TryGetValue(ProjectModelIdentityKeys.EditorName, out string editorName)) { return(UIPropertyEditorDataProducer.CreateEditorValueAsync( queryExecutionContext, id, _projectService, projectPath, propertyPageName, propertyName, editorName, _properties)); } return(NullEntityValue); }
public async Task <Character> Get(EntityIdentity identity) { return(await this.innerRepository.Get(identity)); }
public async Task <GameType> Get(EntityIdentity identity) { return(await this.inMemoryEntityRepository.Get(identity)); }
public NewMembershipEvent(EntityIdentity membership) { this.Membership = membership; }
public LoanOffer(EntityIdentity id, PeselNumber peselNumber, EmailAddress emailAddress, LoanAmount maxLoanAmount) : this(id, peselNumber, emailAddress) { MaxLoanAmount = maxLoanAmount; }
public LoanOffer(EntityIdentity id, PeselNumber peselNumber, EmailAddress emailAddress) { Id = id; PeselNumber = peselNumber; EmailAddress = emailAddress; }