本文整理汇总了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;
}