コード例 #1
0
        public T Create<T>(IDataItem source)
        {
            if (source == null) return default(T);

            if (typeof(T).IsAssignableFrom(source.GetType()))
                return (T)source;

            // need to unproxy otherwise Mapper won't recognize the type (nhibernate proxy class)
            T result = Mapper.Map<T>(NHibernateUtility.Unproxy(Session, source));

            foreach (var injection in _injections)
            {
                result.InjectFrom(injection, source);
            }

            return result;
        }