/// <summary>
        /// Creates dynamic field instance for the specified <see cref="FieldInfo"/>.
        /// </summary>
        /// <param name="field">Field info to create dynamic field for.</param>
        /// <returns>Dynamic field for the specified <see cref="FieldInfo"/>.</returns>
        public static IDynamicField Create(FieldInfo field)
        {
            field.ThrowIfNull("field", "You cannot create a dynamic field for a null value.");

            IDynamicField dynamicField = new SafeFieldWrapper(field);
            return dynamicField;
        }
 public FastField(FieldInfo field, bool omitGetInitializer)
 {
     field.ThrowIfNull("field", "Paramater cannot be null.");
     this.Field = field;
     if (!omitGetInitializer)
         InitializeGet();
     InitializeSet();
 }
        /// <summary>
        /// Creates a new instance of the safe field wrapper.
        /// </summary>
        /// <param name="field">Field to wrap.</param>
        public SafeFieldWrapper(FieldInfo field)
        {
            field.ThrowIfNull("field", "You cannot create a dynamic field for a null value.");

            fieldInfo = field;
            DynamicFieldInfo fi = GetOrCreateDynamicField(field);
            getter = fi.Getter;
            setter = fi.Setter;
        }
        /// <summary>
        /// Create a new Set method delegate for the specified field using <see cref="System.Reflection.Emit.DynamicMethod"/>
        /// </summary>
        /// <param name="fieldInfo">the field to create the delegate for</param>
        /// <returns>a delegate that can be used to read the field.</returns>
        /// <remarks>
        /// If the field's <see cref="FieldInfo.IsLiteral"/> returns true, the returned method 
        /// will throw an <see cref="InvalidOperationException"/> when called.
        /// </remarks>
        public static FieldSetterDelegate CreateFieldSetter(FieldInfo fieldInfo)
        {
            fieldInfo.ThrowIfNull("fieldInfo", "You cannot create a delegate for a null value.");

            bool skipVisibility = true; // !IsPublic(fieldInfo);
            System.Reflection.Emit.DynamicMethod dmSetter = CreateDynamicMethod("set_" + fieldInfo.Name, null, new Type[] { typeof(object), typeof(object) }, fieldInfo, skipVisibility);
            ILGenerator il = dmSetter.GetILGenerator();
            EmitFieldSetter(il, fieldInfo, false);
            return (FieldSetterDelegate)dmSetter.CreateDelegate(typeof(FieldSetterDelegate));
        }