Esempio n. 1
0
        /// <summary>
        ///     Checks if the Database should reset.
        /// </summary>
        private static void CheckDatabaseReset()
        {
            // Init reset procedure if database reset wanted.
            if (ParameterHandler.GetValue("ResetDatabase") == null)
            {
                return;
            }

            const string database         = "EvoMpGtMpServer";
            string       connectionString = "Data Source=(localdb)\\MSSQLLocalDB;" +
                                            //"Initial Catalog=master" +
                                            ";Integrated Security=True;" +
                                            $"Connect Timeout=30;" +
                                            $"Encrypt=False;" +
                                            $"TrustServerCertificate=True;" +
                                            $"ApplicationIntent=ReadWrite;" +
                                            "MultiSubnetFailover=False;" +
                                            "MultipleActiveResultSets = True;";

            // Write console output
            ConsoleOutput.WriteLine(ConsoleType.Database, $"Deleting Database ~o~{database}~;~.");
            string        sqlCommandText = $"DROP DATABASE {database}";
            SqlConnection connection     = new SqlConnection(connectionString);

            connection.Open();
            SqlCommand sqlCommand = new SqlCommand(sqlCommandText, connection);

            sqlCommand.ExecuteNonQuery();
            connection.Close();
            ConsoleOutput.WriteLine(ConsoleType.Database, $"Database ~o~{database}~;~ deleted.");
        }
Esempio n. 2
0
        /// <summary>
        ///     Gets the given server gamemodes.
        ///     The gamemodes are used to load modules filtered.
        ///     If no gamemodes given, any modules would be loaded.
        /// </summary>
        /// <returns>Array[string] with server gamemodes</returns>
        public static string[] GetServerGamemodes()
        {
            // Set defaults
            ParameterHandler.SetDefault("Gamemode", "any");

            // ServerType already setten -> return;
            if (_serverTypes != null)
            {
                return(_serverTypes);
            }

            List <string> serverGamemodes = ParameterHandler.GetValue("Gamemode").Split(',').ToList();

            serverGamemodes.ForEach(x => x = x.Trim());

            // Only default parameter gamemode value loaded -> warning
            if (ParameterHandler.IsDefault("Gamemode"))
            {
                ConsoleOutput.WriteLine(ConsoleType.Config,
                                        $"~-^-~The server started without defined gamemodes, so the default value~o~ \"any\"~;~ was used. " +
                                        $"Nevertheless, it is strongly advised to include the desired gamemodes, " +
                                        $"because mode ~o~\"any\"~;~ could have massive side effects.~-v-~");
            }

            // Shared is always needed
            serverGamemodes.Add("shared");

            // Cast to array
            _serverTypes = serverGamemodes.ToArray();
            return(_serverTypes);
        }
