public RegisterEventHandler( IEntityContext context, IEmailService emailService) { this.context = context; this.emailService = emailService; }
public int Update(CPropertyCategoryPO po, string operatorName) { using (IEntityContext entityContext = CPropertyCategoryPOManager.Instance.CreateEntityContext()) { return(this.UpdateWithContext(entityContext, po, operatorName)); } }
/// <summary> /// Converts a list <paramref name="value"/> to an <see cref="IRdfListAdapter{T}"/> if necessary and return the RDF:List's head /// </summary> /// <returns>an <see cref="IEntity"/></returns> /// <exception cref="ArgumentException">when value is not a collection</exception> public override IEnumerable<Node> ToNodes(object value, IEntityProxy proxy, IPropertyMapping property, IEntityContext context) { if (!(value is IEnumerable)) { throw new ArgumentException("Value must implement IEnumerable", "value"); } if (typeof(IRdfListAdapter<>).IsAssignableFromSpecificGeneric(value.GetType())) { yield return Node.FromEntityId(((IEntity)value.GetType().GetProperty("Head").GetValue(value)).Id); } else { var nodeType = GetNodeType(property); var ownerType = GetOwnerType(property); var itemType = property.ReturnType.GetGenericArguments()[0].FindItemType(); var ctor = typeof(RdfListAdapter<,,>).MakeGenericType(ownerType, nodeType, itemType) .GetConstructor(new[] { typeof(IEntityContext), typeof(IEntity), typeof(OverridingGraphSelector) }); var paremeters = proxy.GraphSelectionOverride ?? new OverridingGraphSelector(proxy.Id, proxy.EntityMapping, property); var rdfList = ctor.Invoke(new object[] { context, proxy, paremeters }); var interfaceMapping = rdfList.GetType().GetInterfaceMap(typeof(IRdfListAdapter<>).MakeGenericType(itemType)); var addMethodInfo = interfaceMapping.InterfaceMethods.First(item => item.Name == "Add"); foreach (var item in (IEnumerable)value) { addMethodInfo.Invoke(rdfList, new[] { item }); } yield return Node.FromEntityId(((IEntity)interfaceMapping.InterfaceMethods.First(item => item.Name == "get_Head").Invoke(rdfList, null)).Id); } }
public ProfileSettingsDataService( IEntityContext entityContext ) { _entityContext = entityContext; _dbSet = _entityContext.Set <UserInfo>(); }
public int Add(CManagerPO po, string operatorName) { using (IEntityContext entityContext = CManagerPOManager.Instance.CreateEntityContext()) { return(AddWithContext(entityContext, po, operatorName)); } }
/// <summary> /// 执行一个不需要返回结果的函数,该函数可接收一个已初始化的 IEntityContext 参数。 /// 如果在执行过程中发生并发冲突,则会额外进行 concurrencyRetryCount 参数指定次数的重试,默认执行 1 次重试。 /// </summary> /// <param name="action">要执行的函数。</param> /// <param name="concurrencyRetryCount">并发重试次数。</param> public static void Execute(Action <IEntityContext> action, int concurrencyRetryCount = 1) { int retryCount = 0; while (true) { using (IEntityContext entityContext = EntityContextFactory.CreateEntityContext()) { try { action(entityContext); break; } catch (EntityConcurrencyException) { retryCount++; if (retryCount > 3) { throw; } continue; } catch { throw; } } } }
public int Update(CRestaurantPO po, string operatorName) { using (IEntityContext entityContext = CRestaurantPOManager.Instance.CreateEntityContext()) { return(UpdateWithContext(entityContext, po, operatorName)); } }
public int Update(CCommodityWithPropertyPO po, string operatorName) { using (IEntityContext entityContext = CCommodityWithPropertyPOManager.Instance.CreateEntityContext()) { return(UpdateWithContext(entityContext, po, operatorName)); } }
/// <summary> /// 执行一个不需要返回结果的函数,该函数可接收一个已初始化的 IEntityContext 参数。 /// 如果在执行过程中发生并发冲突,则会额外进行 concurrencyRetryCount 参数指定次数的重试,默认执行 1 次重试。 /// </summary> /// <typeparam name="TResult">函数执行结果的类型。</typeparam> /// <param name="func">要执行的函数。</param> /// <param name="concurrencyRetryCount">并发重试次数。</param> /// <returns>函数执行的结果。</returns> public static TResult Execute <TResult>(Func <IEntityContext, TResult> func, int concurrencyRetryCount = 1) { int retryCount = 0; while (true) { using (IEntityContext entityContext = EntityContextFactory.CreateEntityContext()) { try { return(func(entityContext)); } catch (EntityConcurrencyException) { retryCount++; if (retryCount > concurrencyRetryCount) { throw; } continue; } catch { throw; } } } }
/// <summary> /// Map a entity with a context. /// </summary> /// <typeparam name="TEntity">Type of entity.</typeparam> /// <param name="context">Entity context.</param> public void MapContext <TEntity>(IEntityContext <TEntity> context) where TEntity : class, IEntity, new() { if (context == null) { throw new ArgumentNullException("context"); } Type type = typeof(TEntity); if (_Map.ContainsKey(type)) { _Map.Remove(type); } if (!_Types.Contains(type)) { _Types.Add(type); } if (_Context.ContainsKey(type)) { _Context[type] = context; } else { _Context.Add(type, context); } }
public BeAwarePlus( [Import] IRendererManager render, [Import] IEntityContext <Unit> context) { Render = render; Context = context; }
public static ObjectContext GetObjectContext(IEntityContext context, string property) { // Lazy-load EF 4.1 or 4.2 var contextAdapter = Type.GetType("System.Data.Entity.Infrastructure.IObjectContextAdapter, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false); if (contextAdapter != null && contextAdapter.IsAssignableFrom(context.GetType())) { return((ObjectContext)contextAdapter.GetProperty("ObjectContext").GetValue(context, null)); } contextAdapter = Type.GetType("System.Data.Entity.Infrastructure.IObjectContextAdapter, EntityFramework, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false); if (contextAdapter != null && contextAdapter.IsAssignableFrom(context.GetType())) { return((ObjectContext)contextAdapter.GetProperty("ObjectContext").GetValue(context, null)); } contextAdapter = Type.GetType("System.Data.Entity.Infrastructure.IObjectContextAdapter, EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false); if (contextAdapter != null && contextAdapter.IsAssignableFrom(context.GetType())) { return((ObjectContext)contextAdapter.GetProperty("ObjectContext").GetValue(context, null)); } if (context is ObjectContext) { return(context as ObjectContext); } throw new InvalidOperationException("An object context could not be obtained from the specified entity context."); }
public PostDataService( IEntityContext context, IPostCacheService postCacheService, IUserLikesDataService userLikesDataService, IUserLikeCacheService userLikesCacheService, IUserFollowCacheService userFollowCacheService, IGroupDataService groupDataService, IGroupCacheService groupCacheService, IReviewCacheService reviewCacheService, IReviewDataService reviewDataService, ICommentCacheService commentCacheService, ICommentDataService commentDataService, IOptions <UserProfileImageSettings> userProfileImageSettings ) { _context = context; _postCacheService = postCacheService; _userLikesCacheService = userLikesCacheService; _userLikesDataService = userLikesDataService; _userFollowCacheService = userFollowCacheService; _groupDataService = groupDataService; _groupCacheService = groupCacheService; _reviewCacheService = reviewCacheService; _reviewDataService = reviewDataService; _commentCacheService = commentCacheService; _commentDataService = commentDataService; _userProfileImageSettings = userProfileImageSettings.Value; }
/// <summary> /// Transforms the resulting <paramref name="nodes"/> to a <see cref="IRdfListAdapter{T}"/> /// </summary> public override object FromNodes(IEntityProxy parent, IPropertyMapping property, IEntityContext context, [AllowNull] IEnumerable<Node> nodes) { var listHead = (IEntity)base.FromNodes(parent, property, context, nodes); var ownerType = GetOwnerType(property); var nodeType = GetNodeType(property); var itemType = property.ReturnType.GetGenericArguments()[0].FindItemType(); var ctor = typeof(RdfListAdapter<,,>).MakeGenericType(ownerType, nodeType, itemType) .GetConstructor(new[] { typeof(IEntityContext), typeof(IEntity), nodeType, typeof(OverridingGraphSelector) }); object head; if (listHead == null) { head = context.GetType().GetInterfaceMap(typeof(IEntityContext)) .InterfaceMethods .Where(item => (item.Name == "Create") && (item.IsGenericMethodDefinition) && (item.GetParameters().Length == 1) && (item.GetParameters()[0].ParameterType == typeof(EntityId))) .Select(item => item.MakeGenericMethod(nodeType)) .First() .Invoke(context, new object[] { new EntityId(Vocabularies.Rdf.nil) }); } else { head = typeof(EntityExtensions).GetMethod("AsEntity").MakeGenericMethod(nodeType).Invoke(null, new object[] { listHead }); } var paremeters = parent.GraphSelectionOverride ?? new OverridingGraphSelector(parent.Id, parent.EntityMapping, property); ((IEntityProxy)((IEntity)head).UnwrapProxy()).OverrideGraphSelection(paremeters); return ctor.Invoke(new[] { context, parent, head, paremeters }); }
public PostLikeDataService( IEntityContext context ) { _context = context; _dbEntitySet = _context.SetChild <UserPostLike>(); }
public GroupDataService( IEntityContext context, IGroupCacheService groupCacheService, IUserLikeCacheService userLikesCacheService, IUserInfoCacheService userCacheService, IUserLikesDataService userLikesDataService, ITrendingDataService trendingDataService, IUserFollowCacheService userFollowCacheService, ITrendingCacheService trendingCacheService, IPostCacheService postCacheService, IOptions <UserProfileImageSettings> _userImageSettings ) { _context = context; _userProfileImageSettings = _userImageSettings.Value; _postCacheService = postCacheService; _userCacheService = userCacheService; _groupCacheService = groupCacheService; _userLikesDataService = userLikesDataService; _userLikesCacheService = userLikesCacheService; _userFollowCacheService = userFollowCacheService; _trendingDataService = trendingDataService; _trendingCacheService = trendingCacheService; _dbEntitySet = _context.Set <Group>(); _userGroupEntitySet = _context.SetChild <UserGroup>(); }
public int UpdateWithContext(IEntityContext entityContext, CManagerPO po, string operatorName) { if (entityContext == null) { throw new ArgumentNullException("entityContext"); } if (po == null) { throw new ArgumentNullException("对象不能为空"); } if (string.IsNullOrWhiteSpace(operatorName)) { throw new ArgumentNullException("操作人不能为空"); } if (po.Id <= 0) { throw new BusinessException("添加对象错误,Id不能小于0"); } po.UpdateTime = DateTime.Now; po.UpdateName = operatorName; object oldObject = this.DtoToPo(this.PoToDto(GetByIdWithContext(entityContext, po.Id))); CManagerPOManager.Instance.UpdateWithContext(entityContext, po); COperationLogManager.Instance.AddOperationLogWithContext(entityContext, po.Id, EnumOperationLogType.CManager, EnumOperationLogAction.Update, oldObject, po, operatorName); return(po.Id); }
public UserActivityDataService( IEntityContext context, IPostCacheService postCacheService, IPostDataService postDataService, IUserInfoCacheService userInfoCacheService, IUserLikesDataService userLikesDataService, IReviewCacheService reviewCacheService, IUserLikeCacheService userLikesCacheService, IReviewDataService reviewDataService, IMapper mapper, IOptions <UserProfileImageSettings> userImageSettings ) { _context = context; _postCacheService = postCacheService; _postDataService = postDataService; _userInfoCacheService = userInfoCacheService; _userLikesDataService = userLikesDataService; _userLikesCacheService = userLikesCacheService; _reviewCacheService = reviewCacheService; _reviewDataService = reviewDataService; _dbSet = _context.Set <UserActivity>(); _mapper = mapper; _userProfileImageSettings = userImageSettings.Value; }
public DeleteRequestHandler(IEntityContext context, ServiceProviderContainer container, CrudlessConfigManager profileManager) : base(context, profileManager) { _container = container; }
public int AddWithContext(IEntityContext entityContext, CManagerPO po, string operatorName) { if (entityContext == null) { throw new ArgumentNullException("entityContext"); } if (po == null) { throw new ArgumentNullException("对象不能为空"); } if (string.IsNullOrWhiteSpace(operatorName)) { throw new ArgumentNullException("操作人不能为空"); } if (po.Id > 0) { throw new BusinessException("添加对象错误,Id不能大于0"); } po.IsDelete = false; po.CreateTime = DateTime.Now; po.CreateName = operatorName; po.UpdateTime = DateTime.Now; po.UpdateName = operatorName; CManagerPOManager.Instance.AddWithContext(entityContext, po); COperationLogManager.Instance.AddOperationLogWithContext(entityContext, po.Id, EnumOperationLogType.CManager, EnumOperationLogAction.Add, null, po, operatorName); return(po.Id); }
public virtual PO GetById(int id) { using (IEntityContext entityContext = CreateEntityContext(true)) { return(GetByIdWithContext(entityContext, id)); } }
public int Add(COrderCommodityRelationPO po, string operatorName) { using (IEntityContext entityContext = COrderCommodityRelationPOManager.Instance.CreateEntityContext()) { return(AddWithContext(entityContext, po, operatorName)); } }
private IEntityContext CreateEntityContext(IKernel kernel, CreationContext context) { IEntityContext result = null; lock (_lock) { EntityContextFactory entityContextFactory = _entityContextFactory.Value; if (!_isNamedGraphSelectorInitialized) { entityContextFactory = entityContextFactory.WithNamedGraphSelector(kernel.Resolve <INamedGraphSelector>()); _isNamedGraphSelectorInitialized = true; } if (!_isBaseUriInitialized) { var baseUri = kernel.Resolve <IHttpServerConfiguration>().BaseUri; if (baseUri != null) { _isBaseUriInitialized = true; result = entityContextFactory.WithBaseUri(policy => policy.Default.Is(baseUri)).CreateContext(); } } if (result == null) { result = entityContextFactory.CreateContext(); } } return(result); }
public void Teardown() { ChildTeardown(); _factory.Dispose(); _entityContext = null; _store = null; }
/// <summary> /// Gets or creates the instance for the specified id. /// </summary> /// <param name="id">The identifier of an existing instance, or null to create a new instance</param> /// <returns>The new or existing instance</returns> protected override object GetInstance(string id) { // Get the current object context IEntityContext context = GetObjectContext(); // Create a new instance if the id is null if (id == null) { // When a new entity is created, it is detached by default. Attach it to the context so it will be tracked. var entity = context.ObjectContext.GetType().GetMethod("CreateObject").MakeGenericMethod(UnderlyingType).Invoke(context.ObjectContext, null); context.ObjectContext.AddObject(QualifiedEntitySetName, entity); return(entity); } // Otherwise, load the existing instance // Split the id string into id tokens var tokens = id.Split(','); if (tokens.Length != IdProperties.Length) { throw new ArgumentException("The specified id, '" + id + "', does not have the correct number of key values."); } // Create an entity key based on the specified id tokens var key = new EntityKey(QualifiedEntitySetName, IdProperties.Select((property, index) => new EntityKeyMember(property.Name, TypeDescriptor.GetConverter(property.PropertyType).ConvertFromString(tokens[index])))); // Attempt to create the entity using the key object instance; context.ObjectContext.TryGetObjectByKey(key, out instance); return(instance); }
public int Add(CCommodityCategoryPO po, string operatorName) { using (IEntityContext entityContext = CCommodityCategoryPOManager.Instance.CreateEntityContext()) { return(this.AddWithContext(entityContext, po, operatorName)); } }
public int UpdateWithContext(IEntityContext entityContext, CCashCouponPO po, string operatorName) { if (po == null) { throw ErrorCodeHelper.CCashCouponNull.ToException(); } if (string.IsNullOrWhiteSpace(po.AssetName)) { throw ErrorCodeHelper.CCashCouponAssetNameNotSet.ToException(); } EnumOperationLogAction enumOperationLogAction = EnumOperationLogAction.Update; CCashCouponPO oldObject = null; CCashCouponPO newObject = po; newObject.UpdateName = operatorName; newObject.UpdateTime = DateTime.Now; oldObject = GetByIdWithContext(entityContext, po.Id); if (oldObject == null) { throw ErrorCodeHelper.CCashCouponNotExist.ToException(); } CCashCouponPOManager.Instance.UpdateWithContext(entityContext, newObject); COperationLogManager.Instance.AddOperationLog(po.Id, EnumOperationLogType.CCashCoupon, enumOperationLogAction, oldObject, newObject, operatorName); return(po.Id); }
public void Setup() { _typesMapping = new TestPropertyMapping(typeof(ITypedEntity), typeof(IEnumerable <EntityId>), "Types", Rdf.type); _factory = new Mock <IEntityContextFactory>(); _ontologyProvider = new TestOntologyProvider(); _mappings = new Mock <IMappingsRepository>(); _entityStore = new Mock <IEntityStore>(); _entityStore.Setup(es => es.GetObjectsForPredicate(It.IsAny <EntityId>(), Rdf.type, It.IsAny <Uri>())) .Returns(new Node[0]); _mappings.Setup(m => m.MappingFor <ITypedEntity>()) .Returns(new EntityMapping(typeof(ITypedEntity), new ClassMapping[0], new[] { _typesMapping }, new PropertyMapping[0])); _mappings.Setup(m => m.MappingFor(typeof(ITypedEntity))) .Returns(new EntityMapping(typeof(ITypedEntity), new ClassMapping[0], new[] { _typesMapping }, new PropertyMapping[0])); _store = new Mock <IEntitySource>(); _baseUriSelector = new Mock <IBaseUriSelectionPolicy>(MockBehavior.Strict); _factory.Setup(f => f.Ontologies).Returns(_ontologyProvider); var catalog = new TestTransformerCatalog(); _changesTracker = new Mock <IDatasetChangesTracker>(MockBehavior.Strict); _entityContext = new EntityContext( _factory.Object, _mappings.Object, _entityStore.Object, _store.Object, _baseUriSelector.Object, new TestCache(), new DefaultBlankNodeIdGenerator(), catalog, new InternalProxyCaster((entity, mapping) => new EntityProxy(entity, mapping, catalog, new TestGraphSelector(), null), _mappings.Object, new TestGraphSelector(), _entityStore.Object), _changesTracker.Object, null); }
/// <summary> /// Constructor /// </summary> /// <param name="dbContext"></param> /// <param name="httpContextAccessor"></param> /// <param name="userManager"></param> /// <param name="localizer"></param> public FormTagHelper(IEntityContext dbContext, IHttpContextAccessor httpContextAccessor, UserManager <GearUser> userManager, IStringLocalizer localizer) { _dbContext = dbContext; _userManager = userManager; _httpContextAccessor = httpContextAccessor; _localizer = localizer; }
public UserActivityActionService( IEntityContext context ) { _context = context; _dbSet = _context.Set <UserActivity>(); }
/// <summary> /// Creates an instance of the query executor aware of the entities queried. /// </summary> /// <param name="entityContext">Entity factory to be used when creating objects.</param> /// <param name="entitySource">Entity source.</param> /// <param name="store">Entity store</param> public EntityQueryExecutor(IEntityContext entityContext, IEntitySource entitySource, IEntityStore store) { _entityContext = entityContext; _entitySource = entitySource; _store = store; _queryOptimizer = new GenericQueryOptimizer(); }
public int Update(CVerificationCodePO po, string operatorName) { using (IEntityContext entityContext = CVerificationCodePOManager.Instance.CreateEntityContext()) { return(this.UpdateWithContext(entityContext, po, operatorName)); } }
/// <summary> /// Converts a node to a correct value based on type (URI, blank or literal) /// or it's datatype in the case of literal nodes /// </summary> public object Convert(Node objectNode, IEntityContext context) { if (objectNode.IsLiteral) { return ConvertLiteral(objectNode, context); } return ConvertUri(objectNode, context); }
/// <summary> /// Initializes a new instance of <see cref="EventRepository"/> /// </summary> /// <param name="entityContext"><see cref="IEntityContext{T}"/> for retrieving events</param> /// <param name="eventConverter"><see cref="IEventConverter"/> for converting events</param> /// <param name="eventMigrationHierarchyManager">A <see cref="IEventMigrationHierarchyManager"/> for managing event migrations</param> public EventRepository( IEntityContext<EventHolder> entityContext, IEventConverter eventConverter, IEventMigrationHierarchyManager eventMigrationHierarchyManager) { _entityContext = entityContext; _eventConverter = eventConverter; _eventMigrationHierarchyManager = eventMigrationHierarchyManager; }
/// <summary>Converts the given node to an object.</summary> public object Convert(Node objectNode, IEntityContext context) { if (!objectNode.IsLiteral) { throw new ArgumentOutOfRangeException("objectNode", "Node is not literal"); } return ConvertInternal(objectNode); }
private static object ConvertLiteral(Node objectNode, IEntityContext context) { var converter = Converters.GetBestConverter(objectNode); if (converter != null) { return converter.Convert(objectNode, context); } throw new InvalidOperationException(); }
public ProductRepository( IEntityContext<Product> productEntityContext, IContentManager contentManager, IImageProcessor imageProcessor, IImageService imageService) { _productEntityContext = productEntityContext; _contentManager = contentManager; _imageService = imageService; _imageProcessor = imageProcessor; }
/// <summary> /// Converts an uri node to URI /// </summary> public object Convert(Node objectNode, IEntityContext context) { if (objectNode.IsBlank) { throw new ArgumentOutOfRangeException("objectNode", "Cannot convert blank node to URI"); } if (objectNode.IsUri) { return objectNode.Uri; } return new Uri(objectNode.Literal); }
protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { if (Context != null) { Context.Dispose(); Context = default(IEntityContext); } } } _isDisposed = true; }
public static Dictionary<string, string> SubmitPaymentRequest(Dictionary<string, string> requestNvps, PaymentProcessorPayFlowProConfiguration settings, UserContext userContext, IEntityContext entityContext) { var payflowProSettings = new PayflowProSettingsDto { Id = settings.Id, Environment = settings.Environment, UserId = settings.UserId, Name = settings.Name, Password = settings.Password, Partner = settings.Partner, VendorId = settings.VendorId }; return SubmitPaymentRequest(requestNvps, payflowProSettings, userContext, entityContext); }
public static Dictionary<string, string> SubmitPaymentRequest(Dictionary<string, string> requestNvps, PayflowProSettingsDto settings, UserContext userContext, IEntityContext entityContext) { CheckSettings(settings); //Add Settings to Request String var nvpRequest = new StringBuilder(); var accountNum = string.Empty; var securityCode = string.Empty; nvpRequest.AppendFormat(CultureInfo.InvariantCulture, "USER={0}&VENDOR={1}&PARTNER={2}&PWD={3}", settings.UserId, settings.VendorId, settings.Partner, settings.Password); foreach (var nvp in requestNvps) { nvpRequest.AppendFormat(CultureInfo.InvariantCulture, "&{0}={1}", nvp.Key, nvp.Value); if (nvp.Key == Constants.AccountNumber) accountNum = nvp.Value; if (nvp.Key == Constants.VerificationCode) securityCode = nvp.Value; } //Create API Request Object var payflowApi = new PayflowNETAPI(); var hostAddress = settings.Environment.ToUpperInvariant() == "SANDBOX" ? "pilot-payflowpro.paypal.com" : "payflowpro.paypal.com"; payflowApi.SetParameters(hostAddress, 443, 45, "", 0, "", "", "enabled", "1", "payflow.log", "10240000", false); //Send request and retrieve response var response = payflowApi.SubmitTransaction(nvpRequest.ToString(), PayflowUtility.RequestId); //Parse Response var responseNvp = new Dictionary<string, string>(); foreach (var pair in response.Split('&')) { var values = pair.Split('='); if (values.Length == 2) responseNvp.Add(values[0], values[1]); } //TODO: edit from original var pnref = responseNvp.ContainsKey("PNREF") ? responseNvp["PNREF"] : string.Empty; var result = responseNvp.ContainsKey("RESULT") ? responseNvp["RESULT"] : string.Empty; CreatePaymentOperationRecord(nvpRequest.ToString(), accountNum, securityCode, result, pnref, settings.Id, userContext, entityContext); return responseNvp; }
/// <summary> /// Filters the query by specialties in use. /// </summary> /// <param name="query">The query.</param> /// <param name="request">The request.</param> /// <param name="entityContext">The entity context.</param> /// <returns></returns> public static IQueryable<Specialty> FilterBySpecialtiesInUse(this IQueryable<Specialty> query, SearchSpecialtyRequest request, IEntityContext entityContext) { if (request.OnlyInUseSpecialties) { query = (from q in query join ps in entityContext.EntitySet<ProviderSpecialty>() on q.Id equals ps.SpecialtyId select q); } else { query = (from q in query where q.IsEnabled select q); } return query; }
/// <inheritdoc /> public object Convert(Node objectNode, IEntityContext context) { if (objectNode.IsLiteral) { return Guid.Parse(objectNode.Literal); } if (objectNode.IsUri && UrnUuidRegex.IsMatch(objectNode.Uri.ToString())) { Guid guid; if (Guid.TryParse(UrnUuidRegex.Replace(objectNode.Uri.ToString(), string.Empty), out guid)) { return guid; } } throw new ArgumentException(string.Format("Cannot convert node '{0}' to guid", objectNode), "objectNode"); }
/// <summary>Get an <see cref="ObservableCollection{T}"/> containing <paramref name="nodes"/>' values.</summary> public override object FromNodes(IEntityProxy parent, IPropertyMapping property, IEntityContext context, [AllowNull] IEnumerable<Node> nodes) { var convertedValues = nodes.Select(node => ((ICollectionMapping)property).ElementConverter.Convert(node, context)); var collectionElements = ((IEnumerable<object>)Aggregator.Aggregate(convertedValues)).ToArray(); var genericArguments = property.ReturnType.GetGenericArguments(); if (typeof(IEntity).IsAssignableFrom(genericArguments.Single())) { genericArguments = new[] { typeof(IEntity) }; } var castMethod = EnumerableCast.MakeGenericMethod(genericArguments); var convertedCollection = castMethod.Invoke(null, new object[] { collectionElements }); var observable = (INotifyCollectionChanged)typeof(ObservableCollection<>).MakeGenericType(genericArguments) .GetConstructor(new[] { typeof(IEnumerable<>).MakeGenericType(genericArguments) }) .Invoke(new[] { convertedCollection }); observable.CollectionChanged += (sender, args) => Impromptu.InvokeSet(parent, property.Name, sender); return observable; }
/// <summary> /// Not used /// </summary> public IEnumerable<Node> ToNodes(object value, IEntityProxy proxy, IPropertyMapping property, IEntityContext context) { var dictionaryIface = typeof(IDictionary<,>).MakeGenericType(property.ReturnType.GenericTypeArguments); var dictionaryType = GetDictionaryType(property); if (!dictionaryIface.IsInstanceOfType(value)) { throw new ArgumentException(string.Format("Value must be a of type {0}", dictionaryIface), "value"); } var dictionary = value as IRdfDictionary; if (dictionary == null) { dictionary = (IRdfDictionary)dictionaryType.GetConstructors() .Single(c => c.GetParameters().Length == 3) .Invoke(new[] { proxy.Id, context, value }); } return dictionary.DictionaryEntries.Select(entity => Node.FromEntityId(entity.Id)); }
public void Setup() { _typesMapping = new TestPropertyMapping(typeof(ITypedEntity), typeof(IEnumerable<EntityId>), "Types", Vocabularies.Rdf.type); _factory = new Mock<IEntityContextFactory>(); _ontologyProvider = new TestOntologyProvider(); _mappings = new Mock<IMappingsRepository>(); _entityStore = new Mock<IEntityStore>(); _entityStore.Setup(es => es.GetObjectsForPredicate(It.IsAny<EntityId>(), Rdf.type, It.IsAny<Uri>())) .Returns(new Node[0]); _mappings.Setup(m => m.MappingFor<ITypedEntity>()).Returns(new EntityMapping(typeof(ITypedEntity), new ClassMapping[0], new[] { _typesMapping })); _mappings.Setup(m => m.MappingFor(typeof(ITypedEntity))).Returns(new EntityMapping(typeof(ITypedEntity), new ClassMapping[0], new[] { _typesMapping })); _store = new Mock<IEntitySource>(); _baseUriSelector = new Mock<IBaseUriSelectionPolicy>(MockBehavior.Strict); var mappingContext = new MappingContext(_ontologyProvider); _entityContext = new EntityContext( _factory.Object, _mappings.Object, mappingContext, _entityStore.Object, _store.Object, _baseUriSelector.Object, new TestGraphSelector(), new TestCache()); }
public EventService(IEntityContext<EventHolder> entityContext, ISerializer serializer) { _entityContext = entityContext; _serializer = serializer; }
/// <summary> /// Initializes a new instance of <see cref="SagaLibrarian"/> /// </summary> /// <param name="entityContext">A <see cref="IEntityContext{SagaHolder}"/> to use for working with persisting and resuming <see cref="ISaga">Sagas</see></param> /// <param name="sagaConverter">A <see cref="ISagaConverter"/> for converting a <see cref="ISaga"/> to a <see cref="SagaHolder"/> and back</param> public SagaLibrarian(IEntityContext<SagaHolder> entityContext, ISagaConverter sagaConverter) { _entityContext = entityContext; _sagaConverter = sagaConverter; }
public object Convert(Node objectNode, IEntityContext context) { return (objectNode.IsUri ? objectNode.Uri.ToString() : objectNode.IsBlank ? objectNode.BlankNode : objectNode.Literal); }
/// <summary> /// Initializes a new instance of <see cref="TaskRepository"/> /// </summary> /// <param name="entityContext"><see cref="IEntityContext{T}"/> that is used for persisting <see cref="Task">tasks</see></param> /// <param name="container"><see cref="IContainer"/> to use for creating instances of <see cref="Task">tasks</see></param> public TaskRepository(IEntityContext<TaskEntity> entityContext, IContainer container) { _entityContext = entityContext; _container = container; }
public UnitOfWork(IEntityContext context) { Context = context; }
public PostStatisticsService(IEntityContext<Post> postsEntityContext, IEntityContext<PostsByYear> postByYearEntityContext) { _postsEntityContext = postsEntityContext; _postByYearEntityContext = postByYearEntityContext; }
internal static bool PredicateIs(this EntityQuad quad, IEntityContext context, Uri type) { return (quad.Predicate.IsUri) && (!quad.Predicate.Uri.AbsoluteUri.StartsWith(EntityConverter.Hydra.AbsoluteUri)) && (context.Load<IEntity>(new EntityId(quad.Predicate.Uri)).GetTypes().Any(currentType => AbsoluteUriComparer.Default.Equals(currentType.Uri, type))); }
public PersonEventSubscriber(IEntityContext<Person> entityContext) { _entityContext = entityContext; }
/// <summary> /// Initializes a new instance of <see cref="EventSubscriptionRepository"/> /// </summary> /// <param name="entityContext">An <see cref="IEntityContext{EventSubscriptionHolder}"/> for working with persisting of <see cref="EventSubscriptionHolder">EventSubscriptionHolders</see></param> /// <param name="serializer">A <see cref="ISerializer"/> to use for serialization</param> public EventSubscriptionRepository(IEntityContext<EventSubscriptionHolder> entityContext, ISerializer serializer) { _entityContext = entityContext; _serializer = serializer; }
public void Teardown() { ChildTeardown(); _entityContext = null; }
public EntityContextTest() { _context = new EntityContext(new EfContext("Data Source=.;Initial Catalog=sdeveloper;Integrated Security=true;MultipleActiveResultSets=true;")); }
private static object ConvertUri(Node uriNode, IEntityContext context) { return context.Load<IEntity>(uriNode.ToEntityId()); }
public ToDoItemService(IEntityContext<ToDoItem> entityContext, IPushService pushService) { _entityContext = entityContext; _pushService = pushService; }
public ChirperFuncs(IEntityContext<ChirperId> chirperEntityContext) { _chirperEntityContext = chirperEntityContext; }