Exemplo n.º 1
0
        internal static void Inject(InjectionInformation injectionInformation)
        {
            using (var zip = ZipFile.Read(injectionInformation.InputXapFile))
            {
                var existingFiles = zip.EntryFileNames;
                if (existingFiles.Contains(injectionInformation.InjectedFileName))
                    zip.RemoveEntry(injectionInformation.InjectedFileName);

                zip.AddEntry(injectionInformation.InjectedFileName, "", File.OpenText(injectionInformation.InjectedFile).ReadToEnd());

                zip.Save(injectionInformation.OutputXapFile);
            }
        }
Exemplo n.º 2
0
        internal static void Inject(InjectionInformation injectionInformation)
        {
            using (var zip = ZipFile.Read(injectionInformation.InputXapFile))
            {
                var existingFiles = zip.EntryFileNames;
                if (existingFiles.Contains(injectionInformation.InjectedFileName))
                {
                    zip.RemoveEntry(injectionInformation.InjectedFileName);
                }

                zip.AddEntry(injectionInformation.InjectedFileName, "", File.OpenText(injectionInformation.InjectedFile).ReadToEnd());

                zip.Save(injectionInformation.OutputXapFile);
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            var inputXapFile     = string.Empty;
            var outputXapFile    = string.Empty;
            var injectedFile     = string.Empty;
            var injectedFileName = string.Empty;
            var helpRequested    = false;

            var optionSet = new OptionSet {
                {
                    "f=|file=",
                    "File to be placed into the XAP.",
                    v => injectedFile = v
                },
                {
                    "h|?|help",
                    "Show this help information.",
                    v => helpRequested = true
                },
                {
                    "n=|name=",
                    "Optional: Name to use for the file when placed into the XAP (file name only, no path - default behaviour is to use the name of the injected file).",
                    v => injectedFileName = v
                },
                {
                    "o=|output=",
                    "Optional: Write the changed XAP file to this location rather than modifying the existing one (default behaviour is to overwrite existing file).",
                    v => outputXapFile = v
                },
                {
                    "x=|xap=",
                    "Source XAP file that file is to be injected into.",
                    v => inputXapFile = v
                },
            };

            optionSet.Parse(args);

            if (helpRequested)
            {
                ShowProgrammeInformation();
                ShowParameterInformation(optionSet);
                Environment.Exit(0);
            }

            InjectionInformation injectionInformation = null;

            try
            {
                injectionInformation = new InjectionInformation(inputXapFile, outputXapFile, injectedFile,
                                                                injectedFileName);
            }
            catch (ArgumentException argumentException)
            {
                ShowError(argumentException.Message);
                ShowParameterInformation(optionSet);
                Environment.Exit(1);
            }

            FileInjector.Inject(injectionInformation);
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            var inputXapFile = string.Empty;
            var outputXapFile = string.Empty;
            var injectedFile = string.Empty;
            var injectedFileName = string.Empty;
            var helpRequested = false;

            var optionSet = new OptionSet {
                                 {
                                     "f=|file=",
                                     "File to be placed into the XAP.",
                                     v => injectedFile = v
                                 },
                                 {
                                     "h|?|help",
                                     "Show this help information.",
                                     v => helpRequested = true
                                 },
                                 {
                                     "n=|name=",
                                     "Optional: Name to use for the file when placed into the XAP (file name only, no path - default behaviour is to use the name of the injected file).",
                                     v => injectedFileName = v
                                 },
                                 {
                                     "o=|output=",
                                     "Optional: Write the changed XAP file to this location rather than modifying the existing one (default behaviour is to overwrite existing file).",
                                     v => outputXapFile = v
                                 },
                                 {
                                     "x=|xap=",
                                     "Source XAP file that file is to be injected into.",
                                     v => inputXapFile = v
                                 },

                             };
            optionSet.Parse(args);

            if (helpRequested)
            {
                ShowProgrammeInformation();
                ShowParameterInformation(optionSet);
                Environment.Exit(0);
            }

            InjectionInformation injectionInformation = null;

            try
            {

                injectionInformation = new InjectionInformation(inputXapFile, outputXapFile, injectedFile,
                                                                  injectedFileName);
            }
            catch(ArgumentException argumentException)
            {
                ShowError(argumentException.Message);
                ShowParameterInformation(optionSet);
                Environment.Exit(1);
            }

            FileInjector.Inject(injectionInformation);
        }