public void TryPublish(ServiceCallEvent callEvent, IEnumerable <DictionaryEntry> arguments, ServiceMethod serviceMethod) { EndPointMetadata metaData = _serviceEndPointDefinition.GetMetaData(serviceMethod); callEvent.Params = arguments.SelectMany(_ => ExtractParamValues(_, metaData)).Select(_ => new Param { Name = _.name, Value = _.value, Sensitivity = _.sensitivity, }); _eventPublisher.TryPublish(callEvent); }
private IEnumerable <Param> ExtractParamValues(object[] arguments, ServiceMethod serviceMethod) { EndPointMetadata metaData = _serviceEndPointDefinition.GetMetaData(serviceMethod); var methodParameterInfos = serviceMethod.ServiceInterfaceMethod.GetParameters(); for (int i = 0; i < arguments.Length; i++) { var parameterInfo = methodParameterInfos[i]; var value = arguments[i]; var sensitivity = metaData.ParameterAttributes[parameterInfo.Name].Sensitivity ?? metaData.MethodSensitivity ?? Sensitivity.Sensitive; if (metaData.ParameterAttributes[parameterInfo.Name].IsLogFieldAttributeExists == true && (value is string) == false && value?.GetType().IsClass == true) { var metaParams = _membersToLogExtractor.ExtractMembersToLog(value); foreach (var metaParam in metaParams) { yield return(new Param { Name = string.Intern($"{parameterInfo.Name}_{metaParam.Name}"), Value = metaParam.Value, Sensitivity = metaParam.Sensitivity ?? sensitivity }); } } else { yield return(new Param { Name = parameterInfo.Name, Value = value, Sensitivity = sensitivity }); } } ; }
private IEnumerable <(string name, object value, Sensitivity sensitivity)> ExtractParamValues(DictionaryEntry pair, EndPointMetadata metaData) { var key = pair.Key.ToString(); var sensitivity = metaData.ParameterAttributes[key].Sensitivity ?? metaData.MethodSensitivity ?? Sensitivity.Sensitive; if (metaData.ParameterAttributes[key].IsLogFieldAttributeExists == true && (pair.Value is string) == false) { var type = pair.Value?.GetType(); if (type?.IsClass == true) { var metaParams = _metadataPropertiesCache.ParseIntoParams(pair.Value); foreach (var metaParam in metaParams) { var tuple = ( name : $"{key}_{metaParam.Name}", value : metaParam.Value, sensitivity : metaParam.Sensitivity ?? sensitivity); yield return(tuple); } } } else { yield return(key, pair.Value, sensitivity); } }