// Keep in mind data contract serializer will bypass constructor
        public SqlServerProfilerResultProcessorConfiguration(string connnectionStringConfigurationKey, 
            string insertCommandText = "",
            ProfilerItemFields? includedProfilerItemFields = null,
            SqlParameterInsertConfiguration sqlParameterInsertConfiguration = null)
        {
            ConnnectionStringConfigurationKey = connnectionStringConfigurationKey;
            InsertCommandText = insertCommandText;

            _userIncludedProfilerItemFields = includedProfilerItemFields;
            _userParameterInsert = sqlParameterInsertConfiguration;

            Init();
        }
        //[TestMethod]
        //This is only here to help regenerate the config section.
        public void CreateConfigurationXml()
        {
            var breadCrumb = new Config.StackTraceBreadCrumbConfiguration(true);
            var parameterInsert = new Config.SqlParameterInsertConfiguration(true, "ProfileItemId", "insert into SqlProfileItemParameter(ProfileItemId, Name, Value, OutputValue, DbType, Size, ParameterDirection) values(@ProfileItemId, @Name, @Value, @OutputValue, @DbType, @Size, @ParameterDirection)");
            var resultProcessor = new Config.SqlServerProfilerResultProcessorConfiguration("NorthwindConnectionString", "insert into SqlProfileItem(CommandText, ExecuteType, StartDateTime, TotalElapsedTicks, TotalElapsedMilliseconds, FirstFetchElapsedTicks, FirstFetchElapsedMilliseconds, StackTraceBreadCrumb, ParameterSummary) values(@ProfileItemId, @CommandText, @ExecuteType, @StartDateTime, @TotalElapsedTicks, @TotalElapsedMilliseconds, @FirstFetchElapsedTicks, @FirstFetchElapsedMilliseconds, @StackTraceBreadCrumb, @ParameterSummary) select @@identity", null, parameterInsert);
            var profilerConfig = new Config.SqlClientProfilerConfiguration(true, resultProcessor, true, breadCrumb);

            var serializer = new DataContractSerializer(typeof(Config.SqlClientProfilerConfiguration));
            using (var fs = new FileStream(@"..\..\..\Generated.config", FileMode.Create))
            {
                serializer.WriteObject(fs, profilerConfig);
            }
        }
        private void Init(bool doDeserializationInit = false)
        {
            if (_initialized)
                return;

            if (_userIncludedProfilerItemFields == null)
            {
                IncludedProfilerItemFields = ProfilerItemFields.CommandText | ProfilerItemFields.ExecuteType | ProfilerItemFields.StartDateTime | ProfilerItemFields.TotalElapsedTicks | ProfilerItemFields.TotalElapsedMilleseconds
                    | ProfilerItemFields.FirstFetchElapsedTicks | ProfilerItemFields.FirstFetchElapsedMilliseconds | ProfilerItemFields.StackTraceBreadCrumb | ProfilerItemFields.ParameterSummary;
            }
            else
                IncludedProfilerItemFields = _userIncludedProfilerItemFields.Value;

            ParameterInsert = _userParameterInsert ?? new SqlParameterInsertConfiguration(false);

            if (doDeserializationInit)
            {
                var requiresInitAfterDeserialization = ParameterInsert as IRequiresInitAfterDeserialization;
                if (requiresInitAfterDeserialization != null)
                    requiresInitAfterDeserialization.InitAfterDeserialization();
            }

            _initialized = true;
        }