예제 #1
0
 public void AddDisk(Guid diskId, PartitionStyle partitionStyle, bool isHotSpare)
 {
     try
     {
         this.pack.AddDisk(diskId, partitionStyle, isHotSpare ? 1U : 0U);
     }
     catch (COMException exception)
     {
         throw new VdsException("The method call IVdsPack::AddDisk failed.", exception);
     }
 }
예제 #2
0
        private void AddPartitionInfo(IDictionary <string, ResultOrError <PartitionInformation> > dictionary, string path, XmlElement node)
        {
            if (node == null)
            {
                return;
            }
            if (dictionary.ContainsKey(path))
            {
                return;
            }

            // Because this is a complex type, The XML will always return the default value.
            ResultOrError <PartitionInformation> result = GetResultOrError <PartitionInformation>(node);

            if (result != null)
            {
                dictionary.Add(path, result);
                return;
            }

            string         style      = node["Style"].Attributes["result"].Value;
            string         number     = node["Number"].Attributes["result"].Value;
            string         offset     = node["Offset"].Attributes["result"].Value;
            string         length     = node["Length"].Attributes["result"].Value;
            PartitionStyle partStyle  = (PartitionStyle)int.Parse(style, CultureInfo.InvariantCulture);
            int            partNumber = int.Parse(number, CultureInfo.InvariantCulture);
            long           partOffset = long.Parse(offset, CultureInfo.InvariantCulture);
            long           partLength = long.Parse(length, CultureInfo.InvariantCulture);

            switch (partStyle)
            {
            case PartitionStyle.MasterBootRecord:
                dictionary.Add(path, new ResultOrError <PartitionInformation>(
                                   new MbrPartition()
                {
                    Number        = partNumber,
                    Offset        = partOffset,
                    Length        = partLength,
                    Bootable      = bool.Parse(node["MbrBootable"].Attributes["result"].Value),
                    HiddenSectors = int.Parse(node["MbrOffset"].Attributes["result"].Value),
                    Type          = int.Parse(node["MbrType"].Attributes["result"].Value)
                }));
                break;

            case PartitionStyle.GuidPartitionTable:
                dictionary.Add(path, new ResultOrError <PartitionInformation>(
                                   new GptPartition()
                {
                    Number     = partNumber,
                    Offset     = partOffset,
                    Length     = partLength,
                    Type       = new Guid(node["GptType"].Attributes["result"].Value),
                    Id         = new Guid(node["GptId"].Attributes["result"].Value),
                    Name       = node["GptName"].Attributes["result"].Value,
                    Attributes = (EFIPartitionAttributes)long.Parse(node["GptAttributes"].Attributes["result"].Value, CultureInfo.InvariantCulture)
                }));
                break;

            default:
                dictionary.Add(path, new ResultOrError <PartitionInformation>(
                                   new PartitionInformation(partStyle)
                {
                    Number = partNumber,
                    Offset = partOffset,
                    Length = partLength
                }));
                break;
            }
        }
예제 #3
0
 private DiskPartitionInfo(uint SizeOfPartitionInfo, PartitionStyle PartitionStyle, DiskPartitionInfoUnion Info)
 => (this.SizeOfPartitionInfo, this.PartitionStyle, this.Info) = (SizeOfPartitionInfo, PartitionStyle, Info);
예제 #4
0
 public PartitionInformation(PartitionStyle style)
 {
     Style = style;
 }
예제 #5
0
 private DriveLayoutInformationEx(PartitionStyle PartitionStyle, DriveLayoutInformationUnion Info, PartitionInformationEx[] PartitionEntry)
 => (this.PartitionStyle, PartitionCount, this.Info, _PartitionEntry) = (PartitionStyle, (uint)(PartitionEntry?.Length ?? 0), Info, (PartitionEntry?.Length ?? 0) == 0 ? new PartitionInformationEx[1] : PartitionEntry);