本文整理汇总了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"]);
}
示例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];
}