Files
WebServer.Test/WebServer/Extensions/ExpandoObject.cs
Kaveman a92acf0597 Update Test Site
+ Localized everything - No external resources required on the front-end
 + `test123` tested Layouts with relative paths.. issue is, its always relative from root
2024-08-18 03:27:36 -07:00

25 lines
860 B
C#

using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Text;
namespace WebServer.Extensions {
public static class ExpandoObjectExt {
public static object GetPropertyOrDefault(this ExpandoObject expando, string propertyName, object defaultValue) {
if (expando is IDictionary<string, object> dict) {
if (!dict.TryGetValue(propertyName, out var result))
dict.Add(propertyName, result = defaultValue);
return result;
}
return defaultValue;
}
public static bool TryGetProperty(this ExpandoObject expando, string propertyName, out object value) {
value = null;
return expando is IDictionary<string, object> dict
&& dict.TryGetValue(propertyName, out value);
}
}
}