Example #1
0
            public ConstructorCacheKey(Type type, object[] parameters)
            {
                string key = type.GetSafeFullName();

                foreach (var parameter in parameters)
                {
                    key += "_" + ObjectToStringHelper.ToFullTypeString(parameter);
                }

                Key       = key;
                _hashCode = Key.GetHashCode();
            }
Example #2
0
            public ConstructorCacheKey(Type type, bool autoCompleteDependecies, object[] parameters)
            {
                string key = type.GetSafeFullName(true);

                foreach (var parameter in parameters)
                {
                    key += "_" + ObjectToStringHelper.ToFullTypeString(parameter);
                }

                Key = key;
                AutoCompleteDependecies = autoCompleteDependecies;
                _hashCode = Key.GetHashCode();
            }
Example #3
0
        private static async Task <bool> ClosingAsync(CloseApplicationWatcherBase watcher)
        {
            try
            {
                Log.Debug($"Executing ClosingAsync() for '{ObjectToStringHelper.ToFullTypeString(watcher)}'");

                var result = await watcher.ClosingAsync();

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Failed to execute ClosingAsync() for '{ObjectToStringHelper.ToFullTypeString(watcher)}'");
                throw;
            }
        }
 public void ReturnsTypeNameForInt()
 {
     Assert.AreEqual("System.Int32", ObjectToStringHelper.ToFullTypeString(42));
 }
 public void ReturnsDbNullStringForDbNullInstance()
 {
     Assert.AreEqual("System.DBNull", ObjectToStringHelper.ToFullTypeString(DBNull.Value));
 }
 public void ReturnsNullStringForNullInstance()
 {
     Assert.AreEqual("null", ObjectToStringHelper.ToFullTypeString(null));
 }
        /// <summary>
        /// Sets the transaction level of the specified <see cref="DbContext"/>.
        /// </summary>
        /// <param name="dbContext">The db context.</param>
        /// <param name="isolationLevel">The isolation level to set.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="dbContext"/> is <c>null</c>.</exception>
        public static void SetTransactionLevel(this DbContext dbContext, IsolationLevel isolationLevel)
        {
            Argument.IsNotNull(() => dbContext);

            Log.Info("Setting transaction isolation level to '{0}' for DbContext '{1}'", isolationLevel, ObjectToStringHelper.ToFullTypeString(dbContext));

            var sqlCommand    = IsolationHelper.TranslateTransactionLevelToSql(isolationLevel);
            var objectContext = dbContext.GetObjectContext();

            objectContext.ExecuteStoreCommand(sqlCommand);
        }
Example #8
0
        public static Task <bool?> ShowWizardAsync <TWizard>(this IWizardService wizardService, object model = null)
            where TWizard : IWizard
        {
            Argument.IsNotNull(() => wizardService);

            var typeFactory = wizardService.GetTypeFactory();

            IWizard wizard = null;

            if (model is not null)
            {
                Log.Debug("Creating wizard '{0}' with model '{1}'", typeof(TWizard).GetSafeFullName(false), ObjectToStringHelper.ToFullTypeString(model));

                wizard = typeFactory.CreateInstanceWithParametersAndAutoCompletion <TWizard>(model);
            }
            else
            {
                Log.Debug("Creating wizard '{0}'", typeof(TWizard).GetSafeFullName(false));

                wizard = typeFactory.CreateInstance <TWizard>();
            }

            return(wizardService.ShowWizardAsync(wizard));
        }