internal void ResolveUnknowns() { if (m_hasUnknowns) { List <ExpressionElement> temp = m_elements; m_elements = new List <ExpressionElement>(); foreach (ExpressionElement ee in temp) { if (ee is UnknownReferenceElement) { Guid guid = ee.Guid; if (m_participantDirectory.Contains(guid)) { m_elements.Add(m_participantDirectory[guid]); } else { IPfcTransitionNode trans = m_owner as IPfcTransitionNode; string msg; if (trans != null) { msg = string.Format("Failed to map Guid {0} into an object on behalf of {1} in Pfc {2}.", guid, trans.Name, trans.Parent.Name); } else { msg = string.Format("Failed to map Guid {0} into an object on behalf of {1}.", guid, m_owner); } throw new ApplicationException(msg); } } else { m_elements.Add(ee); } } m_hasUnknowns = false; } }
/// <summary> /// Creates an Expression from a user-hostile representation of the expression. In that representation, /// we have guids and we have rote strings. /// </summary> /// <param name="uh">The user-hostile representation of the expression.</param> /// <param name="directory">The directory from which the Expression Elements that are referenced here by guid, come.</param> /// <param name="owner">The owner of the expression - usually, the Transition to which it is attached.</param> /// <returns>The newly-created expression.</returns> public static Expression FromUh(string uh, ParticipantDirectory directory, object owner) { Expression expression = new Expression(owner); expression.m_participantDirectory = directory; int cursor = 0; foreach (Match match in _guidFinder.Matches(uh)) { if (match.Index != cursor) { expression.m_elements.Add(new RoteString(uh.Substring(cursor, (match.Index - cursor)))); cursor = match.Index; } Guid guid = new Guid(match.Value); cursor += match.Value.Length; if (directory.Contains(guid)) { expression.m_elements.Add(directory[guid]); } else { expression.m_elements.Add(new UnknownReferenceElement(guid)); expression.m_hasUnknowns = true; } } if (cursor != uh.Length) { expression.m_elements.Add(new RoteString(uh.Substring(cursor))); } return(expression); }