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);
        }
 public string GetString(Rainmeter.Settings.InstanceSettings Instance)
 {
     try
     {
         MeasureResult result = Measure(Instance);
         return(result.AsString(Instance));
     }
     catch (Exception e)
     {
         Rainmeter.Log(Rainmeter.LogLevel.Error, "Sorry, " + e.ToString());
         return("Sorry, " + e.ToString());
     }
 }
 public double Update2(Rainmeter.Settings.InstanceSettings Instance)
 {
     try
     {
         MeasureResult result = Measure(Instance);
         return(result.AsDouble(Instance));
     }
     catch (Exception e)
     {
         Rainmeter.Log(Rainmeter.LogLevel.Error, "Sorry, " + e.ToString());
         return(double.NaN);
     }
 }
 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));
     }
 }
 // 'ExecuteBang' is a way of Rainmeter telling your plugin to do something *right now*.
 // What it wants to do can be defined by the 'Command' parameter.
 public void ExecuteBang(Rainmeter.Settings.InstanceSettings Instance, string Command)
 {
     //string[] args = Command.Split(' ');
     //Command = args[0];
     try
     {
         switch (Command)
         {
         case "ClearCache":
             resetId++;
             return;
         }
         MeasureResult mr = Measure(Instance);
         mr.Bang(GetOutlook(), Command);
     }
     catch (Exception e)
     {
         Rainmeter.Log(Rainmeter.LogLevel.Error, e.ToString());
     }
     return;
 }
        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);
        }