Exemple #1
0
        /// <summary>
        /// Initializes the property and generates the implementation for getter and setter methods.
        /// </summary>
        public FastPropertyInfo(PropertyInfo property)
        {
            this.property = property;

            if (property.CanWrite)
            {
                setValueImpl = DynamicMethodCompiler.CreateSetHandler(property.DeclaringType, property);
            }

            if (property.CanRead)
            {
                getValueImpl = DynamicMethodCompiler.CreateGetHandler(property.DeclaringType, property);
            }
        }
Exemple #2
0
        /// <summary>
        /// Construct a type using the cached constructor
        /// </summary>
        /// todo: consider pooling
        public static object FastConstruct(CacheContext context, Type T)
        {
            InstantiateObjectHandler construct;

            if (context.ConstructCache.TryGetValue(T, out construct))
            {
                return(construct());
            }

            construct = (InstantiateObjectHandler)DynamicMethodCompiler.CreateInstantiateObjectHandler(T);

            context.ConstructCache.Add(T, construct);
            return(construct());
        }