@@ -1045,7 +1045,7 @@ public class GxUserType : IGxXMLSerializable, ICloneable, IGxJSONAble, IGxJSONSe
10451045 {
10461046 static readonly IGXLogger log = GXLoggerFactory . GetLogger < GxUserType > ( ) ;
10471047 protected GXProperties dirties = new GXProperties ( ) ;
1048- private const string PROPERTY_PREFIX = "gxtpr_" ;
1048+
10491049 static object setupChannelObject = null ;
10501050 static bool setupChannelInitialized ;
10511051 [ XmlIgnore ]
@@ -1602,29 +1602,27 @@ public Object GetJSONObject()
16021602 ToJSON ( ) ;
16031603 return JsonObj ;
16041604 }
1605+
16051606 private ICollection getFromJSONObjectOrderIterator ( ICollection it )
16061607 {
1607- if ( GxUploadAttrs . IsEmpty && ! typeof ( GxSilentTrnSdt ) . IsAssignableFrom ( this . GetType ( ) ) )
1608- {
1609- return it ;
1610- }
1611- List < string > _JsonObjectOrderIterator = new List < string > ( ) ;
1612-
1608+ List < string > v = new List < string > ( ) ;
16131609 List < string > vAtEnd = new List < string > ( ) ;
16141610 foreach ( string name in it )
16151611 {
1616- if ( name . EndsWith ( "_N" ) || IsGxUploadAttribute ( name ) )
1612+ string map = JsonMap ( name ) ;
1613+ PropertyInfo objProperty = GetTypeProperty ( "gxtpr_" + ( ! string . IsNullOrEmpty ( map ) ? map : name ) . ToLower ( ) ) ;
1614+ if ( name . EndsWith ( "_N" ) || objProperty != null && IsGxUploadAttribute ( objProperty ) )
16171615 {
16181616 vAtEnd . Add ( name ) ;
16191617 }
16201618 else
16211619 {
1622- _JsonObjectOrderIterator . Add ( name ) ; //keep the order of attributes that do not end with _N.
1620+ v . Add ( name ) ; //keep the order of attributes that do not end with _N.
16231621 }
16241622 }
16251623 if ( vAtEnd . Count > 0 )
1626- _JsonObjectOrderIterator . AddRange ( vAtEnd ) ;
1627- return _JsonObjectOrderIterator ;
1624+ v . AddRange ( vAtEnd ) ;
1625+ return v ;
16281626 }
16291627
16301628 public void FromJSONObject ( dynamic obj )
@@ -1637,7 +1635,9 @@ public void FromJSONObject(dynamic obj)
16371635 foreach ( string name in jsonIterator )
16381636 {
16391637 object currObj = jobj [ name ] ;
1640- PropertyInfo objProperty = GetTypeProperty ( JsonNameToInternalName ( name ) ) ;
1638+ string map = JsonMap ( name ) ;
1639+ PropertyInfo objProperty = GetTypeProperty ( "gxtpr_" + ( map != null ? map : name ) . ToLower ( ) ) ;
1640+
16411641 if ( objProperty != null )
16421642 {
16431643 if ( ! JSONHelper . IsJsonNull ( currObj ) )
@@ -1897,64 +1897,32 @@ private bool TryConvertValueToProperty(object Value, PropertyInfo property, out
18971897 return success ;
18981898 }
18991899
1900- private static ConcurrentDictionary < string , byte > _gxuploadAttrs ;
1901- private bool IsGxUploadAttribute ( string jsonPropertyName )
1902- {
1903- return GxUploadAttrs . ContainsKey ( JsonNameToInternalName ( jsonPropertyName ) ) ;
1904- }
1905- private bool IsGxUploadAttribute ( PropertyInfo propertyInfo )
1906- {
1907- return GxUploadAttrs . ContainsKey ( propertyInfo . Name ) ;
1908- }
1909- private string JsonNameToInternalName ( string jsonPropertyName )
1900+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "GxFxCopRules" , "CR1000:EnforceThreadSafeType" ) ]
1901+ private Dictionary < string , bool > gxuploadAttrs = new Dictionary< string , bool > ( ) ;
1902+ private bool IsGxUploadAttribute ( PropertyInfo property )
19101903 {
1911- string map = JsonMap ( jsonPropertyName ) ;
1912- if ( ! string . IsNullOrEmpty ( map ) )
1913- return PROPERTY_PREFIX + map . ToLower ( ) ;
1914- else
1915- return PROPERTY_PREFIX + jsonPropertyName . ToLower ( ) ;
1916- }
1917- private ConcurrentDictionary < string , byte > GxUploadAttrs
1918- {
1919- get
1904+ string key = property . Name ;
1905+ if ( ! gxuploadAttrs . ContainsKey ( key ) )
19201906 {
1921- if ( _gxuploadAttrs == null )
1922- {
1923- _gxuploadAttrs = new ConcurrentDictionary < string , byte > ( ) ;
1924- foreach ( PropertyInfo property in TypeProperties . Values )
1925- {
1926- bool hasAtt = property . IsDefined ( typeof ( GxUpload ) , false ) ;
1927- if ( hasAtt )
1928- {
1929- _gxuploadAttrs . TryAdd ( property . Name . ToLower ( ) , 1 ) ;
1930- }
1931- }
1932- }
1933- return _gxuploadAttrs ;
1907+ bool hasAtt = property . IsDefined ( typeof ( GxUpload ) , false ) ;
1908+ gxuploadAttrs . Add ( key , hasAtt ) ;
19341909 }
1910+ return gxuploadAttrs [ key ] ;
19351911 }
1936- private static ConcurrentDictionary < string , PropertyInfo > _typeProps ;
1912+
1913+ private Hashtable props ;
19371914
19381915 private PropertyInfo GetTypeProperty ( string propName )
19391916 {
1940- return TypeProperties [ propName ] ;
1941- }
1942- private ConcurrentDictionary < string , PropertyInfo > TypeProperties
1943- {
1944- get {
1945- if ( _typeProps == null )
1917+ if ( props == null )
1918+ {
1919+ props = new Hashtable ( ) ;
1920+ foreach ( PropertyInfo prop in this . GetType ( ) . GetProperties ( ) )
19461921 {
1947- _typeProps = new ConcurrentDictionary < string , PropertyInfo > ( ) ;
1948- foreach ( PropertyInfo prop in this . GetType ( ) . GetProperties ( ) )
1949- {
1950- if ( prop . Name . StartsWith ( PROPERTY_PREFIX , StringComparison . OrdinalIgnoreCase ) )
1951- {
1952- _typeProps . TryAdd ( prop . Name . ToLower ( ) , prop ) ;
1953- }
1954- }
1922+ props . Add ( prop . Name . ToLower ( ) , prop ) ;
19551923 }
1956- return _typeProps ;
19571924 }
1925+ return ( PropertyInfo ) props [ propName ] ;
19581926 }
19591927
19601928 private Hashtable methods ;
0 commit comments