Base sessioned 1C object
Inheritance: BaseObject
Ejemplo n.º 1
0
 private void CheckSession(BaseSessionObject sessionObject)
 {
     if (sessionObject.Session != this)
     {
         throw new Exception("Property 'Session' must be equal current session");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Load objects cache
        /// </summary>
        /// <param name="sessionObjects"></param>
        public void LoadObjectsCache(IEnumerable <BaseSessionObject> sessionObjects)
        {
            var enmrtr = sessionObjects.GetEnumerator();

            XMLWriter xmlWriter = null;
            List <BaseSessionObject> xmlLoadedObjects = null;


            while (enmrtr.MoveNext())
            {
                var sessionObject = enmrtr.Current;

                CheckSession(sessionObject);

                if (sessionObject is IV8XmlSerializable)
                {
                    if (xmlWriter == null)
                    {
                        xmlWriter = new XMLWriter(this);
                        xmlWriter.SetString();
                        xmlLoadedObjects = new List <BaseSessionObject>();
                    }

                    WriteXML(xmlWriter, sessionObject);
                    xmlLoadedObjects.Add(sessionObject);
                }
                else if (sessionObject is IV8Serializable)
                {
                    string str = ValueToStringInternal(sessionObject.Ptr);
                    (sessionObject as IV8Serializable).LoadFromV8String(str);
                }
            }

            if (xmlWriter != null)
            {
                string xml = xmlWriter.Close();

                XmlDocument doc  = new XmlDocument();
                var         root = doc.CreateElement("root");
                root.InnerXml = xml;

                int objectId = 0;
                foreach (var node in root.ChildNodes)
                {
                    if (!(node is XmlElement))
                    {
                        continue;
                    }

                    XmlElement        objectTag = (XmlElement)node;
                    BaseSessionObject v8Object  = xmlLoadedObjects[objectId++];

                    (v8Object as IV8XmlSerializable).LoadFromV8Xml(objectTag);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load object cache
        /// </summary>
        public void LoadObjectCache(BaseSessionObject sessionObject)
        {
            CheckSession(sessionObject);

            if (sessionObject is IV8XmlSerializable)
            {
                XmlDocument doc  = new XmlDocument();
                var         root = doc.CreateElement("root");
                root.InnerXml = ToXML(this);

                (sessionObject as IV8XmlSerializable).LoadFromV8Xml(root.FirstChild);
            }
            else if (sessionObject is IV8Serializable)
            {
                string str = ValueToStringInternal(sessionObject.Ptr);
                (sessionObject as IV8Serializable).LoadFromV8String(str);
            }
        }
Ejemplo n.º 4
0
 private void CheckSession(BaseSessionObject sessionObject)
 {
     if (sessionObject.Session != this)
     {
         throw new Exception("Property 'Session' must be equal current session");
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Load object cache
        /// </summary>
        public void LoadObjectCache(BaseSessionObject sessionObject)
        {
            CheckSession(sessionObject);

            if (sessionObject is IV8XmlSerializable)
            {
                XmlDocument doc = new XmlDocument();
                var root = doc.CreateElement("root");
                root.InnerXml = ToXML(this);

                (sessionObject as IV8XmlSerializable).LoadFromV8Xml(root.FirstChild);
            }
            else if (sessionObject is IV8Serializable)
            {
                string str = ValueToStringInternal(sessionObject.Ptr);
                (sessionObject as IV8Serializable).LoadFromV8String(str);
            }
        }