我怎么能确定,如果我在我的电脑上或云本地运行? [英] How can I determine if I am running locally on my PC or on the cloud?

查看:198
本文介绍了我怎么能确定,如果我在我的电脑上或云本地运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MVC3,我想,以确定如果我在本地运行或部署到云中?

Using MVC3 and I'd like to determine if I am running locally or deployed to the cloud?

推荐答案

这是我使用

public static class Azure
{
    private static bool m_IsRunningAzure = GetIsRunningInAzure();

    private static bool GetIsRunningInAzure()
    {
        Guid guidId;
        if (RoleEnvironment.IsAvailable && Guid.TryParse(RoleEnvironment.DeploymentId, out guidId))
            return true;   
        return false;      
    }

    public static bool IsRunningInAzure()
    {
        return m_IsRunningAzure; 
    }

    private static bool m_IsRunningAzureOrDevFabric = GetIsRunningInAzureOrDevFabric();

    private static bool GetIsRunningInAzureOrDevFabric()
    {
        return RoleEnvironment.IsAvailable;
    }

    public static bool IsRunningInAzureOrDevFabric()
    {
        return m_IsRunningAzureOrDevFabric;
    }
}

这篇关于我怎么能确定,如果我在我的电脑上或云本地运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