By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,307 Members | 2,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,307 IT Pros & Developers. It's quick & easy.

IAddChild and XAML serialization process ?

P: n/a
Hello

I try to use xaml serializer framework to save in .xaml file my own
hierarchical graph of object.
The first step is done : I create my own file with something like this :
<Root
xmlns="clr-namespace:myNameSpace;assembly=MyAssembly">
<Structure ...>
<SimpleText ... />
</Structure>
</Root>
with a simple call like this :
outStream = new System.IO.FileStream(@"c:\temp\essai.xaml",
System.IO.FileMode.Create);
using (outStream)
{
System.Windows.Markup.XamlWriter.Save(rootInstance ,
outStream);
}
BUT when I want to reverse the process (Create a RootInstance from xaml
file) with a call like this :
System.IO.FileStream inStream = new
System.IO.FileStream(@"c:\temp\essai.xaml",
System.IO.FileMode.Open);
using (inStream)
{
return
(Root)System.Windows.Markup.XamlReader.Load(inStre am);
}
Root is created
Structure is created
SimpleText is created
BUT i have after this, an exception like "SimpleText can be added in
Structure" occurs !!
Structure and Root derive from Container class witch supports IEnumerable
and IAddChild interface !!
I don't know what I forgot somewhere ????
could you help me
thanks a lot for your help !

Dec 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
After some research (with Reflector)

It's seems we can not use IAddChild interface in our own classes ???!

an internal method of the framework
(System.Windows.Markup.BamlRecordManager.TreatAsIA ddChild) use this records
:

KnownTypes.Types[0x113].and 0x113 ref a IAddChildInternal, internal
interface witch derivates from public IAddChild interface !!

and so, TradAsIAddChild return false in

System.Windows.Markup.BamlRecordReader.GetFlagsFro mType(Type elementType)

May be some one from Xaml developper team can help me !!!

thanks a lot for your help !
"azerty" <az****@aaaa.fra écrit dans le message de news:
eP****************@TK2MSFTNGP04.phx.gbl...
Hello

I try to use xaml serializer framework to save in .xaml file my own
hierarchical graph of object.
The first step is done : I create my own file with something like this :
<Root
xmlns="clr-namespace:myNameSpace;assembly=MyAssembly">
<Structure ...>
<SimpleText ... />
</Structure>
</Root>
with a simple call like this :
outStream = new System.IO.FileStream(@"c:\temp\essai.xaml",
System.IO.FileMode.Create);
using (outStream)
{
System.Windows.Markup.XamlWriter.Save(rootInstance ,
outStream);
}
BUT when I want to reverse the process (Create a RootInstance from xaml
file) with a call like this :
System.IO.FileStream inStream = new
System.IO.FileStream(@"c:\temp\essai.xaml",
System.IO.FileMode.Open);
using (inStream)
{
return
(Root)System.Windows.Markup.XamlReader.Load(inStre am);
}
Root is created
Structure is created
SimpleText is created
BUT i have after this, an exception like "SimpleText can be added in
Structure" occurs !!
Structure and Root derive from Container class witch supports IEnumerable
and IAddChild interface !!
I don't know what I forgot somewhere ????
could you help me
thanks a lot for your help !

Dec 6 '06 #2

P: n/a
news :

BUT if Structure or Root supports IList ! all work fine !!!!
>a question have no answers : how can I use IAddChild interface ???
"azerty" <az****@aaaa.fra écrit dans le message de news:
eP**************@TK2MSFTNGP03.phx.gbl...
After some research (with Reflector)

It's seems we can not use IAddChild interface in our own classes ???!

an internal method of the framework
(System.Windows.Markup.BamlRecordManager.TreatAsIA ddChild) use this
records :

KnownTypes.Types[0x113].and 0x113 ref a IAddChildInternal, internal
interface witch derivates from public IAddChild interface !!

and so, TradAsIAddChild return false in

System.Windows.Markup.BamlRecordReader.GetFlagsFro mType(Type elementType)

May be some one from Xaml developper team can help me !!!

thanks a lot for your help !
"azerty" <az****@aaaa.fra écrit dans le message de news:
eP****************@TK2MSFTNGP04.phx.gbl...
>Hello

I try to use xaml serializer framework to save in .xaml file my own
hierarchical graph of object.
The first step is done : I create my own file with something like this :
<Root
xmlns="clr-namespace:myNameSpace;assembly=MyAssembly">
<Structure ...>
<SimpleText ... />
</Structure>
</Root>
with a simple call like this :
outStream = new System.IO.FileStream(@"c:\temp\essai.xaml",
System.IO.FileMode.Create);
using (outStream)
{
System.Windows.Markup.XamlWriter.Save(rootInstance ,
outStream);
}
BUT when I want to reverse the process (Create a RootInstance from xaml
file) with a call like this :
System.IO.FileStream inStream = new
System.IO.FileStream(@"c:\temp\essai.xaml",
System.IO.FileMode.Open);
using (inStream)
{
return
(Root)System.Windows.Markup.XamlReader.Load(inStr eam);
}
Root is created
Structure is created
SimpleText is created
BUT i have after this, an exception like "SimpleText can be added in
Structure" occurs !!
Structure and Root derive from Container class witch supports IEnumerable
and IAddChild interface !!
I don't know what I forgot somewhere ????
could you help me
thanks a lot for your help !


Dec 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.