public static bool WriteOutAllEmbeddedStrategies()
        {
            var    assembly             = System.Reflection.Assembly.GetExecutingAssembly();
            var    resourceLoader       = new Resources.ResourceLoader(assembly);
            string strategyResourcePath = "Dominion.DynamicStrategyLoader.EmbeddedStrategies";

            if (!CreateStrategiesFolderIfNecessary())
            {
                return(false);
            }

            bool foundOne = false;

            foreach (string sourcefile in assembly.GetManifestResourceNames())
            {
                if (!sourcefile.StartsWith(strategyResourcePath))
                {
                    continue;
                }

                foundOne = true;

                string fileContents = resourceLoader.GetEmbeddedContent("", sourcefile);
                string fileName     = sourcefile.Remove(0, strategyResourcePath.Length);

                try
                {
                    using (var textWriter = new System.IO.StreamWriter(strategyOutputFolder + "\\" + fileName))
                    {
                        textWriter.Write(fileContents);
                    }
                }
                catch
                {
                    System.Console.WriteLine("Error, Unable to load strategy: " + fileName);
                }
            }

            if (foundOne == false)
            {
                throw new Exception("No embedded strategies loaded");
            }

            return(true);
        }
        public static bool WriteOutAllEmbeddedStrategies()
        {
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var resourceLoader = new Resources.ResourceLoader(assembly);
            string strategyResourcePath = "Dominion.DynamicStrategyLoader.EmbeddedStrategies";

            if (!CreateStrategiesFolderIfNecessary())
                return false;

            bool foundOne = false;

            foreach (string sourcefile in assembly.GetManifestResourceNames())
            {
                if (!sourcefile.StartsWith(strategyResourcePath))
                {
                    continue;
                }

                foundOne = true;

                string fileContents = resourceLoader.GetEmbeddedContent("", sourcefile);
                string fileName = sourcefile.Remove(0, strategyResourcePath.Length);

                try
                {
                    using (var textWriter = new System.IO.StreamWriter(strategyOutputFolder + "\\" + fileName))
                    {
                        textWriter.Write(fileContents);
                    }
                }
                catch
                {
                    System.Console.WriteLine("Error, Unable to load strategy: " + fileName);
                }
            }

            if (foundOne == false)
                throw new Exception("No embedded strategies loaded");

            return true;
        }
Beispiel #3
0
 public static string GetEmbeddedContent(string content)
 {
     return(resourceLoader.GetEmbeddedContent("Webservice.Resources.", content));
 }
 public static string GetEmbeddedContent(string content)
 {
     return(resourceLoader.GetEmbeddedContent("HtmlRenderer.Resources.", content));
 }