/// <summary> /// Gets the ModelClass attribute for a generated entity model class. /// </summary> private static ModelClassAttribute GetModelClassAttribute(Type type) { ModelClassAttribute result = null; object[] attributes = type.GetCustomAttributes(typeof(ModelClassAttribute), false); if (attributes.Length > 0) { result = (ModelClassAttribute)attributes[0]; } return(result); }
/// <summary> /// Gets the ID of the type represented by a C# class. /// </summary> /// <param name="type"></param> /// <returns></returns> public long GetTypeId(Type type) { long id; if (!_strongTypeIdCache.TryGetValue(type, out id)) { id = -1; if (type != typeof(Entity)) { ModelClassAttribute modelClass = GetModelClassAttribute(type); if (modelClass != null) { id = EntityIdentificationCache.GetId(modelClass.TypeAlias); } } _strongTypeIdCache[type] = id; } return(id); }