private TransportModelEntityMember GetBoundMember(TransportModelFunctionParameterBinding binding, TransportModelEntity entity) { if (binding is TransportModelFunctionParameterBindingToProperty propertyBinding) { var property = entity.GetMemberByNameAndResolveGenericArguments(propertyBinding.Name); if (property is null) { throw new InvalidOperationException($"Unable to bind creation method paramter referring to {propertyBinding.Name} for {entity.Name}"); } return(property); } if (binding is TransportModelFunctionParameterBindingToOneOfProperties oneOfProperties) { foreach (var name in oneOfProperties.Names) { var property = entity.GetMemberByNameAndResolveGenericArguments(name); if (property != null) { return(property); } } var props = string.Join(",", oneOfProperties.Names); throw new InvalidOperationException($"Unable to bind creation method paramter referring to one of {props} for {entity.Name}"); } throw new InvalidOperationException($"Unsuppoerted creation function parameter binding type {binding.GetType()}"); }
public static Dictionary <string, TransportModelEntityMember> GetMembers(TransportModelEntity entityModel, List <TransportModelTypeReference> genericArgumentsInScope = null, bool allMembers = false) { Dictionary <string, TransportModelEntityMember> result = new Dictionary <string, TransportModelEntityMember>(); if (entityModel.BaseEntity != null) { result = GetMembers(entityModel.BaseEntity.TransportModelItem, entityModel.BaseEntity.GenericArguments, allMembers); } var members = entityModel.Members.Keys.Select(m => genericArgumentsInScope == null ? entityModel.GetMemberByName(m) : entityModel.GetMemberByNameAndResolveGenericArguments(m, genericArgumentsInScope)); foreach (var member in members) { var finalMember = member; if (entityModel.MemberTypeLimiters.ContainsKey(member.Name)) { finalMember = entityModel.MemberTypeLimiters[member.Name]; } if (result.ContainsKey(member.Name)) { result[member.Name] = finalMember; } else { result.Add(member.Name, finalMember); } } if (!allMembers && entityModel.TsDiscriminant is TransportModelEntityTsDiscriminantBrand brandDiscriminant && result.ContainsKey(brandDiscriminant.BrandPropertyName)) { result.Remove(brandDiscriminant.BrandPropertyName); } return(result); }