/* * Copyright (c) 2005-2006 Erik Tigerholm * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ using System; using System.Collections.Generic; using System.Text; using System.Xml.Serialization; using OpenTraffic.Model.SpeedFunctions; namespace OpenTraffic.Model { [Serializable] public class LinkCategory { #region XmlExport [XmlElement(ElementName = "Id")] public string XmlRegisterId { get { return Name; } set { Importer.Lookup.Get().Add(value, this); } } [XmlElement(ElementName = "Name")] public string Name { get; set; } [XmlElement(ElementName = "IdSpeedflow")] public string XmlRegisterSpeedFlow { get { return SpeedFlow == null ? null : SpeedFlow.SpeedFlowName; } set { SpeedFlow = Importer.Lookup.Get().GetObject(value); } } [XmlAttribute(AttributeName = "Lanes")] public float Lanes { get; set; } [XmlAttribute(AttributeName = "Speed")] public float Speed { get; set; } [XmlAttribute(AttributeName = "Storage")] public float Storage { get; set; } [XmlAttribute(AttributeName = "SaturationFlow")] public float SaturationFlow { get; set; } [XmlElement(ElementName = "Description")] public string Description { get; set; } #endregion #region XmlIgnore [XmlIgnore] public SpeedFlow SpeedFlow { get; private set; } #endregion public LinkCategory() { } public LinkCategory(string name) { this.Name = name; } public LinkCategory( string name, float lanes, float speed, float storage, float saturationFlow, SpeedFlow sf, string description) { this.SpeedFlow = sf; this.Description = description; this.Lanes = lanes; this.Speed = speed; this.Storage = storage; this.Name = name; this.SaturationFlow = saturationFlow; } public override string ToString() { return Name; } } }