Beispiel #1
0
        public static Regulus.Remote.Soul.Service CreateRudp(int port, IEntry entry, params Type[] types)
        {
            var ab          = new Regulus.Remote.Protocol.AssemblyBuilder(types);
            var protocolAsm = ab.Create();
            var protocol    = Regulus.Remote.Protocol.ProtocolProvider.Create(protocolAsm);

            return(new Regulus.Remote.Soul.Service(entry, port, protocol, new Regulus.Network.Rudp.Listener(new Regulus.Network.Rudp.UdpSocket())));
        }
Beispiel #2
0
        private IProtocol _CreateProtocol(string common_path)
        {
            var assembly = Assembly.LoadFrom(common_path);

            var buidler = new Regulus.Remote.Protocol.AssemblyBuilder(assembly.GetExportedTypes());
            var asm     = buidler.Create();

            return(Regulus.Remote.Protocol.ProtocolProvider.Create(asm));
        }
Beispiel #3
0
        public static Regulus.Remote.IAgent CreateTcp(params System.Type[] types)
        {
            var client = new  Regulus.Network.Tcp.ConnectProvider();

            var ab          = new Regulus.Remote.Protocol.AssemblyBuilder(types);
            var protocolAsm = ab.Create();
            var protocol    = Regulus.Remote.Protocol.ProtocolProvider.Create(protocolAsm);
            var agent       = new Regulus.Remote.Ghost.Agent(protocol, client);

            return(agent);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, a) =>
            {
                Regulus.Utility.CrashDump.Write();
                Environment.Exit(0);
            };

            Regulus.Utility.Log.Instance.RecordEvent += _WriteLog;
            if (args.Length < 2)
            {
                Console.WriteLine("Need to build parameters.");
                Console.WriteLine("ex . Regulus.Application.Protocol.Generator.exe path/in-common.dll path/out-protocol.dll");
                return;
            }
            var inPath  = args[0];
            var outPath = args[1];


            try
            {
                if (!System.IO.File.Exists(inPath))
                {
                    throw new Exception($"can not found {inPath}");
                }



                var sourceFullPath = System.IO.Path.GetFullPath(inPath);
                var outputFullPath = System.IO.Path.GetFullPath(outPath);

                Console.WriteLine($"Source {sourceFullPath}");
                Console.WriteLine($"Output {outputFullPath}");
                var sourceAsm        = Assembly.LoadFile(sourceFullPath);
                var libraryAsm       = Assembly.LoadFile(System.IO.Path.GetFullPath("Regulus.Library.dll"));
                var remoteAsm        = Assembly.LoadFile(System.IO.Path.GetFullPath("Regulus.Remote.dll"));
                var serizlizationAsm = Assembly.LoadFile(System.IO.Path.GetFullPath("Regulus.Serialization.dll"));
                var assemblyBuilder  = new Regulus.Remote.Protocol.AssemblyBuilder(sourceAsm.GetExportedTypes());
                assemblyBuilder.CreateFile(outputFullPath);

                Console.WriteLine("Build success.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Build failure.");
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, a) =>
            {
                Regulus.Utility.CrashDump.Write();
                Environment.Exit(0);
            };

            Regulus.Utility.Log.Instance.RecordEvent += _WriteLog;
            if (args.Length == 0)
            {
                Console.WriteLine("Need to build parameters.");
                Console.WriteLine("ex . Regulus.Application.Protocol.Generator.exe build.ini");
                return;
            }
            var path = args[0];

            if (System.IO.File.Exists(path) == false)
            {
                Console.WriteLine($"Non-existent path {path}.");
                return;
            }

            try
            {
                var ini = new Regulus.Utility.Ini(System.IO.File.ReadAllText(path));

                var sourcePath = String.Empty;

                if (_TryRead(ini, "Build", "SourcePath", out sourcePath) == false)
                {
                    Program._ShowBuildIni();
                    return;
                }


                var protocolName = String.Empty;

                if (_TryRead(ini, "Build", "ProtocolName", out protocolName) == false)
                {
                    Program._ShowBuildIni();
                    return;
                }


                var outputPath = String.Empty;
                var outputCode = String.Empty;
                if (_TryRead(ini, "Build", "OutputPath", out outputPath))
                {
                    var sourceFullPath = System.IO.Path.GetFullPath(sourcePath);
                    var outputFullPath = System.IO.Path.GetFullPath(outputPath);

                    Console.WriteLine($"Source {sourceFullPath}");
                    Console.WriteLine($"Output {outputFullPath}");
                    var sourceAsm        = Assembly.LoadFile(sourceFullPath);
                    var libraryAsm       = Assembly.LoadFile("Regulus.Library.dll");
                    var remoteAsm        = Assembly.LoadFile("Regulus.Remote.dll");
                    var serizlizationAsm = Assembly.LoadFile("Regulus.Serialization.dll");
                    var assemblyBuilder  = new Regulus.Remote.Protocol.AssemblyBuilder(sourceAsm.GetExportedTypes());
                    _SaveToFile(assemblyBuilder.Create(), outputPath);

                    Console.WriteLine("Build success.");
                }
                if (_TryRead(ini, "Build", "OutputCode", out outputCode))
                {
                    var sourceFullPath = System.IO.Path.GetFullPath(sourcePath);
                    var outputFullPath = System.IO.Path.GetFullPath(outputCode);

                    Console.WriteLine($"Source {sourceFullPath}");
                    Console.WriteLine($"Output {outputFullPath}");
                    var sourceAsm = Assembly.LoadFile(sourceFullPath);
                    //var assemblyBuilder = new Regulus.Remote.Protocol.AssemblyBuilder();
                    //assemblyBuilder.BuildCode(sourceAsm, protocolName, outputFullPath);
                    throw new NotImplementedException();
                    Console.WriteLine("Build success.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Build failure.");
            }
        }