Transformation and matching scheme of XmlAttribute and entity in C #

Source: Internet
Author: User
Tags reflection

First, the preface

Extensible Markup Language (XML) is a structured markup language that can be used to mark data, define data types, and is a source language that allows users to define their own markup language. XML is used to store data, and the data itself is the most important. The code in this article was sorted out a few months ago and rarely written in the last few months, in addition to work, mostly busy organizing their own framework. This essay is mainly aimed at the matching and conversion between attribute attribute and entity of XML, including reflection, XML and Linqtoxml, the content of the code is to write what it is thought of, it is purely the practice feeling, for reference only. The next essay will be in another form to transform the XML object entity, of course, is mainly reflected, and the idea of this essay is similar, mainly XML format and solution is different. For how to convert an object to XML, the main thing is to look at the situation, and simply convert the simple object, direct reflection can be generated. For complex objects, XML can be customized using dynamic, tree-structured, and recursive algorithm schemes.

Second, class diagram design

The main idea of the service is that it matches the node of the class name (class attribute name or class name) by reflection, and then matches the value of the attribute (property attribute name or attribute name). Conversely, the properties of the entity object are traversed and the corresponding XML is set. Originally wanted to refine the matching and conversion operations, but the class of EA files do not know where to put, only the design of the screenshot is still in the XO. The related class diagram is designed as follows:

PropertyAttribute the attribute name of the primary set property, which is used to convert the process to set the alias of the property, matching the attributes of the XML and the name of the attribute in the process.

ClassAttribute the attribute name of the main set class, which is used to convert the alias of the class to the process, matching the node and the name of the class that match the XML.

Stringextension is primarily a method of extending strings.

Funcdictionary the primary conversion string to a specific type of value.

The Xmlattributeutility main transformation entity object is XML and matches XML as an entity object, which also includes some other basic operations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.