Esempio n. 1
0
        public RegisteredComponent AddComponent(Type classType, VueComponentOptions options)
        {
            var componentName = options.Name ?? classType.Name;
            var component     = new RegisteredComponent(classType, options);

            AddComponent(component);
            return(component);
        }
Esempio n. 2
0
        private void AddComponent(RegisteredComponent component)
        {
            var componentName = component.Options.Name ?? component.ModelType.Name;

            if (null != componentName)
            {
                var elementName = new StringBuilder(componentName);
                for (int i = 0; i < elementName.Length; i++)
                {
                    if (!Char.IsUpper(elementName[i]))
                    {
                        continue;
                    }

                    if (i == 0)
                    {
                        elementName = elementName.Replace(elementName[i], Char.ToLower(elementName[i]), 0, 1);
                        continue;
                    }

                    elementName = elementName.Replace(elementName[i].ToString(), $"-{Char.ToLower(elementName[i])}", i, 1);
                }

                if (RegisteredComponents.ContainsKey(componentName))
                {
                    throw new ArgumentException($"Component with name {componentName} already registered", nameof(component));
                }

                if (RegisteredComponents.ContainsKey(elementName.ToString()))
                {
                    throw new ArgumentException($"Component with name {elementName} already registered", nameof(component));
                }

                RegisteredComponents[componentName]          = component;
                RegisteredComponents[elementName.ToString()] = component;
            }
        }
Esempio n. 3
0
 public void NotifyUsed(RegisteredComponent component)
 {
     ComponentUsed?.Invoke(this, component);
 }