Exemplo n.º 1
0
        /// <summary>
        /// Get internal settings for the channel specified by its ID.
        /// There are 3 states could be:
        /// - explicitly enabled
        /// - explicitly disabled
        /// - undefined (no settings available)
        /// </summary>
        /// <param name="channelId"></param>
        /// <returns></returns>
        public virtual ChannelInternalSetting GetChannelSettings(string channelId)
        {
            CodeContract.RequiresArgumentNotNullAndNotEmpty(channelId, "channelId");
            if (!TypeTools.TryConvertToInt(registryTools.GetRegistryValueFromCurrentUserRoot("Software\\Coding4Fun\\VisualStudio\\Telemetry\\Channels", channelId, (object)(-1)), out int result))
            {
                result = -1;
            }
            ChannelInternalSetting channelInternalSetting = ChannelInternalSetting.Undefined;

            switch (result)
            {
            case 1:
                channelInternalSetting = ChannelInternalSetting.ExplicitlyEnabled;
                break;

            case 0:
                channelInternalSetting = ChannelInternalSetting.ExplicitlyDisabled;
                break;
            }
            if (channelInternalSetting != ChannelInternalSetting.Undefined)
            {
                diagnosticTelemetry.LogRegistrySettings(string.Format(CultureInfo.InvariantCulture, "Channel.{0}", new object[1]
                {
                    channelId
                }), channelInternalSetting.ToString());
            }
            return(channelInternalSetting);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check whether channel is valid to be added to active channel list
        /// </summary>
        /// <param name="channelToValidate"></param>
        /// <returns></returns>
        public bool IsValid(ISessionChannel channelToValidate)
        {
            CodeContract.RequiresArgumentNotNull <ISessionChannel>(channelToValidate, "channelToValidate");
            ChannelInternalSetting channelSettings = internalSettings.GetChannelSettings(channelToValidate.ChannelId);

            if (channelSettings == ChannelInternalSetting.ExplicitlyEnabled)
            {
                channelToValidate.Properties |= ChannelProperties.Default;
            }
            return(channelSettings != ChannelInternalSetting.ExplicitlyDisabled);
        }