本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Table.TableContinuationToken.ReadXml方法的典型用法代码示例。如果您正苦于以下问题:C# TableContinuationToken.ReadXml方法的具体用法?C# TableContinuationToken.ReadXml怎么用?C# TableContinuationToken.ReadXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Table.TableContinuationToken
的用法示例。
在下文中一共展示了TableContinuationToken.ReadXml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeToken
public static TableContinuationToken DeserializeToken(string token)
{
if (!string.IsNullOrWhiteSpace(token))
{
var raw = DecodeBase64(token);
TableContinuationToken contToken = null;
using (var stringReader = new StringReader(raw))
{
contToken = new TableContinuationToken();
using (var xmlReader = XmlReader.Create(stringReader))
{
contToken.ReadXml(xmlReader);
}
}
return contToken;
}
return null;
}
示例2: TableContinuationTokenVerifyXmlWithinXml
public void TableContinuationTokenVerifyXmlWithinXml()
{
CloudTableClient tableClient = GenerateCloudTableClient();
TableResultSegment segment = null;
List<CloudTable> totalResults = new List<CloudTable>();
TableContinuationToken token = null;
do
{
segment = tableClient.ListTablesSegmented("prefixtable", 5, segment != null ? segment.ContinuationToken : null);
totalResults.AddRange(segment);
token = segment.ContinuationToken;
if (token != null)
{
Assert.AreEqual(null, token.GetSchema());
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
StringBuilder sb = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(sb, settings))
{
writer.WriteStartElement("test1");
writer.WriteStartElement("test2");
token.WriteXml(writer);
writer.WriteEndElement();
writer.WriteEndElement();
}
using (XmlReader reader = XmlReader.Create(new StringReader(sb.ToString())))
{
token = new TableContinuationToken();
reader.ReadStartElement();
reader.ReadStartElement();
token.ReadXml(reader);
reader.ReadEndElement();
reader.ReadEndElement();
}
}
}
while (token != null);
Assert.AreEqual(totalResults.Count, tableClient.ListTables("prefixtable").Count());
}
示例3: TableContinuationTokenVerifyEmptyTargetDeserializer
public void TableContinuationTokenVerifyEmptyTargetDeserializer()
{
TableContinuationToken tableContinuationToken = new TableContinuationToken { NextTableName = "tableName", NextPartitionKey = "partitionKey", NextRowKey = "rowKey", TargetLocation = null };
StringBuilder stringBuilder = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(stringBuilder))
{
tableContinuationToken.WriteXml(writer);
}
string stringToken = stringBuilder.ToString();
TableContinuationToken parsedToken = new TableContinuationToken();
parsedToken.ReadXml(XmlReader.Create(new System.IO.StringReader(stringToken)));
Assert.AreEqual(parsedToken.NextTableName, "tableName");
Assert.AreEqual(parsedToken.NextPartitionKey, "partitionKey");
Assert.AreEqual(parsedToken.NextRowKey, "rowKey");
Assert.AreEqual(parsedToken.TargetLocation, null);
}
示例4: TableContinuationTokenVerifySerializer
public void TableContinuationTokenVerifySerializer()
{
XmlSerializer serializer = new XmlSerializer(typeof(TableContinuationToken));
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
StringReader reader;
string tokenxml;
TableContinuationToken writeToken = new TableContinuationToken
{
NextPartitionKey = Guid.NewGuid().ToString(),
NextRowKey = Guid.NewGuid().ToString(),
NextTableName = Guid.NewGuid().ToString(),
TargetLocation = StorageLocation.Primary
};
TableContinuationToken readToken = null;
// Write with XmlSerializer
using (StringWriter writer = new StringWriter())
{
serializer.Serialize(writer, writeToken);
tokenxml = writer.ToString();
}
// Read with XmlSerializer
reader = new StringReader(tokenxml);
readToken = (TableContinuationToken)serializer.Deserialize(reader);
Assert.AreEqual(writeToken.NextTableName, readToken.NextTableName);
// Read with token.ReadXml()
using (XmlReader xmlReader = XmlReader.Create(new StringReader(tokenxml)))
{
readToken = new TableContinuationToken();
readToken.ReadXml(xmlReader);
}
Assert.AreEqual(writeToken.NextTableName, readToken.NextTableName);
// Read with token.ReadXml()
using (XmlReader xmlReader = XmlReader.Create(new StringReader(tokenxml)))
{
readToken = new TableContinuationToken();
readToken.ReadXml(xmlReader);
}
// Write with token.WriteXml
StringBuilder sb = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(sb, settings))
{
writeToken.WriteXml(writer);
}
// Read with XmlSerializer
reader = new StringReader(sb.ToString());
readToken = (TableContinuationToken)serializer.Deserialize(reader);
Assert.AreEqual(writeToken.NextTableName, readToken.NextTableName);
// Read with token.ReadXml()
using (XmlReader xmlReader = XmlReader.Create(new StringReader(sb.ToString())))
{
readToken = new TableContinuationToken();
readToken.ReadXml(xmlReader);
}
Assert.AreEqual(writeToken.NextTableName, readToken.NextTableName);
}
示例5: Deserialize
public TableContinuationToken Deserialize(string serializedContinuationToken)
{
if (serializedContinuationToken == null) return null;
TableContinuationToken continuationToken = new TableContinuationToken();
using (XmlReader xmlReader = XmlReader.Create(new StringReader(serializedContinuationToken)))
{
continuationToken.ReadXml(xmlReader);
}
return continuationToken;
}
开发者ID:JamesRandall,项目名称:AccidentalFish.ApplicationSupport,代码行数:11,代码来源:TableContinuationTokenSerializer.cs