Esempio n. 1
0
        /// <summary>
        /// GreaseMonkeyの読み込み
        /// </summary>
        private void LoadScripts()
        {
            var folder = Path.Combine(mBasePath, "Scripts");

            if (!Directory.Exists(folder))
            {
                return;
            }

            if (!mInitialized)
            {
                try
                {
                    mLock.EnterUpgradeableReadLock();
                    if (!mInitialized)
                    {
                        mTrixieScripts.Clear();
                        Init(mBasePath);
                        var  files = Directory.GetFiles(folder, "*.js");
                        bool flag  = false;
                        foreach (var file in files)
                        {
                            try
                            {
                                var script = new TrixieScript();
                                if (script.Load(file, true))
                                {
                                    mTrixieScripts.Add(script);
                                    var name = Path.GetFileName(file);
                                    if (!mSettings.ContainsKey(name))
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        script.Enabled = mSettings[name];
                                    }
                                }
                            }
                            catch (Exception exception)
                            {
                                Trace.WriteLine(exception);
                            }
                        }
                        if (flag)
                        {
                            UpdateConfigXml();
                        }
                        mInitialized = true;
                    }
                }
                finally
                {
                    mLock.ExitUpgradeableReadLock();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// GreaseMonkeyの読み込み
        /// </summary>
        private void LoadScripts()
        {
            var folder = Path.Combine( mBasePath , "Scripts" );
            if ( !Directory.Exists( folder ) )
            {
                return;
            }

            if ( !mInitialized )
            {
                try
                {
                    mLock.EnterUpgradeableReadLock();
                    if ( !mInitialized )
                    {
                        mTrixieScripts.Clear();
                        Init( mBasePath );
                        var files = Directory.GetFiles( folder , "*.js" );
                        bool flag = false;
                        foreach ( var file in files )
                        {
                            try
                            {
                                var script = new TrixieScript();
                                if ( script.Load( file , true ) )
                                {
                                    mTrixieScripts.Add( script );
                                    var name = Path.GetFileName( file );
                                    if ( !mSettings.ContainsKey( name ) )
                                    {
                                        flag = true;
                                    }
                                    else
                                    {
                                        script.Enabled = mSettings[name];
                                    }
                                }
                            }
                            catch ( Exception exception )
                            {
                                Trace.WriteLine( exception );
                            }
                        }
                        if ( flag )
                        {
                            UpdateConfigXml();
                        }
                        mInitialized = true;
                    }
                }
                finally
                {
                    mLock.ExitUpgradeableReadLock();
                }
            }
        }