Beispiel #1
0
        private void GenericCreate(Func <TestRepository, IDbCommand, int> custom, RepositoryOperations options)
        {
            TestRepository proxy;
            IDbConnection  connection;
            IDbCommand     command;

            InitializeProxy(out proxy, out connection, out command);
            proxy.Operations = options;
            int called = custom(proxy, command);

            DefaultAsserts(connection, command, called);

            if (options.HasFlag(RepositoryOperations.CacheExtendedDatabaseInformation))
            {
                Assert.IsTrue(proxy.ExtendedInformationCacheSize > 0);
            }
            else
            {
                Assert.AreEqual(0, proxy.ExtendedInformationCacheSize);
            }

            proxy.Dispose();

            if (options.HasFlag(RepositoryOperations.CacheExtendedDatabaseInformation))
            {
                Assert.AreEqual(0, proxy.ExtendedInformationCacheSize);
            }

            if (proxy.Operations.HasFlag(RepositoryOperations.LogQueryExecutionTime))
            {
                Console.WriteLine($"Query Execution Time: {proxy.QueryExecutionTime}");
            }
            if (proxy.Operations.HasFlag(RepositoryOperations.LogTotalExecutionTime))
            {
                Console.WriteLine($"Total Execution Time: {proxy.TotalExecutionTime}");
            }
        }
        private ExtendedDatabaseInformationAttribute GetExtendedInformation(MethodInfo mi)
        {
            ExtendedDatabaseInformationAttribute result = null;

            if (_operations.HasFlag(RepositoryOperations.CacheExtendedDatabaseInformation))
            {
                string name = mi.Name;
                if (_cache.ContainsKey(name) == false)
                {
                    result = mi.GetCustomAttribute <ExtendedDatabaseInformationAttribute>();
                    _cache.Add(name, result);
                }
                else
                {
                    result = _cache[name];
                }
            }
            else
            {
                result = mi.GetCustomAttribute <ExtendedDatabaseInformationAttribute>();
            }

            return(result);
        }