예제 #1
0
        //</snippet13>

        //<snippet14>
        public static void Constructor7()
        {
            // Create an instance of the StreamingContext to hold
            // context data.
            StreamingContext sc = new StreamingContext
                                      (StreamingContextStates.CrossAppDomain);

            // Create an XmlDictionary and add values to it.
            XmlDictionary       d          = new XmlDictionary();
            XmlDictionaryString name_value = d.Add("Customer");
            XmlDictionaryString ns_value   = d.Add("http://www.contoso.com");

            // Create an instance of a class that implements the
            // ISurrogateSelector interface. The implementation code
            // is not shown here.
            MySelector mySurrogateSelector = new MySelector();

            NetDataContractSerializer ser =
                new NetDataContractSerializer(
                    name_value,
                    ns_value,
                    sc,
                    int.MaxValue,
                    true,
                    FormatterAssemblyStyle.Simple,
                    mySurrogateSelector);

            // Other code not shown.
        }
예제 #2
0
 public ISerializationSurrogate GetSurrogate(Type type,
                                             StreamingContext context, out ISurrogateSelector selector)
 {
     if (type.GetType() == typeof(Person))
     {
         selector = new MySelector();
         return(new MySerializationSurrogate());
     }
     else
     {
         selector = new MySelector();
         return(new MySerializationSurrogate());
     }
 }
예제 #3
0
        //</snippet11>

        //<snippet12>
        public static void Constructor5()
        {
            // Create an instance of the StreamingContext to hold
            // context data.
            StreamingContext sc = new StreamingContext
                                      (StreamingContextStates.CrossAppDomain);

            // Create an instance of a class that implements the
            // ISurrogateSelector interface. The implementation code
            // is not shown here.
            MySelector mySurrogateSelector = new MySelector();

            NetDataContractSerializer ser =
                new NetDataContractSerializer(
                    sc,
                    int.MaxValue,
                    true,
                    FormatterAssemblyStyle.Simple,
                    mySurrogateSelector);

            // Other code not shown.
        }
예제 #4
0
 public ISerializationSurrogate GetSurrogate(Type type,
                                             StreamingContext context, out ISurrogateSelector selector)
 {
     selector = new MySelector();
     return(new MySerializationSurrogate());
 }