Infragistics2.Shared.v8.1
IKeyedSubObjectEx Interface
See Also  Members   Example
Infragistics.Shared Namespace : IKeyedSubObjectEx Interface

Interface used by sub objects that cache an interned lowercase version of their key to optimize key comparisons.

Syntax

Visual Basic (Declaration) 
Public Interface IKeyedSubObjectEx 
   Inherits IKeyedSubObject 
C# 
public interface IKeyedSubObjectEx : IKeyedSubObject  

Example

The following is a sample implementation of the 'KeyLowercaseInterned' property exposed off the 'IKeyedSubObjectEx' interface,

Visual BasicCopy Code
    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


C#Copy Code
       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;
           }

       }

See Also