Skip to content

Instantly share code, notes, and snippets.

View Badabum's full-sized avatar
💭
I may be slow to respond.

Ihor Korotenko Badabum

💭
I may be slow to respond.
  • Kyiv
View GitHub Profile
public static class JsonPatchDocumentExtensions
{
public static Result Apply<TModel>(this JsonPatchDocument<TModel> jsonPatchDocument, TModel model) where TModel : class
{
Result applyingResult = Result.Ok();
void InCaseOfError(JsonPatchError jsonPatchError) => applyingResult = Result.Failure(jsonPatchError.ErrorMessage);
jsonPatchDocument.ApplyTo(model, InCaseOfError);
return applyingResult;
}
public static Result<TModel, AppError> ApplyOps<TModel>(this JsonPatchDocument<TModel> jsonPatchDocument, TModel model) where TModel : class

Keybase proof

I hereby claim:

  • I am badabum on github.
  • I am ikorotenko (https://keybase.io/ikorotenko) on keybase.
  • I have a public key ASDuEPpUaRCqSPPqswGJRUxL1EfIiQk0fO7cyJCU2M9WQAo

To claim this, I am signing this object:

@Badabum
Badabum / Merge-Json.ps1
Created August 8, 2017 14:40
Merge two .json objects using PowerShell
function Join-Objects($source, $extend){
if($source.GetType().Name -eq "PSCustomObject" -and $extend.GetType().Name -eq "PSCustomObject"){
foreach($Property in $source | Get-Member -type NoteProperty, Property){
if($extend.$($Property.Name) -eq $null){
continue;
}
$source.$($Property.Name) = Join-Objects $source.$($Property.Name) $extend.$($Property.Name)
}
}else{
$source = $extend;