/// <summary>Get a part by part type name.</summary> /// <remarks>Get a part by part type name.</remarks> /// <param name="type">- the message part type name</param> /// <returns>- the message part</returns> public virtual MessagePart GetMessagePart(string type) { MessagePart messagePart = null; if (type != null) { string packageLocationName = type.Contains(".") ? StringUtils.SubstringBefore(type, ".") : type; PackageLocation location = PackageLocations.SafeGet(packageLocationName); if (location == null) { messagePart = null; } else { if (type.Contains(".")) { messagePart = location.MessageParts.SafeGet(type); } else { if (StringUtils.IsNotBlank(location.RootType)) { messagePart = location.MessageParts.SafeGet(location.RootType); } } } } return(messagePart); }
/// <summary>Add a message part.</summary> /// <remarks>Add a message part.</remarks> /// <param name="part">- the message part to add</param> public virtual void AddMessagePart(MessagePart part) { TypeName name = new TypeName(part.Name); string packageName = name.RootName.Name; PackageLocation location = this.packageLocations.SafeGet(packageName); if (location == null) { throw new ArgumentException("No package location exists: " + packageName); } else { location.MessageParts[part.Name] = part; } }
/// <summary>Get a template parameter part by name, relative to a referring part.</summary> /// <remarks>Get a template parameter part by name, relative to a referring part. It is assumed that the parameter part will be in the same package location /// </remarks> /// <param name="basePart">the message part referring to the template parameter</param> /// <param name="templateParameterName">the unqualified name of the template parameter</param> /// <returns>the message part defining the template parameter</returns> public virtual MessagePart ResolveTemplateParameter(MessagePart basePart, string templateParameterName) { MessagePart messagePart = null; if (basePart != null) { string packageLocationName = StringUtils.SubstringBefore(basePart.Name, "."); PackageLocation location = PackageLocations.SafeGet(packageLocationName); if (location != null && StringUtils.IsNotBlank(templateParameterName)) { messagePart = location.MessageParts.SafeGet(packageLocationName + "." + templateParameterName); } } return(messagePart); }
/// <summary>Add a new package location to the MessageSet</summary> /// <param name="packageLocation">the package location</param> public virtual void AddPackageLocation(PackageLocation packageLocation) { this.packageLocations[packageLocation.Name] = packageLocation; }