public bool StreamXmlForTypeName(KSoft.IO.XmlElementStream s, FA mode, string xmlName, ref int dbid, Engine.DatabaseTypeKind kind, bool isOptional = true, XmlNodeType xmlSource = Util.kSourceElement) { Contract.Requires(KSoft.IO.XmlElementStream.StreamSourceIsValid(xmlSource)); Contract.Requires(KSoft.IO.XmlElementStream.StreamSourceRequiresName(xmlSource) == (xmlName != null)); string id_name = null; bool was_streamed = true; bool to_lower = false; if (mode == FA.Read) { if (isOptional) { was_streamed = Util.StreamInternStringOpt(s, mode, xmlName, ref id_name, to_lower, xmlSource); } else { Util.StreamInternString(s, mode, xmlName, ref id_name, to_lower, xmlSource); } if (was_streamed) { dbid = Database.GetId(kind, id_name); Contract.Assert(dbid != PhxUtil.kInvalidInt32); if (PhxUtil.IsUndefinedReferenceHandle(dbid)) { TraceUndefinedHandle(s, id_name, dbid, kind.ToString()); } } else { dbid = PhxUtil.kInvalidInt32; } } else if (mode == FA.Write && dbid != PhxUtil.kInvalidInt32) { id_name = Database.GetName(kind, dbid); Contract.Assert(!string.IsNullOrEmpty(id_name)); if (isOptional) { Util.StreamInternStringOpt(s, mode, xmlName, ref id_name, to_lower, xmlSource); } else { Util.StreamInternString(s, mode, xmlName, ref id_name, to_lower, xmlSource); } } return(was_streamed); }
static void TraceUndefinedHandle(KSoft.IO.XmlElementStream s, string name, int id, string kind) { Debug.Trace.XML.TraceEvent(System.Diagnostics.TraceEventType.Warning, -1, "Generated UndefinedHandle in '{0}' for '{1}' ({2}). {3}={4}", s.StreamName, s.Cursor.Name, kind, name, PhxUtil.GetUndefinedReferenceDataIndex(id).ToString()); }