private MeasureResult Evaluate(Rainmeter.Settings.InstanceSettings Instance)
        {
            MeasureResult result = null;

            try
            {
                result = GetResource(Instance);

                result = result.Select(Instance);

                result = result.Filter(Instance);

                string strIndex = Instance.INI_Value("Index");
                if (strIndex.Length > 0)
                {
                    int index = int.Parse(strIndex);
                    result = result.Index(index, Instance);
                }
            }
            catch (Exception e)
            {
                result = new ErrorResult(-1, e.Message);
            }
            finally
            {
                Instance.SetTempValue("Age", 0);
                Instance.SetTempValue("Cached", result);
                Instance.SetTempValue("resetId", OutlookPlugin.resetId);
            }
            return(result);
        }
        private bool TryUpdateOtherMeasure(string name, Rainmeter.Settings.InstanceSettings Instance, out MeasureResult result)
        {
            string section = name;

            if (section.StartsWith("["))
            {
                section = section.Substring(1, section.Length - 2);
            }
            Rainmeter.Settings.InstanceSettings other = Instance.GetSection(section);
            if (other == null)
            {
                result = null;
                return(false);
            }

            // a measure that is not directly used by a meter does not age,
            // we have to work around this
            int age = Math.Max((int)other.GetTempValue("Age", 0), (int)Instance.GetTempValue("Age", 0));

            other.SetTempValue("Age", age);

            result = Measure(other);
            Instance.SetTempValue("Base", other);
            return(true);
        }
 private MeasureResult Measure(Rainmeter.Settings.InstanceSettings Instance)
 {
     lock (Instance)
     {
         MeasureResult cached = GetCached(Instance);
         if (cached != null)
         {
             int age = (int)Instance.GetTempValue("Age", 0);
             Instance.SetTempValue("Age", age + 1);
             return(cached);
         }
         return(Evaluate(Instance));
     }
 }