示例#1
0
 protected virtual string GetViewName(Type type)
 {
     return(Reflector.CleanTypeName(type));
 }
示例#2
0
        internal protected virtual Table Include(Type type, PropertyRoute?route)
        {
            if (schema.Tables.TryGetValue(type, out var result))
            {
                return(result);
            }

            if (this.Schema.IsCompleted) //Below for nop includes of Views referencing lites or entities
            {
                throw new InvalidOperationException("Schema already completed");
            }

            using (HeavyProfiler.LogNoStackTrace("Include", () => type.TypeName()))
            {
                if (type.IsAbstract)
                {
                    throw new InvalidOperationException(ErrorIncluding(route) + $"Impossible to include in the Schema the type {type} because is abstract");
                }

                if (!Reflector.IsEntity(type))
                {
                    throw new InvalidOperationException(ErrorIncluding(route) + $"Impossible to include in the Schema the type {type} because is not and Entity");
                }

                foreach (var t in type.Follow(a => a.BaseType))
                {
                    if (!t.IsSerializable)
                    {
                        throw new InvalidOperationException(ErrorIncluding(route) + $"Type {t.TypeName()} is not marked as serializable");
                    }
                }

                string cleanName = schema.Settings.desambiguatedNames?.TryGetC(type) ?? Reflector.CleanTypeName(EnumEntity.Extract(type) ?? type);

                if (schema.NameToType.ContainsKey(cleanName))
                {
                    throw new InvalidOperationException(ErrorIncluding(route) + @$ "Two types have the same cleanName '{cleanName}', desambiguate using Schema.Current.Settings.Desambiguate method:
{schema.NameToType[cleanName].FullName}
{type.FullName}");
                }

                try
                {
                    result = new Table(type);

                    schema.Tables.Add(type, result);
                    schema.NameToType[cleanName] = type;
                    schema.TypeToName[type]      = cleanName;

                    Complete(result);

                    return(result);
                }
                catch (Exception) //Avoid half-cooked tables
                {
                    schema.Tables.Remove(type);
                    schema.NameToType.Remove(cleanName);
                    schema.TypeToName.Remove(type);
                    throw;
                }
            }
        }
示例#3
0
 public static string GetKey(object queryName)
 {
     return(queryName is Type t?Reflector.CleanTypeName(EnumEntity.Extract(t) ?? t) :
                queryName.ToString() !);
 }
示例#4
0
        internal void Initialize()
        {
            if (!Initialized)
            {
                foreach (var es in EntitySettings.Values)
                {
                    if (string.IsNullOrEmpty(es.WebTypeName) && !es.StaticType.IsEmbeddedEntity())
                    {
                        es.WebTypeName = TypeLogic.TypeToName.TryGetC(es.StaticType) ?? Reflector.CleanTypeName(es.StaticType);
                    }
                }

                WebTypeNames = EntitySettings.Values.Where(es => es.WebTypeName.HasText())
                               .ToDictionary(es => es.WebTypeName, es => es.StaticType, StringComparer.InvariantCultureIgnoreCase, "WebTypeNames");


                Navigator.RegisterArea(typeof(Navigator), areaName: "Signum", resourcesNamespace: "Signum.Web.Signum");
                FileRepositoryManager.Register(new LocalizedJavaScriptRepository(typeof(JavascriptMessage), "Signum"));
                FileRepositoryManager.Register(new CalendarLocalizedJavaScriptRepository("~/Signum/calendarResources/"));
                FileRepositoryManager.Register(new UrlsRepository("~/Signum/urls/"));



                Schema.Current.ApplicationName = System.Web.Hosting.HostingEnvironment.ApplicationHost.GetPhysicalPath();

                if (Initializing != null)
                {
                    Initializing();
                }

                Initialized = true;
            }
        }
 protected virtual string GetComponentName(Type type)
 {
     return(Reflector.CleanTypeName(type));
 }
示例#6
0
    protected virtual IEnumerable <Module> GetModules()
    {
        var files = Directory.GetFiles(Path.Combine(GetProjectFolder(), "App"), "*.tsx", new EnumerationOptions {
            RecurseSubdirectories = true
        }).GroupToDictionary(a => Path.GetFileNameWithoutExtension(a));

        Dictionary <Type, bool> types = CandidateTypes().ToDictionary(a => a, a => files.ContainsKey(a.Name) || files.ContainsKey(Reflector.CleanTypeName(a)));

        return(ReactGetModules(types, this.SolutionName));
    }