コード例 #1
0
        object DoPSPassThroughConversion <T>(T objectToConvert)
        {
            string content       = PSSerializer.Serialize(objectToConvert, 10);
            var    reconstituted = PSSerializer.Deserialize(content);
            var    converter     = new AzureContextConverter();

            Assert.True(converter.CanConvertFrom(reconstituted, typeof(IAzureContextContainer)));
            return(converter.ConvertFrom(reconstituted, typeof(IAzureContextContainer), CultureInfo.InvariantCulture, true));
        }
コード例 #2
0
        static IAzureContext GetDefaultContext(IProfileProvider provider, System.Management.Automation.InvocationInfo invocationInfo)
        {
            IAzureContextContainer context;
            var contextConverter = new AzureContextConverter();

            if (invocationInfo.BoundParameters.ContainsKey("DefaultContext") &&
                contextConverter.CanConvertFrom(invocationInfo.BoundParameters["DefaultContext"], typeof(IAzureContextContainer)))
            {
                context = contextConverter.ConvertFrom(invocationInfo.BoundParameters["DefaultContext"], typeof(IAzureContextContainer), CultureInfo.InvariantCulture, true) as IAzureContextContainer;
            }
            else
            {
                context = provider.Profile;
            }

            return(context?.DefaultContext);
        }
コード例 #3
0
        private static IAzureContext GetDefaultContext(IProfileProvider provider, InvocationInfo invocationInfo)
        {
            IAzureContextContainer profile;
            var contextConverter = new AzureContextConverter();

            if (invocationInfo.BoundParameters.ContainsKey("DefaultContext") &&
                contextConverter.CanConvertFrom(invocationInfo.BoundParameters["DefaultContext"], typeof(IAzureContextContainer)))
            {
                profile = contextConverter.ConvertFrom(invocationInfo.BoundParameters["DefaultContext"], typeof(IAzureContextContainer), CultureInfo.InvariantCulture, true) as IAzureContextContainer;
            }
            else
            {
                profile = provider.Profile;
            }

            return(profile?.DefaultContext);
        }