示例#1
0
    public static void Main(string[] args)
    {
        string samplesPath = args[0];
        string inDir       = args[1];

        if (!File.Exists(samplesPath))
        {
            Console.WriteLine("Couldn't find samples repository at {0}");
            return;
        }
        if (!Directory.Exists(inDir))
        {
            Console.WriteLine("Couldn't find input snippet directory");
            return;
        }

        var langExtensions = new Dictionary <string, string> ()
        {
            { ".xml", "XML" },
            { ".cs", "C#" }
        };

        SampleRepository samples = SampleRepository.LoadFrom(samplesPath);

        foreach (var file in Directory.EnumerateFiles(inDir, "*", SearchOption.AllDirectories))
        {
            var extension = Path.GetExtension(file);
            var id        = Path.GetFileNameWithoutExtension(file);
            if (string.IsNullOrEmpty(extension) || string.IsNullOrEmpty(id))
            {
                continue;
            }

            string lang;
            if (!langExtensions.TryGetValue(extension, out lang) || !samples.IsValidID(id))
            {
                Console.WriteLine("Not processed: {0}", Path.GetFileName(file));
                continue;
            }

            SampleDesc oldDesc = samples.GetSampleDescFromID(id);
            samples.OverwriteSample(id, File.ReadAllText(file), new SampleDesc {
                ID       = id,
                Language = lang,
                DocumentationFilePath = oldDesc.DocumentationFilePath,
                FullTypeName          = oldDesc.FullTypeName
            });
            Console.WriteLine("Done: {0}", id);
        }

        samples.Close(false);
    }
示例#2
0
        public static void Run(ProcessingContext options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            ProcessingContext = options;
            HtmlLoader        = new HtmlLoader(ProcessingContext);

            // samples are valid only for DroidDoc. Do not try to read them for other doclets.
            try {
                Samples = options.SamplesPath != null?File.Exists(options.SamplesPath) ? SampleRepository.LoadFrom(options.SamplesPath) : new SampleRepository(options.SamplesPath) : null;
            } catch {
            }

            Assemblies     = LoadAssemblies(options.Assemblies);
            EnumMappings   = CreateEnumMappings(out EnumMappingsReversed);
            PackageRenames = CreatePackageRenames();
            ProcessAssemblies(options.TypesToProcess, options.TypesToSkip);
            if (Samples != null)
            {
                Samples.Close(true);
            }
        }