private static void RemoveWellKnownPartitions(GptContext context)
 {
     Log.Debug("Removing well-known partitions");
     context.RemoveExisting(PartitionName.System);
     context.RemoveExisting(PartitionName.Reserved);
     context.RemoveExisting(PartitionName.Windows);
     Log.Debug("Well-known partitions removed");
 }
        private IEnumerable <FileSystem.Gpt.Partition> GetPartitionsAfterData(GptContext c)
        {
            var gptPartition = c.Find(dataPartition.Guid);
            var indexOfData  = c.Partitions.IndexOf(gptPartition);

            var toRemove = c.Partitions
                           .Skip(indexOfData + 1)
                           .ToList();

            return(toRemove);
        }
        // ReSharper disable once UnusedMember.Local
        private static void RemovePartitionsAfterData(GptContext context)
        {
            Log.Debug("Trying to remove partitions created by older version of Deployer");

            var toRemove = GetPartitionsAfter(PartitionName.Data, context).ToList();

            if (toRemove.Any(IsForbidden))
            {
                throw new FileSystemException("Attempt to delete a forbidden partition. Aborting.");
            }

            foreach (var partition in toRemove)
            {
                context.Delete(partition);
            }
        }
        private static IEnumerable <Partition> GetPartitionsAfter(string partitionName, GptContext c)
        {
            var data        = c.Get(partitionName);
            var indexOfData = c.Partitions.IndexOf(data);

            if (indexOfData <= 0)
            {
                return(Enumerable.Empty <Partition>());
            }

            var toRemove = c.Partitions
                           .Skip(indexOfData + 1)
                           .ToList();

            return(toRemove);
        }