本文整理汇总了C#中System.Xml.XmlReader.ReadContentAsLong方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadContentAsLong方法的具体用法?C# XmlReader.ReadContentAsLong怎么用?C# XmlReader.ReadContentAsLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadContentAsLong方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResponseXmlException
void IFlickrParsable.Load(XmlReader reader)
{
if (reader == null) throw new ArgumentNullException("reader");
if (!reader.ReadToFollowing("photos"))
throw new ResponseXmlException("Unable to find \"photos\" element in response.");
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxdisplaypx":
MaximumDisplayPixels = reader.ReadContentAsInt();
break;
case "maxupload":
MaximumPhotoUpload = reader.ReadContentAsLong();
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
if (!reader.ReadToFollowing("videos"))
throw new ResponseXmlException("Unable to find \"videos\" element in response.");
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxduration":
MaximumVideoDuration = reader.ReadContentAsInt();
break;
case "maxupload":
MaximumVideoUpload = reader.ReadContentAsLong();
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Skip();
}
示例2: ParseBandwidth
private void ParseBandwidth(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxbytes":
case "max":
BandwidthMax = reader.ReadContentAsLong();
break;
case "maxkb":
BandwidthMaxKB = reader.ReadContentAsLong();
break;
case "used":
case "usedbytes":
BandwidthUsed = reader.ReadContentAsLong();
break;
case "usedkb":
BandwidthUsedKB = reader.ReadContentAsLong();
break;
case "remainingbytes":
BandwidthRemaining = reader.ReadContentAsLong();
break;
case "remainingkb":
BandwidthRemainingKB = reader.ReadContentAsLong();
break;
case "unlimited":
IsUnlimited = reader.Value == "1";
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
}
示例3: ParseFileSize
private void ParseFileSize(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxbytes":
case "max":
FileSizeMax = reader.ReadContentAsLong();
break;
case "maxkb":
FileSizeMaxKB = reader.ReadContentAsLong();
break;
case "maxmb":
FileSizeMaxMB = reader.ReadContentAsLong();
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
}
示例4: ReadXml
public void ReadXml(XmlReader reader)
{
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case "LogGUID":
LogGUID = reader.ReadContentAsString();
break;
case "LogFileID":
LogFileID = reader.ReadContentAsString();
break;
case "LogTypeKey":
LogTypeKey = reader.ReadContentAsString();
break;
case "LogUserID":
LogUserID = reader.ReadContentAsInt();
break;
case "LogUserName":
LogUserName = reader.ReadContentAsString();
break;
case "LogPortalID":
LogPortalID = reader.ReadContentAsInt();
break;
case "LogPortalName":
LogPortalName = reader.ReadContentAsString();
break;
case "LogCreateDate":
LogCreateDate = DateTime.Parse(reader.ReadContentAsString());
break;
case "LogCreateDateNum":
LogCreateDateNum = reader.ReadContentAsLong();
break;
case "BypassBuffering":
BypassBuffering = bool.Parse(reader.ReadContentAsString());
break;
case "LogServerName":
LogServerName = reader.ReadContentAsString();
break;
case "LogConfigID":
LogConfigID = reader.ReadContentAsString();
break;
}
}
}
//Check for LogProperties child node
reader.Read();
if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "LogProperties")
{
reader.ReadStartElement("LogProperties");
if (reader.ReadState != ReadState.EndOfFile && reader.NodeType != XmlNodeType.None && !String.IsNullOrEmpty(reader.LocalName))
{
LogProperties.ReadXml(reader);
}
}
}
示例5: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "nsid":
GroupId = reader.Value;
break;
case "name":
GroupName = reader.Value;
break;
case "admin":
IsAdmin = reader.Value == "1";
break;
case "eighteenplus":
EighteenPlus = reader.Value == "1";
break;
case "invitation_only":
InvitationOnly = reader.Value == "1";
break;
case "iconfarm":
IconFarm = reader.Value;
break;
case "iconserver":
IconServer = reader.Value;
break;
case "members":
Members = reader.ReadContentAsInt();
break;
case "pool_count":
PoolCount = reader.ReadContentAsLong();
break;
case "is_member":
IsMember = reader.Value == "1";
break;
case "is_moderator":
IsModerator = reader.Value == "1";
break;
case "is_admin":
IsAdmin = reader.Value == "1";
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Read();
}
示例6: ExecuteGql
/*
/// <summary>
/// The entry point for the execution of an <GQL> tag.
/// </summary>
/// <param name="myGQLReader">An XmlReader, that is positioned before an <GQL> tag.</param>
private void ExecuteGql(XmlReader myGQLReader)
{
_logger.Log(Level.FINE, "ExecuteGql started.");
// if no xml is available, we have nothing to do.
if (myGQLReader == null)
//TODO: log something;
return;
try
{
myGQLReader.MoveToContent();
if (!CheckIsGqlElement(myGQLReader))
return ;
String gql = null;
while (myGQLReader.MoveToNextAttribute())
{
switch (myGQLReader.LocalName)
{
case "Query":
gql = myGQLReader.ReadContentAsString();
break;
default:
//TODO: log something
break;
}
}
if (gql == null)
//TODO log something;
return;
var result = _ql.Query(_security, _transaction, gql);
}
finally
{
if (!_closed)
myGQLReader.Close();
_logger.Log(Level.FINE, "ExecuteGql finished.");
}
}
/// <summary>
/// Logs the result of the import as Info.
/// </summary>
/// <param name="myResult"></param>
private void logQueryResult(IQueryResult myResult)
{
throw new NotImplementedException();
}
*/
/// <summary>
/// The entry point for the execution of an <Insert> tag.
/// </summary>
/// <param name="myInsertReader">An XmlReader, that is positioned before an <Insert> tag.</param>
private void ExecuteInsert(XmlReader myInsertReader)
{
_logger.Log(Level.FINE, "ExecuteInsert started.");
// if no xml is available, we have nothing to do.
if (myInsertReader == null)
//TODO: log something;
return;
try
{
myInsertReader.MoveToContent();
if (!CheckIsInsertElement(myInsertReader))
return;
String vertexTypeName = null;
long? id = null;
while (myInsertReader.MoveToNextAttribute())
{
switch (myInsertReader.LocalName)
{
case VertexTypeAttribute:
vertexTypeName = myInsertReader.ReadContentAsString();
break;
case VertexIDAttribute:
id = myInsertReader.ReadContentAsLong();
break;
default:
//TODO: log something
break;
}
}
//.........这里部分代码省略.........
示例7: ExecuteLink
/// <summary>
/// The entry point for the execution of an <Link> tag.
/// </summary>
/// <param name="myLinkReader">An XmlReader, that is positioned before an <Link> tag.</param>
/// <returns>
/// An instance of Link that contains the information of the <Link> tag or <c>Null</c> if the tag contains no information.
/// </returns>
private Link ExecuteLink(XmlReader myLinkReader)
{
_logger.Log(Level.FINE, "ExecuteLink started.");
// if no xml is available, we have nothing to do.
if (myLinkReader == null)
//TODO: log something;
return null;
try
{
myLinkReader.MoveToContent();
if (!CheckIsLinkElement(myLinkReader))
return null;
String vertexType = null;
long? id = null;
while (myLinkReader.MoveToNextAttribute())
{
switch (myLinkReader.LocalName)
{
case VertexTypeAttribute:
vertexType = myLinkReader.ReadContentAsString();
break;
case VertexIDAttribute:
try
{
id = myLinkReader.ReadContentAsLong();
break;
}
catch (Exception e)
{
//TODO: log something;
return null;
}
default:
//TODO: log something
break;
}
}
if (vertexType == null)
//TODO: log something;
return null;
if (!id.HasValue)
//TODO: log something;
return null;
IDictionary<String, String> values = new Dictionary<String, String>();
while (!_closed && myLinkReader.Read())
{
if (CheckIsElement(myLinkReader))
{
var nextReader = myLinkReader.ReadSubtree();
switch (myLinkReader.LocalName)
{
case SetValueTag:
var value = ExecuteSetValue(nextReader);
if (value.HasValue)
values.Add(value.Value);
break;
default:
//TODO: log something
break;
}
}
}
return new Link(new VertexID(vertexType, id.Value), values);
}
finally
{
if (!_closed)
myLinkReader.Close();
_logger.Log(Level.FINE, "ExecuteLink finished.");
}
}
示例8: ParseVideoSize
private void ParseVideoSize(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxbytes":
this.VideoSizeMax = reader.ReadContentAsLong();
continue;
case "maxkb":
this.VideoSizeMaxKB = reader.ReadContentAsLong();
continue;
case "maxmb":
this.VideoSizeMaxMB = reader.ReadContentAsLong();
continue;
default:
continue;
}
}
reader.Read();
}
示例9: ParseBandwidth
private void ParseBandwidth(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "maxbytes":
case "max":
this.BandwidthMax = reader.ReadContentAsLong();
continue;
case "maxkb":
this.BandwidthMaxKB = reader.ReadContentAsLong();
continue;
case "used":
case "usedbytes":
this.BandwidthUsed = reader.ReadContentAsLong();
continue;
case "usedkb":
this.BandwidthUsedKB = reader.ReadContentAsLong();
continue;
case "remainingbytes":
this.BandwidthRemaining = reader.ReadContentAsLong();
continue;
case "remainingkb":
this.BandwidthRemainingKB = reader.ReadContentAsLong();
continue;
case "unlimited":
this.IsUnlimited = reader.Value == "1";
continue;
default:
continue;
}
}
reader.Read();
}
示例10: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "nsid":
this.GroupId = reader.Value;
continue;
case "name":
this.GroupName = reader.Value;
continue;
case "admin":
case "is_admin":
this.IsAdmin = reader.Value == "1";
continue;
case "is_member":
this.IsMember = new bool?(reader.Value == "1");
continue;
case "is_moderator":
this.IsModerator = new bool?(reader.Value == "1");
continue;
case "eighteenplus":
this.EighteenPlus = reader.Value == "1";
continue;
case "invitation_only":
this.InvitationOnly = reader.Value == "1";
continue;
case "iconfarm":
this.IconFarm = reader.Value;
continue;
case "iconserver":
this.IconServer = reader.Value;
continue;
case "members":
this.Members = reader.ReadContentAsInt();
continue;
case "pool_count":
this.PoolCount = reader.ReadContentAsLong();
continue;
default:
continue;
}
}
reader.Read();
}
示例11: InternalReadXml
protected void InternalReadXml(XmlReader r)
{
string containingElementType = "";
MemberInfo[] fields = GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
bool skipCloseElement = false;
foreach (MemberInfo f in fields)
{
var mInfo = Globs.GetAttr<MarshalAsAttribute>(f);
var elementType = Globs.GetMemberType(f);
string elementName = f.Name.TrimStart(new[] { '_' });
if (r.HasAttributes)
{
containingElementType = r.GetAttribute("type");
}
r.ReadStartElement(elementName);
string s;
Object val;
switch (mInfo.MarshType)
{
case MarshalType.UnionSelector:
s = r.ReadContentAsString();
// ReSharper disable once AssignNullToNotNullAttribute
val = Enum.Parse(elementType, s);
Globs.SetMember(f, this, val);
break;
case MarshalType.ArrayCount:
int intVal = r.ReadContentAsInt();
// ReSharper disable once AssignNullToNotNullAttribute
val = Convert.ChangeType(intVal, elementType);
Globs.SetMember(f, this, val);
break;
case MarshalType.Normal:
// ReSharper disable once PossibleNullReferenceException
if (elementType.GetTypeInfo().IsSubclassOf(typeof(TpmStructureBase)))
{
val = Activator.CreateInstance(elementType);
Globs.SetMember(f, this, val);
((TpmStructureBase)val).InternalReadXml(r);
break;
}
// ReSharper disable once RedundantIfElseBlock
else
{
if(elementType.TypeIsEnum())
{
s = r.ReadContentAsString();
val = Enum.Parse(elementType, s);
Globs.SetMember(f, this, val);
break;
}
if (elementType == typeof(uint) || elementType == typeof(ushort) || elementType == typeof(byte))
{
// TODO: This should be unsigned
long longVal = r.ReadContentAsLong();
val = Convert.ChangeType(longVal, elementType);
Globs.SetMember(f, this, val);
break;
}
throw new NotImplementedException("");
}
// ReSharper disable once CSharpWarnings::CS0162
// ReSharper disable once HeuristicUnreachableCode
throw new NotImplementedException("");
case MarshalType.FixedLengthArray:
case MarshalType.VariableLengthArray:
var supportedElementaryTypes = new[] { typeof(byte[]), typeof(ushort[]), typeof(uint[]) };
if (supportedElementaryTypes.Contains(elementType))
{
if (r.HasValue)
{
// ReSharper disable once AssignNullToNotNullAttribute
val = r.ReadContentAs(elementType, null);
Globs.SetMember(f, this, val);
}
else
{
// ReSharper disable once AssignNullToNotNullAttribute
Object nullObj = Activator.CreateInstance(elementType, 0x0);
Globs.SetMember(f, this, nullObj);
skipCloseElement = true;
}
break;
}
// ReSharper disable once RedundantIfElseBlock
else
{
throw new NotImplementedException("");
}
case MarshalType.Union:
// ReSharper disable once AssignNullToNotNullAttribute
val = Activator.CreateInstance(Type.GetType(containingElementType));
//.........这里部分代码省略.........
示例12: ToObject
//.........这里部分代码省略.........
}
else
{
value = reader.ReadContentAsBoolean();
}
dataType = typeof(bool);
formatString = "{0}";
}
else if(edmType == TableStorageConstants.Edm.TYPE_DATETIME)
{
if(isNull)
{
value = DBNull.Value;
}
else
{
value = reader.ReadContentAsDateTime();
}
dataType = typeof(DateTime);
formatString = TableStorageConstants.Edm.DATE_TIME_FORMAT;
}
else if(edmType == TableStorageConstants.Edm.TYPE_DOUBLE)
{
if(isNull)
{
value = DBNull.Value;
}
else
{
value = reader.ReadContentAsDouble();
}
dataType = typeof(double);
formatString = "{0}";
}
else if(edmType == TableStorageConstants.Edm.TYPE_GUID)
{
if(isNull)
{
value = DBNull.Value;
}
else
{
value = Guid.Parse(reader.ReadContentAsString());
}
dataType = typeof(Guid);
formatString = "{0:D}";
}
else if(edmType == TableStorageConstants.Edm.TYPE_INT)
{
if(isNull)
{
value = DBNull.Value;
}
else
{
value = reader.ReadContentAsInt();
}
dataType = typeof(int);
formatString = "{0}";
}
else if(edmType == TableStorageConstants.Edm.TYPE_LONG)
{
if(isNull)
{
value = DBNull.Value;
}
else
{
value = reader.ReadContentAsLong();
}
dataType = typeof(long);
formatString = "{0}";
}
else if(StringComparer.OrdinalIgnoreCase.Equals(TableStorageConstants.Edm.TYPE_STRING, edmType))
{
if(isNull)
{
value = DBNull.Value;
}
else
{
value = reader.ReadContentAsString();
}
dataType = typeof(string);
formatString = "{0}";
}
else
{
throw new TableStorageException(string.Format("The type, '{0},' is not supported.", edmType));
}
return new TableStorageField(value, edmType, propertyName, isNull, dataType, formatString);
}