internal static SchemaMapInfo GetMapInfo() { var getStats = GetRuntimeStats(); var s = Schema.Current; var nodes = (from t in s.Tables.Values where s.IsAllowed(t.Type, true) == null let type = EnumEntity.Extract(t.Type) ?? t.Type select new TableInfo { typeName = TypeLogic.GetCleanName(t.Type), niceName = type.NiceName(), tableName = t.Name.ToString(), columns = t.Columns.Count, entityData = EntityKindCache.GetEntityData(t.Type), entityKind = EntityKindCache.GetEntityKind(t.Type), entityBaseType = GetEntityBaseType(t.Type), @namespace = type.Namespace !, rows = getStats.TryGetC(t.Name)?.rows, total_size_kb = getStats.TryGetC(t.Name)?.total_size_kb, rows_history = t.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.rows), total_size_kb_history = t.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.total_size_kb), mlistTables = t.TablesMList().Select(ml => new MListTableInfo { niceName = ml.PropertyRoute.PropertyInfo !.NiceName(), tableName = ml.Name.ToString(), rows = getStats.TryGetC(ml.Name)?.rows, total_size_kb = getStats.TryGetC(ml.Name)?.total_size_kb, history_rows = ml.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.rows), history_total_size_kb = ml.SystemVersioned?.Let(sv => getStats.TryGetC(sv.TableName)?.total_size_kb), columns = ml.Columns.Count, }).ToList()
protected virtual bool ShouldWriteExpression(ExpressionInfo ei) { return(EntityKindCache.GetEntityKind(ei.FromType) switch { EntityKind.Part or EntityKind.String or EntityKind.SystemString => false, _ => true, });
protected virtual bool ShouldWriteExpression(ExpressionInfo ei) { switch (EntityKindCache.GetEntityKind(ei.FromType)) { case EntityKind.Part: case EntityKind.String: case EntityKind.SystemString: return(false); default: return(true); } }
public static Dictionary <string, TypeInfoTS> GetEntities(IEnumerable <Type> allTypes) { var models = (from type in allTypes where typeof(ModelEntity).IsAssignableFrom(type) && !type.IsAbstract select type).ToList(); var queries = QueryLogic.Queries; var schema = Schema.Current; var settings = Schema.Current.Settings; var result = (from type in TypeLogic.TypeToEntity.Keys.Concat(models) where !type.IsEnumEntity() && !ReflectionServer.ExcludeTypes.Contains(type) let descOptions = LocalizedAssembly.GetDescriptionOptions(type) let allOperations = !type.IsEntity() ? null : OperationLogic.GetAllOperationInfos(type) select KVP.Create(GetTypeName(type), OnAddTypeExtension(new TypeInfoTS { Kind = KindOfType.Entity, FullName = type.FullName, NiceName = descOptions.HasFlag(DescriptionOptions.Description) ? type.NiceName() : null, NicePluralName = descOptions.HasFlag(DescriptionOptions.PluralDescription) ? type.NicePluralName() : null, Gender = descOptions.HasFlag(DescriptionOptions.Gender) ? type.GetGender().ToString() : null, EntityKind = type.IsIEntity() ? EntityKindCache.GetEntityKind(type) : (EntityKind?)null, EntityData = type.IsIEntity() ? EntityKindCache.GetEntityData(type) : (EntityData?)null, IsLowPopulation = type.IsIEntity() ? EntityKindCache.IsLowPopulation(type) : false, IsSystemVersioned = type.IsIEntity() ? schema.Table(type).SystemVersioned != null : false, ToStringFunction = typeof(Symbol).IsAssignableFrom(type) ? null : LambdaToJavascriptConverter.ToJavascript(ExpressionCleaner.GetFieldExpansion(type, miToString)), QueryDefined = queries.QueryDefined(type), Members = PropertyRoute.GenerateRoutes(type).Where(pr => InTypeScript(pr)) .ToDictionary(p => p.PropertyString(), p => { var mi = new MemberInfoTS { NiceName = p.PropertyInfo?.NiceName(), TypeNiceName = GetTypeNiceName(p.PropertyInfo?.PropertyType), Format = p.PropertyRouteType == PropertyRouteType.FieldOrProperty ? Reflector.FormatString(p) : null, IsReadOnly = !IsId(p) && (p.PropertyInfo?.IsReadOnly() ?? false), Unit = UnitAttribute.GetTranslation(p.PropertyInfo?.GetCustomAttribute <UnitAttribute>()?.UnitName), Type = new TypeReferenceTS(IsId(p) ? PrimaryKey.Type(type).Nullify() : p.PropertyInfo?.PropertyType, p.Type.IsMList() ? p.Add("Item").TryGetImplementations() : p.TryGetImplementations()), IsMultiline = Validator.TryGetPropertyValidator(p)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault()?.MultiLine ?? false, MaxLength = Validator.TryGetPropertyValidator(p)?.Validators.OfType <StringLengthValidatorAttribute>().FirstOrDefault()?.Max.DefaultToNull(-1), PreserveOrder = settings.FieldAttributes(p)?.OfType <PreserveOrderAttribute>().Any() ?? false, }; return(OnAddPropertyRouteExtension(mi, p)); }), Operations = allOperations == null ? null : allOperations.ToDictionary(oi => oi.OperationSymbol.Key, oi => OnAddOperationExtension(new OperationInfoTS(oi), oi, type)), RequiresEntityPack = allOperations != null && allOperations.Any(oi => oi.HasCanExecute != null), }, type))).ToDictionaryEx("entities"); return(result); }
static EntityBaseType GetEntityBaseType(Type type) { if (type.IsEnumEntity()) { return(EntityBaseType.EnumEntity); } if (typeof(Symbol).IsAssignableFrom(type)) { return(EntityBaseType.Symbol); } if (typeof(SemiSymbol).IsAssignableFrom(type)) { return(EntityBaseType.SemiSymbol); } if (EntityKindCache.GetEntityKind(type) == EntityKind.Part) { return(EntityBaseType.Part); } return(EntityBaseType.Entity); }
internal static SchemaMapInfo GetMapInfo(out List <MapColorProvider> providers) { var getStats = GetRuntimeStats(); var nodes = (from t in Schema.Current.Tables.Values let type = EnumEntity.Extract(t.Type) ?? t.Type select new TableInfo { findUrl = Finder.IsFindable(t.Type) ? Finder.FindRoute(t.Type) : null, webTypeName = Navigator.ResolveWebTypeName(t.Type), niceName = type.NiceName(), tableName = t.Name.ToString(), columns = t.Columns.Count, entityData = EntityKindCache.GetEntityData(t.Type), entityKind = EntityKindCache.GetEntityKind(t.Type), entityBaseType = GetEntityBaseType(t.Type), @namespace = type.Namespace, rows = getStats.GetOrThrow(t.Name).rows, total_size_kb = getStats.GetOrThrow(t.Name).total_size_kb, mlistTables = t.TablesMList().Select(ml => new MListTableInfo { niceName = ml.Field.Route.PropertyInfo.NiceName(), tableName = ml.Name.ToString(), rows = getStats.GetOrThrow(t.Name).rows, total_size_kb = getStats.GetOrThrow(t.Name).total_size_kb, columns = ml.Columns.Count, }).ToList() }).ToList(); providers = MapClient.GetColorProviders.GetInvocationListTyped().SelectMany(f => f()).OrderBy(a => a.Order).ToList(); var extraActions = providers.Select(a => a.AddExtra).NotNull().ToList(); if (extraActions.Any()) { foreach (var n in nodes) { foreach (var action in extraActions) { action(n); } } } var normalEdges = (from t in Schema.Current.Tables.Values from kvp in t.DependentTables() where !kvp.Value.IsCollection select new RelationInfo { fromTable = t.Name.ToString(), toTable = kvp.Key.Name.ToString(), lite = kvp.Value.IsLite, nullable = kvp.Value.IsNullable }).ToList(); var mlistEdges = (from t in Schema.Current.Tables.Values from tm in t.TablesMList() from kvp in tm.GetTables() select new RelationInfo { fromTable = tm.Name.ToString(), toTable = kvp.Key.Name.ToString(), lite = kvp.Value.IsLite, nullable = kvp.Value.IsNullable }).ToList(); return(new SchemaMapInfo { tables = nodes, relations = normalEdges.Concat(mlistEdges).ToList() }); }
internal static string GetEntityHelp(Type type) { string typeIs = HelpMessage._0IsA1.NiceToString().ForGenderAndNumber(type.BaseType.GetGender()).FormatWith(type.NiceName(), type.BaseType.NiceName()); string kind = HelpKindMessage.HisMainFunctionIsTo0.NiceToString(GetEntityKindMessage(EntityKindCache.GetEntityKind(type), EntityKindCache.GetEntityData(type), type.GetGender())); return(typeIs + ". " + kind + "."); }