private void SerializeProperty(string propertyName, TelemetryComplexProperty propertyValue, IEventProcessorContext eventProcessorContext, List <KeyValuePair <string, string> > propertiesToModify) { serializer.SetTypeConverter(piiProcessor.TypeOfPiiProperty(), converterToHashValue); propertiesToModify.Add(new KeyValuePair <string, string>(propertyName, serializer.Serialize(propertyValue.Value))); if (serializer.WasConverterUsedForType(piiProcessor.TypeOfPiiProperty()) && piiProcessor.CanAddRawValue(eventProcessorContext)) { serializer.SetTypeConverter(piiProcessor.TypeOfPiiProperty(), converterToRawValue); propertiesToModify.Add(new KeyValuePair <string, string>(piiProcessor.BuildRawPropertyName(propertyName), serializer.Serialize(propertyValue.Value))); } }
/// <summary> /// Execute action on event, using eventProcessorContext as a provider of the necessary information. /// Return true if it is allowed to execute next actions. /// Return false action forbids the event. /// </summary> /// <param name="eventProcessorContext"></param> /// <returns>Indicator, whether current action is not explicitely forbid current event</returns> public bool Execute(IEventProcessorContext eventProcessorContext) { CodeContract.RequiresArgumentNotNull <IEventProcessorContext>(eventProcessorContext, "eventProcessorContext"); TelemetryEvent telemetryEvent = eventProcessorContext.TelemetryEvent; List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(); foreach (KeyValuePair <string, object> property in telemetryEvent.Properties) { if (property.Value != null && property.Value.GetType() == piiPropertyProcessor.TypeOfPiiProperty()) { list.Add(new KeyValuePair <string, object>(property.Key, piiPropertyProcessor.ConvertToHashedValue(property.Value))); if (piiPropertyProcessor.CanAddRawValue(eventProcessorContext)) { list.Add(new KeyValuePair <string, object>(piiPropertyProcessor.BuildRawPropertyName(property.Key), piiPropertyProcessor.ConvertToRawValue(property.Value))); } piiedProperties.Add(property.Key); totalPiiProperties++; } } foreach (KeyValuePair <string, object> item in list) { telemetryEvent.Properties[item.Key] = item.Value; } return(true); }