Example #1
0
        public StyleBuilder <T> Register <T>(Func <StyleMatchContext, bool> matcher = null, bool allowDerived = true)
            where T : DotvvmBindableObject
        {
            var styleBuilder = new StyleBuilder <T>(matcher, allowDerived);

            Styles.Add(styleBuilder.GetStyle());
            return(styleBuilder);
        }
Example #2
0
        public StyleBuilder <T> SetControlProperty <TControlType>(DotvvmProperty property, Action <StyleBuilder <TControlType> > styleBuilder = null,
                                                                  StyleOverrideOptions options = StyleOverrideOptions.Overwrite)
        {
            var innerControlStyleBuilder = new StyleBuilder <TControlType>(null, false);

            styleBuilder?.Invoke(innerControlStyleBuilder);

            style.SetProperties[property] = new CompileTimeStyleBase.PropertyControlCollectionInsertionInfo(property, options,
                                                                                                            new ControlResolverMetadata(typeof(TControlType)), innerControlStyleBuilder.GetStyle());

            return(this);
        }
Example #3
0
        public StyleBuilder <T> SetLiteralControlProperty(DotvvmProperty property, string text, StyleOverrideOptions options = StyleOverrideOptions.Overwrite)
        {
            var innerControlStyleBuilder = new StyleBuilder <RawLiteral>(null, false);

            var ctorParameters = new object[] {
                WebUtility.HtmlEncode(text),
                text,
                String.IsNullOrWhiteSpace(text)
            };

            var value = new CompileTimeStyleBase.PropertyControlCollectionInsertionInfo(property, options,
                                                                                        new ControlResolverMetadata(typeof(RawLiteral)), innerControlStyleBuilder.GetStyle(), ctorParameters);

            style.SetProperties.Add((property, value));;

            return(this);
        }
Example #4
0
        public StyleBuilder <T> SetHtmlControlProperty(DotvvmProperty property, string tag, Action <StyleBuilder <HtmlGenericControl> >?styleBuilder = null, StyleOverrideOptions options = StyleOverrideOptions.Overwrite)
        {
            if (tag == null)
            {
                throw new ArgumentNullException(nameof(tag));
            }

            var innerControlStyleBuilder = new StyleBuilder <HtmlGenericControl>(null, false);

            styleBuilder?.Invoke(innerControlStyleBuilder);

            var value = new CompileTimeStyleBase.PropertyControlCollectionInsertionInfo(property, options,
                                                                                        new ControlResolverMetadata(typeof(HtmlGenericControl)), innerControlStyleBuilder.GetStyle(), ctorParameters: new object[] { tag });

            style.SetProperties.Add((property, value));

            return(this);
        }