private IEnumerable <EntityTypeAsset> AssembleEntityTypes( Type externalSystem, EntityTypeSuite entityTypes, ConnectorSuite sinks, ConnectorSuite cacheFeeds, IDictionary <Type, ExternalSystemAsset> externalSystemAssetsByType) { return (entityTypes .DestinationSystemEntityTypes[externalSystem] .Keys .Select(entityType => new EntityTypeAsset( entityType, entityTypes .DestinationSystemEntityTypes[externalSystem][entityType] .Attribute, new SharedIdentifierSourceSystemsProvider( externalSystemAssetsByType, entityTypes .DestinationSystemEntityTypes[externalSystem][entityType] .SharedSourceSystemIdentifiersAttributes), this.GetEntityTypeSink(entityType, externalSystem, sinks), this.GetEntityTypeCacheFeed(entityType, externalSystem, cacheFeeds))) .ToArray()); }
private IEnumerable <Feed> GetFeeds( IDictionary <Type, ExternalSystemAttribute> externalSystems, EntityTypeSuite entityTypes) { var feeds = new HashSet <Feed>(); foreach (CombinedAsset <FeedAttribute> feedAsset in this.assetExtractor.GetFeeds()) { bool isNonGeneric = this.IsNonGeneric(feedAsset.AssetType); bool hasOneGenericArgument = this.HasOneGenericArgument(feedAsset.AssetType); if (isNonGeneric) { this.ProcessNonGenericFeedAsset( feeds, feedAsset, externalSystems, entityTypes); } else if (hasOneGenericArgument) { this.ProcessGenericFeed( feeds, feedAsset, externalSystems, entityTypes); } else { this.ThrowInterfaceImplementedIllegaly( feedAsset.AssetType, typeof(IFeed <>)); } } return(feeds); }
private IDictionary <Type, ExternalSystemAsset> AssembleExternalSystems( IDictionary <Type, ExternalSystemAttribute> externalSystems, IDictionary <Type, SourceSystemParametersAttribute> sourceSystemParameters, EntityTypeSuite entityTypes, ConnectorSuite sinks, ConnectorSuite cacheFeeds) { var externalSystemAssetsByType = new Dictionary <Type, ExternalSystemAsset>(); foreach (Type externalSystem in externalSystems.Keys) { externalSystemAssetsByType.Add( externalSystem, new ExternalSystemAsset( externalSystem, externalSystems[externalSystem], this.Get(externalSystem, sourceSystemParameters), this.AssembleEntityTypes( externalSystem, entityTypes, sinks, cacheFeeds, externalSystemAssetsByType))); } return(externalSystemAssetsByType); }
private void ValidateEntityType(Type entityType, EntityTypeSuite entityTypes) { if (!entityTypes.AllEntityTypes.Contains(entityType)) { throw new InvalidOperationException(string.Format( Resources.TypeDoesNotRepresentEntityType, entityType.FullName)); } }
private ConnectorSuite GetCacheFeeds( IDictionary <Type, ExternalSystemAttribute> externalSystems, EntityTypeSuite entityTypes) { return(this.GetDestinationSystemConnectors( this.assetExtractor.GetCacheFeeds(), cacheFeedAttribute => cacheFeedAttribute.DestinationSystem, typeof(ICacheFeed <>), externalSystems, entityTypes, Resources.MultipleCacheFeedsDefinedForDestinationSystem, Resources.MultipleCacheFeedsDefinedForEntityType)); }
private ConnectorSuite GetDestinationSystemConnectors <TAttribute>( IEnumerable <SingularAsset <TAttribute> > connectorAssets, Func <TAttribute, Type> getDestinationSystem, Type genericInterfaceType, IDictionary <Type, ExternalSystemAttribute> externalSystems, EntityTypeSuite entityTypes, string multipleAssetsDefinedForDestinationSystemExceptionMessageFormat, string multipleAssetsDefinedForEntityTypeExceptionMessageFormat) { var destinationSystemConnectors = new Dictionary <Type, Type>(); var entityTypeConnectors = new Dictionary <Type, Type>(); foreach (SingularAsset <TAttribute> connectorAsset in connectorAssets) { bool isNonGeneric = this.IsNonGeneric(connectorAsset.AssetType); bool hasOneGenericArgument = this.HasOneGenericArgument(connectorAsset.AssetType); Type destinationSystem = getDestinationSystem(connectorAsset.AssetAttribute); if (hasOneGenericArgument && destinationSystem != null) { this.AddDestinationSystemConnector( destinationSystemConnectors, destinationSystem, connectorAsset.AssetType, genericInterfaceType, externalSystems, multipleAssetsDefinedForDestinationSystemExceptionMessageFormat); } else if (isNonGeneric && destinationSystem == null) { this.AddEntityTypeConnectors( entityTypeConnectors, connectorAsset.AssetType, genericInterfaceType, entityTypes, multipleAssetsDefinedForEntityTypeExceptionMessageFormat); } else { this.ThrowInterfaceImplementedIllegaly( connectorAsset.AssetType, genericInterfaceType); } } return(new ConnectorSuite( destinationSystemConnectors, entityTypeConnectors)); }
private AssetSuite AssembleAssets( IDictionary <Type, ExternalSystemAttribute> externalSystems, IDictionary <Type, SourceSystemParametersAttribute> sourceSystemParameters, EntityTypeSuite entityTypes, ConnectorSuite sinks, ConnectorSuite cacheFeeds, IEnumerable <Feed> feeds) { IDictionary <Type, ExternalSystemAsset> externalSystemAssetsByType = this.AssembleExternalSystems( externalSystems, sourceSystemParameters, entityTypes, sinks, cacheFeeds); return(new AssetSuite( externalSystemAssetsByType.Values, this.AssembleFeeds(feeds, externalSystemAssetsByType))); }
private void ProcessGenericFeed( HashSet <Feed> feeds, CombinedAsset <FeedAttribute> feedAsset, IDictionary <Type, ExternalSystemAttribute> externalSystems, EntityTypeSuite entityTypes) { FeedAttribute genericFeedAttribute = this.GetGenericFeedAttribute(feedAsset, externalSystems); foreach (Type entityType in genericFeedAttribute.EntityTypes) { this.ValidateEntityType(entityType, entityTypes); this.AddFeed( feeds, new Feed( genericFeedAttribute.SourceSystem, entityType, feedAsset.AssetType, new[] { genericFeedAttribute })); } }
/// <summary> /// Assembles the suite of assets (i.e., external systems, entity types, feeds, /// etc.) found in all currently loaded assemblies. /// </summary> /// <returns>The suite of assets assembled.</returns> public AssetSuite AssembleAssets() { AssetSuite assetSuite; IDictionary <Type, ExternalSystemAttribute> externalSystems = this.GetExternalSystems(); IDictionary <Type, SourceSystemParametersAttribute> sourceSystemParameters = this.assetExtractor.GetSourceSystemParameters(); EntityTypeSuite entityTypes = this.GetEntityTypes(externalSystems); ConnectorSuite sinks = this.GetSinks(externalSystems, entityTypes); ConnectorSuite cacheFeeds = this.GetCacheFeeds(externalSystems, entityTypes); IEnumerable <Feed> feeds = this.GetFeeds(externalSystems, entityTypes); assetSuite = this.AssembleAssets( externalSystems, sourceSystemParameters, entityTypes, sinks, cacheFeeds, feeds); this.ValidateAssetSuite(assetSuite); return(assetSuite); }
private void ProcessNonGenericFeedAsset( HashSet <Feed> feeds, CombinedAsset <FeedAttribute> feedAsset, IDictionary <Type, ExternalSystemAttribute> externalSystems, EntityTypeSuite entityTypes) { FeedAttribute defaultAttribute = this.GetDefaultFeedAttribute(feedAsset); IDictionary <Type, FeedAttribute> entityTypeFeedAttributes = this.GetEntityTypeFeedAttributes(feedAsset); foreach (Type feedImplementation in this.GetInterfaceImplementations(feedAsset.AssetType, typeof(IFeed <>))) { Type entityType = this.ExtractEntityType(feedImplementation); this.ValidateEntityType(entityType, entityTypes); IEnumerable <FeedAttribute> feedAttributes = this.GetFeedAttributes( feedAsset.AssetType, entityType, defaultAttribute, entityTypeFeedAttributes); Type sourceSystem = this.GetFeedSourceSystem( feedAsset.AssetType, entityType, feedAttributes, externalSystems); this.AddFeed( feeds, new Feed( sourceSystem, entityType, feedAsset.AssetType, feedAttributes)); } this.VerifyEachEntityTypeHasMatchingInterfaceImplementation( feedAsset.AssetType, entityTypeFeedAttributes); }
private void AddEntityTypeConnectors( IDictionary <Type, Type> entityTypeConnectors, Type connectorAssetType, Type genericInterfaceType, EntityTypeSuite entityTypes, string multipleAssetsDefinedForEntityTypeExceptionMessageFormat) { foreach (Type interfaceImplementation in this.GetInterfaceImplementations(connectorAssetType, genericInterfaceType)) { Type entityType = this.ExtractEntityType(interfaceImplementation); this.ValidateEntityType(entityType, entityTypes); if (!entityTypeConnectors.ContainsKey(entityType)) { entityTypeConnectors.Add(entityType, connectorAssetType); } else { throw new InvalidOperationException(string.Format( multipleAssetsDefinedForEntityTypeExceptionMessageFormat, entityType.FullName)); } } }