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 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;
 }
Beispiel #4
0
        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 ElementMappingFeature(IMetadataElement mappedElement)
 {
     if (mappedElement == null)
     {
         throw new ArgumentNullException("mappedElement");
     }
     _mappedElement = mappedElement;
 }
 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));
                }
            }
        }
        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);
        }
 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 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);
 }
Beispiel #12
0
            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;
            }