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


C# FileLocator类代码示例

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


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

示例1: DiskExtent

 public DiskExtent(ExtentDescriptor descriptor, long diskOffset, FileLocator fileLocator, FileAccess access)
 {
     _descriptor = descriptor;
     _diskOffset = diskOffset;
     _fileLocator = fileLocator;
     _access = access;
 }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:7,代码来源:DiskExtent.cs

示例2: CreateDisk

        public override VirtualDisk CreateDisk(FileLocator locator, string variant, string path, long capacity, Geometry geometry, Dictionary<string, string> parameters)
        {
            DiskParameters vmdkParams = new DiskParameters();
            vmdkParams.Capacity = capacity;
            vmdkParams.Geometry = geometry;

            switch (variant)
            {
                case "fixed":
                    vmdkParams.CreateType = DiskCreateType.MonolithicFlat;
                    break;
                case "dynamic":
                    vmdkParams.CreateType = DiskCreateType.MonolithicSparse;
                    break;
                case "vmfsfixed":
                    vmdkParams.CreateType = DiskCreateType.Vmfs;
                    break;
                case "vmfsdynamic":
                    vmdkParams.CreateType = DiskCreateType.VmfsSparse;
                    break;
                default:
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown VMDK disk variant '{0}'", variant), "variant");
            }

            return Disk.Initialize(locator, path, vmdkParams);
        }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:26,代码来源:DiskFactory.cs

示例3: TestNotFoundWithException

        public void TestNotFoundWithException()
        {
            FileLocator locator = new FileLocator();
            locator.Add("testdir/A");
            locator.Add("testdir/B");
            locator.Add("testdir/B/C");

            locator.Find("5");
        }
开发者ID:juanplopes,项目名称:simple,代码行数:9,代码来源:FileLocatorFixture.cs

示例4: TestNotFoundWithoutException

        public void TestNotFoundWithoutException()
        {
            FileLocator locator = new FileLocator();
            locator.Add("testdir/A");
            locator.Add("testdir/B");
            locator.Add("testdir/B/C");

            string file = locator.Find("5", false);
            file.Should().Be.Null();
        }
开发者ID:juanplopes,项目名称:simple,代码行数:10,代码来源:FileLocatorFixture.cs

示例5: CreateDisk

 public override VirtualDisk CreateDisk(FileLocator locator, string variant, string path, VirtualDiskParameters diskParameters)
 {
     switch (variant)
     {
         case "fixed":
             return Disk.InitializeFixed(locator, path, diskParameters.Capacity, diskParameters.Geometry);
         case "dynamic":
             throw new NotImplementedException();
         default:
             throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown VHD disk variant '{0}'", variant), "variant");
     }
 }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:12,代码来源:DiskFactory.cs

示例6: CreateDisk

 public override VirtualDisk CreateDisk(FileLocator locator, string variant, string path, VirtualDiskParameters diskParameters)
 {
     switch (variant)
     {
         case "fixed":
             return Disk.InitializeFixed(locator.Open(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None), Ownership.Dispose, diskParameters.Capacity);
         case "dynamic":
             return Disk.InitializeDynamic(locator.Open(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None), Ownership.Dispose, diskParameters.Capacity);
         default:
             throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown VDI disk variant '{0}'", variant), "variant");
     }
 }
开发者ID:JGTM2016,项目名称:discutils,代码行数:12,代码来源:DiskFactory.cs

示例7: TestSimpleSearches

        public void TestSimpleSearches()
        {
            FileLocator locator = new FileLocator();
            locator.Add("testdir/A");
            locator.Add("testdir/B");
            locator.Add("testdir/B/C");

            var results = new[] { 1, 2, 3, 4 }.Select(x => locator.Find(x.ToString())).ToArray();

            StringAssert.StartsWith("testdir/A", results[0]);
            StringAssert.StartsWith("testdir/A", results[1]);
            StringAssert.StartsWith("testdir/B", results[2]);
            StringAssert.StartsWith("testdir/B/C", results[3]);
        }
开发者ID:juanplopes,项目名称:simple,代码行数:14,代码来源:FileLocatorFixture.cs

示例8: OpenDisk

        public override VirtualDisk OpenDisk(FileLocator locator, string path, string extraInfo, Dictionary<string, string> parameters, FileAccess access)
        {
            VirtualMachine machine = new VirtualMachine(locator.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read), Ownership.Dispose);

            int diskIndex;
            if (!int.TryParse(extraInfo, out diskIndex))
            {
                diskIndex = 0;
            }

            int i = 0;
            foreach (var disk in machine.Disks)
            {
                if (i == diskIndex)
                {
                    return disk;
                }

                ++i;
            }

            return null;
        }
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:23,代码来源:DiskFactory.cs

示例9: CreateDisk

 public override VirtualDisk CreateDisk(FileLocator locator, string variant, string path, VirtualDiskParameters diskParameters)
 {
     throw new NotSupportedException();
 }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:4,代码来源:DiskFactory.cs

