示例#1
0
        public CatalogueElementName(CatalogueName catalogueName, System.Enum element, string name)
        {
            const string method = ".ctor";

            // Check catalogue name.

            if (catalogueName == null)
            {
                throw new NullParameterException(typeof(CatalogueElementName), method, "catalogueName");
            }

            // Check element.

            if (!NameRegex.IsMatch(element.ToString()))
            {
                throw new InvalidParameterFormatException(typeof(CatalogueElementName), method, "element", element.ToString(), Constants.Validation.CompleteNamePattern);
            }

            // Check name.

            if (name == null)
            {
                throw new NullParameterException(typeof(CatalogueElementName), method, "name");
            }
            if (!NameRegex.IsMatch(name))
            {
                throw new InvalidParameterFormatException(typeof(CatalogueElementName), method, "name", name, Constants.Validation.CompleteNamePattern);
            }

            // Assign.

            m_catalogueName = catalogueName.Clone();
            m_element       = element.ToString();
            m_name          = name;
        }
示例#2
0
        public CatalogueElementName(string reference)
        {
            const string method = ".ctor";

            // Use a capturing regex to extract the name, namespace and version.

            Match match = CapturingElementReferenceRegex.Match(reference);

            if (!match.Success)
            {
                throw new InvalidParameterFormatException(typeof(CatalogueElementName), method, "reference", reference, Constants.Validation.CompleteElementReferencePattern);
            }

            m_catalogueName = CatalogueName.CreateUnchecked(match.Groups["CatalogueName"].Value);
            m_element       = match.Groups["Element"].Value;
            m_name          = match.Groups["Name"].Value;
        }
示例#3
0
        public static string ToXsiType(CatalogueName catalogueName)
        {
            const string method = "ToXsiType";

            if (catalogueName == null)
            {
                throw new NullParameterException(typeof(CatalogueName), method, "catalogueName");
            }

            string xsiType = catalogueName.FullName;

            if (catalogueName.Version != null)
            {
                xsiType += "-" + catalogueName.Version;
            }
            return(xsiType);
        }
示例#4
0
        public int CompareTo(CatalogueName other)
        {
            int result = _namespace.CompareTo(other._namespace);

            if (result != 0)
            {
                return(result);
            }
            result = _name.CompareTo(other._name);
            if (result != 0)
            {
                return(result);
            }
            if (_version == null)
            {
                return(other._version == null ? 0 : -1);
            }
            return(other._version == null ? 1 : _version.CompareTo(other._version));
        }
示例#5
0
 /// <summary>
 /// Private constructor for cloning - performs no checks.
 /// </summary>
 private CatalogueElementName(string name, string element, CatalogueName catalogueName)
 {
     m_name          = name;
     m_element       = element;
     m_catalogueName = catalogueName.Clone();
 }
示例#6
0
 private static string GetReferenceUnchecked(CatalogueName catalogueName, string element, string name)
 {
     return(element + "=" + name + ", " + catalogueName.FullyQualifiedReference);
 }