コード例 #1
0
        public override void Open()
        {
            // make new MapDriver
            _vehicle = new MapDriver(Annotations);
            _vehicles.Add(_vehicle);
            Demo.SelectedVehicle = _vehicle;

            // marks as obstacles map cells adjacent to the path
            _usePathFences = true;

            // scatter random rock clumps over map
            _useRandomRocks = true;

            // init Demo camera
            _initCamDist = 30;
            _initCamElev = 15;
            Demo.Init2dCamera(_vehicle, _initCamDist, _initCamElev);
            // "look straight down at vehicle" camera mode parameters
            Demo.Camera.LookDownDistance = 50;
            // "static" camera mode parameters
            Demo.Camera.FixedPosition = new Vector3(145);
            Demo.Camera.FixedTarget.X = 40;
            Demo.Camera.FixedTarget.Y = 0;
            Demo.Camera.FixedTarget.Z = 40;
            Demo.Camera.FixedUp       = Vector3.UnitY;

            // reset this plugin
            Reset();
        }
コード例 #2
0
        public object Retrieve(KeyValuePair <string, string> keyValuePair, Type targetType, Type propertyType)
        {
            if (string.IsNullOrWhiteSpace(keyValuePair.Value))
            {
                throw new NotSupportedException($"Table row column '{keyValuePair.Key}' does not support empty entry.");
            }
            if (MapDriver.IsNotSet(keyValuePair.Value))
            {
                return(0M);
            }

            var isPercentageRepresentation = keyValuePair.Value.Contains("%");
            var stringValue = keyValuePair.Value;

            if (isPercentageRepresentation)
            {
                stringValue = stringValue.Replace("%", "").Trim();
            }

            var value = decimal.Parse(stringValue);

            if (isPercentageRepresentation)
            {
                value *= 0.01M;
            }

            return(value);
        }
コード例 #3
0
        private static IEnumerable <T> GetValue(string value)
        {
            var values     = value.Split(';');
            var enumerable = values.Where(v => MapDriver.IsSet(v.Trim())).Select(ChangeType).ToList();

            return(enumerable.Any() ? enumerable : null);
        }
コード例 #4
0
 public decimal?NullableDecimalTransformation(string value)
 {
     if (MapDriver.IsNotSet(value))
     {
         return(null);
     }
     return(decimal.Parse(value));
 }
コード例 #5
0
        public DateTimeOffset TransformDateTimeOffset(string value)
        {
            if (MapDriver.IsNotSet(value))
            {
                throw new NotSupportedException("'Empty' entry to 'DateTimeOffset' transformation is not supported.");
            }

            return(DateConverter.GetDateOffset(value).Value);
        }
コード例 #6
0
        public bool GetValue(KeyValuePair <string, string> keyValuePair)
        {
            if (string.IsNullOrWhiteSpace(keyValuePair.Value))
            {
                throw new NotSupportedException($"Table row column '{keyValuePair.Key}' does not support empty entry.");
            }

            return(MapDriver.MapToBool(keyValuePair.Value));
        }
        public string[] TransformStringToMultiple(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new NotSupportedException("'Empty' entry to 'string[]' transformation is not supported.");
            }

            return(MapDriver.MapSingleRowCellEntryToMultiple(value).ToArray());
        }
コード例 #8
0
        public bool BoolTransform(string result)
        {
            if (string.IsNullOrWhiteSpace(result))
            {
                throw new NotSupportedException("'Empty' entry to 'bool' transformation is not supported.");
            }

            return(MapDriver.MapToBool(result));
        }
コード例 #9
0
        public short[] TransformToShortArray(string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new NotSupportedException($"'Empty' entry to '{nameof(Int16)}[]' transformation is not supported.");
            }

            return(value.Split(',')
                   .Select(s => s.TrimToNull())
                   .Select(s => MapDriver.IsSet(s) ? short.Parse(s) : default)
コード例 #10
0
        public static string ReplaceMagicStrings(this string value)
        {
            if (MapDriver.IsNotSet(value))
            {
                return(null);
            }

            var result = ReplaceMagicStringOfLength(value);

            result = DateConverter.ReplaceDate(result);

            return(result);
        }
コード例 #11
0
        public object GetValue(KeyValuePair <string, string> keyValuePair, Type enumType)
        {
            if (EnumConverter.IsNotNullableEnum(enumType) && string.IsNullOrWhiteSpace(keyValuePair.Value))
            {
                throw new NotSupportedException($"Table row column '{keyValuePair.Key}' does not support empty entries.");
            }

            try
            {
                return(MapDriver.MapToEnum(keyValuePair.Value, enumType));
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"No enum with value '{keyValuePair.Value}' found for Table row column '{keyValuePair.Key}'.", exception);
            }
        }
コード例 #12
0
 private static DateTimeOffset GetValue(KeyValuePair <string, string> keyValuePair)
 {
     return(MapDriver.IsNotSet(keyValuePair.Value) ? default : DateConverter.GetDateOffset(keyValuePair.Value).Value);
 }
コード例 #13
0
 public object Retrieve(KeyValuePair <string, string> keyValuePair, Type targetType, Type propertyType)
 {
     return(MapDriver.IsNotSet(keyValuePair.Value)
                ? (int?)null
                : int.Parse(keyValuePair.Value.Replace(".", "").Replace(" ", "")));
 }
コード例 #14
0
 public object Retrieve(KeyValuePair <string, string> keyValuePair, Type targetType, Type propertyType)
 {
     return(MapDriver.IsNotSet(keyValuePair.Value)
         ? null
         : _retriever.Retrieve(keyValuePair, targetType, propertyType));
 }