Module: AssOle::Snippets::Shared::XMLSerializer
- Defined in:
- lib/ass_ole/snippets/shared.rb
Overview
Note:
In external runtime it will be cause of a fail in InfoBase#rm! ‘… /1Cv8.1CD (Errno::EBUSY)’ because external connection realy keep alive
Snippet for serialize and deserilize 1C objects to xml
Instance Method Summary collapse
-
#from_xml(xml) ⇒ WIN32OLE
Deserialize 1C object from XML srtring.
-
#from_xml_file(xml_file) ⇒ WIN32OLE
Deserialize 1C object from XML file.
-
#to_xml(obj) ⇒ String
Serialize 1C oject to XML string.
-
#to_xml_file(obj, xml_file) ⇒ Object
Serialize 1C oject to XML file.
Instance Method Details
#from_xml(xml) ⇒ WIN32OLE
Deserialize 1C object from XML srtring
42 43 44 45 46 |
# File 'lib/ass_ole/snippets/shared.rb', line 42 def from_xml(xml) zxml = newObject 'XMLReader' zxml.SetString xml xDTOSerializer.ReadXml zxml end |
#from_xml_file(xml_file) ⇒ WIN32OLE
Deserialize 1C object from XML file
51 52 53 54 55 56 57 58 59 |
# File 'lib/ass_ole/snippets/shared.rb', line 51 def from_xml_file(xml_file) zxml = newObject 'XMLReader' path_ = xml_file.respond_to?(:path) ? xml_file.path : xml_file zxml.openFile(real_win_path(path_)) obj = xDTOSerializer.ReadXml zxml obj ensure zxml.close end |
#to_xml(obj) ⇒ String
Serialize 1C oject to XML string
18 19 20 21 22 23 |
# File 'lib/ass_ole/snippets/shared.rb', line 18 def to_xml(obj) zxml = newObject 'XMLWriter' zxml.SetString xDTOSerializer.WriteXML zxml, obj zxml.close end |
#to_xml_file(obj, xml_file) ⇒ Object
Serialize 1C oject to XML file
29 30 31 32 33 34 35 36 37 |
# File 'lib/ass_ole/snippets/shared.rb', line 29 def to_xml_file(obj, xml_file) zxml = newObject 'XMLWriter' path_ = xml_file.respond_to?(:path) ? xml_file.path : xml_file zxml.openFile(real_win_path(path_)) xDTOSerializer.WriteXML zxml, obj xml_file ensure zxml.close end |