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); } }
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; } }
private DiskPartitionInfo(uint SizeOfPartitionInfo, PartitionStyle PartitionStyle, DiskPartitionInfoUnion Info) => (this.SizeOfPartitionInfo, this.PartitionStyle, this.Info) = (SizeOfPartitionInfo, PartitionStyle, Info);
public PartitionInformation(PartitionStyle style) { Style = style; }
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);