本文整理汇总了C#中Windows.BeginServiceRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Windows.BeginServiceRequest方法的具体用法?C# Windows.BeginServiceRequest怎么用?C# Windows.BeginServiceRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows
的用法示例。
在下文中一共展示了Windows.BeginServiceRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReactiveIndivRequest
/// <summary>
/// Invoked to send the Individualization Request
/// </summary>
async System.Threading.Tasks.Task<bool> ReactiveIndivRequest(Windows.Media.Protection.PlayReady.PlayReadyIndividualizationServiceRequest IndivRequest, Windows.Media.Protection.MediaProtectionServiceCompletion CompletionNotifier)
{
bool bResult = false;
Exception exception = null;
LogMessage("ProtectionManager PlayReady Individualization Service Request in progress...");
try
{
await IndivRequest.BeginServiceRequest();
}
catch (Exception ex)
{
exception = ex;
}
finally
{
if (exception == null)
{
bResult = true;
}
else
{
System.Runtime.InteropServices.COMException comException = exception as System.Runtime.InteropServices.COMException;
if (comException != null && comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED)
{
IndivRequest.NextServiceRequest();
}
}
}
if (bResult == true)
LogMessage("ProtectionManager PlayReady Individualization Service Request successful");
else
LogMessage("ProtectionManager PlayReady Individualization Service Request failed");
if (CompletionNotifier != null) CompletionNotifier.Complete(bResult);
return bResult;
}
示例2: LicenseAcquisitionRequest
/// <summary>
/// Invoked to acquire the PlayReady License
/// </summary>
async System.Threading.Tasks.Task<bool> LicenseAcquisitionRequest(Windows.Media.Protection.PlayReady.PlayReadyLicenseAcquisitionServiceRequest licenseRequest, Windows.Media.Protection.MediaProtectionServiceCompletion CompletionNotifier, string Url, string ChallengeCustomData)
{
bool bResult = false;
string ExceptionMessage = string.Empty;
try
{
if (!string.IsNullOrEmpty(Url))
{
LogMessage("ProtectionManager PlayReady Manual License Acquisition Service Request in progress - URL: " + Url);
if (!string.IsNullOrEmpty(ChallengeCustomData))
{
// disable Base64String encoding
//System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
//byte[] b = encoding.GetBytes(ChallengeCustomData);
//licenseRequest.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);
licenseRequest.ChallengeCustomData = ChallengeCustomData;
}
Windows.Media.Protection.PlayReady.PlayReadySoapMessage soapMessage = licenseRequest.GenerateManualEnablingChallenge();
byte[] messageBytes = soapMessage.GetMessageBody();
Windows.Web.Http.IHttpContent httpContent = new Windows.Web.Http.HttpBufferContent(messageBytes.AsBuffer());
IPropertySet propertySetHeaders = soapMessage.MessageHeaders;
foreach (string strHeaderName in propertySetHeaders.Keys)
{
string strHeaderValue = propertySetHeaders[strHeaderName].ToString();
// The Add method throws an ArgumentException try to set protected headers like "Content-Type"
// so set it via "ContentType" property
if (strHeaderName.Equals("Content-Type", StringComparison.OrdinalIgnoreCase))
httpContent.Headers.ContentType = Windows.Web.Http.Headers.HttpMediaTypeHeaderValue.Parse(strHeaderValue);
else
httpContent.Headers.TryAppendWithoutValidation(strHeaderName.ToString(), strHeaderValue);
}
CommonLicenseRequest licenseAcquision = new CommonLicenseRequest();
Windows.Web.Http.IHttpContent responseHttpContent = await licenseAcquision.AcquireLicense(new Uri(Url), httpContent);
if (responseHttpContent != null)
{
//string res = await responseHttpContent.ReadAsStringAsync();
var buffer = await responseHttpContent.ReadAsBufferAsync();
Exception exResult = licenseRequest.ProcessManualEnablingResponse(buffer.ToArray());
if (exResult != null)
{
throw exResult;
}
bResult = true;
}
else
ExceptionMessage = licenseAcquision.GetLastErrorMessage();
}
else
{
LogMessage("ProtectionManager PlayReady License Acquisition Service Request in progress - URL: " + licenseRequest.Uri.ToString());
await licenseRequest.BeginServiceRequest();
bResult = true;
}
}
catch (Exception e)
{
ExceptionMessage = e.Message;
}
if (bResult == true)
LogMessage(!string.IsNullOrEmpty(Url) ? "ProtectionManager Manual PlayReady License Acquisition Service Request successful" :
"ProtectionManager PlayReady License Acquisition Service Request successful");
else
LogMessage(!string.IsNullOrEmpty(Url) ? "ProtectionManager Manual PlayReady License Acquisition Service Request failed: " + ExceptionMessage :
"ProtectionManager PlayReady License Acquisition Service Request failed: " + ExceptionMessage);
if (CompletionNotifier != null)
CompletionNotifier.Complete(bResult);
return bResult;
}