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


C# IVirtualFile类代码示例

本文整理汇总了C#中IVirtualFile的典型用法代码示例。如果您正苦于以下问题:C# IVirtualFile类的具体用法?C# IVirtualFile怎么用?C# IVirtualFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IVirtualFile类属于命名空间,在下文中一共展示了IVirtualFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFileHash

        public virtual string GetFileHash(IVirtualFile virtualFile)
        {
            if (virtualFile == null)
                return String.Empty;

            return virtualFile.GetFileHash();
        }
开发者ID:rajeshpillai,项目名称:ServiceStack,代码行数:7,代码来源:AbstractVirtualPathProviderBase.cs

示例2: MemCachedFile

        MemCachedFile( IVirtualFile file )
        {
            if (file == null) throw new FileNotFoundException();
            this.path = file.VirtualPath;

            using (Stream s = file.Open()) {
                this.data = StreamExtensions.CopyToBytes(s);
            }
        }
开发者ID:stukalin,项目名称:ImageResizer,代码行数:9,代码来源:MemCachedFile.cs

示例3: ConvertFileNameToTreeableData

        private List<string> ConvertFileNameToTreeableData(IVirtualFile fi)
        {
            List<string> result = fi.VirtualPath.Split('\\').ToList();
            if(result.Count < 3)
                result.Add("CD1");

            result.Add(fi.Name);
            return result;
        }
开发者ID:Epibatidin,项目名称:FLUX,代码行数:9,代码来源:TreeBuilder.cs

示例4: WriteFile

        public static void WriteFile(this IVirtualPathProvider pathProvider, IVirtualFile file, string filePath = null)
        {
            var writableFs = pathProvider as IVirtualFiles;
            if (writableFs == null)
                throw new InvalidOperationException(ErrorNotWritable.Fmt(pathProvider.GetType().Name));

            using (var stream = file.OpenRead())
            {
                writableFs.WriteFile(filePath ?? file.VirtualPath, stream);
            }
        }
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:11,代码来源:VirtualPathProviderExtensions.cs

示例5: RazorPageHost

        public RazorPageHost(IVirtualPathProvider pathProvider,
                              IVirtualFile file,
                              IRazorCodeTransformer codeTransformer,
                              CodeDomProvider codeDomProvider,
                              IDictionary<string, string> directives)
            : base(new CSharpRazorCodeLanguage())
        {
            this.PathProvider = pathProvider;
            this.File = file;

            if (codeTransformer == null)
            {
                throw new ArgumentNullException("codeTransformer");
            }
            if (this.PathProvider == null)
            {
                throw new ArgumentNullException("pathProvider");
            }
            if (this.File == null)
            {
                throw new ArgumentNullException("file");
            }
            if (codeDomProvider == null)
            {
                throw new ArgumentNullException("codeDomProvider");
            }
            _codeTransformer = codeTransformer;
            _codeDomProvider = codeDomProvider;
            _directives = directives;
            base.DefaultNamespace = "ASP";
            EnableLinePragmas = true;

            base.GeneratedClassContext = new GeneratedClassContext(
                executeMethodName: GeneratedClassContext.DefaultExecuteMethodName,
                writeMethodName: GeneratedClassContext.DefaultWriteMethodName,
                writeLiteralMethodName: GeneratedClassContext.DefaultWriteLiteralMethodName,
                writeToMethodName: "WriteTo",
                writeLiteralToMethodName: "WriteLiteralTo",
                templateTypeName: typeof(HelperResult).FullName,
                defineSectionMethodName: "DefineSection",
                beginContextMethodName: "BeginContext",
                endContextMethodName: "EndContext"
                )
                {
                    ResolveUrlMethodName = "Href",
                };

            base.DefaultBaseClass = typeof(ViewPage).FullName;
            foreach (var import in _defaultImports)
            {
                base.NamespaceImports.Add(import);
            }
        }
开发者ID:nustack,项目名称:ServiceStack,代码行数:53,代码来源:RazorPageHost.cs

示例6: HttpResult

        public HttpResult(IVirtualFile fileResponse, string contentType = null, bool asAttachment = false)
            : this(null, contentType ?? MimeTypes.GetMimeType(fileResponse.Name), HttpStatusCode.OK)
        {
            this.AllowsPartialResponse = true;
            this.ResponseStream = fileResponse.OpenRead();

            if (!asAttachment) return;

            var headerValue = $"attachment; filename=\"{fileResponse.Name}\"; size={fileResponse.Length}; modification-date={fileResponse.LastModified.ToString("R").Replace(",", "")}";

            this.Headers = new Dictionary<string, string>
            {
                { HttpHeaders.ContentDisposition, headerValue },
            };
        }
开发者ID:ServiceStack,项目名称:ServiceStack,代码行数:15,代码来源:HttpResult.cs

示例7: FileListItem

        /// <summary>
        /// Creates file list item object.
        /// </summary>
        /// <param name="file">actual file it presents.</param>
        /// <param name="window">window it belongs to.</param>
        public FileListItem(IVirtualFile file, Window window)
            : base(window, CreationFlag.FlagsNone)
        {
            if (null == file)
            {
                throw new Exception("file can not be null");
            }

            this.file = file;
            this.NeedTranslation = false;
            this.Text = file.Name;
            this.Name = file.Name;
            this.ListStyle = ListStyle.Details;
            this.BackColor = Colors.None;

            SetFileIcon();
        }
开发者ID:drme,项目名称:thw-ui,代码行数:22,代码来源:FileListItem.cs

