public static object AutoSetCombinedKey(this ICombineKeyParser parser, object model, string key, object value) { if (model == null) { return(null); } SetProperty(model, key, value); return(model); }
public static string AutoGetCombinedKey(this ICombineKeyParser parser, object model, params string[] includeKeys) { if (model == null) { return(null); } var propertiesDic = GetGetPropertiesDic(model); return(parser.AutoGetCombinedKey(propertiesDic, includeKeys)); }
public static T SetCombinedKeyByProperties <T>(this T model, ICombineKeyParser parser = null) where T : IHasCombineKey <T> { if (model == null) { return(default(T)); } var includeKeyNames = model.GetIncludePropertyNames(); var combineKeyName = model.GetCombinedKeyName(); return(SetCombinedKeyByProperties(model, combineKeyName, includeKeyNames, parser)); }
public static object AutoSetCombinedKey(this ICombineKeyParser parser, object model, IDictionary <string, object> items, params string[] includeKeys) { if (model == null) { return(null); } var includedItems = SelectIncludeItems(items, includeKeys); foreach (var includedItem in includedItems) { SetProperty(model, includedItem.Key, includedItem.Value); } return(model); }
public static IDictionary <string, object> AutoSetCombinedKey(this ICombineKeyParser parser, IDictionary <string, object> model, string key, object value) { if (model == null) { return(null); } var theKey = model.Keys.SingleOrDefault(x => x.Equals(key, StringComparison.OrdinalIgnoreCase)); if (theKey != null) { model[theKey] = value; } return(model); }
public static IDictionary <string, object> AutoSetCombinedKey(this ICombineKeyParser parser, IDictionary <string, object> model, IDictionary <string, object> items, params string[] includeKeys) { if (model == null) { return(null); } var includedItems = SelectIncludeItems(items, includeKeys); foreach (var includedItem in includedItems) { if (model.ContainsKey(includedItem.Key)) { model[includedItem.Key] = includedItem.Value; } } return(model); }
public static string AutoGetCombinedKey(this ICombineKeyParser parser, IDictionary <string, object> items, params string[] includeKeys) { var includedItems = SelectIncludeItems(items, includeKeys); return(parser.CreateCombinedKey(includedItems)); }
public static T SetCombinedKeyByProperties <T>(this T model, string combinedKeyName, string[] includeKeyNames, ICombineKeyParser parser = null) { if (model == null) { return(default(T)); } if (includeKeyNames == null || includeKeyNames.Length == 0) { return(model); } if (string.IsNullOrWhiteSpace(combinedKeyName)) { return(model); } var combineKeyParser = parser ?? CombineKeyParser.Resolve(); var combinedKeyValue = combineKeyParser.AutoGetCombinedKey(model, includeKeyNames); SetProperty(model, combinedKeyName, combinedKeyValue); return(model); }
public static T SetPropertiesByCombinedKey <T>(this T model, string combinedKeyName, string[] includeKeyNames, ICombineKeyParser parser = null) { if (model == null) { return(default(T)); } if (includeKeyNames == null || includeKeyNames.Length == 0) { return(model); } if (string.IsNullOrWhiteSpace(combinedKeyName)) { return(model); } var combineKeyValue = GetProperty(model, combinedKeyName); if (combineKeyValue == null) { return(model); } var combineKeyParser = parser ?? CombineKeyParser.Resolve(); var includeKeys = combineKeyParser.ParseCombinedKey(combineKeyValue.ToString()); foreach (var includeKey in includeKeys) { SetProperty(model, includeKey.Key, includeKey.Value); } return(model); }