/// <summary> /// Initializes a new instance of the <see cref="ArcGeometry"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal ArcGeometry(EditDeserializer editDeserializer) : base(editDeserializer) { m_IsClockwise = editDeserializer.ReadBool(DataField.Clockwise); if (editDeserializer.IsNextField(DataField.Center)) { PointFeature center = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.Center); // The arc is the first arc attached to the circle. However, we cannot // calculate the radius just yet because the bc/ec points are not persisted // as part of the ArcGeometry definition (they are defined as part of the // LineFeature object that utilizes the ArcGeometry). // Even if we did have the bc/ec points at this stage, their positions will // only be available if the data came from an import (they will still be // undefined if the geometry is calculated, since calculation only occurs // after deserialization has been completed). if (center != null) { ApplyFeatureRef(DataField.Center, center); } } else { ArcFeature firstArc = editDeserializer.ReadFeatureRef <ArcFeature>(this, DataField.FirstArc); if (firstArc != null) { ApplyFeatureRef(DataField.FirstArc, firstArc); } } }
/// <summary> /// Initializes a new instance of the <see cref="SectionGeometry"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal SectionGeometry(EditDeserializer editDeserializer) : base(editDeserializer) { m_Base = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Base); if (m_Base == null) { throw new ArgumentNullException(); } }
/// <summary> /// Loads a feature reference back from a storage medium (so long as it comes next in the supplied /// deserialization stream). /// </summary> /// <typeparam name="T">The type of feature expected by the caller.</typeparam> /// <param name="editDeserializer">The mechanism for reading back content.</param> /// <param name="field">The tag that identifies the item.</param> /// <returns>True if a feature reference was loaded, false if the next item in the deserialization /// stream does not have the specified name.</returns> internal bool ReadFeature <T>(EditDeserializer editDeserializer, DataField field) where T : Feature { if (editDeserializer.IsNextField(field)) { T result = editDeserializer.ReadFeatureRef <T>(field); Add(new UpdateItem(field, result)); return(true); } return(false); }