Exemplo n.º 1
0
        public static CommandBindingExpression GetExtensionCommand(this DotvvmControl control, string methodUsageId)
        {
            var propertyName = control.GetType().FullName + "/" + methodUsageId;
            var property     = DotvvmProperty.ResolveProperty(typeof(PropertyBox), propertyName);

            return(control.GetCommandBinding(property) as CommandBindingExpression);
        }
Exemplo n.º 2
0
        public static CommandBindingExpression?GetExtensionCommand(this DotvvmControl control, string methodUsageId)
        {
            var propertyName = control.GetType().FullName + "/" + methodUsageId;
            var property     = DotvvmProperty.ResolveProperty(typeof(PropertyBox), propertyName);

            if (property is null)
            {
                throw new Exception($"Extension command {propertyName} has not been registered.");
            }
            return(control.GetCommandBinding(property) as CommandBindingExpression);
        }
Exemplo n.º 3
0
        public static CommandBindingExpression RegisterExtensionCommand(this DotvvmControl control, Delegate action, string methodUsageId)
        {
            var bindingService = control.GetValue(Internal.RequestContextProperty).CastTo <IDotvvmRequestContext>()
                                 .Configuration.ServiceProvider.GetRequiredService <BindingCompilationService>();
            var id           = control.GetDotvvmUniqueId() + methodUsageId;
            var propertyName = control.GetType().FullName + "/" + methodUsageId;
            var property     = DotvvmProperty.ResolveProperty(typeof(PropertyBox), propertyName) ?? DotvvmProperty.Register(propertyName, typeof(object), typeof(PropertyBox), null, false, null, typeof(PropertyBox), throwOnDuplicitRegistration: false);
            var binding      = new CommandBindingExpression(bindingService, action, id);

            control.SetBinding(property, binding);
            return(binding);
        }
Exemplo n.º 4
0
        public override Type GetChildDataContextType(Type dataContext, DataContextStack controlContextStack, ResolvedControl control, DotvvmProperty dproperty = null)
        {
            var property = DotvvmProperty.ResolveProperty(control.Metadata.Type, PropertyName);
            ResolvedPropertySetter propertyValue;

            if (control.Properties.TryGetValue(property, out propertyValue))
            {
                var binding = propertyValue as ResolvedPropertyBinding;
                if (binding == null)
                {
                    return(dataContext);
                }
                return(binding.Binding.GetExpression().Type);
            }
            else
            {
                return(dataContext);
            }
        }