Beispiel #1
0
        /// <summary>
        /// Loads the vehicle from the given script.
        /// </summary>
        public static DynamicVehicle Load(string script)
        {
            var vehicle = new DynamicVehicle(script);

            vehicle.Register();
            return(vehicle);
        }
Beispiel #2
0
        /// <summary>
        /// Deserializes a vehicle from the given stream.
        /// </summary>
        public static Vehicle Deserialize(Stream stream)
        {
            var typeName = stream.ReadWithSizeString();

            switch (typeName)
            {
            case "Itinero.Profiles.DynamicVehicle":
                var vehicle = new DynamicVehicle(stream.ReadWithSizeString());
                return(vehicle);
            }
            if (Vehicle.CustomDeserializer != null)
            {
                var vehicle = Vehicle.CustomDeserializer(typeName, stream);
                return(vehicle);
            }
            throw new Exception(string.Format("Cannot deserialize for type with name: {0}. A custom deserializer was not found.", typeName));
        }
Beispiel #3
0
 /// <summary>
 /// Loads the vehicle from the embedded resources.
 /// </summary>
 public static DynamicVehicle LoadFromEmbeddedResource(Assembly assembly, string embeddedResource)
 {
     return(DynamicVehicle.Load(assembly.GetManifestResourceStream(embeddedResource).ReadToEnd()));
 }
Beispiel #4
0
 /// <summary>
 /// Loads the vehicle from the given stream.
 /// </summary>
 public static DynamicVehicle LoadFromStream(Stream stream)
 {
     return(DynamicVehicle.Load(stream.ReadToEnd()));
 }
Beispiel #5
0
 /// <summary>
 /// Loads the vehicle from the given stream using the current position as the size.
 /// </summary>
 public static DynamicVehicle LoadWithSize(Stream stream)
 {
     return(DynamicVehicle.Load(stream.ReadWithSizeString()));
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new dynamic profile.
        /// </summary>
        internal DynamicProfile(string name, ProfileMetric metric, string[] vehicleTypes, DynamicVehicle parent, Script script, object factor_and_speed)
            : base(name, metric, vehicleTypes, null, parent)
        {
            _name         = name;
            _metric       = metric;
            _vehicleTypes = vehicleTypes;
            _script       = script;
            _function     = factor_and_speed;

            _attributesTable = new Table(_script);
            _resultsTable    = new Table(_script);
        }