Ejemplo n.º 1
0
 public ConfigProvider(string assemblyPath, string classImplmentation, IGXCliVerbProvider provider)
 {
     AssemblyLocation = assemblyPath;
     ClassName        = classImplmentation;
     Name             = provider.Name;
     Description      = provider.Description;
     Target           = provider.Target;
     Parameters       = provider.Parameters;
     Examples         = provider.Examples;
 }
Ejemplo n.º 2
0
        public static void Install(string gxPath)
        {
            if (string.IsNullOrEmpty(gxPath))
            {
                throw new Exception("You must enter the path to a GeneXus installation");
            }

            if (!Directory.Exists(gxPath))
            {
                throw new DirectoryNotFoundException($"'{gxPath}' does not look like a valid directory");
            }

            string gxExe = Path.Combine(gxPath, Config.GXENEXUS_EXE);

            if (!File.Exists(gxExe))
            {
                throw new Exception($"'{gxPath}' does not look like a valid GeneXus installation folder");
            }

            AssemblyInformationalVersionAttribute afv = Assembly.LoadFrom(gxExe).GetCustomAttribute <AssemblyInformationalVersionAttribute>();

            s_instance = new Config
            {
                GeneXusPath    = gxPath,
                GeneXusVersion = afv.InformationalVersion,
                CurrentVersion = Application.ProductVersion
            };

            var    dir         = AppDomain.CurrentDomain.BaseDirectory;
            string modulesPath = Path.Combine(dir, GXCLI_MODULES);

            foreach (string dllPath in Directory.GetFiles(modulesPath, "*.dll"))
            {
                Assembly ass = Assembly.LoadFrom(dllPath);
                Console.WriteLine($"Analyzing {ass.GetName().Name}...");

                Attribute att = ass.GetCustomAttribute(typeof(GXCliVerbProviderAttribute));
                if (att == null)
                {
                    continue;
                }

                Console.WriteLine($"{ass.GetName().Name} is a gxcli verb provider");
                Console.WriteLine($"Adding {ass.GetName().Name} verbs...");

                foreach (Type t in ass.GetExportedTypes())
                {
                    if (typeof(IGXCliVerbProvider).IsAssignableFrom(t))
                    {
                        IGXCliVerbProvider obj            = Activator.CreateInstance(t) as IGXCliVerbProvider;
                        ConfigProvider     configProvider = new ConfigProvider(dllPath, t.FullName, obj)
                        {
                            HasValidator = typeof(ParameterValidator).IsAssignableFrom(t)
                        };
                        if (!s_instance.Providers.ContainsKey(obj.Name))
                        {
                            Console.WriteLine($"- {obj.Name}");
                            s_instance.Providers.Add(obj.Name.ToLower(), configProvider);
                        }
                    }
                }
            }

            s_instance.Save();
        }