コード例 #1
0
        public static void PopulateDefaultPayload(IEnumerable <string> disabledFields, IHeartbeatProvider provider)
        {
            var enabledProperties = RemoveDisabledDefaultFields(disabledFields);

            var payload = new Dictionary <string, HeartbeatPropertyPayload>();

            foreach (string fieldName in enabledProperties)
            {
                try
                {
                    switch (fieldName)
                    {
                    case "runtimeFramework":
                        provider.AddHeartbeatProperty(fieldName, GetRuntimeFrameworkVer(), true);
                        break;

                    case "baseSdkTargetFramework":
                        provider.AddHeartbeatProperty(fieldName, GetBaseSdkTargetFramework(), true);
                        break;

                    default:
                        provider.AddHeartbeatProperty(fieldName, "UNDEFINED", false);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    CoreEventSource.Log.FailedToObtainDefaultHeartbeatProperty(fieldName, ex.ToString());
                }
            }
        }
        public Task <bool> SetDefaultPayload(IEnumerable <string> disabledFields, IHeartbeatProvider provider)
        {
            bool hasSetValues      = false;
            var  enabledProperties = this.DefaultFields.Except(disabledFields);

            foreach (string fieldName in enabledProperties)
            {
                // we don't need to report out any failure here, so keep this look within the Sdk Internal Operations as well
                try
                {
                    switch (fieldName)
                    {
                    case "runtimeFramework":
                        provider.AddHeartbeatProperty(fieldName, true, GetRuntimeFrameworkVer(), true);
                        hasSetValues = true;
                        break;

                    case "baseSdkTargetFramework":
                        provider.AddHeartbeatProperty(fieldName, true, GetBaseSdkTargetFramework(), true);
                        hasSetValues = true;
                        break;

                    case "osType":
                        provider.AddHeartbeatProperty(fieldName, true, GetRuntimeOsType(), true);
                        hasSetValues = true;
                        break;

                    case "processSessionId":
                        provider.AddHeartbeatProperty(fieldName, true, GetProcessSessionId(), true);
                        hasSetValues = true;
                        break;

                    default:
                        provider.AddHeartbeatProperty(fieldName, true, "UNDEFINED", true);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    CoreEventSource.Log.FailedToObtainDefaultHeartbeatProperty(fieldName, ex.ToString());
                }
            }

            return(Task.FromResult(hasSetValues));
        }