public static AI CreateFromStream(BinaryReader reader) { AI createdAI = null; bool reading = true; while (reading) { StreamEnum nextEnum = (StreamEnum)reader.ReadByte(); switch (nextEnum) { case StreamEnum.NAME: { // parse the type name createdAI = (AI)TypeHelper.CreateFromTypeName(reader.ReadString()); } break; case StreamEnum.STOP: default: reading = false; break; } } return(createdAI); }
public static Part CreateFromStream(BinaryReader reader, Aircraft associatedAircraft = null, bool isBody = false) { Part createdPart = null; bool reading = true; while (reading) { StreamEnum nextEnum = (StreamEnum)reader.ReadByte(); switch (nextEnum) { case StreamEnum.NAME: { // parse the type name createdPart = (Part)TypeHelper.CreateFromTypeName(reader.ReadString()); // if this part is the body of an aircraft assign it right away if (associatedAircraft != null) { if (isBody) { associatedAircraft.Body = createdPart; } else { associatedAircraft.AddChild(createdPart); } } } break; case StreamEnum.MOUNT: { // construct and mount a part int mountIndex = reader.ReadInt32(); createdPart.MountPart(mountIndex, CreateFromStream(reader, associatedAircraft)); } break; case StreamEnum.STOP: default: reading = false; break; } } return(createdPart); }
internal static MathChallenge CreateFromStream(BinaryReader reader, bool keepCurrentMath) { bool reading = true; MathChallenge dummy = null; while (reading) { StreamEnum nextEnum = (StreamEnum)reader.ReadByte(); switch (nextEnum) { case StreamEnum.NAME: { // read the string containing the full name of the challenge class string className = reader.ReadString(); dummy = (MathChallenge)TypeHelper.CreateFromTypeName(className); } break; case StreamEnum.LOCKED: { var locked = reader.ReadBoolean(); if (dummy != null && !keepCurrentMath) { dummy.Locked = locked; } } break; case StreamEnum.COMBO: { var combo = reader.ReadInt32(); if (dummy != null && !keepCurrentMath) { dummy.Combo = combo; } } break; case StreamEnum.STOP: reading = false; break; } } return(dummy); }
/// <summary> /// Initializes a new instance of the <see cref="VideoMetadataInteractionsBuy" /> class. /// </summary> /// <param name="currency">The currency code for the current user's region. (required).</param> /// <param name="displayPrice">Formatted price to display to buy an On Demand video. (required).</param> /// <param name="download">The user's download access to this On Demand video: Option descriptions: * `available` - The video is available for download. * `purchased` - The user has purchased the video. * `restricted` - The user isn't permitted to download the video. * `unavailable` - The video isn't available for download. (required).</param> /// <param name="drm">Whether the video has DRM. (required).</param> /// <param name="link">The URL to buy the On Demand video on Vimeo. (required).</param> /// <param name="price">The numeric value of the price for buying the On Demand video. (required).</param> /// <param name="purchaseTime">The time in ISO 8601 format when the On Demand video was purchased. (required).</param> /// <param name="stream">The user's streaming access to this On Demand video: Option descriptions: * `available` - The video is available for streaming. * `purchased` - The user has purchased the video. * `restricted` - The user isn't permitted to stream the video. * `unavailable` - The video isn't available for streaming (required).</param> /// <param name="uri">The product URI to purchase the On Demand video. (required).</param> public VideoMetadataInteractionsBuy(string currency = default(string), string displayPrice = default(string), DownloadEnum download = default(DownloadEnum), bool drm = default(bool), string link = default(string), decimal?price = default(decimal?), string purchaseTime = default(string), StreamEnum stream = default(StreamEnum), string uri = default(string)) { // to ensure "currency" is required (not null) this.Currency = currency ?? throw new ArgumentNullException("currency is a required property for VideoMetadataInteractionsBuy and cannot be null"); // to ensure "displayPrice" is required (not null) this.DisplayPrice = displayPrice ?? throw new ArgumentNullException("displayPrice is a required property for VideoMetadataInteractionsBuy and cannot be null"); this.Download = download; this.Drm = drm; // to ensure "link" is required (not null) this.Link = link ?? throw new ArgumentNullException("link is a required property for VideoMetadataInteractionsBuy and cannot be null"); // to ensure "price" is required (not null) this.Price = price ?? throw new ArgumentNullException("price is a required property for VideoMetadataInteractionsBuy and cannot be null"); // to ensure "purchaseTime" is required (not null) this.PurchaseTime = purchaseTime ?? throw new ArgumentNullException("purchaseTime is a required property for VideoMetadataInteractionsBuy and cannot be null"); this.Stream = stream; // to ensure "uri" is required (not null) this.Uri = uri ?? throw new ArgumentNullException("uri is a required property for VideoMetadataInteractionsBuy and cannot be null"); }