Esempio n. 1
0
        public static SampleRepository LoadFrom(string file)
        {
            var samples = new SampleRepository(ZipFile.Read(file));

            return(samples);
        }
Esempio n. 2
0
        public AppleDocMerger(Options options)
        {
            this.options = options;

            if (options.Assembly == null)
            {
                throw new ArgumentNullException("options.Assembly");
            }
            if (string.IsNullOrEmpty(options.BaseAssemblyNamespace))
            {
                throw new ArgumentNullException("options.BaseAssemblyNamespace");
            }
            assemblyTypesLookup = new Dictionary <string, TypeDefinition> ();
            foreach (var t in GetTypes(options.Assembly))
            {
                if (assemblyTypesLookup.ContainsKey(t.Name))
                {
                    Console.WriteLine("Duplicated name {0} between {1} and {2}", t.Name, t.FullName, assemblyTypesLookup[t.Name].FullName);
                }
                else
                {
                    assemblyTypesLookup[t.Name] = t;
                }
            }

            if (options.MonodocArchive == null)
            {
                throw new ArgumentNullException("options.MonodocArchive");
            }

            if (string.IsNullOrEmpty(options.DocBase) || !Directory.Exists(options.DocBase))
            {
                throw new ArgumentException(string.Format("DocBase '{0}' isn't valid", options.DocBase), "options.DocBase");
            }

            var dbPath = Path.Combine(options.DocBase, "..", "..", "docSet.dsidx");

            if (!File.Exists(dbPath))
            {
                throw new ArgumentException("DocBase doesn't contain a valid database file", "options.DocBase");
            }
            db = new SQLiteConnection(dbPath);

            var samplesPath = string.IsNullOrEmpty(options.SamplesRepositoryPath) ? Path.Combine(options.DocBase, "samples.zip") : options.SamplesRepositoryPath;

            if (options.ImportSamples && !File.Exists(samplesPath))
            {
                throw new ArgumentException("We were asked to import samples but repository doesn't exist", samplesPath);
            }
            samples = File.Exists(samplesPath) ? SampleRepository.LoadFrom(samplesPath) : new SampleRepository(samplesPath);

            pathCallback = options.MergingPathCallback;

            HtmlToMdocElementMapping = new Dictionary <string, Func <XElement, bool, object> > {
                { "section", (e, i) => new [] { new XElement("para", HtmlToMdoc((XElement)e.FirstNode)) }.Concat(HtmlToMdoc(e.Nodes().Skip(1), i)) },
                { "a", (e, i) => ConvertLink(e, i) },
                { "code", (e, i) => ConvertCode(e, i) },
                { "div", (e, i) => ConvertDiv(e, i) },
                { "em", (e, i) => new XElement("i", HtmlToMdoc(e.Nodes(), i)) },
                { "li", (e, i) => new XElement("item", new XElement("term", HtmlToMdoc(e.Nodes(), i))) },
                { "ol", (e, i) => new XElement("list", new XAttribute("type", "number"), HtmlToMdoc(e.Nodes())) },
                { "p", (e, i) => new XElement("para", HtmlToMdoc(e.Nodes(), i)) },
                { "span", (e, i) => HtmlToMdoc(e.Nodes(), i) },
                { "strong", (e, i) => new XElement("i", HtmlToMdoc(e.Nodes(), i)) },
                { "tt", (e, i) => new XElement("c", HtmlToMdoc(e.Nodes(), i)) },
                { "ul", (e, i) => new XElement("list", new XAttribute("type", "bullet"), HtmlToMdoc(e.Nodes())) },
            };
        }
Esempio n. 3
0
 public static SampleRepository LoadFrom(string file)
 {
     var samples = new SampleRepository (ZipFile.Read (file));
     return samples;
 }