/// <summary> /// Get a deserializer for dynamic objects. /// </summary> /// <typeparam name="T">The type of object to deserialize.</typeparam> /// <typeparam name="TImpl">The type of object to use to implement the requested type.</typeparam> /// <returns>A deserializer that returns dynamic objects.</returns> private static Func <IDataReader, T> GetDynamicDeserializer <T, TImpl>() where TImpl : T, IDictionary <String, Object>, new() { return(r => { // we need it to implement IDictionary so we can set the properties T t = new TImpl(); IDictionary <String, Object> o = (IDictionary <String, Object>)t; // get all of the values at once to avoid overhead int fieldCount = r.FieldCount; object[] values = new object[fieldCount]; r.GetValues(values); // stick the values into the array for (int i = 0; i < fieldCount; i++) { // handle dbnull conversion object value = values[i]; if (value == DBNull.Value) { value = null; } // set the value on the dictionary // GetName is pretty efficient o.Add(r.GetName(i), value); } return t; }); }
public AvaloniaLocator ToSingleton <TImpl>() where TImpl : class, TService, new() { TImpl instance = null; return(ToFunc(() => instance ?? (instance = new TImpl()))); }
public XRC4Cipher(string pKey) { m_pImpl = new TImpl(); Clear(); m_pImpl.Init(pKey); }
public ConvertComparer(TImpl source) { _source = source; }
public ConvertCursor(ICursor <TKey, TValue> innerCursor, TImpl source) { _innerCursor = innerCursor; _source = source; }