public static IUiControl CreateControl(IFormChannelIdentifier channel, string namespaceName, string name)
 {
     return(UiControlFactoryPluginFacade.CreateControl(channel, namespaceName, name));
 }
Пример #2
0
 public object CreateProducer(IFormChannelIdentifier channel, string namespaceName, string name)
 {
     return(UiControlFactoryPluginFacade.CreateControl(channel, namespaceName, name));
 }
 public static IUiControl CreateControl(string channelName, string namespaceName, string name)
 {
     return(UiControlFactoryPluginFacade.CreateControl(new ChannelIdentifier(channelName), namespaceName, name));
 }
        private ElementCompileTreeNode HandleProducerElement(ElementCompileTreeNode element, List <PropertyCompileTreeNode> newProperties, string defaultOverloadPropertyName)
        {
            PropertyAssigner.AssignPropertiesToProducer(element, _compileContext);

            string replacingPropertyName = CompilerGlobals.DefaultPropertyName;

            if (defaultOverloadPropertyName != null)
            {
                replacingPropertyName = defaultOverloadPropertyName;
            }

            var    replacingProperty = new PropertyCompileTreeNode(replacingPropertyName, element.XmlSourceNodeInformation);
            object result            = ProducerMediatorPluginFacade.EvaluateProducer(element.XmlSourceNodeInformation.NamespaceURI, element.Producer);

            if (result is BindingProducer)
            {
                var bindingProducer = (BindingProducer)result;

                if (string.IsNullOrEmpty(bindingProducer.name))
                {
                    throw new FormCompileException("A binding declaraions is missing its name attribute", element.XmlSourceNodeInformation);
                }

                if (!_compileContext.RegistarBindingName(bindingProducer.name))
                {
                    throw new FormCompileException(string.Format("Name binding name {0} is used twice which is not allowed", bindingProducer.name), element.XmlSourceNodeInformation);
                }

                //if (_compileContext.GetBindingObject(bindingProducer.name) == null && !bindingProducer.optional)
                //{
                //    throw new FormCompileException(string.Format("The non optional binding {0} is missing its binding value", bindingProducer.name), element.XmlSourceNodeInformation);
                //}

                Type type = TypeManager.GetType(bindingProducer.type);

                _compileContext.SetBindingType(bindingProducer.name, type);
            }
            else if (_withDebug && result is IUiControl)
            {
                IUiControl uiControl = result as IUiControl;

                string debugControlNamespace;
                string debugControlName;
                UiControlFactoryPluginFacade.GetDebugControlName(_compileContext.CurrentChannel, out debugControlNamespace, out debugControlName);

                DebugUiControl debug = ProducerMediatorPluginFacade.CreateProducer(_compileContext.CurrentChannel, debugControlNamespace, debugControlName) as DebugUiControl;
                debug.UiControlID = _compileContext.GetNextDebugControlId;
                debug.UiControl   = uiControl;
                result            = debug;

                debug.UiControlID        = uiControl.UiControlID;
                debug.TagName            = element.XmlSourceNodeInformation.TagName;
                debug.SourceElementXPath = element.XmlSourceNodeInformation.XPath;


                foreach (CompileContext.IRebinding rd in _compileContext.Rebindings)
                {
                    if (ReferenceEquals(uiControl, rd.SourceProducer))
                    {
                        debug.Bindings.Add(new DebugUiControl.BindingInformation(
                                               rd.BindingObjectName,
                                               rd.DestinationObjectType,
                                               rd.PropertyName));
                    }
                }
            }

            replacingProperty.Value = result;

            newProperties.Add(replacingProperty);

            return(null);
        }