예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LegFace"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LegFace(EditDeserializer editDeserializer)
        {
            // Only connection paths should generate LegFace instances
            PathOperation op = (editDeserializer.CurrentEdit as PathOperation);

            if (op == null)
            {
                throw new ApplicationException("Unexpected creating edit for a leg face");
            }

            this.Sequence = editDeserializer.ReadInternalId(DataField.Id);

            if (editDeserializer.IsNextField(DataField.PrimaryFaceId))
            {
                InternalIdValue primaryFaceId = editDeserializer.ReadInternalId(DataField.PrimaryFaceId);
                LegFace         face          = op.FindFace(primaryFaceId);

                if (face == null)
                {
                    throw new ApplicationException("Cannot locate primary face " + primaryFaceId);
                }

                Leg = face.Leg;
                Leg.AlternateFace = this;
            }
            else
            {
                // This should never happen. Primary faces are not serialized using the LegFace
                // class (we only use LegFace as part of a PathOperation to simplify import of
                // extra legs from old CEdit files).

                throw new ApplicationException();
            }

            // Convert the data entry string into observed spans
            string       entryString      = editDeserializer.ReadString(DataField.EntryString);
            DistanceUnit defaultEntryUnit = EditingController.Current.EntryUnit;

            Distance[] dists = LineSubdivisionFace.GetDistances(entryString, defaultEntryUnit, false);
            m_Spans = new SpanInfo[dists.Length];

            for (int i = 0; i < m_Spans.Length; i++)
            {
                m_Spans[i] = new SpanInfo()
                {
                    ObservedDistance = dists[i]
                };
            }
        }
예제 #2
0
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="id">The internal of the feature within the project that created it.</param>
 /// <param name="entity">The type of real-world object that the feature corresponds to.</param>
 /// <param name="fid">The ID of the feature (may be null).</param>
 static void ReadData(EditDeserializer editDeserializer, out InternalIdValue id, out IEntity entity, out FeatureId fid)
 {
     id     = editDeserializer.ReadInternalId(DataField.Id);
     entity = editDeserializer.ReadEntity(DataField.Entity);
     fid    = editDeserializer.ReadFeatureId();
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IdMapping"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 internal IdMapping(EditDeserializer editDeserializer)
 {
     m_InternalId = editDeserializer.ReadInternalId(DataField.Id);
     m_RawId      = editDeserializer.ReadUInt32(DataField.Key);
 }