// Helper internal static bool IsEnsureUpdateStoreNeeded(Type interfaceType) { using (TimerProfilerFacade.CreateTimerProfiler()) { DataTypeDescriptor newDataTypeDescriptor; if (!TryGetDataTypeDescriptor(interfaceType, out newDataTypeDescriptor)) { newDataTypeDescriptor = BuildNewDataTypeDescriptor(interfaceType); } var oldDataTypeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(newDataTypeDescriptor.DataTypeId); if (oldDataTypeDescriptor == null) { DataMetaDataFacade.PersistMetaData(newDataTypeDescriptor); return(false); } var dataTypeChangeDescriptor = new DataTypeChangeDescriptor(oldDataTypeDescriptor, newDataTypeDescriptor); if (!dataTypeChangeDescriptor.AlteredTypeHasChanges) { return(false); } return(dataTypeChangeDescriptor.AlteredTypeHasChanges); } }
// Helper internal static bool EnsureUpdateStore(Type interfaceType, string providerName, bool makeAFlush) { using (TimerProfilerFacade.CreateTimerProfiler(interfaceType.ToString())) { var newDataTypeDescriptor = BuildNewDataTypeDescriptor(interfaceType); var oldDataTypeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(newDataTypeDescriptor.DataTypeId); if (oldDataTypeDescriptor == null) { DataMetaDataFacade.PersistMetaData(newDataTypeDescriptor); return(false); } var dataTypeChangeDescriptor = new DataTypeChangeDescriptor(oldDataTypeDescriptor, newDataTypeDescriptor); if (!dataTypeChangeDescriptor.AlteredTypeHasChanges) { return(false); } Log.LogVerbose("DynamicTypeManager", "Updating the store for interface type '{0}' on the '{1}' data provider", interfaceType, providerName); var updateDataTypeDescriptor = new UpdateDataTypeDescriptor(oldDataTypeDescriptor, newDataTypeDescriptor, providerName); AlterStore(updateDataTypeDescriptor, makeAFlush); return(true); } }
/// <exclude /> public void UpdateDataTypeDescriptor(DataTypeDescriptor dataTypeDescriptor, bool flushTheSystem) { dataTypeDescriptor.Validate(); DataMetaDataFacade.PersistMetaData(dataTypeDescriptor); if (flushTheSystem) { GlobalEventSystemFacade.FlushTheSystem(); } }
// Helper internal static bool EnsureUpdateStore(Type interfaceType, string providerName, bool makeAFlush) { using (TimerProfilerFacade.CreateTimerProfiler(interfaceType.ToString())) { var newDataTypeDescriptor = BuildNewDataTypeDescriptor(interfaceType); var oldDataTypeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(newDataTypeDescriptor.DataTypeId); if (interfaceType.IsGenerated()) { var customFields = oldDataTypeDescriptor.Fields.Where(f => !f.Inherited && !oldDataTypeDescriptor.KeyPropertyNames .Contains(f.Name)); foreach (var field in customFields) { newDataTypeDescriptor.Fields.Remove(newDataTypeDescriptor.Fields[field.Name]); newDataTypeDescriptor.Fields.Add(field); } } if (oldDataTypeDescriptor == null) { DataMetaDataFacade.PersistMetaData(newDataTypeDescriptor); return(false); } var dataTypeChangeDescriptor = new DataTypeChangeDescriptor(oldDataTypeDescriptor, newDataTypeDescriptor); if (!dataTypeChangeDescriptor.AlteredTypeHasChanges) { if (dataTypeChangeDescriptor.TypeHasMetaDataChanges) { Log.LogInformation(nameof(DynamicTypeManager), $"Updating data type descriptor for type '{newDataTypeDescriptor.GetFullInterfaceName()}'"); DataMetaDataFacade.PersistMetaData(newDataTypeDescriptor); } return(false); } Log.LogVerbose(nameof(DynamicTypeManager), "Updating the store for interface type '{0}' on the '{1}' data provider", interfaceType, providerName); var updateDataTypeDescriptor = new UpdateDataTypeDescriptor(oldDataTypeDescriptor, newDataTypeDescriptor, providerName); AlterStore(updateDataTypeDescriptor, makeAFlush); return(true); } }
/// <exclude /> public void AlterStore(UpdateDataTypeDescriptor updateDataTypeDescriptor, bool forceCompile) { DataTypeChangeDescriptor dataTypeChangeDescriptor = updateDataTypeDescriptor.CreateDataTypeChangeDescriptor(); dataTypeChangeDescriptor.AlteredType.Validate(); using (var transactionScope = TransactionsFacade.CreateNewScope()) { DataMetaDataFacade.PersistMetaData(dataTypeChangeDescriptor.AlteredType); if (dataTypeChangeDescriptor.AlteredTypeHasChanges) { DataProviderPluginFacade.AlterStore(updateDataTypeDescriptor, forceCompile); } transactionScope.Complete(); } }
/// <exclude /> public void CreateStores(string providerName, IReadOnlyCollection <DataTypeDescriptor> typeDescriptors, bool doFlush) { Verify.ArgumentNotNullOrEmpty(providerName, "providerName"); Verify.ArgumentNotNull(typeDescriptors, "typeDescriptors"); typeDescriptors.ForEach(d => d.Validate()); using (var transactionScope = TransactionsFacade.CreateNewScope()) { foreach (var typeDescriptor in typeDescriptors) { DataMetaDataFacade.PersistMetaData(typeDescriptor); } DataProviderPluginFacade.CreateStores(providerName, typeDescriptors); transactionScope.Complete(); } if (doFlush) { GlobalEventSystemFacade.FlushTheSystem(); } }