internal PICSProductInfo(CMsgClientPICSProductInfoResponse parentResponse, CMsgClientPICSProductInfoResponse.AppInfo app_info) { this.ID = app_info.appid; this.ChangeNumber = app_info.change_number; this.MissingToken = app_info.missing_token; this.SHAHash = app_info.sha; this.KeyValues = new KeyValue(); if (app_info.buffer != null) { // we don't want to read the trailing null byte using (var ms = new MemoryStream(app_info.buffer, 0, app_info.buffer.Length - 1)) { this.KeyValues.ReadAsText(ms); } } this.OnlyPublic = app_info.only_public; // We should have all these fields set for the response to a metadata-only request, but guard here just in case. if (this.SHAHash != null && this.SHAHash.Length > 0 && !string.IsNullOrEmpty(parentResponse.http_host)) { var shaString = BitConverter.ToString(this.SHAHash) .Replace("-", string.Empty) .ToLower(); var uriString = string.Format("http://{0}/appinfo/{1}/sha/{2}.txt.gz", parentResponse.http_host, this.ID, shaString); this.HttpUri = new Uri(uriString); } this.UseHttp = this.HttpUri != null && app_info.size >= parentResponse.http_min_size; }
internal PICSProductInfoCallback(CMsgClientPICSProductInfoResponse msg) { MetaDataOnly = msg.meta_data_only; ResponsePending = msg.response_pending; UnknownPackages = new ReadOnlyCollection <uint>(msg.unknown_packageids); UnknownApps = new ReadOnlyCollection <uint>(msg.unknown_appids); Packages = new Dictionary <uint, PICSProductInfo>(); Apps = new Dictionary <uint, PICSProductInfo>(); foreach (var package_info in msg.packages) { Packages.Add(package_info.packageid, new PICSProductInfo(package_info)); } foreach (var app_info in msg.apps) { Apps.Add(app_info.appid, new PICSProductInfo(msg, app_info)); } }