Esempio n. 3
0
        public ThriftMethodHandler(ThriftMethodMetadata methodMetadata, ThriftCodecManager codecManager)
        {
            this.QualifiedName         = methodMetadata.QualifiedName;
            this.Name                  = methodMetadata.Name;
            this._invokeAsynchronously = methodMetadata.IsAsync;
            this._oneway               = !_invokeAsynchronously && methodMetadata.IsOneWay;

            ParameterHandler[] parameters = new ParameterHandler[methodMetadata.Parameters.Count()];

            foreach (var fieldMetadata in methodMetadata.Parameters)
            {
                ThriftParameterInjection parameter = (ThriftParameterInjection)fieldMetadata.Injections.First();

                ParameterHandler handler = new ParameterHandler(
                    fieldMetadata.Id,
                    fieldMetadata.Name,
                    codecManager.GetCodec(fieldMetadata.ThriftType));

                parameters[parameter.ParameterIndex] = handler;
            }
            this._parameterCodecs = parameters;

            var builder = ImmutableDictionary.CreateBuilder <short, IThriftCodec>();

            foreach (var entry in methodMetadata.Exceptions)
            {
                builder.Add(entry.Key, codecManager.GetCodec(entry.Value));
            }
            _exceptionCodecs = builder.ToImmutableDictionary();

            // get the thrift codec for the return value
            _successCodec = codecManager.GetCodec(methodMetadata.ReturnType);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var             handler    = new ParameterHandler();
            var             parameters = handler.ToModel <QueryParameters>(@"--include (cs|json)$ --exclude obj  --verbose --match (\d+\.){2,3}\d+ -dir ./");
            DiskIoOperation operate    = new DiskIoOperation(parameters);

            operate.Print();
            // Directory.GetFiles("./").Select(f => new FileInfo(f)).Select(f => f.FullName).ToList().ForEach(Console.WriteLine);
        }
        public short LastRegisteredEvent()
        {
            ParameterHandler handler = new ParameterHandler();

            setParamHandler(handler);
            ExecuteSanscript("local integer l_tag; system 5156, l_tag; OLE_SetProperty(\"Result\", str(l_tag));", out _);

            return(short.Parse(handler.Result));
        }
        void SetParameters(ICallInfo call)
        {
            var parameterValues = call.Parameters.Select(p => p.Value).ToArray();

            if (!Controller.Attributes.IsRecursive)
            {
                ParameterHandler.Set(ActionSet, parameterValues);
            }
            else
            {
                ParameterHandler.Push(ActionSet, parameterValues);
            }
        }
 public WebService1()
 {
     _parameterHandler = new ParameterHandler();
     _debugLogHandler  = new DebugLogHandler();
     _serialPort       = SerialPortManager.Instance;
     _buadrate         = Int32.Parse(ConfigurationManager.AppSettings["buadrate"]);
     _portName         = ConfigurationManager.AppSettings["portName"];
     if (!_serialPort.IsOpen)
     {
         _serialPort.Open(_portName);
     }
     stackTrace = new StackTrace();
 }
Esempio n. 8
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
         return;
     }
     else
     {
         Destroy(this.gameObject);
         return;
     }
 }
Esempio n. 9
0
        public ALUResponse ProcessPayment(OrderDetails parameters)
        {
            var parameterHandler = new ParameterHandler(parameters);

            parameterHandler.CreateOrderRequestHash(this.SignatureKey);
            var requestData = parameterHandler.GetRequestData();

            //Console.WriteLine("Request is {0}", string.Join(", ", requestData.AllKeys.Select(key => key + ": " + requestData[key]).ToArray()));

            var response = ALURequest.SendRequest(this, requestData);

            //Console.WriteLine("Response: {0}", response);

            return(ALUResponse.FromString(response));
        }
Esempio n. 10
0
        public DbAccess()
        {
            // Get Database name from Parameter
            ParameterHandler.SetDefault("DatabaseName", "EvoMpGtMpServer");
            string dataBaseName = ParameterHandler.GetValue("DatabaseName");

            // Write console output
            ConsoleOutput.WriteLine(ConsoleType.Database, $"Database: ~#8effa3~{dataBaseName}");

            SetConnectionString();

            void SetConnectionString(bool force = false)
            {
                string dbConnectionString = Environment.GetEnvironmentVariable("EvoMp_dbConnectionString");

#if __MonoCS__
                string connectionString = "Data Source=localhost\\SQLEXPRESS;" +
                                          "Initial Catalog=" + dataBaseName + ";" +
                                          "User ID=EvoMp; " +
                                          "Password=evomp;" +
                                          "Integrated Security=True;" +
                                          "Connect Timeout=30;" +
                                          "Encrypt=False;" +
                                          "MultipleActiveResultSets=True;";
#else
                string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;" +
                                          "Initial Catalog=" + dataBaseName +
                                          ";Integrated Security=True;" +
                                          $"Connect Timeout=30;" +
                                          $"Encrypt=False;" +
                                          $"TrustServerCertificate=True;" +
                                          $"ApplicationIntent=ReadWrite;" +
                                          "MultiSubnetFailover=False;" +
                                          "MultipleActiveResultSets = True;";
#endif

                if (dbConnectionString == null || force)
                {
                    Environment.SetEnvironmentVariable("NameOrConnectionString", connectionString);
                }
                else
                {
                    Environment.SetEnvironmentVariable("NameOrConnectionString",
                                                       Environment.GetEnvironmentVariable("EvoMp_dbConnectionString"));
                }
            }
        }
