/// <summary>
        /// Convert an ASM version string into a <see cref="SchemaVersion" />
        /// </summary>
        /// <param name="version"></param>
        /// <returns></returns>
        public static SchemaVersion ToSchemaVersion(this string version)
        {
            if (string.IsNullOrEmpty(version))
            {
                return null;
            }

            var parts = version.Split('.');
            var schemaVersion = new SchemaVersion();
            switch (parts.GetUpperBound(0))
            {
                case 0:
                    schemaVersion.Schema = null;
                    schemaVersion.Version = parts[0].ToVersion();
                    break;

                case 1:
                    schemaVersion.Schema = parts[0];
                    schemaVersion.Version = parts[1].ToVersion();
                    break;

                default:
                    throw new MappingException("Cannot parse schema version: " + version);
            }

            return schemaVersion;
        }
예제 #2
0
        /// <summary>
        /// Convert an ASM version string into a <see cref="SchemaVersion" />
        /// </summary>
        /// <param name="version"></param>
        /// <returns></returns>
        public static SchemaVersion ToSchemaVersion(this string version)
        {
            if (string.IsNullOrEmpty(version))
            {
                return(null);
            }

            var parts         = version.Split('.');
            var schemaVersion = new SchemaVersion();

            switch (parts.GetUpperBound(0))
            {
            case 0:
                schemaVersion.Schema  = null;
                schemaVersion.Version = parts[0].ToVersion();
                break;

            case 1:
                schemaVersion.Schema  = parts[0];
                schemaVersion.Version = parts[1].ToVersion();
                break;

            default:
                throw new MappingException("Cannot parse schema version: " + version);
            }

            return(schemaVersion);
        }
 public void FromSSchemaVersionTochemaMajor()
 {
     string expected = "Cts.V2";
     var value = new SchemaVersion { Schema = "Cts", Version = new Version(2, 0) };
     var candidate = value.ToString();
     this.Check(expected, candidate);
 }
 public void FromSchemaMajorMinorToSchemaVersion()
 {
     string value = "Cts.V2_1";
     var expected = new SchemaVersion { Schema = "Cts", Version = new Version(2, 1) };
     var candidate = value.ToSchemaVersion();
     this.Check(expected, candidate);
 }
 public void FromMajorToSchemaVersion()
 {
     string value = "V2";
     var expected = new SchemaVersion { Version = new Version(2, 0) };
     var candidate = value.ToSchemaVersion();
     this.Check(expected, candidate);
 }
예제 #6
0
 /// <summary>
 /// Convert a version to a schema qualified version string.
 /// </summary>
 /// <param name="version">Version to use.</param>
 public static string ToAsmVersion(this SchemaVersion version)
 {
     return(version == null ? null : version.Version.ToAsmVersion(version.Schema));
 }