Esempio n. 1
0
        public override void OnLoaded()
        {
            _vueData.Initialize();

            Task.Run(() =>
            {
                BeforeVue();

                foreach (var comp in _componentTypes)
                {
                    Execute(CreateComponentTemplate(comp.Value));
                }

                Execute(VueTemplates.Format_VueCore(VueElementID,
                                                    _vueData.AsVueDataString(), base.IPCAvailable
                                                    .Select(x => $"'{x}':{x}")
                                                    .ToArray()));
            }).ContinueWith((t) =>
            {
                AggregateException ex = t.Exception;
                if (ex != null && ex.InnerExceptions.Count > 0)
                {
                    foreach (Exception x in ex.InnerExceptions)
                    {
                        WebAppLogger.Log(WebAppLogLevel.Error, $"[{x.GetType().Name}]{x.Message}");
                    }
                }
            });
        }
Esempio n. 2
0
        private string CreateComponentTemplate(Type compType)
        {
            if (!_componentTypes.ContainsKey(compType.Name))
            {
                throw new ArgumentException("Component [" + compType.Name + "] does not exist");
            }

            VueTemplateAttribute templateAtt = compType.GetCustomAttribute <VueTemplateAttribute>();

            if (templateAtt == null)
            {
                throw new InvalidOperationException("Missing VueComponentTemplateAttribute missing");
            }

            return(VueTemplates.Format_VueComponent(compType.Name,
                                                    VueComponent.GetVueProperties(compType, false)
                                                    .Select(x => $"{x.Name}: undefined").ToArray(),
                                                    VueComponent.GetVueMethods(compType, WebExposeType.All)
                                                    .Select(x => VueTemplates.Format_VueComponentCall(x.Name, x.GetCustomAttribute <VuePreventTickAttribute>() == null)).ToArray(),
                                                    WebContext.LoadStringResource(EntryAssembly ?? Assembly.GetEntryAssembly(), templateAtt.Resource)));
        }