object[] GetValues( string [] properties, IContact contact ) { object [] values = new object[ properties.Length ]; for ( int i = 0; i < properties.Length; i++ ) { if ( properties[ i ].Length >= 3 ) { string propertyName = properties[ i ].Substring( 1, properties[ i ].Length - 2 ) ; if ( propertyName != "DisplayName" ) { try { PropertyAccessor propertyAccessor = new PropertyAccessor( typeof ( IContact ), propertyName ) ; values[ i ] = propertyAccessor.Get( contact ) ; } catch ( PropertyAccessorException ) { values[ i ] = string.Format( Resources.Error_InvalidContactProp, propertyName ) ; } } else { values[ i ] = Resources.Error_InvDisplayName ; } } else { values[ i ] = null ; } } return values ; }
private object GetValueSafe(string name) { PropertyAccessor propertyAccessor; lock (_propertyAccessorLock) { _propertyAccessors.TryGetValue(name, out propertyAccessor); if (propertyAccessor == null) { propertyAccessor = new PropertyAccessor(typeof (Contact), name); _propertyAccessors.Add(name, propertyAccessor); } } if (_activeContact != null) { return propertyAccessor.Get(_activeContact); } else { return null; } }