Example #1
0
    public static void ExportCulture(string directoryName, CultureInfo ci)
    {
        bool?replace = null;
        bool?delete  = null;

        SyncFolder(ref replace, ref delete, Path.Combine(directoryName, ci.Name, AppendicesDirectory),
                   Database.Query <AppendixHelpEntity>().Where(ah => ah.Culture.Name == ci.Name).ToList(),
                   ah => "{0}.{1}.help".FormatWith(RemoveInvalid(ah.UniqueName), ah.Culture.Name),
                   ah => AppendixXml.ToXDocument(ah));

        SyncFolder(ref replace, ref delete, Path.Combine(directoryName, ci.Name, NamespacesDirectory),
                   Database.Query <NamespaceHelpEntity>().Where(nh => nh.Culture.Name == ci.Name).ToList(),
                   nh => "{0}.{1}.help".FormatWith(RemoveInvalid(nh.Name), nh.Culture.Name),
                   nh => NamespaceXml.ToXDocument(nh));

        SyncFolder(ref replace, ref delete, Path.Combine(directoryName, ci.Name, TypesDirectory),
                   Database.Query <TypeHelpEntity>().Where(th => th.Culture.Name == ci.Name).ToList(),
                   th => "{0}.{1}.help".FormatWith(RemoveInvalid(th.Type.CleanName), th.Culture.Name),
                   th => EntityXml.ToXDocument(th));

        SyncFolder(ref replace, ref delete, Path.Combine(directoryName, ci.Name, QueriesDirectory),
                   Database.Query <QueryHelpEntity>().Where(qh => qh.Culture.Name == ci.Name).ToList(),
                   qh => "{0}.{1}.help".FormatWith(RemoveInvalid(qh.Query.Key), qh.Culture.Name),
                   qh => QueryXml.ToXDocument(qh));
    }
Example #2
0
        public static void ExportAll(string directoryName = "../../Help")
        {
            bool?replace = null;

            foreach (var ah in Database.Query <AppendixHelpEntity>())
            {
                string path = Path.Combine(directoryName, ah.Culture.Name, AppendicesDirectory, "{0}.{1}.help".FormatWith(RemoveInvalid(ah.UniqueName), ah.Culture.Name));

                FileTools.CreateParentDirectory(path);

                if (!File.Exists(path) || SafeConsole.Ask(ref replace, "Overwrite {0}?".FormatWith(path)))
                {
                    AppendixXml.ToXDocument(ah).Save(path);
                }
            }

            foreach (var nh in Database.Query <NamespaceHelpEntity>())
            {
                string path = Path.Combine(directoryName, nh.Culture.Name, NamespacesDirectory, "{0}.{1}.help".FormatWith(RemoveInvalid(nh.Name), nh.Culture.Name));

                FileTools.CreateParentDirectory(path);

                if (!File.Exists(path) || SafeConsole.Ask(ref replace, "Overwrite {0}?".FormatWith(path)))
                {
                    NamespaceXml.ToXDocument(nh).Save(path);
                }
            }

            foreach (var eh in Database.Query <EntityHelpEntity>())
            {
                string path = Path.Combine(directoryName, eh.Culture.Name, EntitiesDirectory, "{0}.{1}.help".FormatWith(RemoveInvalid(eh.Type.CleanName), eh.Culture.Name));

                FileTools.CreateParentDirectory(path);

                if (!File.Exists(path) || SafeConsole.Ask(ref replace, "Overwrite {0}?".FormatWith(path)))
                {
                    EntityXml.ToXDocument(eh).Save(path);
                }
            }

            foreach (var qh in Database.Query <QueryHelpEntity>())
            {
                string path = Path.Combine(directoryName, qh.Culture.Name, QueriesDirectory, "{0}.{1}.help".FormatWith(RemoveInvalid(qh.Query.Key), qh.Culture.Name));

                FileTools.CreateParentDirectory(path);

                if (!File.Exists(path) || SafeConsole.Ask(ref replace, "Overwrite {0}?".FormatWith(path)))
                {
                    QueryXml.ToXDocument(qh).Save(path);
                }
            }
        }