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


C# IFileSystem.AddFile方法代码示例

本文整理汇总了C#中IFileSystem.AddFile方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.AddFile方法的具体用法?C# IFileSystem.AddFile怎么用?C# IFileSystem.AddFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFileSystem的用法示例。


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

示例1: CreateDocument

 private static XDocument CreateDocument(XName rootName, IFileSystem fileSystem, string path)
 {
     XDocument document = new XDocument(new XElement(rootName));
     // Add it to the file system
     fileSystem.AddFile(path, document.Save);
     return document;
 }
开发者ID:OsirisTerje,项目名称:sonarlint-vs,代码行数:7,代码来源:XmlUtility.cs

示例2: Initialize

        public override void Initialize()
        {
            base.Initialize();

            _fileSystem = new PhysicalFileSystem(SystemDirectories.Css);
            var stream = CreateStream("body {background:#EE7600; color:#FFF;}");
            _fileSystem.AddFile("styles.css", stream);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:8,代码来源:StylesheetRepositoryTest.cs

示例3: Initialize

        public override void Initialize()
        {
            base.Initialize();

            _fileSystem = new PhysicalFileSystem(SystemDirectories.Scripts);
            using (var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");"))
            {
                _fileSystem.AddFile("test-script.js", stream);    
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:10,代码来源:ScriptRepositoryTest.cs

示例4: SaveDocument

 private static void SaveDocument(IFileSystem fileSystem, string path, string content)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         using (StreamWriter sw = new StreamWriter(stream))
         {
             sw.Write(content);
             sw.Flush();
             stream.Seek(0, SeekOrigin.Begin);
             fileSystem.AddFile(path, stream);
         }
     }
 }
开发者ID:zhiliangxu,项目名称:TestEasy,代码行数:13,代码来源:NuGetWebProjectSystem.cs

示例5: SaveDocument

 private static void SaveDocument(IFileSystem fileSystem, string webConfigPath, XDocument document)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         document.Save(stream);
         stream.Seek(0, SeekOrigin.Begin);
         fileSystem.AddFile(webConfigPath, stream);
     }
 }
开发者ID:Newtopian,项目名称:nuget,代码行数:9,代码来源:WebProjectSystem.cs

示例6: PushPackageToFileSystem

 /// <summary>
 /// Pushes a package to a FileSystem.
 /// </summary>
 /// <param name="fileSystem">The FileSystem that the package is pushed to.</param>
 /// <param name="package">The package to be pushed.</param>
 private static void PushPackageToFileSystem(IFileSystem fileSystem, IPackage package)
 {
     var pathResolver = new DefaultPackagePathResolver(fileSystem);
     var packageFileName = pathResolver.GetPackageFileName(package);
     using (var stream = package.GetStream())
     {
         fileSystem.AddFile(packageFileName, stream);
     }
 }
开发者ID:Newtopian,项目名称:nuget,代码行数:14,代码来源:PackageServer.cs

示例7: GenerateThumbnail

        private static ResizedImage GenerateThumbnail(Image image, int maxWidthHeight, int fixedWidth, int fixedHeight, string thumbnailFileName, string extension, IFileSystem fs)
        {
            // Generate thumbnail
            float f = 1;
            if (maxWidthHeight >= 0)
            {
                var fx = (float)image.Size.Width / maxWidthHeight;
                var fy = (float)image.Size.Height / maxWidthHeight;

                // must fit in thumbnail size
                f = Math.Max(fx, fy);
            }

            //depending on if we are doing fixed width resizing or not.
            fixedWidth = (maxWidthHeight > 0) ? image.Width : fixedWidth;
            fixedHeight = (maxWidthHeight > 0) ? image.Height : fixedHeight;

            var widthTh = (int)Math.Round(fixedWidth / f);
            var heightTh = (int)Math.Round(fixedHeight / f);

            // fixes for empty width or height
            if (widthTh == 0)
                widthTh = 1;
            if (heightTh == 0)
                heightTh = 1;

            // Create new image with best quality settings
            using (var bp = new Bitmap(widthTh, heightTh))
            {
                using (var g = Graphics.FromImage(bp))
                {
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    g.CompositingQuality = CompositingQuality.HighQuality;

                    // Copy the old image to the new and resized
                    var rect = new Rectangle(0, 0, widthTh, heightTh);
                    g.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);

                    // Copy metadata
                    var imageEncoders = ImageCodecInfo.GetImageEncoders();

                    var codec = extension.ToLower() == "png" || extension.ToLower() == "gif"
                        ? imageEncoders.Single(t => t.MimeType.Equals("image/png"))
                        : imageEncoders.Single(t => t.MimeType.Equals("image/jpeg"));

                    // Set compresion ratio to 90%
                    var ep = new EncoderParameters();
                    ep.Param[0] = new EncoderParameter(Encoder.Quality, 90L);

                    // Save the new image using the dimensions of the image
                    var newFileName = thumbnailFileName.Replace("UMBRACOSYSTHUMBNAIL", string.Format("{0}x{1}", widthTh, heightTh));
                    using (var ms = new MemoryStream())
                    {
                        bp.Save(ms, codec, ep);
                        ms.Seek(0, 0);

                        fs.AddFile(newFileName, ms);
                    }

                    return new ResizedImage(widthTh, heightTh, newFileName);
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:65,代码来源:ImageHelper.cs


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