示例10: OpenDiskLayer

 public override VirtualDiskLayer OpenDiskLayer(FileLocator locator, string path, FileAccess access)
 {
     return new DiskImageFile(locator, path, access);
 }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:4,代码来源:DiskFactory.cs

示例11: OpenDisk

 public override VirtualDisk OpenDisk(FileLocator locator, string path, FileAccess access)
 {
     return new Disk(locator, path, access);
 }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:4,代码来源:DiskFactory.cs

示例12: DoInitialize

        private static DiskImageFile DoInitialize(FileLocator fileLocator, string file, long capacity, DiskCreateType type, DescriptorFile baseDescriptor)
        {
            if (type == DiskCreateType.MonolithicSparse)
            {
                // MonolithicSparse is a special case, the descriptor is embedded in the file itself...
                using (Stream fs = fileLocator.Open(file, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    long descriptorStart;
                    CreateExtent(fs, capacity, ExtentType.Sparse, 10 * Sizes.OneKiB, out descriptorStart);

                    ExtentDescriptor extent = new ExtentDescriptor(ExtentAccess.ReadWrite, capacity / Sizes.Sector, ExtentType.Sparse, file, 0);
                    fs.Position = descriptorStart * Sizes.Sector;
                    baseDescriptor.Extents.Add(extent);
                    baseDescriptor.Write(fs);
                }
            }
            else
            {
                ExtentType extentType = CreateTypeToExtentType(type);
                long totalSize = 0;
                List<ExtentDescriptor> extents = new List<ExtentDescriptor>();
                if (type == DiskCreateType.MonolithicFlat || type == DiskCreateType.VmfsSparse || type == DiskCreateType.Vmfs)
                {
                    string adornment = "flat";
                    if(type == DiskCreateType.VmfsSparse)
                    {
                        adornment = string.IsNullOrEmpty(baseDescriptor.ParentFileNameHint) ? "sparse" : "delta";
                    }

                    string fileName = AdornFileName(file, adornment);

                    using(Stream fs = fileLocator.Open(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                    {
                        CreateExtent(fs, capacity, extentType);
                        extents.Add(new ExtentDescriptor(ExtentAccess.ReadWrite, capacity / Sizes.Sector, extentType, fileName, 0));
                        totalSize = capacity;
                    }
                }
                else if (type == DiskCreateType.TwoGbMaxExtentFlat || type == DiskCreateType.TwoGbMaxExtentSparse)
                {
                    int i = 1;
                    while (totalSize < capacity)
                    {
                        string adornment;
                        if (type == DiskCreateType.TwoGbMaxExtentSparse)
                        {
                            adornment = string.Format(CultureInfo.InvariantCulture, "s{0:x3}", i);
                        }
                        else
                        {
                            adornment = string.Format(CultureInfo.InvariantCulture, "{0:x6}", i);
                        }

                        string fileName = AdornFileName(file, adornment);

                        using (Stream fs = fileLocator.Open(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                        {
                            long extentSize = Math.Min(2 * Sizes.OneGiB - Sizes.OneMiB, capacity - totalSize);
                            CreateExtent(fs, extentSize, extentType);
                            extents.Add(new ExtentDescriptor(ExtentAccess.ReadWrite, extentSize / Sizes.Sector, extentType, fileName, 0));
                            totalSize += extentSize;
                        }

                        ++i;
                    }
                }
                else
                {
                    throw new NotSupportedException("Creating disks of this type is not supported");
                }

                using (Stream fs = fileLocator.Open(file, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    baseDescriptor.Extents.AddRange(extents);
                    baseDescriptor.Write(fs);
                }
            }

            return new DiskImageFile(fileLocator, file, FileAccess.ReadWrite);
        }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:80,代码来源:DiskImageFile.cs

示例13: Disk

 internal Disk(FileLocator layerLocator, string path, FileAccess access)
 {
     _path = path;
     _files = new List<ThinkAway.Tuple<VirtualDiskLayer, Ownership>>();
     _files.Add(new ThinkAway.Tuple<VirtualDiskLayer, Ownership>(new DiskImageFile(layerLocator, path, access), Ownership.Dispose));
     ResolveFileChain();
 }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:7,代码来源:Disk.cs

示例14: Initialize

 internal static Disk Initialize(FileLocator fileLocator, string path, DiskParameters parameters)
 {
     return new Disk(DiskImageFile.Initialize(fileLocator, path, parameters), Ownership.Dispose);
 }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:4,代码来源:Disk.cs

示例15: OpenDiskLayer

 public override VirtualDiskLayer OpenDiskLayer(FileLocator locator, string path, FileAccess access)
 {
     FileMode mode = (access == FileAccess.Read) ? FileMode.Open : FileMode.OpenOrCreate;
     FileShare share = (access == FileAccess.Read) ? FileShare.Read : FileShare.None;
     return new DiskImageFile(locator.Open(path, mode, access, share), Ownership.Dispose);
 }
开发者ID:JGTM2016,项目名称:discutils,代码行数:6,代码来源:DiskFactory.cs


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