Beispiel #1
0
        static DcTypeBase()
        {
            Assembly assembly = typeof(EntityBase).GetTypeInfo().Assembly;

            foreach (var t in assembly.DefinedTypes)
            {
                if (typeof(EntityBase).IsAssignableFrom(t.AsType()))
                {
                    var modelType = new ModelType(t);
                    DictionaryOfModelTypesKeyedOnTypeName.Add(modelType.TypeInfo.FullName, modelType);
                    DictionaryOfModelTypesKeyedOnTypeDbId.Add(modelType.TypeDbId, modelType);
                }
            }

            var allModelTypes = DictionaryOfModelTypesKeyedOnTypeName.Values;

            foreach (var modelType in allModelTypes)
            {
                modelType._NotAbstractTypeDbIds.AddRange(allModelTypes.Where(t => !t.TypeInfo.IsAbstract && modelType.TypeInfo.IsAssignableFrom(t.TypeInfo)).Select(t => t.TypeDbId));

                var baseType = modelType.TypeInfo.BaseType;

                while (baseType != null)
                {
                    ModelType baseModelType;
                    if (baseType.FullName != null &&
                        DictionaryOfModelTypesKeyedOnTypeName.TryGetValue(baseType.FullName, out baseModelType))
                    {
                        modelType._BaseTypeDbId = baseModelType.TypeDbId;
                        break;
                    }
                    baseType = baseType.GetTypeInfo().BaseType;
                }
            }
        }
Beispiel #2
0
 public static bool TryGetModelType(int typeDbId, out ModelType modelType)
 {
     return(DictionaryOfModelTypesKeyedOnTypeDbId.TryGetValue(typeDbId, out modelType));
 }