Esempio n. 11
0
        public string RenderPaymentInputs(OrderDetails order)
        {
            var parameterHandler = new ParameterHandler(order, false);

            parameterHandler.CreateOrderRequestHash(this.SignatureKey);
            var requestData = parameterHandler.GetRequestData();

            var sb = new StringBuilder();

            foreach (var key in requestData.AllKeys)
            {
                sb.AppendFormat(@"<input type=""hidden"" name=""{0}"" value=""{1}"">", key, requestData[key]);
                sb.AppendLine();
            }

            return(sb.ToString());
        }
Esempio n. 12
0
        /*
         * // NOTE: This isn't applicable to C# - can't change accessibility
         * def ensureAccessible[T <: AccessibleObject](accessible: T): T = {
         *  if (!accessible.isAccessible) {
         *  accessible.setAccessible(true)
         *  }
         *  accessible
         * } */


        internal static ParameterHandler <TContext>[] GetParameterHandlers <TContext>(MethodBase method)
            where TContext : IContext
        {
            var methodParameters = method.GetParameters().ToArray();
            var handlers         = new ParameterHandler <TContext> [methodParameters.Length];

            for (var i = 0; i < methodParameters.Length; i++)
            {
                var parameter    = new MethodParameter(method, i);
                var contextClass = typeof(TContext);
                if (IsWithinBounds(parameter.ParameterType, typeof(IContext), contextClass))
                {
                    handlers[i] = new ContextParameterHandler <TContext>();
                }
                else if (typeof(IContext).IsAssignableFrom(parameter.ParameterType))
                {
                    throw new CloudStateException(
                              $"Unsupported context parameter on [{method.Name}], " +
                              $"[{parameter.ParameterType.Name}] must be the same or a super type of [{contextClass.Name}]"
                              );
                }
                else if (parameter.ParameterType == typeof(IServiceCallFactory))
                {
                    handlers[i] = new ServiceCallFactoryParameterHandler <TContext>();
                }
                else if (parameter.Attributes.Any(x => typeof(EntityIdAttribute) == x.GetType()))
                {
                    if (parameter.ParameterType != typeof(string))
                    {
                        throw new CloudStateException(
                                  $"[EntityIdAttribute] annotated parameter on method {method.Name} " +
                                  $"has type {parameter.ParameterType}, but must be String."
                                  );
                    }

                    handlers[i] = new EntityIdParameterHandler <TContext>();
                }
                else
                {
                    // TODO: revisit extra arguments implementation
                    handlers[i] = new MainArgumentParameterHandler <TContext>(parameter.ParameterType);
                }
            }

            return(handlers);
        }
Esempio n. 13
0
 public RefundResult PayCancel(RefundRequest refund)
 {
     try
     {
         refund.Merchant = merchant;
         var parameterHandler = new ParameterHandler(refund);
         var hashData         = parameterHandler.CreateOrderRequestHash(signatureKey);
         var requestData      = parameterHandler.GetRequestData();
         var requestHelper    = new RequestHelper <RefundResult>();
         var result           = requestHelper.SendRequest(refundEndPoint, requestData);
         return(result);
     }
     catch (PayuException ex)
     {
         //Exception loglanabilir..
     }
     return(new RefundResult());
 }
