bubdm / dynamicstruct Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jasonbrice/dynamicstruct
Simple class library that creates an in-memory struct from XML
This project forked from jasonbrice/dynamicstruct
Simple class library that creates an in-memory struct from XML
This project contains two MS VS2010 Solutions: a simple class library that uses reflection to create a struct from an XML file, and a simple WinForms app that uses the library to create the struct in memory and tells you if it worked (or not). For example, you have a struct in which you won't know the field names or data types until runtime. But let's say that at runtime, you want a struct that look like this: using System; using System.Runtime.InteropServices; namespace MyGreatProject { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct MyCoolStruct { public System.Double Latitude; public System.Double Longitude; public System.Int32 Altitude; } } The code supplied will create that struct for you in memory, assuming it finds an XML file like this: <?xml version="1.0" encoding="utf-8"?> <StructFieldCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <DataSet> <StructField> <Name>Latitude</Name> <DataType>System.Double</DataType> </StructField> <StructField> <Name>Longitude</Name> <DataType>System.Double</DataType> </StructField> <StructField> <Name>Altitude</Name> <DataType>System.Int32</DataType> </StructField> </DataSet> </StructFieldCollection> What could you use this for? Hmm... I use it for a vendor-specific API that requires a struct defining each of the (possibly hundreds) of variables you want to read to/write from their system. Keeping this straight and trying to quickly test the addition/removal of a field or two got unmanageable. But you could pass Windows messages (WM_COPYDATA / Marshal.PtrToStructure...) from one app to another without having to compile each app every time you changed the structure of the data in the message. (Of course you could do this also with UDP packets sent to/from localhost, or a message bus, or a shared database, or possibly even smoke signals. But that's for another project...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.