Quintiq file version 2.0
|
#parent: #root
|
Method SynchronizeAttributes (JSON jsondata)
|
{
|
TextBody:
|
[*
|
new := construct( Lib3DS_Attributes );
|
|
attrnamedata := guard( jsondata.Get( 'attribute' ), null( JSON, owning ) );
|
attrtypedata := guard( jsondata.Get( 'attribute.type' ), null( JSON, owning ) );
|
attrvaluedata := guard( jsondata.Get( 'attribute.value' ), null( JSON, owning ) );
|
|
if( guard( attrnamedata.IsArray(), false )
|
and guard( attrtypedata.IsArray(), false )
|
and guard( attrvaluedata.IsArray(), false ) )
|
{
|
for( i := 0; i < attrnamedata.Size(); i++ )
|
{
|
attr := Lib3DS_Attribute::FindOrCreate( this, attrnamedata.Get( i ).GetString() );
|
attr.Type( guard( attrtypedata.Get( i ).GetString(), '' ) );
|
attr.Value( guard( attrvaluedata.Get( i ).GetString(), '' ) );
|
new.Add( attr );
|
}
|
}
|
else // Read individual attributes
|
{
|
// Traverse all properties
|
for( i := 0; i < jsondata.Size(); i++ )
|
{
|
key := jsondata.GetProperty( i );
|
|
// Find attribute properties (type or value)
|
if( key.Wildcard( 'attribute[*].type' ) or key.Wildcard( 'attribute[*].value' ) )
|
{
|
// Extract property name
|
start := key.FindString( '[', 0 ) + 1;
|
end := key.FindString( ']', 0 );
|
count := end - start;
|
attrname := key.SubString( start, count );
|
|
// Find or create attribute object
|
attr := Lib3DS_Attribute::FindOrCreate( this, attrname );
|
if( key.EndsWith( 'type' ) )
|
{
|
attr.Type( guard( jsondata.Get( key ).GetString(), '' ) );
|
}
|
else if( key.EndsWith( 'value' ) )
|
{
|
attr.Value( guard( jsondata.Get( key ).GetString(), '' ) );
|
}
|
new.Add( attr );
|
}
|
}
|
}
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|