Example #1
0
        /// <summary>
        /// Returns the supplied Source object without any event hooks.
        /// </summary>
        public static object WithoutEventHooks(this object Source)
        {
            if (Source == null)
            {
                return(null);
            }

            var FieldDefs = Source.GetType().GetEventFields();

            foreach (FieldInfo FieldDef in FieldDefs)
            {
                if (FieldDef.GetValue(Source) != null)
                {
                    FieldDef.SetValue(Source, null);
                }
            }

            return(Source);
        }