Archive for July, 2009

Google Wave 中文:谷歌波霸?

July 6th, 2009

Google gives preview of its new product called Google Wave in Google I/O. It says that “Google Wave is a new tool for communication and collaboration on the web, coming later this year.” I have no idea what exactly it is but some people say that it is google’s new tool to compete with Flash/Silverlight. Will it be the new surprise from Google? Definitely it is. But will it change the situation of the whole RIA? I have no idea.

Check the pictures:

People can add their friends to Wave. And they can plan the activities for their friends.

0741443204360074

Combined with google’s various tools such as Google map search blah blah blah, people can share their views.

0741422762450938

And use the google map functions, they can plan the routine and etc.

07414742102262112

ANYWAY, I do not have super interest on this product because It sounds more like a super chatting room. But google will never let us down, will they?

Serializing Objects to Isolated Storage in Silverlight 2 / Silverlight2中序列化和反序列化

July 5th, 2009

最近遇到silverlight2中序列和反序列以及存储的问题,总结了一下。

因为silverlight2库的问题,silverlight2并不支持BinaryFormatter的序列化和反序列化的方式。如果要实现序列化,可以是用XML的方式。不过我们也可以运用System.Runtime.Serialization里面的DataContractSerializer来实现。

结合silverlight2的独立储存技术,让我们来看看如何运用DataContractSerializer来serialize object. Note that the object will be serailized to an XML format and saved in the directory of “C:\users\Administrator\AppData\LocalLow\Microsoft\Silverlight\….. The default maximum volume of the XML file is 1MB which is supported by Silverlight 2. But you can apply for larger space using “TryIncreaseQuotaTo” under “IsolatedStorageFile”

So if we have an object called List<FavoriteItem> for saving user’s controls last time. We want to save it and automatically load it next time the users comes again.

You can then use the DataContractSerializer as follows to save List<FavoriteItem>data to Iso storage:

序列化List<FavoriteItem>对象

        public List<FavoriteItem> FavoriteList = new List<FavoriteItem>();
        public string strFile = "favorite.xml";

        public void saveFavorite()
        {
            try
            {
                //apply for the storage in Silverlight
                using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    string dirPath = "MyDir";
                    if (!store.DirectoryExists(dirPath))
                    {
                        //Create directory
                        store.CreateDirectory("MyDir");
                    }

                    string filePath = Path.Combine("MyDir", strFile);
                    //MessageBox.Show(strFile);
                    if (store.FileExists(filePath))
                    {
                        store.DeleteFile(filePath);
                    }

                    //Serialize using DateContractSerializer
                    IsolatedStorageFileStream fileStream = store.CreateFile(filePath);
                    DataContractSerializer serializer = new DataContractSerializer(typeof(List<FavoriteItem>));
                    serializer.WriteObject(fileStream, FavoriteList);
                    fileStream.Close();

                }
            }
           catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

And the following to read it:

反序列化List<FavoriteItem>

        public List<FavoriteItem> loadFavorite()
        {
            try
            {
                List<FavoriteItem> listHistory;
                using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    string filePath = Path.Combine("MyDir", strFile);
                    if (store.FileExists(filePath))
                    {
                        //Deserialize
                        IsolatedStorageFileStream fileStream = store.OpenFile(filePath, FileMode.Open);
                        DataContractSerializer serializer = new DataContractSerializer(typeof(List<FavoriteItem>));
                        listHistory = (List<FavoriteItem>)serializer.ReadObject(fileStream);
                        fileStream.Close();
                        return listHistory;
                    }
                    else
                    {
                        return null;
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }

Thanks for visiting and pointing out mistakes. 原创转载请注明。

Alex Niu

好累

July 1st, 2009

天天也不知道在公司留到那么晚干什么 主要回去也没什么事情做
今天终于把TIMELINE那个老大难问题解决了 现在又在弄Virtual Earth Map的SDK 很是头痛 反正心情有点LOW
学了很多SILVERLIGHT的东西 最近又想法说把这个网站用SILVERLIGHT好好做一下 也算是一直以来的一个梦想 想好好自己设计并且做一个像样的网站 特别是做了SILVERLIGHT以后 毕竟目前熟练SILVERLIGHT的人并不多 也算是一个技能
SHARE一下今天看到的HARRY一段视频 介绍BING的 很不错

Play Video