/// <summary> /// Creates a sanitized updatedResource based on one supplied by the caller /// </summary> /// <param name="id"> /// The id of the updatedResource to create /// </param> /// <param name="untrusted"> /// The resource supplied by the caller /// </param> /// <param name="versionOption"> /// The version option /// </param> /// <returns> /// A new resource based on the untrusted resource /// </returns> /// <remarks> /// Sanitizing a resource means converting an untrusted resource /// into something you can trust. /// </remarks> internal static Sample CreateSanitizedResource( int id, Sample untrusted, SampleResourceVersionOption versionOption) { // Return a new sanitized updatedResource with only the changes allowed return(new Sample { Key = id, Data = untrusted.Data, Tag = (versionOption == SampleResourceVersionOption.New) ? Guid.NewGuid().ToString() : untrusted.Tag, // ReadOnlyData is not initialized because we don't allow the caller to update it }); }
/// <summary> /// Creates a sanitized updatedResource based on one supplied by the caller /// </summary> /// <param name="id"> /// The id of the updatedResource to create /// </param> /// <param name="untrusted"> /// The resource supplied by the caller /// </param> /// <param name="versionOption"> /// The version option /// </param> /// <returns> /// A new resource based on the untrusted resource /// </returns> /// <remarks> /// Sanitizing a resource means converting an untrusted resource /// into something you can trust. /// </remarks> internal static Sample CreateSanitizedResource( int id, Sample untrusted, SampleResourceVersionOption versionOption) { // Return a new sanitized updatedResource with only the changes allowed return new Sample { Key = id, Data = untrusted.Data, Tag = (versionOption == SampleResourceVersionOption.New) ? Guid.NewGuid().ToString() : untrusted.Tag, // ReadOnlyData is not initialized because we don't allow the caller to update it }; }