src/Microsoft.PowerShell.GraphicalHost/ManagementList/FilterProviders/FilterRuleTemplateSelector.cs
/// <summary>
/// Selects a template based upon the type of the item and and the 
/// corresponding template that is registered in the TemplateDictionary.
/// </summary>
/// <param name="item">
/// The item to return a template for.
/// </param>
/// <param name="container">
/// The parameter is not used.
/// </param>
/// <returns>
/// Returns a DataTemplate for item.
/// </returns>
Selects a template based upon the type of the item and and the
corresponding template that is registered in the TemplateDictionary.
Selects a template based upon the type of the item and and the corresponding template that is registered in the TemplateDictionary .
public override DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            if (null == item)
            {
                return base.SelectTemplate(item, container);
            }
            Type type = item as Type;
            if (null == type)
            {
                type = item.GetType();
            }
            DataTemplate template;
            do
            {
                if (type.IsGenericType)
                {
                    type = type.GetGenericTypeDefinition();
                }
                if (this.TemplateDictionary.TryGetValue(type, out template))
                {
                    return template;
                }
                type = type.BaseType;
            } 
            while (null != type);
            return base.SelectTemplate(item, container);
        }
public override DataTemplate SelectTemplate ( object item , System . Windows . DependencyObject container ) { if ( null == item ) { return base . SelectTemplate ( item , container ) ; } Type type = item as Type ; if ( null == type ) { type = item . GetType ( ) ; } DataTemplate template ; do { if ( type . IsGenericType ) { type = type . GetGenericTypeDefinition ( ) ; } if ( this . TemplateDictionary . TryGetValue ( type , out template ) ) { return template ; } type = type . BaseType ; } while ( null != type ) ; return base . SelectTemplate ( item , container ) ; }
Selects a template based upon the type of the item and and the
corresponding template that is registered in the TemplateDictionary.
Selects a template based upon the type of the item and and the corresponding template that is registered in the TemplateDictionary .
Returns a DataTemplate for item.
Returns a DataTemplate for item .
item
object
The item to return a template for.
The item to return a template for .
container
System.Windows.DependencyObject
The parameter is not used.
The parameter is not used .