none
Silverlight 2的变化(Breaking Changes in Silverlight 2)之三 RRS feed

  • 常规讨论

  • Silverlight 2的变化(Breaking Changes in Silverlight 2)
    发布于:2008-06-06 15:45:29 作者:works guo 来源:www.cnblogs.com 访问:17次 文字:


    (15)Assembly 变化

    agclr.dll被重命名为System.Window.dll.
    System.Xml.Core.dll被重命名为 System.Xml.dll .
    System.Silverlight.dll 被重命名为 System.Windows.Browser.dll.


    (16)新做一个Web Service Client Proxies

    给用户的一个为Silverlight 1.1 Alpha和Alpha Refresh projects产生的Web service client proxies将重新产生一个为Silverlight的最新版本的proxies.因为System.Windows.Browser.Net.SoapHttpClientProtocol类被ClientBase<T>取代,这个类是在System.ServiceModel.dll中.



    (17)WCF JSON Services 可以需要SOAP Endpoints(Endpoints 翻译版本太多)

    用户依赖于为他们的Silverlight1.1 Alpha和Alpha Refresh 工程的WCF ASP.NET AJAX("WCF JSON") services,在最新版本的Silverlight版本中将添加SOAP终端.

    用户依赖于为他们的Silverlight1.1 Alpha和Alpha Refresh 工程的".asmx" ASP.NET AJAX("ASMX JSON") services将不能使用,在大部分案例中,不得不从根本改变他们的服务端(除非SOAP被明确指定为disabled,在这些案例中它应该re-enabled).


    (18)在Visual Studio,使用"Add Service Reference"被"Add Web Reference"取代

    用户将需要为Silverlight使用服务将Add Service Reference替换Add Web Reference.

    (19)Loaded事件签名的变化

    Loaded事件签名现在是RoutedEventHandler/Args.它行为是没有改变(这里不同的是tunneling/bubbling.)RoutedEventArgs 和 RoutedEventHandler的namespace从System.Windows.Input 改变到 System.Windows.
    之后
    using System.Windows.Input;

    canvas.Loaded 
    += 
        
    new EventHandler(My_Handler);

    void My_Handler (object sender, EventArgs e) {
    }
    现在
    using System.Windows;

    canvas.Loaded 
    += 
         
    new RoutedEventHandler(My_Handler);

    void My_Handler (object sender, RoutedEventArgs e) {
    }


    (20)托管的Downloader被移出

    托管的Downloader对象已经被移出.它的功能被WebClient类替换.不再有JavaScript Downloader对象.
    之前
    Downloader downloader = new Downloader();
    downloader.Open(
    "GET""http://data.com/resource.xml");
    downloader.DownloadProgressChanged 
    += new EventHandler(downloader_DownloadProgressChanged);
    downloader.Completed 
    += new EventHandler(downloader_Completed);
    downloader.DownloadFailed 
    += new ErrorEventHandler(downloader_DownloadFailed);
    downloader.Send();
     
           
     
    void downloader_Completed(object sender, EventArgs e)
    {
        Downloader downloader 
    = (Downloader)sender;
        Stream stream 
    = downloader.GetResponseStream();
    }
    现在
    WebClient webClient = new WebClient();
    webClient.DownloadProgressChanged 
    += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
    webClient.OpenReadCompleted 
    += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
    webClient.DownloadStringAsync(
    new Uri("http://data.com/resource.xml"));
     

     
    void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        
    if ((e.Error == null&& (e.Cancelled == false))
        
    {
            Stream stream 
    = e.Result;
        }

    }


    (21)BrowserHttpWebRequest 被移出

    一个新的HttpWebRequest类被添加,并且BrowserHttpWebRequest类/实现已经被移出.
    HttpWebRequest request = new BrowserHttpWebRequest(new Uri("http://Contoso.com"));
    HttpWebResponse response 
    = request.GetResponse();
    Stream content 
    = response.GetResponseStream();
     
    using (XmlReader reader = XmlReader.Create(new StreamReader(content)))
    {
        
    while (reader.Read())
        
    {
            
    if ((reader.IsStartElement()) && ("item" == reader.LocalName))
            
    {
                
    using (XmlReader itemReader = reader.ReadSubtree())
                
    {
                    
    while (itemReader.Read())
                    
    {
                        
    if (itemReader.IsStartElement())
                        
    {
                            
    if ("title" == itemReader.LocalName)
                            
    {
                            }

                            
    else if ("link" == itemReader.LocalName)
                            
    {
                            }

                        }

                    }

                }

            }

        }

    }

    response.Close();
    现在
    HttpWebRequest request = (HttpWebRequest) WebRequest.Create(new Uri("http://contoso.com"));
    request.BeginGetResponse(
    new AsyncCallback(ResponseCallback), request);
     

     
    // AsyncCallback called back on UIThread
    private void ResponseCallback(IAsyncResult asyncResult)
    {
        HttpWebRequest request 
    = (HttpWebRequest)asyncResult.AsyncState;
     
        HttpWebResponse response 
    = (HttpWebResponse)request.EndGetResponse(asyncResult);
        Stream content 
    = response.GetResponseStream();
     
        
    using (XmlReader reader = XmlReader.Create(new StreamReader(content)))
        
    {
            
    while (reader.Read())
            
    {
                
    if ((reader.IsStartElement()) && ("item" == reader.LocalName))
                
    {
                    
    using (XmlReader itemReader = reader.ReadSubtree())
                    
    {
                        
    while (itemReader.Read())
                        
    {
                            
    if (itemReader.IsStartElement())
                            
    {
                                
    if ("title" == itemReader.LocalName)
                                
    {
                                }

                                
    else if ("link" == itemReader.LocalName)
                                
    {
                                }

                            }

                        }

                    }

                }

            }

        }

        content.Close();
    }


    (22)托管的MediaElement/Image.SetSource(downloader, partName)被移出


    My blog: http://blog.csdn.net/dotfun http://dotfun.cnblogs.com

    My contact: QQ:372900288 E-mail:372900288@qq.com msn:sellnet007@hotmail.com

    2009年3月11日 7:06
    版主