예제 #1
0
        public ComponentInfo Load(ComponentDiscover discover)
        {
            var type = discover.File.ViewModel == null ?
                       typeof(ViewModel) :
                       discover.Assembly.GetType(discover.File.ViewModel, true);

            var component = new ComponentInfo
            {
                Name           = discover.Name,
                Template       = this.Compile(discover.File.Template),
                InheritAttrs   = discover.File.InheritAttrs ?? true,
                Styles         = discover.File.Styles.Select(x => this.Compile(x)).ToList(),
                Scripts        = discover.File.ClientScripts.Select(x => this.Compile(x)).ToList(),
                Includes       = discover.File.Includes,
                IsAutenticated = discover.File.IsAutenticated,
                Roles          = discover.File.Roles.ToArray(),
                ViewModelType  = type,
                JsonData       = this.GetJsonData(type),
                Props          = this.GetProps(type).ToList(),
                Locals         = this.GetLocals(type).ToList(),
                Computed       = this.GetComputed(type).ToDictionary(x => x.Key, x => x.Value),
                Methods        = this.GetMethods(type).ToDictionary(x => x.Method.Name, x => x)
            };

            return(component);
        }
예제 #2
0
파일: Config.cs 프로젝트: uzbekdev1/DotVue
        /// <summary>
        /// Add new assembly into vue handler components
        /// </summary>
        public void AddAssembly(Assembly assembly)
        {
            foreach (var resourceName in assembly
                     .GetManifestResourceNames()
                     .Where(x => Path.GetExtension(x) == Extension))
            {
                var file = new HtmlFile(assembly.GetManifestResourceStream(resourceName));
                var name = file.Name ?? ComponentLoader.GetName(resourceName);

                _discovers[name] = new ComponentDiscover
                {
                    Name     = name,
                    Assembly = assembly,
                    File     = file
                };
            }
        }
예제 #3
0
파일: Config.cs 프로젝트: uzbekdev1/DotVue
        /// <summary>
        /// Add new assembly into vue handler components
        /// </summary>
        private void AddWebFiles(string root, Assembly assembly)
        {
            foreach (var path in Directory.GetFiles(root, "*" + Extension, SearchOption.AllDirectories))
            {
                var file = new HtmlFile(File.OpenRead(path));
                var name = file.Name ?? ComponentLoader.GetName(path.Replace(@"\", "."));

                _discovers[name] = new ComponentDiscover
                {
                    Name     = name,
                    Assembly = assembly,
                    File     = file
                };

                // remove component to be re-loaded on next Load method (only for debug)
                _components.Remove(name);
            }
        }