internal XamlObjectWriterSettings StripDelegates()
        {
            XamlObjectWriterSettings result = new XamlObjectWriterSettings(this);

            // We need better protection against leaking out these delegates
            result.AfterBeginInitHandler   = null;
            result.AfterEndInitHandler     = null;
            result.AfterPropertiesHandler  = null;
            result.BeforePropertiesHandler = null;
#if !TARGETTING35SP1
            result.XamlSetValueHandler = null;
#endif
            return(result);
        }
        public XamlObjectWriterSettings(XamlObjectWriterSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            AfterBeginInitHandler   = settings.AfterBeginInitHandler;
            BeforePropertiesHandler = settings.BeforePropertiesHandler;
            AfterPropertiesHandler  = settings.AfterPropertiesHandler;
            AfterEndInitHandler     = settings.AfterEndInitHandler;
#if !TARGETTING35SP1
            XamlSetValueHandler = settings.XamlSetValueHandler;
#endif
            RootObjectInstance               = settings.RootObjectInstance;
            IgnoreCanConvert                 = settings.IgnoreCanConvert;
            ExternalNameScope                = settings.ExternalNameScope;
            SkipDuplicatePropertyCheck       = settings.SkipDuplicatePropertyCheck;
            RegisterNamesOnExternalNamescope = settings.RegisterNamesOnExternalNamescope;
            AccessLevel                     = settings.AccessLevel;
            SkipProvideValueOnRoot          = settings.SkipProvideValueOnRoot;
            PreferUnconvertedDictionaryKeys = settings.PreferUnconvertedDictionaryKeys;
            SourceBamlUri                   = settings.SourceBamlUri;
        }