// // Copyright (c) 2008-2011, Kenneth Bell // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // namespace DiscUtils.BootConfig { using System; /// /// The value of an element. /// public abstract class ElementValue { /// /// Gets the format of the value. /// public abstract ElementFormat Format { get; } /// /// Gets the parent object (only for Device values). /// public virtual Guid ParentObject { get { return Guid.Empty; } } /// /// Gets a value representing a device (aka partition). /// /// Object containing detailed information about the device. /// The volume to represent. /// The value as an object. public static ElementValue ForDevice(Guid parentObject, PhysicalVolumeInfo physicalVolume) { return new DeviceElementValue(parentObject, physicalVolume); } /// /// Gets a value representing the logical boot device. /// /// The boot pseudo-device as an object. public static ElementValue ForBootDevice() { return new DeviceElementValue(); } /// /// Gets a value representing a string value. /// /// The value to convert. /// The value as an object. public static ElementValue ForString(string value) { return new StringElementValue(value); } /// /// Gets a value representing an integer value. /// /// The value to convert. /// The value as an object. public static ElementValue ForInteger(long value) { return new IntegerElementValue((ulong)value); } /// /// Gets a value representing an integer list value. /// /// The value to convert. /// The value as an object. public static ElementValue ForIntegerList(long[] values) { ulong[] ulValues = new ulong[values.Length]; for (int i = 0; i < values.Length; ++i) { ulValues[i] = (ulong)values[i]; } return new IntegerListElementValue(ulValues); } /// /// Gets a value representing a boolean value. /// /// The value to convert. /// The value as an object. public static ElementValue ForBoolean(bool value) { return new BooleanElementValue(value); } /// /// Gets a value representing a GUID value. /// /// The value to convert. /// The value as an object. public static ElementValue ForGuid(Guid value) { return new GuidElementValue(value.ToString("B")); } /// /// Gets a value representing a GUID list value. /// /// The value to convert. /// The value as an object. public static ElementValue ForGuidList(Guid[] values) { string[] strValues = new string[values.Length]; for (int i = 0; i < values.Length; ++i) { strValues[i] = values[i].ToString("B"); } return new GuidListElementValue(strValues); } } }