Now able to get a field from a path

This commit is contained in:
2026-02-03 23:31:54 -06:00
parent 30236924a0
commit 2a016dad89
5 changed files with 86 additions and 3 deletions

View File

@@ -1,5 +1,3 @@
using System.Net.NetworkInformation;
namespace SzCore; namespace SzCore;
public static class SZ public static class SZ
@@ -130,4 +128,4 @@ public static class SZ
{ {
if (!IsInitalized) throw new Exception("SZ.Init has not been called."); if (!IsInitalized) throw new Exception("SZ.Init has not been called.");
} }
} }

View File

@@ -88,6 +88,33 @@ public class SzDataHandler
return SzResult<SzDataset>.Success(newDataset); return SzResult<SzDataset>.Success(newDataset);
} }
public async Task<SzResult<string>> GetFieldValueFromPath(string path)
{
var parts = path.Split('.');
if (parts.Length < 3) return SzResult<string>.Failure("Not enough arguments in path");
var datasetId = parts[0];
var dataObjectId = parts[1];
var fieldPath = string.Join(".", parts.Skip(2));
var datasetResult = await LoadDatasetAsync(datasetId);
if (!datasetResult.IsSuccess)
return SzResult<string>.Failure($"Could not get field value, dataset with id '{datasetId}' could not be loaded: {datasetResult.Error}");
var dataset = datasetResult.Value;
if (dataset is null) return SzResult<string>.Failure("Dataset was null somehow");
if (!dataset.DataObjects.TryGetValue(dataObjectId, out var dataObject))
return SzResult<string>.Failure($"Data object {dataObjectId} does not exist in dataset {datasetId}");
if (!dataObject.Fields.TryGetValue(fieldPath, out var field))
return SzResult<string>.Failure($"Field {fieldPath} does not exist in Data Object {dataObjectId}");
return SzResult<string>.Success(field.Value);
}
#endregion #endregion
#region Templates #region Templates

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1770115704,
"narHash": "sha256-KHFT9UWOF2yRPlAnSXQJh6uVcgNcWlFqqiAZ7OVlHNc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e6eae2ee2110f3d31110d5c222cd395303343b08",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

30
flake.nix Normal file
View File

@@ -0,0 +1,30 @@
{
description = "Session Zero development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
dotnet-sdk
omnisharp-roslyn
];
shellHook = ''
echo "// SESSION ZERO DEV SHELL //"
'';
};
});
};
}

View File

@@ -5,6 +5,7 @@ pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
dotnet-sdk dotnet-sdk
omnisharp-roslyn omnisharp-roslyn
]; ];
shellHook = '' shellHook = ''