• 00
  • :
  • 00
  • :
  • 00

C#判断VS是否处于设计模式

public class CheckDesingModel
    {
        public static bool IsDesingMode()
        {
            bool ReturnFlag = false;
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
                ReturnFlag = true;
            else if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")
                ReturnFlag = true;
            //if (ReturnFlag)
            //    Msg.Warning("设计模式");
            //else Msg.Warning("非设计模式!");
            return ReturnFlag;
        }
    }

 

        public static bool isDebug(HttpRequestMessage request)
        {
            if (request == null)
            {
                return System.Diagnostics.Process.GetCurrentProcess().ProcessName == "iisexpress";
            }
            else
            {
                string sign = request.Headers.Contains("sign") ? request.Headers.GetValues("sign").FirstOrDefault() : "";

                bool result = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "iisexpress") && (sign == "GarsonZhang2017");
                //bool result = sign == "GarsonZhang2017";

                return result;
            }
        }

 

posted @ 2014-10-30 15:13  Garson_Zhang  阅读(1074)  评论(0编辑  收藏  举报