当前位置: 首页>>代码示例>>C#>>正文


C# AtomEntry.SaveToXml方法代码示例

本文整理汇总了C#中Google.GData.Client.AtomEntry.SaveToXml方法的典型用法代码示例。如果您正苦于以下问题:C# AtomEntry.SaveToXml方法的具体用法?C# AtomEntry.SaveToXml怎么用?C# AtomEntry.SaveToXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google.GData.Client.AtomEntry的用法示例。


在下文中一共展示了AtomEntry.SaveToXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Index

        public void Index()
        {
            var g = new Service("local", "application");//, "ABQIAAAACPMbozlNv9AIzNvsWUm6vhSvnLMDprvOSMH9Qt_oH5Ww7FTw1hRHT7gTSie1yM34rowNwVfw424XPA");

            Assert.Fail("Need to put password here");
            g.setUserCredentials("[email protected]", "zzz");
            var entry = new AtomEntry();
            entry.Content.ExtensionFactories.Add(new MapsExtension());
            entry.Title.Text = "test";
               entry.Content.Type = "application/vnd.google-earth.kml+xml";
               XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'>
                   <name>Faulkner's Birthplace</name>
                   <description/>
                   <Point>
                     <coordinates>-89.520753,34.360902,0.0</coordinates>
                   </Point>
                 </Placemark>");
            entry.Content.ExtensionElements.Add(new XmlExtension((XmlNode)doc.DocumentElement));
                 //    doc.LoadXml(@"@"<m:Placemark>
                 //  <m:name>Faulkner's Birthplace</m:name>
                 //  <m:description/>
                 //  <m:Point>
                 //    <m:coordinates>-89.520753,34.360902,0.0</m:coordinates>
                 //  </m:Point>
                 //</m:Placemark>";

            //entry.Content.Content = ;
            //entry.AddExtension(new MapsExtension());
            var m = new MemoryStream();
            //var mapStuff = entry.Content.CreateExtension("PlaceMark", "http://www.opengis.net/kml/2.2");

               // entry.Update();
            try
            {
                entry.SaveToXml(m);
            }
            catch (Exception e)
            {
                var s = e.ToString();
                throw;
            }
            m.Position = 0;
            var mm = new StreamReader(m).ReadToEnd();
             var q = g.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry);

            var p = g.Query(new Uri("http://maps.google.com/maps/feeds/maps/default/full"));

            var z = new StreamReader(p).ReadToEnd();

            //// Arrange
            //HomeController controller = new HomeController();

            //// Act
            //ViewResult result = controller.Index() as ViewResult;

            //// Assert
            //ViewDataDictionary viewData = result.ViewData;
            //Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]);
        }
开发者ID:hankbeasley,项目名称:hoahome,代码行数:60,代码来源:HomeControllerTest.cs

示例2: Update

        /////////////////////////////////////////////////////////////////////////////





        //////////////////////////////////////////////////////////////////////
        /// <summary>WebResponse Update(Uri updateUri, Stream entryStream, ICredentials credentials)</summary> 
        /// <param name="entry">the old entry to update</param> 
        /// <returns> the new Entry, as returned from the server</returns>
        //////////////////////////////////////////////////////////////////////
        public AtomEntry Update(AtomEntry entry)
        {
            Tracing.Assert(entry != null, "entry should not be null");
            if (entry == null)
            {
                throw new ArgumentNullException("entry"); 
            }

            if (entry.ReadOnly == true)
            {
                throw new GDataRequestException("Can not update a read-only entry"); 
            }


            Uri target = new Uri(entry.EditUri.ToString());

            IGDataRequest request = this.RequestFactory.CreateRequest(GDataRequestType.Update,target);
            request.Credentials = this.Credentials;
            Stream outputStream = request.GetRequestStream();

            entry.SaveToXml(outputStream);
            request.Execute();
            outputStream.Close();

            AtomFeed returnFeed = createFeed(target);

            returnFeed.NewAtomEntry += new FeedParserEventHandler(this.OnParsedNewEntry); 
            returnFeed.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);

            Stream returnStream = request.GetResponseStream();

            returnFeed.Parse(returnStream, AlternativeFormat.Atom);
            // there should be ONE entry echoed back. 
            returnStream.Close(); 

            return returnFeed.Entries[0]; 

        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:49,代码来源:service.cs


注:本文中的Google.GData.Client.AtomEntry.SaveToXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。