< Summary

Information
Class: ValidateLib.TabularData.Datatypes.DatatypeFactory
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\TabularData\Datatypes\DatatypeFactory.cs
Line coverage
81%
Covered lines: 211
Uncovered lines: 48
Coverable lines: 259
Total lines: 511
Line coverage: 81.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\TabularData\Datatypes\DatatypeFactory.cs

#LineLine coverage
 1using ValidateLib.Metadata.Descriptors;
 2using ValidateLib.TabularData.Datatypes.DateDatatypes;
 3using ValidateLib.TabularData.Datatypes.DurationDatatypes;
 4using ValidateLib.TabularData.Datatypes.NumericDatatypes;
 5using ValidateLib.TabularData.Datatypes.StringDatatypes;
 6
 7namespace ValidateLib.TabularData.Datatypes
 8{
 9    public class DatatypeFactory
 10    {
 11        public static BaseDT GetDatatype(string? strValue, string baseType, FormatDescriptor? format)
 12        {
 13            switch (baseType)
 14            {
 15                case "anyAtomicType":
 16                case "any":
 017                    return ProduceAny(strValue, format);
 18                case "anyURI":
 119                    return ProduceAnyUri(strValue, format);
 20                case "base64Binary":
 21                case "binary":
 122                    return ProduceBinary(strValue, format);
 23                case "boolean":
 124                    return ProduceBoolean(strValue, format);
 25                case "date":
 126                    return ProduceDate(strValue, format);
 27                case "dateTime":
 28                case "datetime":
 129                    return ProduceDateTime(strValue, format);
 30                case "dateTimeStamp":
 131                    return ProduceDateTimeStamp(strValue, format);
 32                case "decimal":
 133                    return ProduceDecimal(strValue, format);
 34                case "integer":
 135                    return ProduceInteger(strValue, format);
 36                case "long":
 137                    return ProduceLong(strValue, format);
 38                case "int":
 139                    return ProduceInt(strValue, format);
 40                case "short":
 141                    return ProduceShort(strValue, format);
 42                case "byte":
 143                    return ProduceByte(strValue, format);
 44                case "nonNegativeInteger":
 145                    return ProduceNonNegativeInteger(strValue, format);
 46                case "positiveInteger":
 147                    return ProducePositiveInteger(strValue, format);
 48                case "unsignedLong":
 149                    return ProduceUnsignedLong(strValue, format);
 50                case "unsignedInt":
 151                    return ProduceUnsignedInt(strValue, format);
 52                case "unsignedShort":
 153                    return ProduceUnsignedShort(strValue, format);
 54                case "unsignedByte":
 155                    return ProduceUnsignedByte(strValue, format);
 56                case "nonPositiveInteger":
 157                    return ProduceNonPositiveInteger(strValue, format);
 58                case "negativeInteger":
 159                    return ProduceNegativeInteger(strValue, format);
 60                case "double":
 61                case "number":
 162                    return ProduceDouble(strValue, format);
 63                case "duration":
 164                    return ProduceDuration(strValue, format);
 65                case "dayTimeDuration":
 166                    return ProduceDayTimeDuration(strValue, format);
 67                case "yearMonthDuration":
 168                    return ProduceYearMonthDuration(strValue, format);
 69                case "float":
 170                    return ProduceFloat(strValue, format);
 71                case "gDay":
 172                    return ProduceGDay(strValue, format);
 73                case "gMonth":
 174                    return ProduceGMonth(strValue, format);
 75                case "gMonthDay":
 176                    return ProduceGMonthDay(strValue, format);
 77                case "gYear":
 178                    return ProduceGYear(strValue, format);
 79                case "gYearMonth":
 180                    return ProduceGYearMonth(strValue, format);
 81                case "hexBinary":
 182                    return ProduceHexBinary(strValue, format);
 83                case "QName":
 184                    return ProduceQName(strValue, format);
 85                case "string":
 186                    return ProduceString(strValue, format);
 87                case "normalizedString":
 188                    return ProduceNormalizedString(strValue, format);
 89                case "token":
 190                    return ProduceToken(strValue, format);
 91                case "language":
 192                    return ProduceLanguage(strValue, format);
 93                case "Name":
 194                    return ProduceName(strValue, format);
 95                case "NMTOKEN":
 196                    return ProduceNMTOKEN(strValue, format);
 97                case "xml":
 198                    return ProduceXml(strValue!, format);
 99                case "html":
 0100                    return ProduceHtml(strValue, format);
 101                case "json":
 0102                    return ProduceJson(strValue, format);
 103                case "time":
 1104                    return ProduceTime(strValue, format);
 105                default:
 0106                    throw new ArgumentException();
 107            }
 108
 109        }
 110
 111        static BaseDT ProduceAny(string? strValue, FormatDescriptor? format)
 112        {
 0113            if (strValue == null)
 0114                return new AnyAtomicTypeDT();
 0115            if (format == null)
 0116                return new AnyAtomicTypeDT(strValue);
 117            else
 0118                return new AnyAtomicTypeDT(strValue, format);
 119        }
 120
 121        static BaseDT ProduceAnyUri(string? strValue, FormatDescriptor? format)
 122        {
 1123            if (strValue == null)
 1124                return new AnyUriDT();
 1125            if (format == null)
 1126                return new AnyUriDT(strValue);
 127            else
 1128                return new AnyUriDT(strValue, format);
 129        }
 130
 131        static BaseDT ProduceBinary(string? strValue, FormatDescriptor? format)
 132        {
 1133            if (strValue == null)
 1134                return new Base64BinaryDT();
 1135            if (format == null)
 1136                return new Base64BinaryDT(strValue);
 137            else
 0138                return new Base64BinaryDT(strValue, format);
 139        }
 140
 141        static BaseDT ProduceBoolean(string? strValue, FormatDescriptor? format)
 142        {
 1143            if (strValue == null)
 1144                return new BooleanDT();
 1145            if (format == null)
 1146                return new BooleanDT(strValue);
 147            else
 1148                return new BooleanDT(strValue, format);
 149        }
 150
 151        static BaseDT ProduceDate(string? strValue, FormatDescriptor? format)
 152        {
 1153            if (strValue == null)
 1154                return new DateDT();
 1155            if (format is null)
 1156                return new DateDT(strValue, new FormatDescriptor());
 1157            return new DateDT(strValue, format);
 158        }
 159        //
 160        static BaseDT ProduceDateTime(string? strValue, FormatDescriptor? format)
 161        {
 1162            if (strValue == null)
 1163                return new DateTimeDT();
 1164            if (format is null)
 1165                return new DateTimeDT(strValue, new FormatDescriptor());
 1166            return new DateTimeDT(strValue, format);
 167        }
 168
 169        static BaseDT ProduceDateTimeStamp(string? strValue, FormatDescriptor? format)
 170        {
 1171            if (strValue == null)
 1172                return new DateTimeStampDT();
 1173            if (format is null)
 1174                return new DateTimeStampDT(strValue, new FormatDescriptor());
 1175            return new DateTimeStampDT(strValue, format);
 176        }
 177
 178
 179        static BaseDT ProduceDecimal(string? strValue, FormatDescriptor? format)
 180        {
 1181            if (strValue == null)
 1182                return new DecimalDT();
 1183            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1184                return new DecimalDT(strValue);
 185            else
 1186                return new DecimalDT(strValue, format);
 187        }
 188
 189        static BaseDT ProduceInteger(string? strValue, FormatDescriptor? format)
 190        {
 1191            if (strValue == null)
 1192                return new IntegerDT();
 1193            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1194                return new IntegerDT(strValue);
 195            else
 1196                return new IntegerDT(strValue, format);
 197        }
 198
 199        static BaseDT ProduceLong(string? strValue, FormatDescriptor? format)
 200        {
 1201            if (strValue == null)
 1202                return new LongDT();
 1203            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1204                return new LongDT(strValue);
 205            else
 0206                return new LongDT(strValue, format);
 207        }
 208        static BaseDT ProduceInt(string? strValue, FormatDescriptor? format)
 209        {
 1210            if (strValue == null)
 1211                return new IntDT();
 1212            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1213                return new IntDT(strValue);
 214            else
 0215                return new IntDT(strValue, format);
 216        }
 217        static BaseDT ProduceShort(string? strValue, FormatDescriptor? format)
 218        {
 1219            if (strValue == null)
 1220                return new ShortDT();
 1221            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1222                return new ShortDT(strValue);
 223            else
 0224                return new ShortDT(strValue, format);
 225        }
 226        static BaseDT ProduceByte(string? strValue, FormatDescriptor? format)
 227        {
 1228            if (strValue == null)
 1229                return new ByteDT();
 1230            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1231                return new ByteDT(strValue);
 232            else
 0233                return new ByteDT(strValue, format);
 234        }
 235        static BaseDT ProduceNonNegativeInteger(string? strValue, FormatDescriptor? format)
 236        {
 1237            if (strValue == null)
 1238                return new NonNegativeIntegerDT();
 1239            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1240                return new NonNegativeIntegerDT(strValue);
 241            else
 0242                return new NonNegativeIntegerDT(strValue, format);
 243        }
 244        static BaseDT ProducePositiveInteger(string? strValue, FormatDescriptor? format)
 245        {
 1246            if (strValue == null)
 1247                return new DateDT();
 1248            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1249                return new PositiveIntegerDT(strValue);
 250            else
 0251                return new PositiveIntegerDT(strValue, format);
 252        }
 253        static BaseDT ProduceUnsignedLong(string? strValue, FormatDescriptor? format)
 254        {
 1255            if (strValue == null)
 1256                return new UnsignedLongDT();
 1257            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1258                return new UnsignedLongDT(strValue);
 259            else
 0260                return new UnsignedLongDT(strValue, format);
 261        }
 262        static BaseDT ProduceUnsignedInt(string? strValue, FormatDescriptor? format)
 263        {
 1264            if (strValue == null)
 1265                return new UnsignedIntDT();
 1266            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1267                return new UnsignedIntDT(strValue);
 268            else
 0269                return new UnsignedIntDT(strValue, format);
 270        }
 271        static BaseDT ProduceUnsignedShort(string? strValue, FormatDescriptor? format)
 272        {
 1273            if (strValue == null)
 1274                return new UnsignedShortDT();
 1275            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1276                return new UnsignedShortDT(strValue);
 277            else
 0278                return new UnsignedShortDT(strValue, format);
 279        }
 280        static BaseDT ProduceUnsignedByte(string? strValue, FormatDescriptor? format)
 281        {
 1282            if (strValue == null)
 1283                return new UnsignedByteDT();
 1284            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1285                return new UnsignedByteDT(strValue);
 286            else
 0287                return new UnsignedByteDT(strValue, format);
 288        }
 289        static BaseDT ProduceNonPositiveInteger(string? strValue, FormatDescriptor? format)
 290        {
 1291            if (strValue == null)
 1292                return new NonPositiveIntegerDT();
 1293            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1294                return new NonPositiveIntegerDT(strValue);
 295            else
 0296                return new NonPositiveIntegerDT(strValue, format);
 297        }
 298        static BaseDT ProduceNegativeInteger(string? strValue, FormatDescriptor? format)
 299        {
 1300            if (strValue == null)
 1301                return new NegativeIntegerDT();
 1302            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1303                return new NegativeIntegerDT(strValue);
 304            else
 0305                return new NegativeIntegerDT(strValue, format);
 306        }
 307        static BaseDT ProduceDouble(string? strValue, FormatDescriptor? format)
 308        {
 1309            if (strValue == null)
 1310                return new DoubleDT();
 1311            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1312                return new DoubleDT(strValue);
 313            else
 1314                return new DoubleDT(strValue, format);
 315        }
 316        static BaseDT ProduceFloat(string? strValue, FormatDescriptor? format)
 317        {
 1318            if (strValue == null)
 1319                return new FloatDT();
 1320            if (format == null || format.pattern is null && format.decimalChar is null && format.groupChar is null)
 1321                return new FloatDT(strValue);
 322            else
 0323                return new FloatDT(strValue, format);
 324        }
 325
 326        static BaseDT ProduceDuration(string? strValue, FormatDescriptor? format)
 327        {
 1328            if (strValue == null)
 1329                return new DurationDT();
 1330            if (format == null)
 1331                return new DurationDT(strValue);
 332            else
 1333                return new DurationDT(strValue, format);
 334        }
 335
 336
 337        static BaseDT ProduceDayTimeDuration(string? strValue, FormatDescriptor? format)
 338        {
 1339            if (strValue == null)
 1340                return new DayTimeDurationDT();
 1341            if (format == null)
 1342                return new DayTimeDurationDT(strValue);
 343            else
 1344                return new DayTimeDurationDT(strValue, format);
 345        }
 346        static BaseDT ProduceYearMonthDuration(string? strValue, FormatDescriptor? format)
 347        {
 1348            if (strValue == null)
 1349                return new YearMonthDurationDT();
 1350            if (format == null)
 1351                return new YearMonthDurationDT(strValue);
 352            else
 1353                return new YearMonthDurationDT(strValue, format);
 354        }
 355        static BaseDT ProduceGDay(string? strValue, FormatDescriptor? format)
 356        {
 1357            if (strValue == null)
 1358                return new GDayDT();
 1359            if (format == null)
 1360                return new GDayDT(strValue);
 361            else
 0362                return new GDayDT(strValue, format);
 363        }
 364        static BaseDT ProduceGMonth(string? strValue, FormatDescriptor? format)
 365        {
 1366            if (strValue == null)
 1367                return new GMonthDT();
 1368            if (format == null)
 1369                return new GMonthDT(strValue);
 370            else
 0371                return new GMonthDT(strValue, format);
 372        }
 373        static BaseDT ProduceGMonthDay(string? strValue, FormatDescriptor? format)
 374        {
 1375            if (strValue == null)
 1376                return new GMonthDayDT();
 1377            if (format == null)
 1378                return new GMonthDayDT(strValue);
 379            else
 0380                return new GMonthDayDT(strValue, format);
 381        }
 382        static BaseDT ProduceGYear(string? strValue, FormatDescriptor? format)
 383        {
 1384            if (strValue == null)
 1385                return new GYearDT();
 1386            if (format == null)
 1387                return new GYearDT(strValue);
 388            else
 0389                return new GYearDT(strValue, format);
 390        }
 391        static BaseDT ProduceGYearMonth(string? strValue, FormatDescriptor? format)
 392        {
 1393            if (strValue == null)
 1394                return new GYearMonthDT();
 1395            if (format == null)
 1396                return new GYearMonthDT(strValue);
 397            else
 0398                return new GYearMonthDT(strValue, format);
 399        }
 400        static BaseDT ProduceHexBinary(string? strValue, FormatDescriptor? format)
 401        {
 1402            if (strValue == null)
 1403                return new HexBinaryDT();
 1404            if (format == null)
 1405                return new HexBinaryDT(strValue);
 406            else
 0407                return new HexBinaryDT(strValue, format);
 408        }
 409        static BaseDT ProduceQName(string? strValue, FormatDescriptor? format)
 410        {
 1411            if (strValue == null)
 0412                return new QNameDT();
 1413            if (format == null)
 1414                return new QNameDT(strValue);
 415            else
 0416                return new QNameDT(strValue, format);
 417        }
 418        static BaseDT ProduceString(string? strValue, FormatDescriptor? format)
 419        {
 1420            if (strValue == null)
 1421                return new StringDT();
 1422            if (format == null)
 1423                return new StringDT(strValue);
 424            else
 1425                return new StringDT(strValue, format);
 426
 427        }
 428        static BaseDT ProduceNormalizedString(string? strValue, FormatDescriptor? format)
 429        {
 1430            if (strValue == null)
 1431                return new NormalizedStringDT();
 1432            if (format == null)
 1433                return new NormalizedStringDT(strValue);
 434            else
 1435                return new NormalizedStringDT(strValue, format);
 436        }
 437        static BaseDT ProduceToken(string? strValue, FormatDescriptor? format)
 438        {
 1439            if (strValue == null)
 0440                return new TokenDT();
 1441            if (format == null)
 1442                return new TokenDT(strValue);
 443            else
 0444                return new TokenDT(strValue, format);
 445        }
 446        static BaseDT ProduceLanguage(string? strValue, FormatDescriptor? format)
 447        {
 1448            if (strValue == null)
 0449                return new LanguageDT();
 1450            if (format == null)
 1451                return new LanguageDT(strValue);
 452            else
 0453                return new LanguageDT(strValue, format);
 454        }
 455        static BaseDT ProduceName(string? strValue, FormatDescriptor? format)
 456        {
 1457            if (strValue == null)
 0458                return new NameDT();
 1459            if (format == null)
 1460                return new NameDT(strValue);
 461            else
 0462                return new NameDT(strValue, format);
 463        }
 464        static BaseDT ProduceNMTOKEN(string? strValue, FormatDescriptor? format)
 465        {
 1466            if (strValue == null)
 1467                return new NMTOKENDT();
 1468            if (format == null)
 1469                return new NMTOKENDT(strValue);
 470            else
 1471                return new NMTOKENDT(strValue, format);
 472        }
 473        static BaseDT ProduceXml(string? strValue, FormatDescriptor? format)
 474        {
 1475            if (strValue == null)
 1476                return new XmlDT();
 1477            if (format == null)
 1478                return new XmlDT(strValue);
 479            else
 0480                return new XmlDT(strValue, format);
 481        }
 482        static BaseDT ProduceHtml(string? strValue, FormatDescriptor? format)
 483        {
 0484            if (strValue == null)
 0485                return new HtmlDT();
 0486            if (format == null)
 0487                return new HtmlDT(strValue);
 488            else
 0489                return new HtmlDT(strValue, format);
 490        }
 491        static BaseDT ProduceJson(string? strValue, FormatDescriptor? format)
 492        {
 0493            if (strValue == null)
 0494                return new JsonDT();
 0495            if (format == null)
 0496                return new JsonDT(strValue);
 497            else
 0498                return new JsonDT(strValue, format);
 499        }
 500        static BaseDT ProduceTime(string? strValue, FormatDescriptor? format)
 501        {
 1502            if (strValue == null)
 1503                return new TimeDT();
 1504            if (format == null)
 1505                return new TimeDT(strValue);
 506            else
 1507                return new TimeDT(strValue, format);
 508        }
 509
 510    }
 511}

Methods/Properties

GetDatatype(string, string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceAny(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceAnyUri(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceBinary(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceBoolean(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDate(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDateTime(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDateTimeStamp(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDecimal(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceInteger(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceLong(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceInt(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceShort(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceByte(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceNonNegativeInteger(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProducePositiveInteger(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceUnsignedLong(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceUnsignedInt(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceUnsignedShort(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceUnsignedByte(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceNonPositiveInteger(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceNegativeInteger(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDouble(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceFloat(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDuration(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceDayTimeDuration(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceYearMonthDuration(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceGDay(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceGMonth(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceGMonthDay(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceGYear(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceGYearMonth(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceHexBinary(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceQName(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceString(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceNormalizedString(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceToken(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceLanguage(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceName(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceNMTOKEN(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceXml(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceHtml(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceJson(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)
ProduceTime(string, ValidateLib.Metadata.Descriptors.FormatDescriptor)