Esempio n. 1
0
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));

            //Todo : Here _filePathToPatch should be the equal to temp folder containing all the assets
            var sourcePath = Path.Combine(Parent.ConfigDirectoryPath, PathConverter.Convert(Source));

            if (!string.IsNullOrWhiteSpace(Parent.CommonDirectoryPath) && !File.Exists(sourcePath))
            {
                sourcePath = Path.Combine(Parent.CommonDirectoryPath, PathConverter.Convert(Source));
            }

            if (!File.Exists(sourcePath))
            {
                // source file not found, abort!
                return;
            }

            if (Path.GetFullPath(sourcePath) == Path.GetFullPath(destPath))
            {
                //prevent sharing violation if source and destination have the same path
                return;
            }

            File.Copy(sourcePath, destPath, true);
        }
Esempio n. 2
0
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));
            var doc      = new XmlDocument();

            doc.Load(destPath);

            XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);

            nsManager.AddNamespace("a", "http://schemas.microsoft.com/developer/msbuild/2003");
            nsManager.AddNamespace("android", "http://schemas.android.com/apk/res/android");

            var node = doc.SelectSingleNode(NodeSelector, nsManager);

            if (string.IsNullOrEmpty(Attribute))
            {
                SetterEle(Parent.Config, node as XmlElement);
            }
            else
            {
                XmlAttribute att = node.Attributes[Attribute];
                SetterAtt(Parent.Config, att);
            }

            using (var writer = new XmlTextWriter(destPath, new UTF8Encoding(false)))
            {
                writer.Formatting = Formatting.Indented;
                doc.Save(writer);
            }
        }
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));
            var doc      = new XmlDocument();

            doc.Load(destPath);

            XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);

            nsManager.AddNamespace("a", "http://schemas.microsoft.com/developer/msbuild/2003");
            nsManager.AddNamespace("android", "http://schemas.android.com/apk/res/android");

            var nodes = doc.SelectNodes(NodeSelector, nsManager);

            for (int i = 0; i < nodes.Count; i++)
            {
                if (string.IsNullOrEmpty(Attribute))
                {
                    SetterEle(Parent.Config, nodes[i] as XmlElement);
                }
                else
                {
                    XmlAttribute att = nodes[i].Attributes[Attribute];
                    SetterAtt(Parent.Config, att);
                }
            }

            doc.Save(destPath);
        }
Esempio n. 4
0
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));

            var sourcePath = Path.Combine(Parent.ConfigDirectoryPath, PathConverter.Convert(Source));

            if (!string.IsNullOrWhiteSpace(Parent.CommonDirectoryPath) && !File.Exists(sourcePath))
            {
                sourcePath = Path.Combine(Parent.CommonDirectoryPath, PathConverter.Convert(Source));
            }

            if (!File.Exists(sourcePath))
            {
                // original file not found, resizing default image
                var defaultSourcePath = Path.Combine(Parent.ConfigDirectoryPath, PathConverter.Convert(DefaultSource));
                var newImage          = new Bitmap((int)OutputSize.Width, (int)OutputSize.Height, PixelFormat.Format24bppRgb);
                var defaultImage      = Bitmap.FromFile(defaultSourcePath);

                // Draws the image in the specified size with quality mode set to HighQuality
                using (Graphics graphics = Graphics.FromImage(newImage))
                {
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphics.SmoothingMode      = SmoothingMode.HighQuality;
                    graphics.DrawImage(defaultImage, 0, 0, OutputSize.Width, OutputSize.Height);
                }

                newImage.Save(destPath, ImageFormat.Png);
            }
            else
            {
                File.Copy(sourcePath, destPath, true);
            }
        }
        public override void Apply()
        {
            var sourcePath   = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Source));
            var fileContents = File.ReadAllText(sourcePath);

            fileContents = fileContents.Replace(ToReplace, ReplaceWith);

            File.WriteAllText(sourcePath, fileContents);
        }