示例8: TrackRazorPage

        protected virtual void TrackRazorPage( IVirtualFile file )
        {
            //get the base type.
            var pageBaseType = this.Config.PageBaseType;

            var transformer = new RazorViewPageTransformer( pageBaseType );

            //create a RazorPage
            var page = new RazorPage
                {
                    PageHost = new RazorPageHost( PathProvider, file, transformer, new CSharpCodeProvider(), new Dictionary<string, string>() ),
                    IsValid = false,
                    File = file
                };

            //add it to our pages dictionary.
            AddRazorPage(page);
        }
开发者ID:joshearl,项目名称:ServiceStack,代码行数:18,代码来源:ViewManager.cs

示例9: WriteToStream

 /// <summary>
 /// The write to stream.
 /// </summary>
 /// <param name="provider">
 /// The provider.
 /// </param>
 /// <param name="sw">
 /// The sw.
 /// </param>
 /// <param name="vf">
 /// The vf.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="origUrl">
 /// The orig url.
 /// </param>
 /// <param name="http">
 /// The http.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public bool WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, IVirtualFile vf, ClientDependencyType type, string origUrl, HttpContextBase http)
 {
     try
     {
         using (var readStream = vf.Open())
         using (var streamReader = new StreamReader(readStream))
         {
             var output = streamReader.ReadToEnd();
             DefaultFileWriter.WriteContentToStream(provider, sw, output, type, http, origUrl);
             return true;
         }
     }
     catch (Exception)
     {
         // the file must have failed to open
         return false;
     }
 }
开发者ID:netaddicts,项目名称:nuPickers,代码行数:42,代码来源:EmbeddedResourceWriter.cs

示例10: WriteToStream

 /// <summary>
 /// Writes the virtual file to a stream for serving.
 /// </summary>
 /// <param name="provider">The file processing provider.</param>
 /// <param name="streamWriter">The <see cref="StreamWriter"/>.</param>
 /// <param name="virtualFile">The <see cref="IVirtualFile"/> to write.</param>
 /// <param name="type">The <see cref="ClientDependencyType"/> the virtual file matches.</param>
 /// <param name="originalUrl">The original url to the virtual file.</param>
 /// <param name="context">The <see cref="HttpContextBase"/>.</param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public bool WriteToStream(
     BaseCompositeFileProcessingProvider provider, 
     StreamWriter streamWriter, 
     IVirtualFile virtualFile, 
     ClientDependencyType type, 
     string originalUrl, 
     HttpContextBase context)
 {
     try
     {
         using (Stream readStream = virtualFile.Open())
         using (StreamReader streamReader = new StreamReader(readStream))
         {
             string output = streamReader.ReadToEnd();
             DefaultFileWriter.WriteContentToStream(provider, streamWriter, output, type, context, originalUrl);
             return true;
         }
     }
     catch (Exception)
     {
         // The file must have failed to open
         return false;
     }
 }
开发者ID:JimBobSquarePants,项目名称:UmbracoPersonalisationGroups,代码行数:36,代码来源:EmbeddedResourceWriter.cs

示例11: IsViewFile

 public virtual bool IsViewFile(IVirtualFile virtualFile)
 {
     return virtualFile.RealPath != null
         && virtualFile.RealPath.Contains("{0}{1}".Fmt(RealPathSeparator, "Views"));
 }
开发者ID:rajeshpillai,项目名称:ServiceStack,代码行数:5,代码来源:AbstractVirtualPathProviderBase.cs

示例12: GetFileIfCached

 public IVirtualFile GetFileIfCached(string virtualPath, System.Collections.Specialized.NameValueCollection queryString, IVirtualFile original)
 {
     //Use alternate cache key if provided
     string key = original is IVirtualFileSourceCacheKey ? ((IVirtualFileSourceCacheKey)original).GetCacheKey(true) : original.VirtualPath;
     //If cached, serve it.
     CachedVirtualFile c = cache.Get(key);
     if (c != null) return c;
     //If not, let's cache it.
     if ("mem".Equals(queryString["scache"], StringComparison.OrdinalIgnoreCase)) {
         locks.TryExecute(key, 3000, delegate() {
             c = cache.Get(key);
             if (c == null) {
                 using (Stream data = original.Open()) {//Very long-running call
                     c = new CachedVirtualFile(original.VirtualPath, StreamExtensions.CopyToBytes(data, true));
                 }
                 cache.Set(key, c);//Save to cache (may trigger cleanup)
             }
         });
         return c;
     }
     return null;
 }
开发者ID:eakova,项目名称:resizer,代码行数:22,代码来源:SourceMemCache.cs

示例13: IsViewFile

 public override bool IsViewFile(IVirtualFile virtualFile)
 {
     return virtualFile.VirtualPathProvider.IsViewFile(virtualFile);
 }
开发者ID:tystol,项目名称:ServiceStack,代码行数:4,代码来源:MultiVirtualPathProvider.cs

示例14: AddPage

 public virtual RazorPage AddPage(IVirtualFile file)
 {
     return IsWatchedFile(file)
         ? TrackPage(file)
         : null;
 }
开发者ID:tystol,项目名称:ServiceStack,代码行数:6,代码来源:RazorViewManager.cs

示例15: TrackPage

        public virtual RazorPage TrackPage(IVirtualFile file)
        {
            //get the base type.
            var pageBaseType = this.Config.PageBaseType;

            var transformer = new RazorViewPageTransformer(pageBaseType);

            //create a RazorPage
            var page = new RazorPage
            {
                PageHost = new RazorPageHost(PathProvider, file, transformer, new CSharpCodeProvider(), new Dictionary<string, string>()),
                IsValid = false,
                File = file
            };

            //add it to our pages dictionary.
            AddPage(page);

            if (Config.PrecompilePages.GetValueOrDefault())
                PrecompilePage(page);

            return page;
        }
开发者ID:tystol,项目名称:ServiceStack,代码行数:23,代码来源:RazorViewManager.cs


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