public static IObjectDataValue CreateObjectValue <T>(this IObjectData data, T value, Action <T, IObjectData, bool> saveObject, string name, bool overwrite, bool omitDefault) { // argument checks Debug.Assert(data != null); Debug.Assert(saveObject != null); Debug.Assert(name != null || overwrite == false); IObjectData objectData = null; if (value != null) { // get IObjectData into which the value saves its contents if (overwrite) { // overwirte mode objectData = data.GetObjectValue(name, defaultValue: null); } if (objectData == null) { // create a empty IObjectData objectData = data.CreateObject(); } // save the value's contents saveObject(value, objectData, omitDefault); } return(data.CreateValue(objectData)); }