// helper method for appending query parameters private static void AppendQueryParam(StringBuilder urlBuilder, string key, string value) { urlBuilder.Append('&'); urlBuilder.Append(key); urlBuilder.Append('='); urlBuilder.Append(PercentEncoder.Encode(value, Encoding.UTF8, QueryReservedCharacters)); }
private OpenKitConfiguration(IOpenKitBuilder builder) { EndpointUrl = builder.EndpointUrl; DeviceId = builder.DeviceId; OrigDeviceId = builder.OrigDeviceId; OpenKitType = builder.OpenKitType; ApplicationId = builder.ApplicationId; ApplicationIdPercentEncoded = PercentEncoder.Encode(ApplicationId, EncodingCharset, ReservedCharacters); ApplicationName = builder.ApplicationName; ApplicationVersion = builder.ApplicationVersion; OperatingSystem = builder.OperatingSystem; Manufacturer = builder.Manufacturer; ModelId = builder.ModelId; DefaultServerId = builder.DefaultServerId; TrustManager = builder.TrustManager; }
// *** public methods *** /// <summary> /// create web request tag /// </summary> /// <param name="parentActionID"></param> /// <param name="sequenceNo"></param> /// <returns></returns> public string CreateTag(int parentActionID, int sequenceNo) { if (BeaconConfiguration.DataCollectionLevel == DataCollectionLevel.OFF) { return(string.Empty); } return($"{WebRequestTagPrefix}_" + $"{ProtocolConstants.ProtocolVersion}_" + $"{httpConfiguration.ServerID}_" + $"{PercentEncoder.Encode(DeviceID, Encoding.UTF8, ReservedCharacters)}_" + $"{SessionNumber}_" + $"{configuration.ApplicationIDPercentEncoded}_" + $"{parentActionID}_" + $"{threadIDProvider.ThreadID}_" + $"{sequenceNo}"); }
// *** constructors *** public OpenKitConfiguration(OpenKitType openKitType, string applicationName, string applicationID, string deviceID, string endpointURL, ISessionIDProvider sessionIDProvider, ISSLTrustManager trustManager, Device device, string applicationVersion, BeaconCacheConfiguration beaconCacheConfiguration, BeaconConfiguration beaconConfiguration) { OpenKitType = openKitType; // immutable settings ApplicationName = applicationName; ApplicationID = applicationID; ApplicationIDPercentEncoded = PercentEncoder.Encode(applicationID, Encoding.UTF8, new [] { '_' }); DeviceID = deviceID; EndpointURL = endpointURL; // mutable settings capture = DEFAULT_CAPTURE; sendInterval = DEFAULT_SEND_INTERVAL; maxBeaconSize = DEFAULT_MAX_BEACON_SIZE; captureErrors = DEFAULT_CAPTURE_ERRORS; captureCrashes = DEFAULT_CAPTURE_CRASHES; this.device = device; HTTPClientConfig = new HTTPClientConfiguration( endpointURL, openKitType.DefaultServerID, applicationID, trustManager); this.applicationVersion = applicationVersion; this.beaconCacheConfiguration = beaconCacheConfiguration; this.sessionIDProvider = sessionIDProvider; BeaconConfig = beaconConfiguration; }
// helper method for adding key/value pairs with string values private static void AddKeyValuePair(StringBuilder builder, string key, string stringValue) { AppendKey(builder, key); builder.Append(PercentEncoder.Encode(stringValue, Encoding.UTF8, ReservedCharacters)); }