Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableFailureMechanismSection"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="failureMechanismSectionCollection">The failure mechanism sections object the section belong to.</param>
        /// <param name="startDistance">The distance over the reference line where this section starts in meters.</param>
        /// <param name="endDistance">The distance over the reference line where this section ends in meters.</param>
        /// <param name="geometry">The geometry of the section.</param>
        /// <param name="sectionType">The type of the section.</param>
        /// <param name="assemblyMethod">The assembly method used to create this section.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanismSectionCollection"/>,
        /// or <paramref name="geometry"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when:
        /// <list type="bullet">
        /// <item><paramref name="geometry"/> contains no elements.</item>
        /// <item><paramref name="id"/> is invalid.</item>
        /// </list>
        /// </exception>
        public SerializableFailureMechanismSection(string id,
                                                   SerializableFailureMechanismSectionCollection failureMechanismSectionCollection,
                                                   double startDistance,
                                                   double endDistance,
                                                   IEnumerable <Point2D> geometry,
                                                   SerializableFailureMechanismSectionType sectionType,
                                                   SerializableAssemblyMethod?assemblyMethod = null)
        {
            SerializableIdValidator.ThrowIfInvalid(id);

            if (failureMechanismSectionCollection == null)
            {
                throw new ArgumentNullException(nameof(failureMechanismSectionCollection));
            }

            if (geometry == null)
            {
                throw new ArgumentNullException(nameof(geometry));
            }

            Id            = id;
            StartDistance = new SerializableMeasure(startDistance);
            EndDistance   = new SerializableMeasure(endDistance);
            FailureMechanismSectionCollectionId = failureMechanismSectionCollection.Id;
            Geometry       = new SerializableLine(geometry);
            Length         = new SerializableMeasure(Math2D.Length(geometry));
            AssemblyMethod = assemblyMethod;
            FailureMechanismSectionType = sectionType;
        }
Exemplo n.º 2
0
 public DialogueLine MakeLine(SerializableLine line)
 {
     if (string.IsNullOrEmpty(line.name))
     {
         line.name = this.npcName;
     }
     //if the image index is unspecified it defaults to zero, no need to catch it
     return(new DialogueLine(line.text, line.name, line.imageIndex));
 }
Exemplo n.º 3
0
        public void DefaultConstructor_ReturnsDefaultValues()
        {
            // Call
            var line = new SerializableLine();

            // Assert
            Assert.IsNull(line.LineString);

            SerializableAttributeTestHelper.AssertXmlElementAttribute<SerializableLine>(
                nameof(SerializableLine.LineString), "LineString", "http://www.opengis.net/gml/3.2");
        }
Exemplo n.º 4
0
        public void Constructor_WithValidData_ReturnsExpectedValues()
        {
            // Setup
            var random = new Random(39);
            var geometry = new[]
            {
                new Point2D(random.NextDouble(), random.NextDouble()),
                new Point2D(random.NextDouble(), random.NextDouble())
            };

            // Call
            var line = new SerializableLine(geometry);

            // Assert
            Assert.AreEqual(GeometrySerializationFormatter.Format(geometry), line.LineString.Geometry);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new instance of <see cref="SerializableAssessmentSection"/>.
        /// </summary>
        /// <param name="id">The unique assembly ID.</param>
        /// <param name="name">The name of the assessment section.</param>
        /// <param name="geometry">The geometry of the reference line.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter except <paramref name="id"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when:
        /// <list type="bullet">
        /// <item><paramref name="geometry"/> contains no elements.</item>
        /// <item><paramref name="id"/> is invalid.</item>
        /// </list>
        /// </exception>
        public SerializableAssessmentSection(string id,
                                             string name,
                                             IEnumerable <Point2D> geometry) : this()
        {
            SerializableIdValidator.ThrowIfInvalid(id);

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (geometry == null)
            {
                throw new ArgumentNullException(nameof(geometry));
            }

            Id   = id;
            Name = name;
            ReferenceLineLength   = new SerializableMeasure(Math2D.Length(geometry));
            ReferenceLineGeometry = new SerializableLine(geometry);
        }
Exemplo n.º 6
0
        public override SerializableBase CreateSerializableObject()
        {
            SerializableLine line = new SerializableLine(this);

            return(line);
        }