public ControlResolverMetadata(ControlType controlType) : base(controlType)
        {
            this.controlType = controlType;

            DataContextChangeAttributes = Type.GetCustomAttributes<DataContextChangeAttribute>(true).ToArray();
			DataContextManipulationAttribute = Type.GetCustomAttribute<DataContextStackManipulationAttribute>(true);
			if (DataContextManipulationAttribute != null && DataContextChangeAttributes.Any())
				throw new Exception($"{nameof(DataContextChangeAttributes)} and {nameof(DataContextManipulationAttribute)} can not be set at the same time at control '{controlType.Type.FullName}'.");
        }
Example #2
0
 protected bool Equals(ControlType other)
 {
     return Equals(Type, other.Type) && Equals(ControlBuilderType, other.ControlBuilderType);
 }
Example #3
0
 /// <summary>
 /// Resolves the control metadata for specified type.
 /// </summary>
 public ControlResolverMetadata ResolveControl(ControlType controlType)
 {
     return cachedMetadata.GetOrAdd(controlType.Type, _ => BuildControlMetadata(controlType));
 }
Example #4
0
        /// <summary>
        /// Gets the control metadata.
        /// </summary>
        private ControlResolverMetadata BuildControlMetadata(ControlType type)
        {
            var attribute = type.Type.GetCustomAttribute<ControlMarkupOptionsAttribute>();

            var properties = GetControlProperties(type.Type);
            var metadata = new ControlResolverMetadata()
            {
                Name = type.Type.Name,
                Namespace = type.Type.Namespace,
                HasHtmlAttributesCollection = typeof(IControlWithHtmlAttributes).IsAssignableFrom(type.Type),
                Type = type.Type,
                ControlBuilderType = type.ControlBuilderType,
                Properties = properties,
                IsContentAllowed = attribute.AllowContent,
                VirtualPath = type.VirtualPath,
                DataContextConstraint = type.DataContextRequirement,
                DefaultContentProperty = attribute.DefaultContentProperty != null ? properties[attribute.DefaultContentProperty] : null
            };
            return metadata;
        }
Example #5
0
 /// <summary>
 /// Resolves the control metadata for specified type.
 /// </summary>
 public ControlResolverMetadata ResolveControl(ControlType controlType)
 {
     return(cachedMetadata.GetOrAdd(controlType, _ => BuildControlMetadata(controlType)));
 }