Esempio n. 14
0
        private void WriteArguments(TProtocol outProtocol, int sequenceId, Object[] args)
        {
            // Note that though setting message type to ONEWAY can be helpful when looking at packet
            // captures, some clients always send CALL and so servers are forced to rely on the "oneway"
            // attribute on thrift method in the interface definition, rather than checking the message
            // type.
            outProtocol.WriteMessageBegin(new TMessage(this.QualifiedName, _oneway ? TMessageType.Oneway : TMessageType.Call, sequenceId));

            // write the parameters
            TProtocolWriter writer = new TProtocolWriter(outProtocol);

            writer.WriteStructBegin(this.Name + "_args");
            for (int i = 0; i < args.Length; i++)
            {
                Object           value     = args[i];
                ParameterHandler parameter = _parameterCodecs[i];
                writer.WriteField(parameter.Name, parameter.Id, parameter.Codec, value);
            }
            writer.WriteStructEnd();

            outProtocol.WriteMessageEnd();
            outProtocol.Transport.Flush();
        }
Esempio n. 15
0
        /// <summary>
        ///     Refreshing the server resource modules.
        ///     Hint: Runs only if "DEBUG" constant is given
        /// </summary>
        public void CopyModulesToServer()
        {
#if !DEBUG
            if (ParameterHandler.IsDefault("onlyCopy"))
            {
                ConsoleOutput.WriteLine(ConsoleType.Core, "Release state. Copying modules skipped.");
                return;
            }
#endif
            ConsoleOutput.WriteLine(ConsoleType.Core,
                                    $"Refreshing server resource modules...");
            // Define constants for the folder top copy from and to copy to
            const string gtMpServerModulesFolder = @"./resources/EvoMp/dist";
            const string projectSolutionCompiledModulesFolder = @"./../EvoMp/";


            // Create the Modules folder in the resource if it doesnt exist
            if (!Directory.Exists(gtMpServerModulesFolder))
            {
                Directory.CreateDirectory(gtMpServerModulesFolder);
            }

            // Delete old modules
            List <string> oldModules = Directory.EnumerateFiles(gtMpServerModulesFolder, "EvoMp.Module.*.*",
                                                                SearchOption.AllDirectories)
                                       .Where(file => file.Contains("EvoMp.Module."))
                                       .ToList();

            // Get the DLLs from the project folders
            // (Including *.pdb files. Used for debugging)
            try
            {
                ConsoleOutput.AppendPrefix("\t");
                // Search for modules.
                List <string> newModules = Directory.EnumerateFiles(projectSolutionCompiledModulesFolder,
                                                                    "EvoMp.Module.*.*",
                                                                    SearchOption.AllDirectories).ToList();
                newModules = newModules.Select(file => file.Replace(@"\", "/")).ToList();

                newModules = newModules.Where(path => path.Contains("bin/"))
                             .Where(file =>
                                    file.ToLower().EndsWith("dll") || file.ToLower().EndsWith("pdb") ||
                                    file.ToLower().EndsWith("xml"))
                             .ToList();

                const string slash = "/";

                // Clean old modules wich existing as dll's in other modules
                foreach (string module in newModules.ToArray())
                {
                    // modulePath contains no "\" -> next
                    if (!module.Contains(slash))
                    {
                        continue;
                    }

                    string moduleFile = module.Substring(module.LastIndexOf(slash, StringComparison.Ordinal) + 1);
                    string modulePath = module.Substring(0, module.LastIndexOf(slash, StringComparison.Ordinal));

                    // ModuleFile contains no "." -> next
                    if (!moduleFile.Contains("."))
                    {
                        continue;
                    }
                    // Remove .dll .pdb etc..
                    moduleFile = moduleFile.Substring(0, moduleFile.LastIndexOf(".", StringComparison.Ordinal));

                    // Path didn't contains the name of the module file -> remove from new modules
                    if (!modulePath.Contains(moduleFile))
                    {
                        newModules.Remove(module);
                    }
                }

                // Copy new modules
                foreach (string newModule in newModules)
                {
                    string destFile = gtMpServerModulesFolder + slash + Path.GetFileName(newModule);

                    // Destfile exist & destfile is same to new file -> skip
                    if (File.Exists(destFile))
                    {
                        if (new FileInfo(destFile).LastWriteTime >= new FileInfo(newModule).LastWriteTime)
                        {
                            continue;
                        }
                    }

                    // Copy new module & write message
                    File.Copy(newModule, destFile, true);
                    if (destFile.EndsWith(".dll"))
                    {
                        ConsoleOutput.WriteLine(ConsoleType.Core,
                                                $"Copying module: ~#83cfff~\"{Path.GetFileName(destFile)}\".");
                    }
                }

                // Delete old modules
                foreach (string deleteModule in oldModules.Where(t => !newModules.Select(Path.GetFileName)
                                                                 .Contains(Path.GetFileName(t))))
                {
                    File.Delete(deleteModule);
                    ConsoleOutput.WriteLine(ConsoleType.Core,
                                            $"Delete old module: ~#83cfff~\"{Path.GetFileName(deleteModule)}\".");
                }

                ConsoleOutput.ResetPrefix();
            }
            catch (Exception exception)
            {
                // Throw exception
                throw new Exception($"Internal error in \"EvoMp.Core.Core.ModuleStructure\" " +
                                    $"{Environment.NewLine}" +
                                    $"{exception.Message}{Environment.NewLine}" +
                                    $"{exception.StackTrace}");
            }
        }
Esempio n. 16
0
        /// <summary>
        ///     Copying NuGet packages to the gtmp server files
        ///     Hint: Runs only if "DEBUG" constant is given
        /// </summary>
        public void CopyNuGetPackagesToServer()
        {
#if !DEBUG
            if (ParameterHandler.IsDefault("onlyCopy"))
            {
                ConsoleOutput.WriteLine(ConsoleType.Core, "Release state. Copying NuGet packeges skipped.");
                return;
            }
#endif
            const string serverRootFolder = ".";

            const string projectSolutionNuGetPackagesFolder = @"../EvoMp/packages";

            try
            {
                // Search for solution NuGet packages
                ConsoleOutput.WriteLine(ConsoleType.Core,
                                        $"Searching for new dependencies in " +
                                        $"~#83cfff~\"{Path.GetFullPath(projectSolutionNuGetPackagesFolder)}\\*\"~;~.");
                List <string> packageFiles = Directory.EnumerateFiles(projectSolutionNuGetPackagesFolder, "*",
                                                                      SearchOption.AllDirectories)
                                             .Where(file => file.ToLower().EndsWith("dll") || file.ToLower().EndsWith("xml"))
                                             .Where(file => file.Contains(@"lib\net45"))
                                             .Where(file => !Path.GetFileName(file).ToLower().StartsWith("evomp"))
                                             .ToList();

                // Clear duplicates
                packageFiles = packageFiles.Distinct().ToList();


                ConsoleOutput.WriteLine(ConsoleType.Core, "Using dependencies: ");
                ConsoleOutput.AppendPrefix("\t");

                List <string> usedPackagesList = new List <string>();
                // Copy new NuGet packages
                foreach (string packageFile in packageFiles)
                {
                    if (packageFile.EndsWith(".dll"))
                    {
                        string packageName = Path.GetFileName(packageFile).Replace("\\", "/");

                        // Packed already loaded -> continue;
                        if (usedPackagesList.Contains(packageName))
                        {
                            continue;
                        }

                        ConsoleOutput.WriteLine(ConsoleType.Core,
                                                $"~#83cfff~\"{packageName}\".");

                        usedPackagesList.Add(packageName);
                    }

                    // Get target filename
                    string destinationFile = serverRootFolder + @"/" + Path.GetFileName(packageFile).Replace("\\", "/");

                    // File exist -> Check creation date and delete if older
                    if (File.Exists(destinationFile))
                    {
                        // File is newest -> skip
                        if (new FileInfo(destinationFile).LastWriteTime >= new FileInfo(packageFile).LastWriteTime)
                        {
                            continue;
                        }

                        // Try to delete older file, if fails, skip file..
                        // I knew, not the best way.
                        // Feel free if u knew a better way..
                        // (But info one of the project directors about our change)
                        try
                        {
                            File.Delete(destinationFile);
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                    }

                    // Copy file & message
                    File.Copy(packageFile, destinationFile);
                }

                ConsoleOutput.ResetPrefix();
            }
            catch (Exception exception)
            {
                // Throw exception
                throw new Exception($"Internal error in \"EvoMp.Core.Core.CopyNuGetPackagesToServer\" " +
                                    $"{Environment.NewLine}" +
                                    $"{exception.Message}{Environment.NewLine}" +
                                    $"{exception.StackTrace}");
            }
        }
 public void AddParametersToAssigner() => ParameterHandler.AddParametersToAssigner(ActionSet.IndexAssigner);
 void Awake()
 {
     if (instance == null) {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
         return;
     } else {
         Destroy(this.gameObject);
         return;
     }
 }
Esempio n. 19
0
        public Main()
        {
            DbConfiguration.SetConfiguration(new QueryLogDbConfiguration());
            try
            {
                #region Core preparing / initialization

                // Clear console, set console color & write copyright
                ConsoleUtils.Clear();

                // Prepare Console set title
                ConsoleHandler.Server.ConsoleHandler.PrepareConsole();

                #endregion // Core preparing / initialization

                ConsoleUtils.SetConsoleTitle("EvoMp GT-MP Server Core. All rights reserverd.");

                // Load Console params
                ParameterHandler.LoadParams();

                CheckDatabaseReset();

                // Load logo
                ParameterHandler.SetDefault("LogoPath", "./ServerFiles/Default_Logo.txt");
                string asciiLogoFile = ParameterHandler.GetValue("LogoPath");

                #region Logo, Copyright, Server informations

                ConsoleOutput.PrintLine("-", "~#E6E6E6~");

                // Write logo from logo file
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               ConsoleUtils.ParseTextFileForConsole($"{asciiLogoFile}", 2, 1));

                // No Logo defined -> message and use default Logo
                if (ParameterHandler.IsDefault("LogoPath"))
                {
                    ConsoleOutput.WriteCentredText(ConsoleType.Config,
                                                   $"Using logo file ~o~\"{Path.GetFullPath($"{asciiLogoFile}")}\"~;~.\n" +
                                                   $"Please start your server with the ~b~" +
                                                   $"logopath ~;~ " +
                                                   $"parameter.");
                }

                // GetServerGamemodes writes cfg message to if not setten
                string moduleTypesString =
                    string.Join(", ",
                                ModuleTypeHandler.GetServerGamemodes().ToList().ConvertAll(input => input.ToUpper()));

                const string leftServerInfo  = "~#90A4AE~";
                const string rightServerInfo = "~#ECEFF1~";

                // Tiny gray line & Empty
                ConsoleOutput.PrintLine(" ");

                // Small centered line with headline & developer
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               "".PadRight(80, '-') + "\n" +
                                               "Server information\n" +
                                               "".PadRight(80, '-'));

                ConsoleOutput.WriteCentredText(ConsoleType.Info,
                                               $"{leftServerInfo}{"Server mode:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{moduleTypesString}".PadRight(35)}\n" +
                                               $"{leftServerInfo}{"Runtime mode:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{(Debug ? "Debugging" : "Release")}".PadRight(35)}\n" +
                                               $"{leftServerInfo}{"Server name:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{API.getServerName()}{"".PadRight(ColorUtils.CleanUp(API.getServerName()).Length > 35 ? 0 : 35 - ColorUtils.CleanUp(API.getServerName()).Length)}\n" +
                                               $"{leftServerInfo}{"Server port:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{API.getServerPort():0000}".PadRight(35)}\n" +
                                               $"{leftServerInfo}{"Max players:".PadRight(35)}{string.Empty.PadRight(5)}{rightServerInfo}{$"{API.getMaxPlayers():0000}".PadRight(35)}\n");

                // One empty lines
                ConsoleOutput.PrintLine(" ");

                // Small centered line with headline & developer
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               "".PadRight(80, '-') + "\n" +
                                               "Developer team\n" +
                                               "".PadRight(80, '-'));

                const string usernameColor   = "~#ECEFF1~";
                const string diTitleColor    = "~#03A9F4~";
                const string depyTitleColor  = "~#4FC3F7~";
                const string staffTitleColor = "~#B3E5FC~";

                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               $"{diTitleColor}{"Freeroam Director".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"Ruffo ~c~(Christian Groothoff)".PadRight(35 + 3)}\n" +
                                               $"{depyTitleColor}{"Freeroam Deputy".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"Koka".PadRight(35)}\n" +
                                               $"{depyTitleColor}{"Freeroam Staff".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"Sascha".PadRight(35)}\n" +
                                               $"{staffTitleColor}{"Freeroam Staff".PadRight(35)}{string.Empty.PadRight(5)}{usernameColor}{"James".PadRight(35)}\n"
                                               );

                ConsoleOutput.PrintLine(" ");

                // Startup parameters
                ConsoleOutput.WriteCentredText(ConsoleType.Note,
                                               "".PadRight(80, '-') + "\n" +
                                               "Startup Parameters\n" +
                                               "".PadRight(80, '-'));
                ParameterHandler.PrintArgs();

                ConsoleOutput.PrintLine(" ");
                ConsoleOutput.PrintLine("-");

                #endregion Logo, Copyright, Server informations

                // Only copy and then stop. Used for docker

                ParameterHandler.SetDefault("onlyCopy", "false");

                // Write information about Core startup
                ConsoleOutput.WriteLine(ConsoleType.Core, "Initializing EvoMp Core...");

                // Init ModuleStructurer
                ModuleStructurer moduleStructurer = new ModuleStructurer();

                // Copy modules & NuGet files to Server
                moduleStructurer.CopyModulesToServer();
                moduleStructurer.CopyNuGetPackagesToServer();

                // Write complete & loading modules message
                ConsoleOutput.WriteLine(ConsoleType.Core, "Initializing EvoMp Core completed.");

                if (!ParameterHandler.IsDefault("onlyCopy"))
                {
                    // Finish sequence
                    SharedEvents.OnOnCoreStartupCompleted();
                    ConsoleOutput.WriteLine(ConsoleType.Core, "Core startup completed");
                    ConsoleOutput.PrintLine("-");

                    ConsoleOutput.WriteLine(ConsoleType.Core, "OnlyCopy parameter has been detected! Stopping Server!");
                    Environment.Exit(0);
                }
                else
                {
                    SharedEvents.OnOnModuleLoadingStart(API);

                    // Load Modules
                    new ModuleLoader(API).Load();

                    // Finish sequence
                    SharedEvents.OnOnCoreStartupCompleted();
                    ConsoleOutput.WriteLine(ConsoleType.Core, "Core startup completed");
                    ConsoleOutput.PrintLine("-");
                }

                SharedEvents.OnOnAfterCoreStartupCompleted();
            }
            catch (Exception e)
            {
                //#if DEBUG
                ConsoleOutput.WriteException(e.ToString());
                Exception innerException = e.InnerException;
                while (innerException != null)
                {
                    ConsoleOutput.WriteException(innerException.ToString());
                    innerException = innerException.InnerException;
                }

                //throw lastInnerException;
//#endif
            }
        }
Esempio n. 20
0
 public ParameterController(ApplicationDbContext applicationDbContext, ParameterHandler parameterHandler)
 {
     this._context          = applicationDbContext;
     this._parameterHandler = parameterHandler;
 }
 public static void addParameter <T>(string name, Converter <T> c)
 {
     ParameterHandler <T> .addParameter(name, c);
 }