Пример #1
0
        /// <summary>
        /// Returns true if this is the first run.
        /// </summary>
        private bool CheckFirstRun()
        {
            // Chuleta:
            // conf = startDate
            // settings = lastUse
            IValueStore[] stores = { new RegistryValueStore("default_conf"),     new AdsValueStore("default_conf"),
                                     new RegistryValueStore("default_settings"), new AdsValueStore("default_settings") };

            bool anyWritten = false;

            for (int i = 0; i < stores.Length; i++)
            {
                IValueStore store = stores[i];
                if (store.HasBeenWrittenBefore())
                {
                    anyWritten = true;
                    break;
                }
            }
            return(!anyWritten);
        }
Пример #2
0
        private static bool GetConsistentValue(IValueStore[] stores, out long value)
        {
            long? lastUseLong = new long?();
            value = 0;
            for (int i = 0; i < stores.Length; i++)
            {
                long lastUseLongTemp;
                if (stores[i].TryReadValue(out lastUseLongTemp))
                {
                    if (!lastUseLong.HasValue)
                        lastUseLong = lastUseLongTemp;
                    else if (lastUseLong != lastUseLongTemp)
                        return false;
                }
                else
                    return false;
            }

            // Consistent!
            value = lastUseLong.Value;
            return true;
        }