本文整理汇总了C#中ILog.?.Info方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.?.Info方法的具体用法?C# ILog.?.Info怎么用?C# ILog.?.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILog
的用法示例。
在下文中一共展示了ILog.?.Info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureQueueExists
/// <summary>
/// Creates the MSMQ queue with the specified path if it does not already exist. If it is created, the user account
/// of the currently executing process will get <see cref="MessageQueueAccessRights.GenericWrite"/> permissions to it,
/// and the local administrators group will get <see cref="MessageQueueAccessRights.FullControl"/>.
/// </summary>
public static void EnsureQueueExists(string inputQueuePath, ILog log = null, Action<MessageQueue> permissionsCallback = null)
{
if (MessageQueue.Exists(inputQueuePath)) return;
try
{
log?.Info("Queue '{0}' does not exist - it will be created now", inputQueuePath);
var newQueue = MessageQueue.Create(inputQueuePath, true);
var administratorAccountName = GetAdministratorsGroupAccountName();
newQueue.SetPermissions(Thread.CurrentPrincipal.Identity.Name, MessageQueueAccessRights.GenericWrite);
newQueue.SetPermissions(administratorAccountName, MessageQueueAccessRights.FullControl);
if (permissionsCallback != null)
{
log?.Info("Custom MessageQueue callback will be invoked");
permissionsCallback.Invoke(newQueue);
}
}
catch (MessageQueueException exception)
{
if (exception.MessageQueueErrorCode == MessageQueueErrorCode.QueueExists)
{
// all is good ;)
return;
}
throw;
}
}