1 Star 0 Fork 0

冯子君/ServiceBusExplorer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Program.cs 6.35 KB
一键复制 编辑 原始数据 按行查看 历史
#region Copyright
//=======================================================================================
// Microsoft Azure Customer Advisory Team
//
// This sample is supplemental to the technical guidance published on my personal
// blog at http://blogs.msdn.com/b/paolos/.
//
// Author: Paolo Salvatori
//=======================================================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// LICENSED UNDER THE APACHE LICENSE, VERSION 2.0 (THE "LICENSE"); YOU MAY NOT USE THESE
// FILES EXCEPT IN COMPLIANCE WITH THE LICENSE. YOU MAY OBTAIN A COPY OF THE LICENSE AT
// http://www.apache.org/licenses/LICENSE-2.0
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE DISTRIBUTED UNDER THE
// LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
// PERMISSIONS AND LIMITATIONS UNDER THE LICENSE.
//=======================================================================================
#endregion
#region Using Directives
using System;
using System.Threading;
using System.Globalization;
using System.Windows.Forms;
#endregion
namespace Microsoft.WindowsAzure.CAT.ServiceBusExplorer
{
static class Program
{
#region Private Constants
//***************************
// Formats
//***************************
private const string ExceptionFormat = "Exception: {0}";
private const string InnerExceptionFormat = "InnerException: {0}";
#endregion
#region Static Main Method
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
try
{
string argument = null;
string value = null;
if (args != null && args.Length >= 2)
{
for (var i = 0; i < args.Length; i++)
{
if ((string.Compare(args[i], "/n", StringComparison.InvariantCultureIgnoreCase) == 0 ||
string.Compare(args[i], "-n", StringComparison.InvariantCultureIgnoreCase) == 0) &&
args.Length > i + 1 &&
!string.IsNullOrWhiteSpace(args[i + 1]))
{
argument = args[i];
value = args[i + 1];
}
if ((string.Compare(args[i], "/c", StringComparison.InvariantCultureIgnoreCase) == 0 ||
string.Compare(args[i], "-c", StringComparison.InvariantCultureIgnoreCase) == 0) &&
args.Length > i + 1 &&
!string.IsNullOrWhiteSpace(args[i + 1]))
{
argument = args[i];
value = args[i + 1];
}
if ((string.Compare(args[i], "/q", StringComparison.InvariantCultureIgnoreCase) == 0 ||
string.Compare(args[i], "-q", StringComparison.InvariantCultureIgnoreCase) == 0) &&
args.Length > i + 1 &&
!string.IsNullOrWhiteSpace(args[i + 1]))
{
FilterExpressionHelper.QueueFilterExpression = args[i + 1];
}
if ((string.Compare(args[i], "/t", StringComparison.InvariantCultureIgnoreCase) == 0 ||
string.Compare(args[i], "-t", StringComparison.InvariantCultureIgnoreCase) == 0) &&
args.Length > i + 1 &&
!string.IsNullOrWhiteSpace(args[i + 1]))
{
FilterExpressionHelper.TopicFilterExpression = args[i + 1];
}
if ((string.Compare(args[i], "/s", StringComparison.InvariantCultureIgnoreCase) == 0 ||
string.Compare(args[i], "-s", StringComparison.InvariantCultureIgnoreCase) == 0) &&
args.Length > i + 1 &&
!string.IsNullOrWhiteSpace(args[i + 1]))
{
FilterExpressionHelper.SubscriptionFilterExpression = args[i + 1];
}
}
}
if (!string.IsNullOrWhiteSpace(argument) &&
!string.IsNullOrWhiteSpace(value))
{
Application.Run(new MainForm(argument, value));
}
else
{
Application.Run(new MainForm());
}
}
// ReSharper disable EmptyGeneralCatchClause
catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
{
}
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
if (e != null &&
e.Exception != null)
{
HandleException(e.Exception);
}
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e != null &&
e.ExceptionObject != null)
{
HandleException(e.ExceptionObject as Exception);
}
}
static void HandleException(Exception ex)
{
if (ex != null && !string.IsNullOrWhiteSpace(ex.Message))
{
MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, ExceptionFormat, ex.Message));
if (ex.InnerException != null && !string.IsNullOrWhiteSpace(ex.InnerException.Message))
{
MainForm.StaticWriteToLog(string.Format(CultureInfo.CurrentCulture, InnerExceptionFormat, ex.InnerException.Message));
}
}
}
#endregion
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/fengzijun/ServiceBusExplorer.git
git@gitee.com:fengzijun/ServiceBusExplorer.git
fengzijun
ServiceBusExplorer
ServiceBusExplorer
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385