📄 data2xml.cs
字号:
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "ClassName" )
{
itemData.PhotoType.className = xmlReader.Value;
}
else if( xmlReader.Name == "fullName" )
{
itemData.PhotoType.fullName = xmlReader.Value;
}
else if( xmlReader.Name == "noName" )
{
itemData.PhotoType.noName = xmlReader.Value;
}
else if( xmlReader.Name == "paramDefaultValus" )
{
itemData.PhotoType.paramDefaultValus = xmlReader.Value;
}
else if( xmlReader.Name == "paramNames" )
{
itemData.PhotoType.paramNames = xmlReader.Value;
}
else if( xmlReader.Name == "paramTypes" )
{
itemData.PhotoType.paramTypes = xmlReader.Value;
}
else if( xmlReader.Name == "phototypeInitExpression" )
{
itemData.PhotoType.phototypeInitExpression = xmlReader.Value;
}
else if( xmlReader.Name == "phototypeType" )
{
itemData.PhotoType.phototypeType = xmlReader.Value;
}
else if( xmlReader.Name == "uniqueSignature" )
{
itemData.PhotoType.uniqueSignature = xmlReader.Value;
}
}
// Read the </PhotoType> tag
xmlReader.Read();
if( xmlReader.NodeType != XmlNodeType.EndElement )
throw new Exception( "Unexpected end of Phototype tag!" );
}
else throw new Exception( "After delegate data must be Phototype data" );
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, delegateData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadClass( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "ClassData Item attribute cannot be zero! This is not my fault" );
ClassData classData = new ClassData();
elementData.AddMember( classData );
classData.Parent = elementData;
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
classData.Name = xmlReader.Value;
}
else if( xmlReader.Name == "IsAbstract" )
{
classData.IsAbstract = xmlReader.Value == "true" ? true : false;
}
else if( xmlReader.Name == "AccessType" )
{
classData.AccessType = AssignAccessType ( xmlReader.Value );
}
else if( xmlReader.Name == "Comment" )
{
classData.DocComment = xmlReader.Value;
}
else if( xmlReader.Name == "BaseClass" )
{
classData.BaseList.Add( xmlReader.Value );
}
}
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, classData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadFunction( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "Function Item attribute cannot be zero! This is not my fault" );
FunctionData functionData = new FunctionData();
elementData.AddMember( functionData );
functionData.Parent = elementData;
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
functionData.Name = xmlReader.Value;
}
else if( xmlReader.Name == "FunctionType" )
{
functionData.FunctionType = AssignFunctionType ( xmlReader.Value );
}
else if( xmlReader.Name == "AccessType" )
{
functionData.AccessType = AssignAccessType ( xmlReader.Value );
}
else if( xmlReader.Name == "Comment" )
{
functionData.DocComment = xmlReader.Value;
}
else if( xmlReader.Name == "CanOverrided" )
{
functionData.CanOverride = xmlReader.Value == "true" ? true : false;
}
else if( xmlReader.Name == "IsOverloaded" )
{
functionData.IsOverloaded = xmlReader.Value == "true" ? true : false;
}
else if( xmlReader.Name == "IsShared" )
{
functionData.IsShared = xmlReader.Value == "true" ? true : false;
}
}
// Read PhotoTypes
// This are MUST be PhotoTypes, otherwise send exception error message
xmlReader.Read();
FunctionData itemData = functionData;
if( xmlReader.Name == "Phototypes" )
{
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "ClassName" )
{
itemData.PhotoType.className = xmlReader.Value;
}
else if( xmlReader.Name == "fullName" )
{
itemData.PhotoType.fullName = xmlReader.Value;
}
else if( xmlReader.Name == "noName" )
{
itemData.PhotoType.noName = xmlReader.Value;
}
else if( xmlReader.Name == "paramDefaultValus" )
{
itemData.PhotoType.paramDefaultValus = xmlReader.Value;
}
else if( xmlReader.Name == "paramNames" )
{
itemData.PhotoType.paramNames = xmlReader.Value;
}
else if( xmlReader.Name == "paramTypes" )
{
itemData.PhotoType.paramTypes = xmlReader.Value;
}
else if( xmlReader.Name == "phototypeInitExpression" )
{
itemData.PhotoType.phototypeInitExpression = xmlReader.Value;
}
else if( xmlReader.Name == "phototypeType" )
{
itemData.PhotoType.phototypeType = xmlReader.Value;
}
else if( xmlReader.Name == "uniqueSignature" )
{
itemData.PhotoType.uniqueSignature = xmlReader.Value;
}
}
// Read the </PhotoType> tag
xmlReader.Read();
if( xmlReader.NodeType != XmlNodeType.EndElement )
throw new Exception( "Unexpected end of Phototype tag!" );
}
else throw new Exception( "After Function data must be Phototype data" );
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, functionData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadEnum( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "Enum Item attribute cannot be zero! This is not my fault" );
EnumData enumData = new EnumData();
elementData.AddMember( enumData );
enumData.Parent = elementData;
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
enumData.Name = xmlReader.Value;
}
else if( xmlReader.Name == "AccessType" )
{
enumData.AccessType = AssignAccessType ( xmlReader.Value );
}
else if( xmlReader.Name == "Comment" )
{
enumData.DocComment = xmlReader.Value;
}
}
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, enumData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadInterface( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "Interface Item attribute cannot be zero! This is not my fault" );
InterfaceData interfaceData = new InterfaceData();
elementData.AddMember( interfaceData );
interfaceData.Parent = elementData;
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
interfaceData.Name = xmlReader.Value;
}
else if( xmlReader.Name == "AccessType" )
{
interfaceData.AccessType = AssignAccessType ( xmlReader.Value );
}
else if( xmlReader.Name == "Comment" )
{
interfaceData.DocComment = xmlReader.Value;
}
else if( xmlReader.Name == "BaseClass" )
{
interfaceData.BaseList.Add( xmlReader.Value );
}
}
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, interfaceData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadNameSpace( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "NameSpace Item attribute cannot be zero! This is not my fault" );
NameSpaceData nameSpaceData = new NameSpaceData();
elementData.AddMember( nameSpaceData );
nameSpaceData.Parent = elementData;
// here i should be 2
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
nameSpaceData.Name = xmlReader.Value;
}
if( xmlReader.Name == "Comment" )
{
nameSpaceData.DocComment = xmlReader.Value;
}
}
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, nameSpaceData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadParameter( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "Parameter Item attribute cannot be zero! This is not my fault" );
ParameterData parameterData = new ParameterData();
elementData.AddMember( parameterData );
parameterData.Parent = elementData;
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
parameterData.Name = xmlReader.Value;
}
}
// Next parse
{
bool bJumpHigher = false;
do
{
bJumpHigher = DispatchReadAction( xmlReader, parameterData );
}while( bJumpHigher == false );
}
}
/// <summary>
/// Read the element data ( attribute )
/// </summary>
/// <param name="xmlReader">XMLTextReader class</param>
/// <param name="elementData">ElementData class</param>
private static void ReadProperty( XmlTextReader xmlReader, ElementData elementData )
{
if( xmlReader.AttributeCount <= 0 )
throw new Exception( "Property Item attribute cannot be zero! This is not my fault" );
PropertyData propertyData = new PropertyData();
elementData.AddMember( propertyData );
propertyData.Parent = elementData;
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "Name" )
{
propertyData.Name = xmlReader.Value;
}
else if( xmlReader.Name == "AccessType" )
{
propertyData.AccessType = AssignAccessType ( xmlReader.Value );
}
else if( xmlReader.Name == "Comment" )
{
propertyData.DocComment = xmlReader.Value;
}
}
// This are MUST be PhotoTypes, otherwise send exception error message
xmlReader.Read();
PropertyData itemData = propertyData;
if( xmlReader.Name == "Phototypes" )
{
for( int i = 0 ; i < xmlReader.AttributeCount ; i ++ )
{
xmlReader.MoveToAttribute(i);
if( xmlReader.Name == "ClassName" )
{
itemData.PhotoType.className = xmlReader.Value;
}
else if( xmlReader.Name == "fullName" )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -