public static bool AddCustomFieldToSchema(string customType, string schemaKey, Dictionary<string, object> schemaData, string newFieldName, bool isList, out string error) { bool result = IsFieldNameValid(schemaKey, newFieldName, out error); if (result) { if (isList) { result = schemaData.TryAddValue(newFieldName, new List<object>()); schemaData.Add(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, newFieldName), customType); schemaData.Add(string.Format(GDEConstants.MetaDataFormat, GDEConstants.IsListPrefix, newFieldName), true); } else { result = schemaData.TryAddValue(newFieldName, "null"); schemaData.Add(string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, newFieldName), customType); } AddFieldToListByFieldName(newFieldName, schemaKey); AddCustomFieldToItems(customType, schemaKey, newFieldName, isList); } return result; }
public static bool AddBasicFieldToSchema(BasicFieldType type, string schemaKey, Dictionary<string, object> schemaData, string newFieldName, out string error, bool isList = false, object defaultValue = null) { string typeKey = string.Format(GDEConstants.MetaDataFormat, GDEConstants.TypePrefix, newFieldName); error = ""; bool result = IsFieldNameValid(schemaKey, newFieldName, out error); if (result) { if (isList) { result = schemaData.TryAddValue(newFieldName, new List<object>()); schemaData.Add(typeKey, type); schemaData.Add(string.Format(GDEConstants.MetaDataFormat, GDEConstants.IsListPrefix, newFieldName), true); } else { result = schemaData.TryAddValue(newFieldName, defaultValue); schemaData.Add(typeKey, type); } AddFieldToListByFieldName(newFieldName, schemaKey); AddBasicFieldToItems(type, schemaKey, newFieldName, isList, defaultValue); } return result; }