public IFactProcessor Create(IMetadataElement factMetadata) { var factType = factMetadata.GetType().GenericTypeArguments[0]; var processorType = typeof(FactProcessor<>).MakeGenericType(factType); var processor = _unityContainer.Resolve(processorType, new DependencyOverride(factMetadata.GetType(), factMetadata)); return (IFactProcessor)processor; }
public IStatisticsProcessor Create(IMetadataElement metadata) { var statisticsType = metadata.GetType().GenericTypeArguments[0]; var processorType = typeof(StatisticsProcessor<>).MakeGenericType(statisticsType); var processor = _unityContainer.Resolve(processorType, new DependencyOverride(metadata.GetType(), metadata)); return (IStatisticsProcessor)processor; }
public IAggregateProcessor Create(IMetadataElement aggregateMetadata) { var aggregateType = aggregateMetadata.GetType().GenericTypeArguments[0]; var processorType = typeof(AggregateProcessor<>).MakeGenericType(aggregateType); var processor = _unityContainer.Resolve(processorType, new DependencyOverride(aggregateMetadata.GetType(), aggregateMetadata)); return (IAggregateProcessor)processor; }
public ElementMappingFeature(IMetadataElement mappedElement) { if (mappedElement == null) { throw new ArgumentNullException("mappedElement"); } _mappedElement = mappedElement; }
private static IMetadataSource MockSource(IMetadataElement context) { var source = new Mock<IMetadataSource>(); source.Setup(x => x.Kind).Returns(new QueryingMetadataIdentity()); source.Setup(x => x.Metadata).Returns(new Dictionary<Uri, IMetadataElement> { { Metamodeling.Elements.Identities.Builder.Metadata.Id.For<QueryingMetadataIdentity>(), context } }); return source.Object; }
public void Annotate(IMetadataElement metadataElement, IEdmElement edmElement, IEdmModel edmModel) { if (metadataElement is EntityElement || metadataElement is EnumTypeElement) { var typeName = metadataElement.Identity.Id.Segments.Last(); var clrType = _clrTypes.SingleOrDefault(x => x.Name.Equals(typeName, StringComparison.OrdinalIgnoreCase)); if (clrType != null) { edmModel.SetAnnotationValue(edmElement, new ClrTypeAnnotation(clrType)); } } }
public void Annotate(IMetadataElement metadataElement, IEdmElement edmElement, IEdmModel edmModel) { if (metadataElement is EntityElement || metadataElement is EnumTypeElement) { edmModel.SetAnnotationValue(edmElement, AnnotationNamespace, AnnotationAttribute, metadataElement.Identity.Id); var clrType = _clrTypeProvider.Get(metadataElement.Identity); if (clrType != null) { edmModel.SetAnnotationValue(edmElement, new ClrTypeAnnotation(clrType)); } } }
private static IMetadataSource MockSource(IMetadataElement context) { var source = new Mock <IMetadataSource>(); source.Setup(x => x.Kind).Returns(new QueryingMetadataIdentity()); source.Setup(x => x.Metadata).Returns(new Dictionary <Uri, IMetadataElement> { { Metadata.Id.For <QueryingMetadataIdentity>(), context } }); return(source.Object); }
public IReadOnlyCollection <IBulkReplicator> Create(IMetadataElement metadataElement) { var aggregateMetadata = (AggregateMetadata <T>)metadataElement; return(new IBulkReplicator[] { new InsertsBulkReplicator <T>(_query, _dataConnection, aggregateMetadata.MapSpecificationProviderForSource.Invoke(Specs.Find.All <T>())) } .Concat(aggregateMetadata.Elements .OfType <IValueObjectMetadataElement>() .SelectMany(valueObjectMetadata => { var factoryType = typeof(ValueObjectsBulkReplicatorFactory <>).MakeGenericType(valueObjectMetadata.ValueObjectType); var factory = (IBulkReplicatorFactory)Activator.CreateInstance(factoryType, _query, _dataConnection); return factory.Create(valueObjectMetadata); })) .ToArray()); }
IReadOnlyCollection <IBulkReplicator> IBulkReplicatorFactory.Create(IMetadataElement metadataElement) { var metadataElementType = metadataElement.GetType(); Type factoryType; if (!RoutingDictionary.TryGetValue(metadataElementType.GetGenericTypeDefinition(), out factoryType)) { throw new NotSupportedException($"Bulk replication is not supported for the mode described with {metadataElement}"); } var objType = metadataElementType.GenericTypeArguments[0]; var factory = (IBulkReplicatorFactory)Activator.CreateInstance(factoryType.MakeGenericType(objType), new LinqToDbQuery(_sourceDataConnection), _targetDataConnection); return(factory.Create(metadataElement)); }
public IEdmSchemaType BuildSchemaType(IMetadataElement metadataElement) { IEdmSchemaType complexType; if (!_builtTypes.TryGetValue(metadataElement.Identity, out complexType)) { var entityElement = metadataElement as EntityElement; if (entityElement != null) { _builtTypes.Add(metadataElement.Identity, complexType = entityElement.KeyProperties.Any() ? (IEdmSchemaType)BuildEntityType(entityElement) : (IEdmSchemaType)BuildComplexType(entityElement)); } } return(complexType); }
public void Process( IMetadataKindIdentity metadataKind, MetadataSet flattenedMetadata, MetadataSet concreteKindMetadata, IMetadataElement element) { bool hasReferences = false; var dereferencedChilds = new List <IMetadataElement>(); foreach (var child in element.Elements) { var reference = child as MetadataReference; if (reference == null) { dereferencedChilds.Add(child); continue; } IMetadataElement metadataElement; var absoluteId = reference.ReferencedElementId.IsAbsoluteUri ? reference.ReferencedElementId : element.Identity.Id.WithRelative(reference.ReferencedElementId); if (!flattenedMetadata.Metadata.TryGetValue(absoluteId, out metadataElement)) { throw new InvalidOperationException($"Can't resolve metadata for referenced element: {reference.ReferencedElementId}. " + $"References is ecounterred in {reference.Parent.Identity.Id} childs list"); } hasReferences = true; flattenedMetadata.Metadata.Remove(reference.Identity.Id); concreteKindMetadata.Metadata.Remove(reference.Identity.Id); ((IMetadataElementUpdater)metadataElement).ReferencedBy(element); dereferencedChilds.Add(metadataElement); } if (!hasReferences) { return; } ((IMetadataElementUpdater)element).ReplaceChilds(dereferencedChilds); }
public void Process( IMetadataKindIdentity metadataKind, MetadataSet flattenedMetadata, MetadataSet concreteKindMetadata, IMetadataElement element) { bool hasReferences = false; var dereferencedChilds = new List<IMetadataElement>(); foreach (var child in element.Elements) { var reference = child as MetadataReference; if (reference == null) { dereferencedChilds.Add(child); continue; } IMetadataElement metadataElement; var absoluteId = reference.ReferencedElementId.IsAbsoluteUri ? reference.ReferencedElementId : element.Identity.Id.WithRelative(reference.ReferencedElementId); if (!flattenedMetadata.Metadata.TryGetValue(absoluteId, out metadataElement)) { throw new InvalidOperationException($"Can't resolve metadata for referenced element: {reference.ReferencedElementId}. " + $"References is ecounterred in {reference.Parent.Identity.Id} childs list"); } hasReferences = true; flattenedMetadata.Metadata.Remove(reference.Identity.Id); concreteKindMetadata.Metadata.Remove(reference.Identity.Id); ((IMetadataElementUpdater)metadataElement).ReferencedBy(element); dereferencedChilds.Add(metadataElement); } if (!hasReferences) { return; } ((IMetadataElementUpdater)element).ReplaceChilds(dereferencedChilds); }
public IAggregateProcessor Create(IMetadataElement aggregateMetadata) { return new AggregateProcessor<TAggregate>((AggregateMetadata<TAggregate>)aggregateMetadata, this, _query, _repositoryFactory.Create<TAggregate>()); }
private static bool TryGetMetadata(string path, out IMetadataElement element) { var id = Metadata.Id.For <QueryingMetadataIdentity>(path); return(TestMetadataProvider.Instance.TryGetMetadata(id, out element)); }
public static string Serialize(this IMetadataElement element, string[] properties, Type[] ignoredFeatures = null) { return(element.ToJson(false, new HashSet <string>(properties), ignoredFeatures).Replace("\"", "'")); }
public IFactProcessor Create(IMetadataElement factMetadata) { return(new FactProcessor <TFact>((FactMetadata <TFact>)factMetadata, this, _query, _repository)); }
public IReadOnlyCollection <IBulkReplicator> Create(IMetadataElement metadata) { var statisticsRecalculationMetadata = (StatisticsRecalculationMetadata <T, TKey>)metadata; return(new[] { new InsertsBulkReplicator <T>(_query, _dataConnection, statisticsRecalculationMetadata.MapSpecificationProviderForSource.Invoke(Specs.Find.All <T>())) }); }
public GenericParamList(AssemblyLoader loader, IMetadataElement owner) { _list = loader.GenericParameters.Find(owner.MetadataToken); }
private static void ConfigureTable(TypeConventionConfiguration configuration, IMetadataElement tableElement) { string schemaName; var tableName = tableElement.ResolveName(); ParseTableName(ref tableName, out schemaName); configuration.Configure(x => x.ToTable(tableName, schemaName)); configuration.Configure(x => x.HasTableAnnotation(AnnotationKey, tableElement.Identity.Id)); }
private DependencyOverride ResolveDepencencyProcessorsDependency(IMetadataElement metadata) { return(new DependencyOverride( typeof(IReadOnlyCollection <IFactDependencyProcessor>), metadata.Features.OfType <IFactDependencyFeature>().Select(_dependencyProcessorFactory.Create).ToArray())); }
public void Annotate(IMetadataElement metadataElement, IEdmElement edmElement, IEdmModel edmModel) { }
private static bool TryGetMetadata(string path, out IMetadataElement element) { var id = Metadata.Id.For<QueryingMetadataIdentity>(path); return TestMetadataProvider.Instance.TryGetMetadata(id, out element); }
public IReadOnlyCollection <IBulkReplicator> Create(IMetadataElement metadataElement) { var factMetadata = (FactMetadata <T>)metadataElement; return(new[] { new InsertsBulkReplicator <T>(_query, _dataConnection, factMetadata.MapSpecificationProviderForSource.Invoke(Specs.Find.All <T>())) }); }
private bool TryGetMetadata(string path, out IMetadataElement element) { var id = Metamodeling.Elements.Identities.Builder.Metadata.Id.For<QueryingMetadataIdentity>(path); return _provider.TryGetMetadata(id, out element); }
public IEdmSchemaType BuildSchemaType(IMetadataElement metadataElement) { IEdmSchemaType complexType; if (!_builtTypes.TryGetValue(metadataElement.Identity, out complexType)) { var entityElement = metadataElement as EntityElement; if (entityElement != null) { _builtTypes.Add(metadataElement.Identity, complexType = entityElement.KeyProperties.Any() ? (IEdmSchemaType)BuildEntityType(entityElement) : (IEdmSchemaType)BuildComplexType(entityElement)); } } return complexType; }
public static int RowIndex(this IMetadataElement element) { return(((SimpleIndex)element.MetadataToken).Index - 1); }
public static void Dump(this IMetadataElement element, MetadataKind metadata, Type[] ignoredFeatures = null) { Debug.WriteLine(element.ToJson(true, ResolvePropertyNames(metadata), ignoredFeatures)); }
public static void Dump(this IMetadataElement element, string[] properties, Type[] ignoredFeatures = null) { Debug.WriteLine(element.ToJson(true, new HashSet <string>(properties), ignoredFeatures)); }
private bool TryGetMetadata(string path, out IMetadataElement element) { var id = Metamodeling.Elements.Identities.Builder.Metadata.Id.For <QueryingMetadataIdentity>(path); return(_provider.TryGetMetadata(id, out element)); }
public static string Serialize(this IMetadataElement element, MetadataKind metadata, Type[] ignoredFeatures = null) { return(element.ToJson(false, ResolvePropertyNames(metadata), ignoredFeatures).Replace("\"", "'")); }
public IReadOnlyCollection <IBulkReplicator> Create(IMetadataElement metadataElement) { var valueObjectMetadataElement = (StatisticsRecalculationMetadata <T>)metadataElement; return(new[] { new UpdatesBulkReplicator <T>(_query, _dataConnection, valueObjectMetadataElement.MapSpecificationProviderForSource.Invoke(Specs.Find.All <T>())) }); }
public IReadOnlyCollection <IBulkReplicator> Create(IMetadataElement metadata) { var valueObjectMetadata = (ValueObjectMetadata <TValueObject, TKey>)metadata; return(new[] { new InsertsBulkReplicator <TValueObject>(_query, _dataConnection, valueObjectMetadata.MapSpecificationProviderForSource.Invoke(Specs.Find.All <TValueObject>())) }); }