sdk/dotnet/src/Microsoft.Datasync.Client/Serialization/DatasyncContractResolver.cs
/// <summary>
/// Determines which of the properties is the ID property for the type.
/// </summary>
/// <param name="type">The type to determine the ID property of.</param>
/// <param name="properties">The property ame.</param>
/// <returns></returns>
Determines which of the properties is the ID property for the type.
Determines which of the properties is the ID property for the type .
private JsonProperty GetIdProperty(Type type, IEnumerable<JsonProperty> properties)
        {
            JsonProperty[] idProperties = properties.Where(p => p.PropertyName.Equals(SystemProperties.JsonIdProperty, StringComparison.OrdinalIgnoreCase) && !p.Ignored).ToArray();
            if (idProperties.Length > 1)
            {
                throw new InvalidOperationException($"Only one member of the type '{type.FullName}' may be an ID.");
            }
            if (idProperties.Length < 1)
            {
                throw new InvalidOperationException($"No '{SystemProperties.JsonIdProperty}' properties found on type '{type.FullName}'");
            }
            JsonProperty idProperty = idProperties[0];
            idProperty.PropertyName = SystemProperties.JsonIdProperty;
            idProperty.NullValueHandling = NullValueHandling.Ignore;
            idProperty.DefaultValueHandling = DefaultValueHandling.Ignore;
            lock (idPropertyCache)
            {
                idPropertyCache[type] = idProperty;
            }
            return idProperty;
        }
private JsonProperty GetIdProperty ( Type type , IEnumerable < JsonProperty > properties ) { JsonProperty [ ] idProperties = properties . Where ( p => p . PropertyName . Equals ( SystemProperties . JsonIdProperty , StringComparison . OrdinalIgnoreCase ) && ! p . Ignored ) . ToArray ( ) ; if ( idProperties . Length > 1 ) { throw new InvalidOperationException ( $" Only one member of the type ' { type . FullName } ' may be an ID. " ) ; } if ( idProperties . Length < 1 ) { throw new InvalidOperationException ( $" No ' { SystemProperties . JsonIdProperty } ' properties found on type ' { type . FullName } ' " ) ; } JsonProperty idProperty = idProperties [ 0 ] ; idProperty . PropertyName = SystemProperties . JsonIdProperty ; idProperty . NullValueHandling = NullValueHandling . Ignore ; idProperty . DefaultValueHandling = DefaultValueHandling . Ignore ; lock ( idPropertyCache ) { idPropertyCache [ type ] = idProperty ; } return idProperty ; }
Determines which of the properties is the ID property for the type.
Determines which of the properties is the ID property for the type .
None
type
Type
The type to determine the ID property of.
The type to determine the ID property of .
properties
IEnumerable<JsonProperty>
The property ame.
The property ame .