RemovePropertyIfPresent() public method

Remove a property from the event, if present. Otherwise no action is performed.
public RemovePropertyIfPresent ( string propertyName ) : void
propertyName string The name of the property to remove.
return void
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory factory)
        {
            var trace = new StackTrace();
            const int index = 5;
            if (trace.FrameCount < index)
            {
                logEvent.RemovePropertyIfPresent("ClassName");
                logEvent.RemovePropertyIfPresent("MethodName");
                return;
            }

            var method = trace.GetFrame(index).GetMethod();

            logEvent.AddOrUpdateProperty(factory.CreateProperty("ClassName", method.ReflectedType));
            logEvent.AddOrUpdateProperty(factory.CreateProperty("MethodName", method.ToString()));
        }
        public void Emit(LogEvent logEvent)
        {
            var correctedLogEvent = logEvent;
            if (logEvent.Properties.ContainsKey(Common.Constants.KeyPassportTimestamp))
            {
                var passportTimestampProperty = logEvent.Properties[Common.Constants.KeyPassportTimestamp];
                if (passportTimestampProperty != null)
                {
                    var passportTimestampValue = passportTimestampProperty as ScalarValue;
                    if (passportTimestampValue != null)
                    {
                        if (passportTimestampValue.Value is DateTimeOffset)
                        {
                            var passportTimestamp = (DateTimeOffset)passportTimestampValue.Value;
                            correctedLogEvent = new LogEvent(passportTimestamp
                                                                , logEvent.Level
                                                                , logEvent.Exception
                                                                , logEvent.MessageTemplate
                                                                , logEvent.Properties.Select(x => new LogEventProperty(x.Key, x.Value)).ToList()
                                                                );
                            correctedLogEvent.RemovePropertyIfPresent(Common.Constants.KeyPassportTimestamp);
                        }
                    }
                }
            }

            _destination.Write(correctedLogEvent);
        }