Version

IKeyedSubObjectEx Interface

Interface used by sub objects that cache an interned lowercase version of their key to optimize key comparisons.
Syntax
'Declaration
 
Public Interface IKeyedSubObjectEx 
   Inherits IKeyedSubObject 
public interface IKeyedSubObjectEx : IKeyedSubObject  
Example
The following is a sample implementation of the 'KeyLowercaseInterned' property exposed off the 'IKeyedSubObjectEx' interface,

Private KeyValue As String = ""
Private KeyInternedValue As String = ""
Private KeyLowercaseInternedValue As String = ""

Public ReadOnly Property KeyLowercaseInterned() As String Implements Infragistics.Shared.IKeyedSubObjectEx.KeyLowercaseInterned

    Get
        If Me.KeyValue.Length = 0 Then Return Me.KeyValue

        ' If the string hasn't changed since the last internment
        ' then return the cached value
        If Object.ReferenceEquals(Me.KeyValue, Me.KeyInternedValue) = True Then
            If Not Me.KeyLowercaseInternedValue Is Nothing Then
                Return Me.KeyLowercaseInternedValue
            End If
        End If

        ' Intern the key and save the interned string reference
        Me.KeyInternedValue = String.Intern(Me.KeyValue)

        ' Intern the string converted to lowercase so we can do case
        ' insensitive compares
        Me.KeyLowercaseInternedValue = String.Intern(Me.KeyInternedValue.ToLower())

        Return Me.KeyLowercaseInternedValue

    End Get

End Property
private string keyInterned;
private string keyLowercaseInterned;
private string key = "";

string IKeyedSubObjectEx.KeyLowercaseInterned
{

	get 
	{
		string key = this.key;
		
		if ( key == null || key.Length == 0 )
			return key;
		
		// If the string hasn't changed since the last internment
		// then return the cached value
		if ( object.ReferenceEquals( key, this.keyInterned ) )
		{
			if ( this.keyLowercaseInterned != null )
				return this.keyLowercaseInterned;
		}
		
		// Intern the key and save the interned string reference
		//
		this.keyInterned = string.Intern( key );
		
		// Intern the string converted to lowercase so we can do case
		// insensitive compares
		//
		this.keyLowercaseInterned = string.Intern( this.keyInterned.ToLower() );
		
		return this.keyLowercaseInterned;
	}

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also