public JMXSchemaProviderDB(string connectionString, ILogger logger) { connectionString.NullTest(nameof(connectionString)); logger.NullTest(nameof(logger)); _logger = logger; _isLocalLog = false; _cn = connectionString; string dbProviderName = new ConnectInfo(connectionString).ProviderName; if (_counter == 0) { ImplementsList.Add(typeof(ISchemaDBSync)); } _syncronizer = GetSyncronizer(dbProviderName); _syncronizer.SchemaProvider = this; _syncronizer.Logger = logger; if (_counter == 0) { using (var mdb = new MdbContext(_cn)) { if (!_syncronizer.TestSysCatAsync(mdb).GetAwaiter().GetResult()) { _syncronizer.CreateDbSchemaAsync(mdb).GetAwaiter().GetResult(); } _defaultDbSchema = _syncronizer.GetDefaultDbSchemaAsync(mdb).GetAwaiter().GetResult(); Interlocked.Increment(ref _counter); } } }
private void CreateTypesListSpeedTest() { using (FileLog _logger = typeof(FileLog).CreateInstance <FileLog>(new object[] { "ORMSchemaTest", new FileLogSettings() { DateFolderMask = "yyyy-MM-dd" } })) { _logger.Debug("List implements IDataReader"); ImplementsList.Add(typeof(IDataReader)); foreach (var s in ImplementsList.GetTypes(typeof(IDataReader))) { _logger.Debug(s.FullName); } _logger.Debug("Start speed test for find implements IDataReader"); for (int i = 0; i < 1000000; i++) { var l = ImplementsList.GetTypes(typeof(IDataReader)).ToArray(); } //ImplementsList.Add(typeof(IDataReader)); //foreach (var s in ImplementsList.GetTypes(typeof(IDataReader))) // _logger.Debug(s.FullName); //_logger.Debug("Start speed test for find implements IDataReader"); //for (int i = 0; i < 1000000; i++) //{ // var l = ImplementsList.GetTypes(typeof(IDataReader)).ToArray(); //} _logger.Debug("Finish speed test"); } }
private static IAppEvaluator CreateEvaluator(ActionInfo ai, DataPackage inParamStor) { var inParams = ai.InterfaceParameters.Where(kvp => kvp.Value.Dirrect == ParamDirrect.Input && kvp.Value.Required).Select(kvp => kvp.Value); int pCount = inParams.Count(); if (inParamStor != null) { inParamStor.GoDataTop(); } if (pCount > 0 && (inParamStor == null || inParamStor.FieldCount < pCount || !inParamStor.Read())) { throw new InvalidOperationException( Strings.S031_MetaStack_Core_Actions_CreateEvaluator_2 .ToFormat(ai.ActionID, ai.InterfaceID)); } else if (pCount > 0) { foreach (ParamInfo pi in inParams) { try { var val = inParamStor[pi.ParameterID]; } catch { throw new InvalidOperationException( Strings.S031_MetaStack_Core_Actions_CreateEvaluator_1 .ToFormat(ai.InterfaceID, pi.ParameterID, ai.ActionID)); } } inParamStor.GoDataTop(); } if (!_loadedTypesCache.TryGetValue(ai.ClassName, out Type type)) { var a = LoadAssembly(ai.AssemblyID); ImplementsList.Add(typeof(IAppEvaluator), a); type = ImplementsList.GetTypes(typeof(IAppEvaluator)) .FirstOrDefault(t => t.FullName.Equals(ai.ClassName, StringComparison.Ordinal)); _loadedTypesCache.TryAdd(ai.ClassName, type); } return(type.CreateInstance <IAppEvaluator>()); }
public static void RegisterProvider <T>() where T : class, IJMXSchemaProvider { ImplementsList.Add(typeof(IJMXSchemaProvider)); }