コード例 #1
0
        // Loads a setup from a dll file thats implements the ISetup interface
        private void InitializeConfiguration()
        {
            try
            {
                ISetup setup = InterfaceLoader.Get <ISetup>();
                if (setup is null)
                {
                    throw new Exception("Could not find external configuration");
                }

                setup.Initialize(Configuration);
            }
            catch
            {
                Configuration = new Configuration();
            }
        }
コード例 #2
0
        private static async Task <bool> RunSetup(ISetup operation, bool Depends = true)
        {
            var depends = operation.GetType().GetCustomAttributes(typeof(DependsAttribute), true).FirstOrDefault() as DependsAttribute;

            if (Depends && depends != null)
            {
                foreach (var depend in depends.Depends)
                {
                    if (!await RunSetup(depend).ConfigureAwait(false))
                    {
                        Logger.Error($"Failed to run operation {depend}");
                    }
                }
            }

            var name = operation.GetType().GetCustomAttributes(typeof(OperationAttribute), true).FirstOrDefault() as OperationAttribute;

            var start = DateTime.UtcNow;

            Logger.Info("**************************************************************");
            Logger.Info($"   Running operation {name.Name}");
            Logger.Info("**************************************************************");


            if (!await operation.Initialize().ConfigureAwait(false))
            {
                Logger.Info("ERROR - Failed to seed entities!");
                return(false);
            }

            Logger.Info("**************************************************************");
            Logger.Info($"   Finished operation {name.Name} in {DateTime.UtcNow - start}");
            Logger.Info("**************************************************************");

            return(true);
        }