示例#1
0
        /// <summary>
        /// Allow special syntax to retrieve property values:
        /// ${property:PropertyName}
        /// ${property:PropertyName??DefaultValue}
        /// ${property:ContainerName/PropertyName}
        /// ${property:ContainerName/PropertyName??DefaultValue}
        /// A container is a Properties instance stored in the PropertyService. This is
        /// used by many AddIns to group all their properties into one container.
        /// </summary>
        static string GetProperty(string propertyName)
        {
            string defaultValue = "";
            int    pos          = propertyName.LastIndexOf("??", StringComparison.Ordinal);

            if (pos >= 0)
            {
                defaultValue = propertyName.Substring(pos + 2);
                propertyName = propertyName.Substring(0, pos);
            }
            Properties properties = ServiceSingleton.GetRequiredService <IPropertyService>().MainPropertiesContainer;

            pos = propertyName.IndexOf('/');
            while (pos >= 0)
            {
                properties   = properties.NestedProperties(propertyName.Substring(0, pos));
                propertyName = propertyName.Substring(pos + 1);
                pos          = propertyName.IndexOf('/');
            }
            return(properties.Get(propertyName, defaultValue));
        }
示例#2
0
 /// <inheritdoc cref="Properties.NestedProperties"/>
 public Properties NestedProperties(string key)
 {
     return(properties.NestedProperties(key));
 }