예제 #1
0
        public TypeClassWriter(ProtocolClass pClass, D2JsonProvider provider)
        {
            Class    = pClass;
            Provider = provider;

            _writer = new StringBuilder();
        }
예제 #2
0
        public EnumClassWriter(EnumClass eClass, D2JsonProvider provider)
        {
            Class    = eClass;
            Provider = provider;

            _writer = new StringBuilder();
        }
예제 #3
0
        /// <summary>
        ///     App logic, ask for path of d2json output if not exist
        ///     If you don't have a .json file path to provide, press enter
        ///     The .json will be auto-generated using d2json if app is in the current folder
        /// </summary>
        /// <param name="args">Main method args</param>
        /// <returns><see cref="D2JsonProvider" /> object wich contains classes</returns>
        internal static void ProcessArgs(string[] args, out D2JsonProvider d2JsonProvider)
        {
            Title = "Cookie Protocol Builder - DevChris";
            WriteLine("\n--------------------------------------------------------------\n");
            WriteLine(
                @"_________                __   .__                                                                     
\_   ___ \  ____   ____ |  | _|__| ____                                                               
/    \  \/ /  _ \ /  _ \|  |/ /  |/ __ \                                                              
\     \___(  <_> |  <_> )    <|  \  ___/                                                              
 \______  /\____/ \____/|__|_ \__|\___  >                                                             
        \/                   \/       \/                                                              
__________                __                      .__    __________      .__.__       .___            
\______   \_______  _____/  |_  ____   ____  ____ |  |   \______   \__ __|__|  |    __| _/___________ 
 |     ___/\_  __ \/  _ \   __\/  _ \_/ ___\/  _ \|  |    |    |  _/  |  \  |  |   / __ |/ __ \_  __ \
 |    |     |  | \(  <_> )  | (  <_> )  \__(  <_> )  |__  |    |   \  |  /  |  |__/ /_/ \  ___/|  | \/
 |____|     |__|   \____/|__|  \____/ \___  >____/|____/  |______  /____/|__|____/\____ |\___  >__|   
                                          \/                     \/                    \/    \/       ");
            WriteLine("\n--------------------------------------------------------------\n");
            WriteLine("> Welcome to Cookie's protocol builder !");

            ProtocolJsonPath = $@"{Directory.GetCurrentDirectory()}\DofusProtocol.json";

            if (!File.Exists(ProtocolJsonPath))
            {
                WriteLine("> Please insert json file path (it'll be auto-generated if empty)");

                // enter in loop because args parameter length = 0 when entering the app
                while (args.Length != 1)
                {
                    Write("> ");
                    args = new[] { ReadLine() };

                    if (string.IsNullOrEmpty(args[0]))
                    {
                        Throw.If(!TryBuildNewProtocol(), nameof(TryBuildNewProtocol));
                    }
                    else if (args[0].IsValidPath())
                    {
                        ProtocolJsonPath = args[0];
                    }
                }
            }

            d2JsonProvider = new D2JsonProvider(ProtocolJsonPath);
        }
예제 #4
0
 public void OnMatch(StringBuilder writer, Field fi, D2JsonProvider provider)
 {
     writer.AppendLine(
         $"using Cookie.Protocol.{provider.Types.First(t => t.Name == fi.Type).Namespace.NamespaceToCSharpFormat()};");
 }