|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XMLIgnore Atributehttp://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.csharp&tid=129eaabb-a6d2-4fc4-8ebc-85878d2303b4&cat=en-us-msdn-visualtools-vcsharp&lang=en&cr=US&sloc=en-us&m=1&p=1 Well, I never did get the built-in XML Serialization method working so I wrote my own. I use Reflection to work its way through my complex object and "manually" write out what I need to do. It works great. I'm now expanding my XML Save method to write out a bunch of system-type properties. But some of them I don't actually want to write out. So I stuck the [XMLIgnore] attribute before those I want to ignore. But I can't figure out what to look for in the Reflection code to spot those properties that are so labelled. Does anyone know precisely what field(s) this attribute changes within a Property structure? Robert,
You will want to call the GetCustomAttributes method on the PropertyInfo representing the property. You can pass typeof(XMLIgnore) to the method, and it will return the attribute if it exists on the property. Hope this helps. -- Show quoteHide quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Robert W." <Robe***@discussions.microsoft.com> wrote in message news:85EFDEBD-BC94-47C9-B39C-888AEE4D03F6@microsoft.com... >A while back I posted this: > http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.csharp&tid=129eaabb-a6d2-4fc4-8ebc-85878d2303b4&cat=en-us-msdn-visualtools-vcsharp&lang=en&cr=US&sloc=en-us&m=1&p=1 > > Well, I never did get the built-in XML Serialization method working so I > wrote my own. I use Reflection to work its way through my complex object > and "manually" write out what I need to do. It works great. > > I'm now expanding my XML Save method to write out a bunch of system-type > properties. But some of them I don't actually want to write out. So I > stuck > the [XMLIgnore] attribute before those I want to ignore. But I can't > figure > out what to look for in the Reflection code to spot those properties that > are > so labelled. > > Does anyone know precisely what field(s) this attribute changes within a > Property structure? > > -- > Robert W. > Vancouver, BC > www.mwtech.com > Nicholas,
Thank you, thank you, thank you!!! A few lines of code and IT WORKS!!! I struggled with this for HOURS!!!! I still don't understand why I wasn't able to "see" the presence of the XMLIgnore attribute when I used QuickWatch during Reflection. I clearly was looking at the PropertyInfo object but could not see any difference between those properties I had so marked and those with no attributes. The mysteries of dotNet!!!! Once again, thank you! You just made the sun rise in my day! Show quoteHide quote "Nicholas Paldino [.NET/C# MVP]" wrote: > Robert, > > You will want to call the GetCustomAttributes method on the PropertyInfo > representing the property. You can pass typeof(XMLIgnore) to the method, > and it will return the attribute if it exists on the property. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > "Robert W." <Robe***@discussions.microsoft.com> wrote in message > news:85EFDEBD-BC94-47C9-B39C-888AEE4D03F6@microsoft.com... > >A while back I posted this: > > http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.csharp&tid=129eaabb-a6d2-4fc4-8ebc-85878d2303b4&cat=en-us-msdn-visualtools-vcsharp〈=en&cr=US&sloc=en-us&m=1&p=1 > > > > Well, I never did get the built-in XML Serialization method working so I > > wrote my own. I use Reflection to work its way through my complex object > > and "manually" write out what I need to do. It works great. > > > > I'm now expanding my XML Save method to write out a bunch of system-type > > properties. But some of them I don't actually want to write out. So I > > stuck > > the [XMLIgnore] attribute before those I want to ignore. But I can't > > figure > > out what to look for in the Reflection code to spot those properties that > > are > > so labelled. > > > > Does anyone know precisely what field(s) this attribute changes within a > > Property structure? > > > > -- > > Robert W. > > Vancouver, BC > > www.mwtech.com > > > > >
Other interesting topics
|
|||||||||||||||||||||||