Ejemplo n.º 1
0
        /// <include file="Tools/.Docs/.ManifestInstaller.xml" path="docs/method[@name='Install(string, ManifestComponents, bool)']/*"/>
        public static bool Install(string AppDirectory, ManifestComponents Components, bool ThrowExceptions)
        {
            foreach (var Component in Components.Values)
            {
                var InstallationPath = PathService.CombinePath(AppDirectory, Component.FileName);

                try
                {
                    PathCreator.Create(PathService.GetDirectoryPath(InstallationPath));
                    FileCreator.Create(InstallationPath, Component.Data);
                }
                catch
                {
                    if (ThrowExceptions)
                    {
                        throw;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Write("Enter name of file: ");
            string name = Console.ReadLine();

            string[]          variants = new string[] { "txt", "jpeg", "docx", "rtf" };
            FileNameCreator[] creators = new FileNameCreator[] { new TxtFileNameCreator(name),
                                                                 new JpegFileNameCreator(name),
                                                                 new DocxFileNameCreator(name),
                                                                 new RtfFileNameCreator(name) };

            int selection = SelectCreator(variants);

            FileCreator.Create(creators[selection]);
            Console.Write("File was created successfully");

            Console.ReadLine();
        }