当前位置: 首页>>代码示例>>C#>>正文


C# Proxy.GetInterviewDefinition方法代码示例

本文整理汇总了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;
        }
开发者ID:W800RDY,项目名称:hotdocs-open-sdk,代码行数:53,代码来源:WebService.Services.cs


注:本文中的System.Proxy.GetInterviewDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。