Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PathOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PathOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            //try
            //{
            m_From             = editDeserializer.ReadFeatureRef <PointFeature>(DataField.From);
            m_To               = editDeserializer.ReadFeatureRef <PointFeature>(DataField.To);
            m_EntryString      = editDeserializer.ReadString(DataField.EntryString);
            m_DefaultEntryUnit = editDeserializer.ReadDistanceUnit(DataField.DefaultEntryUnit);

            Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit);
            PrepareLegs(this.EditSequence, legs);
            m_Legs = new List <Leg>(legs);

            Project p         = editDeserializer.Project;
            IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);
            IEntity lineType  = editDeserializer.ReadEntity(DataField.LineType);

            // Pick up any alternate faces (these may be defined ONLY when dealing with
            // data files that were derived from old CEdit files). The deserializaing
            // constructor will connect the alternate faces to the legs we've just
            // created.
            if (editDeserializer.IsNextField(DataField.AlternateFaces))
            {
                editDeserializer.ReadPersistentArray <LegFace>(DataField.AlternateFaces);
            }

            // Create stubs for everything that we could conceivably create (including
            // any alternate faces).
            FeatureStub[] stubs = CreateStubs(p, pointType, lineType);

            var result = new DeserializationFactory(this, stubs);

            result.PointType = pointType;
            result.LineType  = lineType;

            // Create feature objects
            ProcessFeatures(result);

            // Apply any IDs
            if (editDeserializer.IsNextField(DataField.Ids))
            {
                editDeserializer.ReadIdMappings(DataField.Ids);
            }
            //}

            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LineSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LineSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Line = editDeserializer.ReadFeatureRef <LineFeature>(DataField.Line);
            m_Face = editDeserializer.ReadPersistent <LineSubdivisionFace>(DataField.Face);
            //FeatureStub[] sections = editDeserializer.ReadFeatureStubArray(DataField.Result);

            if (editDeserializer.IsNextField(DataField.OtherSide))
            {
                InternalIdValue id = editDeserializer.ReadInternalId(DataField.OtherSide);
                OtherSide = (LineSubdivisionOperation)editDeserializer.MapModel.FindOperation(id);
                Debug.Assert(OtherSide != null);
                OtherSide.OtherSide = this;
            }

            Project p         = editDeserializer.Project;
            IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);

            FeatureStub[] sections = CreateStubs(p, pointType, m_Line.EntityType);

            DeserializationFactory result = new DeserializationFactory(this, sections);

            ProcessFeatures(result);

            // Apply any IDs
            if (editDeserializer.IsNextField(DataField.Ids))
            {
                editDeserializer.ReadIdMappings(DataField.Ids);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LineSubdivisionOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal LineSubdivisionOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Line = editDeserializer.ReadFeatureRef<LineFeature>(DataField.Line);
            m_Face = editDeserializer.ReadPersistent<LineSubdivisionFace>(DataField.Face);
            //FeatureStub[] sections = editDeserializer.ReadFeatureStubArray(DataField.Result);

            if (editDeserializer.IsNextField(DataField.OtherSide))
            {
                InternalIdValue id = editDeserializer.ReadInternalId(DataField.OtherSide);
                OtherSide = (LineSubdivisionOperation)editDeserializer.MapModel.FindOperation(id);
                Debug.Assert(OtherSide != null);
                OtherSide.OtherSide = this;
            }

            Project p = editDeserializer.Project;
            IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);
            FeatureStub[] sections = CreateStubs(p, pointType, m_Line.EntityType);

            DeserializationFactory result = new DeserializationFactory(this, sections);
            ProcessFeatures(result);

            // Apply any IDs
            if (editDeserializer.IsNextField(DataField.Ids))
                editDeserializer.ReadIdMappings(DataField.Ids);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PathOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal PathOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            //try
            //{
                m_From = editDeserializer.ReadFeatureRef<PointFeature>(DataField.From);
                m_To = editDeserializer.ReadFeatureRef<PointFeature>(DataField.To);
                m_EntryString = editDeserializer.ReadString(DataField.EntryString);
                m_DefaultEntryUnit = editDeserializer.ReadDistanceUnit(DataField.DefaultEntryUnit);

                Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit);
                PrepareLegs(this.EditSequence, legs);
                m_Legs = new List<Leg>(legs);

                Project p = editDeserializer.Project;
                IEntity pointType = editDeserializer.ReadEntity(DataField.PointType);
                IEntity lineType = editDeserializer.ReadEntity(DataField.LineType);

                // Pick up any alternate faces (these may be defined ONLY when dealing with
                // data files that were derived from old CEdit files). The deserializaing
                // constructor will connect the alternate faces to the legs we've just
                // created.
                if (editDeserializer.IsNextField(DataField.AlternateFaces))
                    editDeserializer.ReadPersistentArray<LegFace>(DataField.AlternateFaces);

                // Create stubs for everything that we could conceivably create (including
                // any alternate faces).
                FeatureStub[] stubs = CreateStubs(p, pointType, lineType);

                var result = new DeserializationFactory(this, stubs);
                result.PointType = pointType;
                result.LineType = lineType;

                // Create feature objects
                ProcessFeatures(result);

                // Apply any IDs
                if (editDeserializer.IsNextField(DataField.Ids))
                    editDeserializer.ReadIdMappings(DataField.Ids);
            //}

            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
 /// <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();
 }