Exemplo n.º 1
0
        /// <summary>
        /// Returns the full qualified name of the unit.
        /// </summary>
        /// <returns>Full qualified unit name</returns>
        public string ToQualifiedString()
        {
            string encodedApplicationName = UnitNameEncoder.Encode(ApplicationFragment);
            string encodedVersion         = UnitVersionEncoder.Encode(VersionFragment);
            string encodedUseCaseName     = UnitNameEncoder.Encode(UseCaseFragment);
            string encodedScenarioName    = UnitNameEncoder.Encode(ScenarioFragment);
            string fullName = string.Format("{0}{4}{1}{4}{2}{4}{3}",
                                            encodedApplicationName, encodedVersion, encodedUseCaseName, encodedScenarioName, Separator);

            return(fullName);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance based on the given full qualified unit name. If the given <paramref name="fullQualifiedUnitName"/> is NULL or empty,
        /// a <see cref="ArgumentNullException"/> is thrown. Additionally, an <see cref="UnitNameFormatException"/> is thrown when the value
        /// does not match the unit name format.
        /// </summary>
        /// <param name="fullQualifiedUnitName">Full qualified unit name</param>
        /// <exception cref="ArgumentNullException">If <paramref name="fullQualifiedUnitName"/> is NULL or empty</exception>
        /// <exception cref="UnitNameFormatException">If the unit name format is invalid</exception>
        public UnitName(string fullQualifiedUnitName)
        {
            string[] nameFragments = Assert.NotNullOrEmpty(() => fullQualifiedUnitName).Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
            if (nameFragments.Length != 4)
            {
                throw new UnitNameFormatException(string.Format("Unit name '{0}' does not match the unit name format", fullQualifiedUnitName));
            }
            if (!UnitNameEncoder.IsEncoded(nameFragments[0]))
            {
                throw new UnitNameFormatException(String.Format("Unit name '{0}' does not match the unit name format", fullQualifiedUnitName));
            }
            if (!UnitVersionEncoder.IsEncoded(nameFragments[1]))
            {
                throw new UnitNameFormatException(String.Format("Unit name '{0}' does not match the unit name format", fullQualifiedUnitName));
            }

            ApplicationFragment = UnitNameEncoder.Decode(nameFragments[0]);
            VersionFragment     = UnitVersionEncoder.Decode(nameFragments[1]);
            UseCaseFragment     = UnitNameEncoder.Decode(nameFragments[2]);
            ScenarioFragment    = UnitNameEncoder.Decode(nameFragments[3]);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Returns the encoded form of the <see cref="ScenarioFragment"/>.
 /// </summary>
 /// <returns>Encoded form of the <see cref="ScenarioFragment"/></returns>
 public string GetEncodedScenarioName()
 {
     return(UnitNameEncoder.Encode(ScenarioFragment));
 }