Ejemplo n.º 1
0
        public AppDelegate()
        {
            PrepareCache();
            ExtractImages();
            controller = new MonodocDocumentController();

            // Some UI feature we use rely on Lion or better, so special case it
            try {
                var version    = new NSDictionary("/System/Library/CoreServices/SystemVersion.plist");
                var osxVersion = Version.Parse(version.ObjectForKey(new NSString("ProductVersion")).ToString());
                isOnLion = osxVersion.Major == 10 && osxVersion.Minor >= 7;
            } catch {}

            // Load documentation
            var args = Environment.GetCommandLineArgs();
            IEnumerable <string> extraDocs = null, extraUncompiledDocs = null;

            if (args != null && args.Length > 1)
            {
                var extraDirs = args.Skip(1);
                extraDocs = extraDirs
                            .Where(d => d.StartsWith("+"))
                            .Select(d => d.Substring(1))
                            .Where(d => Directory.Exists(d));
                extraUncompiledDocs = extraDirs
                                      .Where(d => d.StartsWith("@"))
                                      .Select(d => d.Substring(1))
                                      .Where(d => Directory.Exists(d));
            }

            if (extraUncompiledDocs != null)
            {
                foreach (var dir in extraUncompiledDocs)
                {
                    RootTree.AddUncompiledSource(dir);
                }
            }

            if (ConfigurationManager.AppSettings == null)
            {
                Logger.Log("Setting default settings because ConfigurationManager.AppSettings is null");
                var keyValueConfigurationCollection = new KeyValueConfigurationCollection();
                keyValueConfigurationCollection.Add("docPath", "/Library/Frameworks/Mono.framework/Versions/Current/lib/monodoc/");
                keyValueConfigurationCollection.Add("docExternalPath", "");
                typeof(Config).GetField("exeConfig", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, keyValueConfigurationCollection);
                Lucene.Net.Support.AppSettings.Set("java.version", "");
                Lucene.Net.Support.AppSettings.Set("java.vendor", "");
            }

            Root = RootTree.LoadTree();

            if (extraDocs != null)
            {
                foreach (var dir in extraDocs)
                {
                    Root.AddSource(dir);
                }
            }

            var macDocPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "macdoc");

            if (!Directory.Exists(macDocPath))
            {
                Directory.CreateDirectory(macDocPath);
            }
            var helpSources = Root.HelpSources
                              .Cast <HelpSource> ()
                              .Where(hs => !string.IsNullOrEmpty(hs.BaseFilePath) && !string.IsNullOrEmpty(hs.Name))
                              .Select(hs => Path.Combine(hs.BaseFilePath, hs.Name + ".zip"))
                              .Where(File.Exists);

            IndexUpdateManager = new IndexUpdateManager(helpSources,
                                                        macDocPath);
            BookmarkManager = new BookmarkManager(macDocPath);
        }
Ejemplo n.º 2
0
        public AppDelegate()
        {
            PrepareCache();
            ExtractImages();
            controller = new MonodocDocumentController();

            // Some UI feature we use rely on Lion or better, so special case it
            try {
                var version    = new NSDictionary("/System/Library/CoreServices/SystemVersion.plist");
                var osxVersion = Version.Parse(version.ObjectForKey(new NSString("ProductVersion")).ToString());
                isOnLion = osxVersion.Major == 10 && osxVersion.Minor >= 7;
            } catch {}

            // Load documentation
            var args = Environment.GetCommandLineArgs();
            IEnumerable <string> extraDocs = null, extraUncompiledDocs = null;

            if (args != null && args.Length > 1)
            {
                var extraDirs = args.Skip(1);
                extraDocs = extraDirs
                            .Where(d => d.StartsWith("+"))
                            .Select(d => d.Substring(1))
                            .Where(d => Directory.Exists(d));
                extraUncompiledDocs = extraDirs
                                      .Where(d => d.StartsWith("@"))
                                      .Select(d => d.Substring(1))
                                      .Where(d => Directory.Exists(d));
            }

            if (extraUncompiledDocs != null)
            {
                foreach (var dir in extraUncompiledDocs)
                {
                    RootTree.AddUncompiledSource(dir);
                }
            }

            Root = RootTree.LoadTree();

            if (extraDocs != null)
            {
                foreach (var dir in extraDocs)
                {
                    Root.AddSource(dir);
                }
            }

            var macDocPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "macdoc");

            if (!Directory.Exists(macDocPath))
            {
                Directory.CreateDirectory(macDocPath);
            }
            var helpSources = Root.HelpSources
                              .Cast <HelpSource> ()
                              .Where(hs => !string.IsNullOrEmpty(hs.BaseFilePath) && !string.IsNullOrEmpty(hs.Name))
                              .Select(hs => Path.Combine(hs.BaseFilePath, hs.Name + ".zip"))
                              .Where(File.Exists);

            IndexUpdateManager = new IndexUpdateManager(helpSources,
                                                        macDocPath);
            BookmarkManager = new BookmarkManager(macDocPath);
            AppleDocHandler = new AppleDocHandler("/Library/Frameworks/Mono.framework/Versions/Current/etc/");
        }