本文整理匯總了C#中System.Proxy.GetInterviewDefinition方法的典型用法代碼示例。如果您正苦於以下問題:C# Proxy.GetInterviewDefinition方法的具體用法?C# Proxy.GetInterviewDefinition怎麽用?C# Proxy.GetInterviewDefinition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Proxy
的用法示例。
在下文中一共展示了Proxy.GetInterviewDefinition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetInterviewFile
/// <summary>
/// Retrieves a file required by the interview. This could be either an interview definition that contains the
/// variables and logic required to display an interview (questionaire) for the main template or one of its
/// inserted templates, or it could be an image file displayed on a dialog within the interview.
/// </summary>
/// <param name="template">The template related to the requested file.</param>
/// <param name="fileName">The file name of the image, or the file name of the template for which the interview
/// definition is being requested. In either case, this value is passed as "template" on the query string by the browser interview.</param>
/// <param name="fileType">The type of file being requested: img (image file), js (JavaScript interview definition),
/// or dll (Silverlight interview definition).</param>
/// <returns>A stream containing the requested interview file, to be returned to the caller.</returns>
public Stream GetInterviewFile(Template template, string fileName, string fileType)
{
// Validate input parameters, creating defaults as appropriate.
if (template == null)
throw new ArgumentNullException("template", @"WebService.Services.GetInterviewFile: the ""template"" parameter passed in was null");
if (string.IsNullOrEmpty(fileName))
throw new ArgumentNullException("fileName", @"WebService.Services.GetInterviewFile: the ""fileName"" parameter passed in was null or empty");
if (string.IsNullOrEmpty(fileType))
throw new ArgumentNullException("fileType", @"WebService.Services.GetInterviewFile: the ""fileType"" parameter passed in was null or empty");
// Return an image or interview definition from the template.
InterviewFormat format = InterviewFormat.Unspecified;
switch (fileType.ToUpper())
{
case "IMG":
return template.Location.GetFile(fileName);
case "DLL":
format = InterviewFormat.Silverlight;
break;
case "JS":
format = InterviewFormat.JavaScript;
break;
}
if (format == InterviewFormat.Unspecified)
throw new ArgumentOutOfRangeException(); // The format must be either JS or DLL.
System.IO.Stream result = null;
using (Proxy client = new Proxy(_endPointName))
{
string templateId = GetRelativePath(Path.Combine(Path.GetDirectoryName(template.GetFullPath()), fileName)); // The relative path to the template folder.
string templateName = fileName; // The name of the template file for which the interview is being requested (e.g., demoempl.rtf).
string templateState = string.Empty; // We are using the templateId rather than template state since all we have to work with is a template locator.
BinaryObject binaryObject = client.GetInterviewDefinition(templateId, templateName, format, templateState);
SafeCloseClient(client, null);
result = new MemoryStream(binaryObject.Data);
}
return result;
}