public AdInfo(string adInfoString) { string adUnitIdentifier; string networkName; string creativeIdentifier; string placement; string revenue; // NOTE: Unity Editor creates empty string var adInfoObject = MaxSdkUtils.PropsStringToDict(adInfoString); AdUnitIdentifier = adInfoObject.TryGetValue("adUnitId", out adUnitIdentifier) ? adUnitIdentifier : ""; NetworkName = adInfoObject.TryGetValue("networkName", out networkName) ? networkName : ""; CreativeIdentifier = adInfoObject.TryGetValue("creativeId", out creativeIdentifier) ? creativeIdentifier : ""; Placement = adInfoObject.TryGetValue("placement", out placement) ? placement : ""; if (adInfoObject.TryGetValue("revenue", out revenue)) { try { // InvariantCulture guarantees the decimal is used for the separator even in regions that use commas as the separator Revenue = double.Parse(revenue, NumberStyles.Any, CultureInfo.InvariantCulture); } catch (Exception exception) { MaxSdkLogger.E("Failed to parse double (" + revenue + ") with exception: " + exception); Revenue = -1; } } else { Revenue = -1; } }
public ErrorInfo(IDictionary <string, string> errorInfoDictionary) { string code; string message; string adLoadFailureInfo; Message = errorInfoDictionary.TryGetValue("errorMessage", out message) ? message : ""; AdLoadFailureInfo = errorInfoDictionary.TryGetValue("adLoadFailureInfo", out adLoadFailureInfo) ? adLoadFailureInfo : ""; if (errorInfoDictionary.TryGetValue("errorCode", out code)) { try { Code = (ErrorCode)int.Parse(code); } catch (Exception exception) { MaxSdkLogger.E("Failed to parse int (" + code + ") with exception: " + exception); Code = ErrorCode.Unspecified; } } else { Code = ErrorCode.Unspecified; } }