// Constructors public DomainModelConverter( HandlerAccessor handlers, ITypeIdProvider typeIdProvider, PartialIndexFilterCompiler compiler, MappingResolver resolver, IFullTextCatalogNameBuilder fulltextCatalogNameBuilder, bool isUpgradingStage) { ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); ArgumentValidator.EnsureArgumentNotNull(typeIdProvider, "typeIdProvider"); ArgumentValidator.EnsureArgumentNotNull(compiler, "compiler"); ArgumentValidator.EnsureArgumentNotNull(resolver, "resolver"); this.handlers = handlers; this.compiler = compiler; this.typeIdProvider = typeIdProvider; this.resolver = resolver; this.isUpgradingStage = isUpgradingStage; this.fulltextCatalogNameBuilder = fulltextCatalogNameBuilder; sourceModel = handlers.Domain.Model; configuration = handlers.Domain.Configuration; providerInfo = handlers.ProviderInfo; driver = handlers.StorageDriver; nameBuilder = handlers.NameBuilder; FieldMapping = new Dictionary <StoredFieldInfo, StoredFieldInfo>(); StorageModel = null; CurrentModelTypes = new Dictionary <string, StoredTypeInfo>(); }
// Constructors public UpgradeHintsProcessor( HandlerAccessor handlers, MappingResolver resolver, StoredDomainModel currentDomainModel, StoredDomainModel extractedDomainModel, StorageModel extractedStorageModel, bool autoDetectTypesMovements) { ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); ArgumentValidator.EnsureArgumentNotNull(resolver, "resolver"); ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, "currentDomainModel"); ArgumentValidator.EnsureArgumentNotNull(extractedDomainModel, "extractedDomainModel"); ArgumentValidator.EnsureArgumentNotNull(extractedStorageModel, "extractedStorageModel"); typeMapping = new Dictionary <StoredTypeInfo, StoredTypeInfo>(); reverseTypeMapping = new Dictionary <StoredTypeInfo, StoredTypeInfo>(); fieldMapping = new Dictionary <StoredFieldInfo, StoredFieldInfo>(); reverseFieldMapping = new Dictionary <StoredFieldInfo, StoredFieldInfo>(); this.resolver = resolver; nameBuilder = handlers.NameBuilder; domainModel = handlers.Domain.Model; this.extractedStorageModel = extractedStorageModel; currentModel = currentDomainModel; currentTypes = currentModel.Types.ToDictionary(t => t.UnderlyingType); extractedModel = extractedDomainModel; extractedTypes = extractedModel.Types.ToDictionary(t => t.UnderlyingType); this.autoDetectTypesMovements = autoDetectTypesMovements; hints = new NativeTypeClassifier <UpgradeHint>(true); suspiciousTypes = new List <StoredTypeInfo>(); }
public void Setup() { _handler = new HandlerAccessor(HttpActionExecutedContext) { InnerHandler = new InstrumentActionMessageHandler { InnerHandler = new FakeHandler(HttpActionExecutedContext) } }; }
public void Setup() { _handler = new HandlerAccessor(HttpActionExecutedContext) { InnerHandler = new InstrumentActionMessageHandler { InnerHandler = new FakeHandler(HttpActionExecutedContext) } }; }
// Constructors internal Domain(DomainConfiguration configuration, object upgradeContextCookie, SqlConnection singleConnection, DefaultSchemaInfo defaultSchemaInfo) { Configuration = configuration; Handlers = new HandlerAccessor(this); GenericKeyFactories = new ConcurrentDictionary <TypeInfo, GenericKeyFactory>(); RecordSetReader = new RecordSetReader(this); KeyGenerators = new KeyGeneratorRegistry(); PrefetchFieldDescriptorCache = new ConcurrentDictionary <TypeInfo, ReadOnlyList <PrefetchFieldDescriptor> >(); KeyCache = new LruCache <Key, Key>(Configuration.KeyCacheSize, k => k); QueryCache = new LruCache <object, Pair <object, TranslatedQuery> >(Configuration.QueryCacheSize, k => k.First); PrefetchActionMap = new Dictionary <TypeInfo, Action <SessionHandler, IEnumerable <Key> > >(); Extensions = new ExtensionCollection(); UpgradeContextCookie = upgradeContextCookie; SingleConnection = singleConnection; StorageNodeManager = new StorageNodeManager(Handlers); }
// Constructors internal Domain(DomainConfiguration configuration, object upgradeContextCookie, SqlConnection singleConnection) { Configuration = configuration; Handlers = new HandlerAccessor(this); GenericKeyFactories = new ConcurrentDictionary <TypeInfo, GenericKeyFactory>(); EntityDataReader = new EntityDataReader(this); KeyGenerators = new KeyGeneratorRegistry(); PrefetchFieldDescriptorCache = new ConcurrentDictionary <TypeInfo, ReadOnlyList <PrefetchFieldDescriptor> >(); KeyCache = new LruCache <Key, Key>(Configuration.KeyCacheSize, k => k); QueryCache = new FastConcurrentLruCache <object, Pair <object, ParameterizedQuery> >(Configuration.QueryCacheSize, k => k.First); PrefetchActionMap = new Dictionary <TypeInfo, Action <SessionHandler, IEnumerable <Key> > >(); Extensions = new ExtensionCollection(); UpgradeContextCookie = upgradeContextCookie; SingleConnection = singleConnection; StorageNodeManager = new StorageNodeManager(Handlers); isDebugEventLoggingEnabled = OrmLog.IsLogged(LogLevel.Debug); // Just to cache this value }
// Constructors public UpgradeHintsProcessor( HandlerAccessor handlers, MappingResolver resolver, StoredDomainModel currentDomainModel, StoredDomainModel extractedDomainModel, StorageModel extractedStorageModel, bool autoDetectTypesMovements) { ArgumentValidator.EnsureArgumentNotNull(handlers, nameof(handlers)); ArgumentValidator.EnsureArgumentNotNull(resolver, nameof(resolver)); ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, nameof(currentDomainModel)); ArgumentValidator.EnsureArgumentNotNull(extractedDomainModel, nameof(extractedDomainModel)); ArgumentValidator.EnsureArgumentNotNull(extractedStorageModel, nameof(extractedStorageModel)); // since type mapping is intersection of current types and extracted types // it will be equal or less than min size of these two sets var typesCapacity = currentDomainModel.Types.Length > extractedDomainModel.Types.Length ? extractedDomainModel.Types.Length : currentDomainModel.Types.Length; // By setting capacity we eliminate resize work and memory fluctuations. // In the worst case, when almost all types don't intersect, we will have some waste of memory // but in real life this is very rare case. typeMapping = new Dictionary <StoredTypeInfo, StoredTypeInfo>(typesCapacity); reverseTypeMapping = new Dictionary <StoredTypeInfo, StoredTypeInfo>(typesCapacity); fieldMapping = new Dictionary <StoredFieldInfo, StoredFieldInfo>(); reverseFieldMapping = new Dictionary <StoredFieldInfo, StoredFieldInfo>(); this.resolver = resolver; nameBuilder = handlers.NameBuilder; domainModel = handlers.Domain.Model; this.extractedStorageModel = extractedStorageModel; currentModel = currentDomainModel; currentTypes = currentModel.Types.ToDictionary(t => t.UnderlyingType, StringComparer.Ordinal, currentModel.Types.Length); extractedModel = extractedDomainModel; extractedTypes = extractedModel.Types.ToDictionary(t => t.UnderlyingType, StringComparer.Ordinal, extractedModel.Types.Length); this.autoDetectTypesMovements = autoDetectTypesMovements; hints = new NativeTypeClassifier <UpgradeHint>(true); suspiciousTypes = new HashSet <StoredTypeInfo>(); }
// Constructors public HintGenerator(Dictionary <StoredTypeInfo, StoredTypeInfo> typeMapping, Dictionary <StoredTypeInfo, StoredTypeInfo> reverseTypeMapping, Dictionary <StoredFieldInfo, StoredFieldInfo> fieldMapping, NativeTypeClassifier <UpgradeHint> hints, HandlerAccessor handlers, MappingResolver resolver, StorageModel extractedStorageModel, StoredDomainModel currentDomainModel, StoredDomainModel extractedDomainModel) { ArgumentValidator.EnsureArgumentNotNull(typeMapping, "typeMapping"); ArgumentValidator.EnsureArgumentNotNull(reverseTypeMapping, "reverseTypeMapping"); ArgumentValidator.EnsureArgumentNotNull(fieldMapping, "fieldMapping"); ArgumentValidator.EnsureArgumentNotNull(hints, "hints"); ArgumentValidator.EnsureArgumentNotNull(handlers, "handlers"); ArgumentValidator.EnsureArgumentNotNull(resolver, "resolver"); ArgumentValidator.EnsureArgumentNotNull(extractedStorageModel, "extractedStorageModel"); ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, "currentDomainModel"); ArgumentValidator.EnsureArgumentNotNull(extractedDomainModel, "extractedDomainModel"); this.typeMapping = typeMapping; this.reverseTypeMapping = reverseTypeMapping; this.fieldMapping = fieldMapping; this.hints = hints; extractedModelFields = new Dictionary <StoredTypeInfo, StoredFieldInfo[]>(); this.extractedStorageModel = extractedStorageModel; this.resolver = resolver; nameBuilder = handlers.NameBuilder; currentModel = currentDomainModel; currentModel.UpdateReferences(); extractedModel = extractedDomainModel; foreach (var type in extractedModel.Types) { extractedModelFields.Add(type, type.Fields.Flatten(f => f.Fields, null, true).ToArray()); } }
// Constructors public HintGenerator(UpgradeHintsProcessingResult hintsProcessingResult, HandlerAccessor handlers, MappingResolver resolver, StorageModel extractedStorageModel, StoredDomainModel currentDomainModel, StoredDomainModel extractedDomainModel) { ArgumentValidator.EnsureArgumentNotNull(hintsProcessingResult, nameof(hintsProcessingResult)); ArgumentValidator.EnsureArgumentNotNull(handlers, nameof(handlers)); ArgumentValidator.EnsureArgumentNotNull(resolver, nameof(resolver)); ArgumentValidator.EnsureArgumentNotNull(extractedStorageModel, nameof(extractedStorageModel)); ArgumentValidator.EnsureArgumentNotNull(currentDomainModel, nameof(currentDomainModel)); ArgumentValidator.EnsureArgumentNotNull(extractedDomainModel, nameof(extractedDomainModel)); typeMapping = hintsProcessingResult.TypeMapping; reverseTypeMapping = hintsProcessingResult.ReverseTypeMapping; fieldMapping = hintsProcessingResult.FieldMapping; hints = hintsProcessingResult.Hints; suspiciousTypes = hintsProcessingResult.SuspiciousTypes; currentNonConnectorTypes = hintsProcessingResult.CurrentNonConnectorTypes; extractedNonConnectorTypes = hintsProcessingResult.ExtractedNonConnectorTypes; this.extractedStorageModel = extractedStorageModel; this.resolver = resolver; nameBuilder = handlers.NameBuilder; currentModel = currentDomainModel; currentModel.UpdateReferences(); extractedModelFields = new Dictionary <StoredTypeInfo, StoredFieldInfo[]>(); extractedModel = extractedDomainModel; foreach (var type in extractedModel.Types) { extractedModelFields.Add(type, type.Fields.Flatten(f => f.Fields, null, true).ToArray()); } }
private IUpgradeHintsProcessor GetHintProcessor(StoredDomainModel currentDomainModel, StorageModel extractedSchema, HandlerAccessor handlers) { var oldModel = context.ExtractedDomainModel; var stage = context.Stage; if (stage == UpgradeStage.Upgrading && oldModel != null) { return(new UpgradeHintsProcessor(handlers, context.Services.MappingResolver, currentDomainModel, oldModel, extractedSchema, context.TypesMovementsAutoDetection)); } if (context.UpgradeMode == DomainUpgradeMode.Validate && oldModel != null) { return(new UpgradeHintsProcessor(handlers, context.Services.MappingResolver, currentDomainModel, oldModel, extractedSchema, false)); } return(new NullUpgradeHintsProcessor(currentDomainModel)); }
public SqlCompiler(HandlerAccessor handlers, CompilerConfiguration configuration) : base(handlers, configuration) { }
// Constructors internal StorageNodeManager(HandlerAccessor handlers) { this.handlers = handlers; }
internal void Initialize(HandlerAccessor handlers) { Handlers = handlers; Initialize(); }
public static ModelMapping Build(HandlerAccessor handlers, SchemaExtractionResult sqlModel, MappingResolver resolver, NodeConfiguration nodeConfiguration, bool isLegacy) { var domainModel = handlers.Domain.Model; var configuration = handlers.Domain.Configuration; var providerInfo = handlers.ProviderInfo; var mapping = new ModelMapping(); // Register persistent types var typesToProcess = domainModel.Types.AsEnumerable(); if (isLegacy || configuration.IsMultidatabase) { typesToProcess = typesToProcess.Where(t => !t.IsSystem); } foreach (var type in typesToProcess) { var primaryIndex = type.Indexes.FindFirst(IndexAttributes.Real | IndexAttributes.Primary); if (primaryIndex == null || primaryIndex.IsAbstract) { continue; } var reflectedType = primaryIndex.ReflectedType; var nodeName = resolver.GetNodeName(reflectedType); var storageTable = resolver.Resolve(sqlModel, nodeName).GetTable(); if (storageTable == null) { throw new DomainBuilderException(String.Format(Strings.ExTableXIsNotFound, nodeName)); } mapping.Register(reflectedType, storageTable); } // Register key generators var keyGenerator = domainModel.Hierarchies .Select(h => h.Key.Sequence) .Where(s => s != null) .Distinct(); Func <MappingResolveResult, SchemaNode> nodeResolver; if (providerInfo.Supports(ProviderFeatures.Sequences)) { nodeResolver = r => r.GetSequence(); } else { nodeResolver = r => r.GetTable(); } foreach (var sequence in keyGenerator) { var nodeResult = resolver.Resolve(sqlModel, resolver.GetNodeName(sequence)); var node = nodeResolver.Invoke(nodeResult); mapping.Register(sequence, node); } // Fill information for TemporaryTableManager var defaultSchema = resolver.ResolveSchema(sqlModel, configuration.DefaultDatabase, configuration.DefaultSchema); if (configuration.ShareStorageSchemaOverNodes && handlers.ProviderInfo.Supports(ProviderFeatures.Multischema)) { mapping.TemporaryTableDatabase = nodeConfiguration.GetActualNameFor(defaultSchema.Catalog); mapping.TemporaryTableSchema = nodeConfiguration.GetActualNameFor(defaultSchema); } else { mapping.TemporaryTableDatabase = defaultSchema.Catalog.GetNameInternal(); mapping.TemporaryTableSchema = defaultSchema.GetNameInternal(); } if (providerInfo.Supports(ProviderFeatures.Collations)) { if (!string.IsNullOrEmpty(configuration.Collation)) { // If user explicitly specified collation use that mapping.TemporaryTableCollation = configuration.Collation; } else { // Otherwise use first available collation var collation = defaultSchema.Collations.FirstOrDefault(); mapping.TemporaryTableCollation = collation != null ? collation.Name : null; } } mapping.Lock(); return(mapping); }