public static Dictionary <string, object> Cast(string fileName, long fileSize, string base64Content, string baseUrl) { var dict = new Dictionary <string, object>(); dict.Add("_links", D8HALJson.GetFileLinks(baseUrl)); dict.Add("filename", Value(fileName)); dict.Add("filemime", Value("application/octet-stream")); dict.Add("data", Value(base64Content)); //dict.Add("type" , D8HALJson.TargetIdField("file")); //dict.Add("filesize", Value(fileSize)); //dict.Add("uri" , Value($"public://test/{fileName}")); return(dict); }
private static KeyValuePair <string, object>?GetD8FieldAndValue(PropertyInfo prop, object sourceObj) { var attr = FindThisAttribute(prop); if (attr == null) { return(null); } var key = $"field_{GetFieldName(attr)}"; var val = prop.GetValue(sourceObj); return(new KeyValuePair <string, object> (key, D8HALJson.ValueField(val))); }
public static Dictionary <string, object> Cast <T>(T sourceObj, string baseUrl) where T : D8NodeBase { var dict = new Dictionary <string, object>(); dict.Add("title", ContentTitleAttribute.ToD8Field(sourceObj)); dict.Add("type", D8HALJson.TargetIdField(sourceObj.D8TypeName)); dict.Add("_links", D8HALJson.GetNodeLinks(sourceObj, baseUrl)); foreach (var field in _Attribute.FindInPropertiesOf(sourceObj)) { dict.Add(field.Key, field.Value); } return(dict); }
private static List <Dictionary <string, object> > Value <T>(T value) => D8HALJson.ValueField(value);
internal static List <Dictionary <string, object> > ToD8Field <T>(T sourceObj) where T : D8NodeBase => D8HALJson.ValueField(GetPropertyValue(sourceObj)?.ToString());