private string AdjustTableToServerTableName(string tableName, IConfigData data) { // Server table names are of different format due to historical reasons try { var type = data.GetType(); MethodInfo methodInfo = type.GetMethod("GetServerTableName"); if (methodInfo != null) { return((string)methodInfo.Invoke(data, null)); } else { tableName = tableName.Replace("_Config", ""); tableName = tableName.Replace("_config", ""); tableName = Regex.Replace(tableName, "_[a-z]", m => m.ToString().Replace("_", "").ToUpper()); tableName = FirstCharToUpper(tableName); } } catch (AmbiguousMatchException) { // ambiguous means there is more than one result, // which means: a method with that name does exist return(tableName); } return(tableName); }
private bool IsBlobObject(IConfigData data) { try { var type = data.GetType(); MethodInfo methodInfo = type.GetMethod("IsBlob"); if (methodInfo == null) { return(false); } return((bool)methodInfo.Invoke(data, null)); } catch (AmbiguousMatchException) { // ambiguous means there is more than one result, // which means: a method with that name does exist return(true); } }
/// <summary> /// Make a new cache key using the object /// </summary> /// <param name="data">the object</param> public ConfigDataCacheKey(IConfigData data) { ObjectType = data.GetType(); BirthMark = string.Format("{0}_{1}", data.Type, data.UniqueKey); }
/// <summary> /// Gets the statically formatted filename for an entity /// </summary> /// <param name="entity">The entity in question</param> /// <returns>the filename</returns> public string GetEntityFilename(IConfigData entity) { return(string.Format("{0}.{1}", entity.UniqueKey, entity.GetType().Name)); }