In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "What is WCF KnownType". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's make up a small series to take you to learn "WCF KnownType is what"!
Notice the ClassWillProcessl type, what types do we need to add to KnownType? If we can assign instances of ClassB to ca in our application, we need to add ClassB to KnowType ([KnowType(typeof(ClassB))]), because ClassB derives from ClassA, so there is a downward cast in deserialization. If that is not possible, then leave it alone.
Since the declaration type of ia is an interface, we need to add the implementation class of the interface to WCF KnownType. Here are ImplA and ImplB. Imagine if we only added ImplA to KnownType and we assigned an instance of ImplB to ia, the deserialization engine would still deserialize it to ImplA because it only knows ImplA. If we put ClassC and ClassD in arraylist1 collection, since non-generic collections use Object to hold actual objects, we also need to add ClassC and ClassD to WCF KnownType. If we also want to store an array of int in numberValue (which rarely happens in practice), we also need to add int[] to WCF KnownType.
The ClassWillProcessl type with KnownType added is as follows:
[DataContract] [KnowType(typeof(ClassB))] [KnowType(typeof(ImplA))] [KnowType(typeof(ImplB))] [KnowType(typeof(ClassC))] [KnowType(typeof(ClassD))] [KnowType(typeof(int[]))] Public class ClassWillProcess { [DataMember] ClassA ca; [DataMember] InterfaceA ia; [DataMember] ArrayList arraylist1; Object numberValue; [DataMember] Public object Numbers { get {return numberValue;} set {numberValue=value;} } } At this point, I believe that everyone has a deeper understanding of "WCF KnownType is what", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.