コード例 #1
0
        public SerializableObjectList EnsureSerializableObjectList(Type contentType, string sObjectListName)
        {
            SerializableObjectList lObjects = null;

            if (this.ContainsKey(sObjectListName))
            {
                lObjects = this[sObjectListName];
            }
            else
            {
                lObjects = new SerializableObjectList(contentType, sObjectListName);
                base.Add(sObjectListName, lObjects);
            }

            return(lObjects);
        }
コード例 #2
0
        private void BuildTraceString <T>(DelegateFormatString dfs)
        {
            string sObjectListName          = LineContainer.ContentTypeToObjectListName(typeof(T));
            SerializableObjectList lObjects = m_di.SafelyGetValue(sObjectListName);

            if (lObjects != null && lObjects.Count > 0)
            {
                List <string> l = new List <string>();

                foreach (ISerializableObject so in lObjects)
                {
                    string sData = dfs(so);
                    l.Add(sData);
                }

                m_sTrace += string.Format("{0} (Count={1}): {2}\r\n", sObjectListName, l.Count, string.Join(", ", l.ToArray()));
            }
        }
コード例 #3
0
        public void FromXml(XmlTextReader tr)
        {
            CheckTime ct = new CheckTime(false, "LineContainer.FromXml() entered.");

            try
            {
                while (tr.Read())
                {
                    string sCurrentTagName = tr.Name;

                    switch (tr.NodeType)
                    {
                    case XmlNodeType.Attribute:

                        break;

                    case XmlNodeType.Element:

                        while (tr.MoveToNextAttribute())
                        {
                            this.Attributes[tr.Name] = tr.Value;
                        }

                        if (sCurrentTagName == this.XmlTagName)
                        {
                            break;
                        }

                        if (!tr.IsEmptyElement)
                        {
                            try
                            {
                                Type contentType = ObjectListNameToContentType(sCurrentTagName);
                                SerializableObjectList lObjects = m_di.EnsureSerializableObjectList(contentType, sCurrentTagName);
                                lObjects.FromXml(tr);
                                ct.AddEvent("{0} completed", sCurrentTagName);
                            }
                            catch (Exception excp)
                            {
                                throw;
                            }
                        }

                        break;

                    case XmlNodeType.EndElement:

                        if (tr.Name == this.XmlTagName)
                        {
                            return;
                        }

                        break;
                    }
                }
            }
            finally
            {
                ct.AddEvent("LineContainer.FromXml() completed.");
                ct.Info(m_logger);
            }
        }