コード例 #1
0
 public static MethodInvocationLoggingConfiguration <BusinessEvent> WithAdditionalData(
     this MethodInvocationLoggingConfiguration <BusinessEvent> config, Func <IContainer, InvocationData, object> additionalDataRetriever, string additionalDataKey)
 {
     return(config.PrepareLogData((container, data, logData) =>
     {
         logData.AdditionalData.Add(additionalDataKey, additionalDataRetriever(container, data));
     }));
 }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithAllArguments(this MethodInvocationLoggingConfiguration <DictionaryLogData> config)
 {
     return(config.PrepareLogData((container, data, logData) =>
     {
         foreach (KeyValuePair <string, object> arg in data.Arguments)
         {
             logData[arg.Key] = arg.Value;
         }
     }));
 }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithExceptionIfThrown(this MethodInvocationLoggingConfiguration <DictionaryLogData> config,
                                                                                              string dataKeyName)
 {
     return(config.PrepareLogData(((container, invocationData, logData) =>
     {
         if (invocationData.Raw.Exception != null)
         {
             logData[dataKeyName] = invocationData.Raw.Exception;
         }
     })));
 }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithArguments(this MethodInvocationLoggingConfiguration <DictionaryLogData> config,
                                                                                      params string[] argumentsNames)
 {
     return(config.PrepareLogData((container, data, logData) =>
     {
         foreach (string argName in argumentsNames)
         {
             logData[argName] = data.Arguments[argName];
         }
     }));
 }
コード例 #5
0
        public static MethodInvocationLoggingConfiguration <BusinessEvent> WithUserNameFromCurrentUserContext(
            this MethodInvocationLoggingConfiguration <BusinessEvent> config)
        {
            return(config.PrepareLogData(((container, invocationData, logData) =>
            {
                var currentUserContext = container.Resolve <IUserContext>();
                var userNameRetriever = container.Resolve <IUserNameRetriever>();

                logData.UserName = userNameRetriever.GetUserName(currentUserContext.UserId);

                container.Release(userNameRetriever);
                container.Release(currentUserContext);
            })));
        }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithAdditionalData <TDataValue, TComponent>(
     this MethodInvocationLoggingConfiguration <DictionaryLogData> config,
     Func <TComponent, InvocationData, TDataValue> valueRetrieveFunction, string dataKeyName) where TComponent : class
 {
     return(config.PrepareLogData(((container, invocationData, logData) =>
     {
         TComponent component = null;
         try
         {
             component = container.Resolve <TComponent>();
             logData[dataKeyName] = valueRetrieveFunction(component, invocationData);
         }
         finally
         {
             if (component != null)
             {
                 container.Release(component);
             }
         }
     })));
 }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithAdditionalData <TDataValue>(this MethodInvocationLoggingConfiguration <DictionaryLogData> config,
                                                                                                        Func <IContainer, InvocationData, TDataValue> valueRetrieveFunction, string dataKeyName)
 {
     return(config.PrepareLogData(((container, invocationData, logData) => logData[dataKeyName] = valueRetrieveFunction(container, invocationData))));
 }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithExecutionDuration(
     this MethodInvocationLoggingConfiguration <DictionaryLogData> config, string dataKeyName)
 {
     return(config.PrepareLogData(((container, invocationData, logData) => logData[dataKeyName] = invocationData.Raw.Duration)));
 }
 public static MethodInvocationLoggingConfiguration <DictionaryLogData> WithConst <T>(
     this MethodInvocationLoggingConfiguration <DictionaryLogData> config, string dataKeyName, T dataValue)
 {
     return(config.PrepareLogData(((container, invocationData, logData) => logData[dataKeyName] = dataValue)));
 }