Пример #1
0
        /// <summary>
        /// This method will set the value for a given property
        /// </summary>
        /// <param name="tag">property name</param>
        /// <param name="tagvalue">property value</param>
        public static void SetProperty(string tag, string tagvalue)
        {
            if (String.IsNullOrEmpty(tag) || tag[0] != '#')
            {
                return;
            }

            if (tagvalue == null)
            {
                tagvalue = string.Empty;
            }

            if (tag.Equals("#currentmodule"))
            {
                try
                {
                    GUIGraphicsContext.form.Text = "MediaPortal - " + tagvalue;
                }
                catch (Exception ex)
                {
                    Log.Error("PropertyManager: SetProperty {0}", ex.Message);
                }
            }

            bool changed = false;

            lock (_properties)
            {
                string oldValue;
                changed = !_properties.TryGetValue(tag, out oldValue) || oldValue != tagvalue; // saves one lookup
                //changed = (!_properties.ContainsKey(tag) || _properties[tag] != tagvalue);
                if (changed)
                {
                    _properties[tag] = tagvalue;
                }
            }

            if (changed)
            {
                GUIExpressionManager.InvalidateExpression(tag);
            }

            if (changed && OnPropertyChanged != null)
            {
                _isChanged = true;
                OnPropertyChanged(tag, tagvalue);
            }
        }
Пример #2
0
        /// <summary>
        /// Parses a property request.
        /// </summary>
        /// <param name="line">The identification of the propertie (e.g.,#title).</param>
        /// <param name="options">Expresson manager processing options.</param>
        /// <returns>The value of the property.</returns>
        public static string Parse(string line, GUIExpressionManager.ExpressionOptions options)
        {
            if (line == null)
            {
                return(string.Empty);
            }

            line = GUIExpressionManager.Parse(line, options);

            if (line.IndexOf('#') > -1)
            {
                // Matches a property tag and replaces it with the value for that property
                // sort the matches descending by the length of their value, to prevent a match named "#selecteditem" replacing "#selecteditem2" in the line
                var matches = from Match aMatch in propertyExpr.Matches(line)
                              orderby aMatch.Value.Length descending
                              select aMatch.Value;
                foreach (string match in matches)
                {
                    line = line.Replace(match, ParseProperty(match));
                }
            }

            return(line);
        }
Пример #3
0
    /// <summary>
    /// Parses a property request.
    /// </summary>
    /// <param name="line">The identification of the propertie (e.g.,#title).</param>
    /// <param name="options">Expresson manager processing options.</param>
    /// <returns>The value of the property.</returns>
    public static string Parse(string line, GUIExpressionManager.ExpressionOptions options)
    {
      if (line == null)
      {
        return string.Empty;
      }

      line = GUIExpressionManager.Parse(line, options);

      if (line.IndexOf('#') > -1)
      {
        // Matches a property tag and replaces it with the value for that property
        // sort the matches descending by the length of their value, to prevent a match named "#selecteditem" replacing "#selecteditem2" in the line
        var matches = from Match aMatch in propertyExpr.Matches(line)
                      orderby aMatch.Value.Length descending
                      select aMatch.Value;
        foreach (string match in matches)
        {
          line = line.Replace(match, ParseProperty(match));
        }
      }

      return line;
    }