Esempio n. 6
0
        public ConfigSplash(AppConfig parent, string filePathToPatch, string outputFolder, string filename)
            : base(parent)
        {
            //Todo : Here _filePathToPatch should be the equal to temp folder containing all the assets
            _filePathToPatch = Path.Combine(Parent.ConfigDirectoryPath, PathConverter.Convert(filePathToPatch));
            _outputFolder    = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(outputFolder));

            _filename = filename;
        }
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));

            //Todo : Here _filePathToPatch should be the equal to temp folder containing all the assets
            var sourcePath = Path.Combine(Parent.ConfigDirectoryPath, PathConverter.Convert(Source));

            if (!File.Exists(sourcePath))
            {
                sourcePath = Path.Combine(Parent.CommonDirectoryPath, PathConverter.Convert(Source));
            }
            File.Copy(sourcePath, destPath, true);
        }
Esempio n. 8
0
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));

            var doc = new XmlDocument();

            doc.Load(destPath);

            var node = doc.SelectSingleNode("//key[. = '" + Key + "']");

            SetterEle(node.NextSibling  as XmlElement);

            var w = new NullSubsetXmlTextWriter(destPath, Encoding.UTF8);

            w.Formatting = Formatting.Indented;
            doc.Save(w);
            w.Close();
            w = null;
        }
        public override void Apply()
        {
            var destPath = Path.Combine(Parent.SrcDirectoryPath, PathConverter.Convert(Destination));

            var files = Directory.GetFiles(destPath, "*.axml");

            foreach (var filePath in files)
            {
                var file = File.ReadAllText(filePath);
                var f    = Regex.Replace(file, Namespace + @"=""([^""]+)""", Namespace + @"=""http://schemas.android.com/apk/res/" + Value + @""""); // .IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase)


                using (var writer = new StreamWriter(filePath, false))
                {
                    writer.Write(f);
                    writer.Close();
                }
            }
        }
Esempio n. 10
0
        static int Main(string[] args)
        {
            Console.WriteLine("Starting");
            try
            {
                var c         = new CompanyServiceClient();
                var companies = c.GetCompanies();


                var fullPath    = Path.GetFullPath(PathConverter.Convert(ToolSettings.Default.RootDirectory));
                var directories = Directory.GetDirectories(fullPath);
                if (!directories.Any(dir => Path.GetFileName(dir).ToLower() == "src"))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Cannot find the src folder in : " + fullPath + Environment.NewLine +
                                      "Press any key to exit...");
                    return(1);
                }


                var src           = directories.Single(dir => Path.GetFileName(dir).ToLower() == "src");
                var configFolders = Path.Combine(fullPath, "Config");
                var config        = companies.Select(company => new AppConfig(company.CompanyKey, company, src, Path.Combine(configFolders, company.CompanyKey))).ToArray();

                if (args.Length >= 2)
                {
                    var configSelected = config.FirstOrDefault(x => x.Name == args[0]);
                    var serviceUrl     = args[1];
                    if (configSelected != null)
                    {
                        configSelected.Apply(serviceUrl);
                    }
                    else
                    {
                        Console.WriteLine("Invalid config selected. Press any key to exit...");
                        return(1);
                    }
                }
                else
                {
                    Console.WriteLine("Choose the config to apply : ");
                    Console.WriteLine("");

                    for (int i = 0; i < config.Count(); i++)
                    {
                        Console.WriteLine(i.ToString() + " - " + config.ElementAt(i).Name + " - " + config.ElementAt(i).Company.CompanyName);
                    }
                    Console.WriteLine("");
                    Console.WriteLine("Enter the config number:");
                    var selectedText = Console.ReadLine();
                    int selected     = int.Parse(selectedText);

                    Console.WriteLine("Enter the server url:");
                    var url = "http://test.taxihail.biz:8181/taxihaildemo/api/";                    //Console.ReadLine();

                    if (!string.IsNullOrWhiteSpace(url))
                    {
                        config.ElementAt(selected).Apply(url);
                    }
                    else
                    {
                        Console.WriteLine("Invalid config selected or bad service url. Press any key to exit...");
                        //Console.ReadKey();
                        return(1);
                    }
                }

                Console.WriteLine("Done. Closing...");
                Thread.Sleep(2000);
            }catch (Exception e)
            {
                Console.WriteLine("Errors:");
                Console.WriteLine(e.Message);
                //Console.ReadKey();
                return(1);
            }
            Console.WriteLine("Finished");
            return(0);
        }