Apricot.Script.Script C# (CSharp) Method

Script() private method

private Script ( ) : System
return System
        private Script()
        {
            //
            // TODO: Add constructor logic here
            //
            this.characterCollection = new Collection<Character>();
            this.wordCollection = new Collection<Word>();
            this.sequenceCollection = new Collection<Sequence>();
            this.sequenceStateDictionary = new Dictionary<string, string>();
            this.sequenceQueue = new Queue<Sequence>();
            this.cacheDictionary = new Dictionary<string, KeyValuePair<List<KeyValuePair<Entry, double>>, double>>();
            this.recentTermList = new List<string>();
            this.activateEntryQueue = new Queue<Entry>();
            this.lastPolledDateTime = DateTime.Now;
            this.lastUpdatedDateTime = DateTime.Now;

            System.Configuration.Configuration config = null;
            string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);

            if (Directory.Exists(directory))
            {
                string fileName = Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);

                foreach (string s in from s in Directory.EnumerateFiles(directory, "*.config") where fileName.Equals(Path.GetFileNameWithoutExtension(s)) select s)
                {
                    System.Configuration.ExeConfigurationFileMap exeConfigurationFileMap = new System.Configuration.ExeConfigurationFileMap();

                    exeConfigurationFileMap.ExeConfigFilename = s;
                    config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(exeConfigurationFileMap, System.Configuration.ConfigurationUserLevel.None);
                }
            }

            if (config == null)
            {
                config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
            }

            if (config.AppSettings.Settings["PollingInterval"] != null)
            {
                if (config.AppSettings.Settings["PollingInterval"].Value.Length > 0)
                {
                    this.pollingTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Normal);
                    this.pollingTimer.Tick += new EventHandler(delegate
                    {
                        DateTime nowDateTime = DateTime.Now;

                        for (DateTime dateTime = this.lastPolledDateTime.AddSeconds(1); dateTime <= nowDateTime; dateTime = dateTime.AddSeconds(1))
                        {
                            Tick(dateTime);
                        }

                        if (this.sequenceQueue.Count > 0)
                        {
                            this.idleTimeSpan = TimeSpan.Zero;
                        }
                        else
                        {
                            this.idleTimeSpan += nowDateTime - this.lastPolledDateTime;
                        }

                        if (this.idleTimeSpan.Ticks >= this.activateThreshold)
                        {
                            Activate();
                        }

                        if (this.idleTimeSpan.Ticks > 0)
                        {
                            Idle();
                        }

                        this.lastPolledDateTime = nowDateTime;
                    });
                    this.pollingTimer.Interval = TimeSpan.Parse(config.AppSettings.Settings["PollingInterval"].Value, CultureInfo.InvariantCulture);
                }
            }

            if (config.AppSettings.Settings["UpdateInterval"] != null)
            {
                if (config.AppSettings.Settings["UpdateInterval"].Value.Length > 0)
                {
                    this.updateTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Normal);
                    this.updateTimer.Tick += new EventHandler(delegate
                    {
                        Update();
                    });
                    this.updateTimer.Interval = TimeSpan.Parse(config.AppSettings.Settings["UpdateInterval"].Value, CultureInfo.InvariantCulture);
                }
            }

            if (config.AppSettings.Settings["ActivateThreshold"] != null)
            {
                if (config.AppSettings.Settings["ActivateThreshold"].Value.Length > 0)
                {
                    this.activateThreshold = Int64.Parse(config.AppSettings.Settings["ActivateThreshold"].Value, CultureInfo.InvariantCulture);
                }
            }
        }
Script