public void MergeEmptyChild()
        {
            ManagedList parent = new ManagedList();

            parent.Add("one");
            parent.Add("two");
            ManagedList child = new ManagedList();

            child.MergeEnabled = true;
            IList mergedList = (IList)child.Merge(parent);

            Assert.AreEqual(2, mergedList.Count);
        }
        public void MergeChildValueOverrideTheParents()
        {
            //doesn't make much sense in the context of a list...
            ManagedList parent = new ManagedList();

            parent.Add("one");
            parent.Add("two");
            ManagedList child = new ManagedList();

            child.Add("one");
            child.MergeEnabled = true;
            IList mergedList = (IList)child.Merge(parent);

            Assert.AreEqual(3, mergedList.Count);
        }
        internal static bool SetCollectionPropertyIfElementDefined(XmlElement element, ParserContext parserContext,
                                                                   ObjectDefinitionBuilder builder, string propertyName, string parentPropertyName, string parentId)
        {
            var propertyElement = element.GetSingleChildElement(propertyName.ToCamelCase());

            if (propertyElement != null)
            {
                var managedList = new ManagedList();

                foreach (XmlNode node in propertyElement)
                {
                    var parser           = NamespaceParserRegistry.GetParser(node.NamespaceURI);
                    var objectDefinition = parser.ParseElement((XmlElement)node, parserContext);

                    if (!string.IsNullOrEmpty(parentPropertyName))
                    {
                        //if the child object has a parent Property specified then set it as well for bi-directional relationships to work seamlessly.
                        objectDefinition.PropertyValues.Add(parentPropertyName, new RuntimeObjectReference(parentId));
                    }

                    managedList.Add(objectDefinition);
                }
                builder.AddPropertyValue(propertyName, managedList);

                return(true);
            }

            return(false);
        }
        protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder)
        {
            base.DoParse(element, builder);
            ParseSimpleProperties(element, builder);

            XmlNodeList subElements = element.ChildNodes;
            ManagedList locators    = new ManagedList(subElements.Count);
            ManagedList servers     = new ManagedList(subElements.Count);

            for (int i = 0; i < subElements.Count; i++)
            {
                XmlNode subElement = subElements.Item(i);
                if (subElement != null && subElement.NodeType == XmlNodeType.Element)
                {
                    if ("locator".Equals(subElement.LocalName))
                    {
                        locators.Add(ParseLocator((XmlElement)subElement));
                    }
                    if ("server".Equals(subElement.LocalName))
                    {
                        servers.Add(ParseServer((XmlElement)subElement));
                    }
                }
            }

            if (locators.Count > 0)
            {
                builder.AddPropertyValue("Locators", locators);
            }
            if (servers.Count > 0)
            {
                builder.AddPropertyValue("Servers", servers);
            }
        }
        public void MergeWithNullParent()
        {
            ManagedList child = new ManagedList();

            child.Add("one");
            child.MergeEnabled = true;
            Assert.AreSame(child, child.Merge(null));
        }
        public void MergeWithNonCompatibleParentType()
        {
            ManagedList child = new ManagedList();

            child.Add("one");
            child.MergeEnabled = true;
            Assert.Throws <InvalidOperationException>(() => child.Merge("hello"));
        }
        public void MergeWithNonCompatibleParentType()
        {
            ManagedList child = new ManagedList();

            child.Add("one");
            child.MergeEnabled = true;
            child.Merge("hello");
        }
        public static object ParseRefOrNestedObjectDeclaration(ParserContext parserContext, XmlElement element,
                                                               ObjectDefinitionBuilder builder, string refAttrName)
        {
            String attr   = element.GetAttribute(refAttrName);
            bool   hasRef = StringUtils.HasText(attr);


            XmlNodeList childNodes = element.ChildNodes;

            if (hasRef)
            {
                if (childNodes.Count > 0)
                {
                    //"either use the '" + refAttrName + "' attribute or a nested object declaration for '"
                    //+ element.getLocalName() + "' element, but not both", element);
                    parserContext.ReaderContext.ReportException(element, element.LocalName,
                                                                "either use the '" + refAttrName +
                                                                "' attribute or a nested object declaration for '"
                                                                + element.LocalName + "' element, but not both");
                }
                return(new RuntimeObjectReference(attr));
            }

            if (childNodes.Count == 0)
            {
                parserContext.ReaderContext.ReportException(element, element.LocalName,
                                                            "specify either '" + refAttrName +
                                                            "' attribute or a nested object declaration for '"
                                                            + element.LocalName + "' element");
            }
            // nested parse nested object definition
            if (childNodes.Count == 1)
            {
                if (childNodes[0].NodeType == XmlNodeType.Element)
                {
                    XmlElement childElement = (XmlElement)childNodes[0];
                    return(ParsePropertySubElement(childElement, builder.RawObjectDefinition, parserContext));
                }
            }


            ManagedList list = new ManagedList();

            for (int i = 0; i < childNodes.Count; i++)
            {
                XmlNode childNode = childNodes.Item(i);
                if (childNode != null && childNode.NodeType == XmlNodeType.Element)
                {
                    list.Add(ParsePropertySubElement((XmlElement)childNode, builder.RawObjectDefinition, parserContext));
                }
            }

            return(list);
        }
Exemple #9
0
        private static IManagedCollection ToList <TTargetType>(IEnumerable <IDefinition <TTargetType> > items)
        {
            var list = new ManagedList {
                ElementTypeName = typeof(TTargetType).FullName
            };

            foreach (var def in items.Select(i => i.DefinitionObject))
            {
                list.Add(def);
            }
            return(list);
        }
        /**
         * Parses the 'advice-chain' element's sub-elements.
         */
        private static void ConfigureAdviceChain(XmlNode adviceChainElement, ObjectDefinitionBuilder targetBuilder, ParserContext parserContext)
        {
            ManagedList adviceChain = new ManagedList();

            adviceChain.ElementTypeName = typeof(IAdvice).FullName;
            XmlNodeList childNodes = adviceChainElement.ChildNodes;

            for (int i = 0; i < childNodes.Count; i++)
            {
                XmlNode child = childNodes.Item(i);
                if (child.NodeType == XmlNodeType.Element)
                {
                    XmlElement childElement = (XmlElement)child;
                    string     localName    = child.LocalName;
                    if ("object".Equals(localName))
                    {
                        //ObjectDefinitionHolder holder = parserContext.ParserHelper.ParseObjectDefinitionElement(childElement, targetBuilder.ObjectDefinition);
                        IObjectDefinition def  = parserContext.ParserHelper.ParseCustomElement(childElement, targetBuilder.ObjectDefinition);
                        string            name = parserContext.ReaderContext.RegisterWithGeneratedName(def);
                        adviceChain.Add(new RuntimeObjectReference(name));
                    }
                    else if ("ref".Equals(localName))
                    {
                        String refatr = childElement.GetAttribute("object");
                        adviceChain.Add(new RuntimeObjectReference(refatr));
                    }
                    else
                    {
                        IObjectDefinition customBeanDefinition = parserContext.ParserHelper.ParseCustomElement(childElement, targetBuilder.ObjectDefinition);
                        if (customBeanDefinition == null)
                        {
                            parserContext.ReaderContext.ReportException(childElement, childElement.Name, "failed to parse custom element '" + localName + "'");
                        }
                    }
                }
            }
            targetBuilder.AddPropertyValue("adviceChain", adviceChain);
        }
        public ManagedList ParseInterceptors(XmlElement element, ParserContext parserContext)
        {
            ManagedList interceptors = new ManagedList();

            foreach (XmlNode child in element.ChildNodes)
            {
                /* TODO:
                 * check full elementname (incl. NamespaceUri)
                 */
                if (child.NodeType == XmlNodeType.Element)
                {
                    XmlElement childElement = (XmlElement)child;
                    string     localName    = child.LocalName;
                    if ("object".Equals(localName))
                    {
                        ObjectDefinitionHolder holder = parserContext.ParserHelper.ParseObjectDefinitionElement(childElement);
                        interceptors.Add(holder);
                    }
                    else if ("ref".Equals(localName))
                    {
                        string reference = childElement.GetAttribute("object");
                        interceptors.Add(new RuntimeObjectReference(reference));
                    }
                    else
                    {
                        if (!parsers.ContainsKey(localName))
                        {
                            parserContext.ReaderContext.ReportException(childElement, localName, "unsupported interceptor element");
                        }
                        IObjectDefinitionRegisteringParser parser = parsers[localName];
                        string interceptorObjectName = parser.Parse(childElement, parserContext);
                        interceptors.Add(new RuntimeObjectReference(interceptorObjectName));
                    }
                }
            }
            return(interceptors);
        }
Exemple #12
0
    private void CreatePlayer(string name)
    {
        if (players.Count >= 8)
        {
            return;
        }

        Player player;

        players.Add(player = new Player(name));

        GameObject listElement = Instantiate(playerListElementPrefab, playerListElementParent);

        listElement.GetComponentInChildren <Button>().onClick.AddListener(() =>
        {
            Destroy(listElement.gameObject);
            players.Remove(player);
        });
        listElement.GetComponentInChildren <Text>().text = name;
    }
Exemple #13
0
        protected override ObjectDefinitionBuilder ParseHandler(XmlElement element, ParserContext parserContext)
        {
            ObjectDefinitionBuilder builder     = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.HANDLER_PACKAGE + ".MessageHandlerChain");
            ManagedList             handlerList = new ManagedList();

            handlerList.ElementTypeName = typeof(IMessageHandler).FullName;
            XmlNodeList children = element.ChildNodes;

            for (int i = 0; i < children.Count; i++)
            {
                XmlNode child = children.Item(i);
                if (child.NodeType == XmlNodeType.Element && !"poller".Equals(child.LocalName))
                {
                    string childBeanName = ParseChild((XmlElement)child, parserContext, builder.ObjectDefinition);
                    handlerList.Add(new RuntimeObjectReference(childBeanName));
                }
            }
            builder.AddPropertyValue("handlers", handlerList);
            return(builder);
        }
        /// <summary>
        /// Creates and initialise the object definition that will be registered in your context.
        /// </summary>
        /// <param name="objectDefinitionService">The object definition service.</param>
        /// <returns></returns>
        public IObjectDefinition GetObjectDefinition(IObjectDefinitionService objectDefinitionService)
        {
            if (_interfaceType == null || String.IsNullOrEmpty(_interfaceType.FullName))
            {
                throw new ConfigurationErrorsException(string.Format("You are trying to bind a type to a null interface!"));
            }

            IConfigurableObjectDefinition objectDefinition;
            var conditionalList = new ManagedList();

            if (!objectDefinitionService.Registry.ContainsObjectDefinition(_interfaceType.FullName))
            {
                objectDefinition            = objectDefinitionService.Factory.CreateObjectDefinition(typeof(ConstrainableDuringLoadFactoryObject).AssemblyQualifiedName, null, AppDomain.CurrentDomain);
                objectDefinition.ObjectType = typeof(ConstrainableDuringLoadFactoryObject);
                objectDefinition.PropertyValues.Add("IsSingleton", _isStatic);
                objectDefinition.PropertyValues.Add("ConditionObjectDefinitions", conditionalList);
            }
            else
            {
                objectDefinition = (IConfigurableObjectDefinition)objectDefinitionService.Registry.GetObjectDefinition(_interfaceType.FullName);
                conditionalList  = (ManagedList)objectDefinition.PropertyValues.GetPropertyValue("ConditionObjectDefinitions").Value;
            }

            if (_constraintRegistry.ContainsKey(_interfaceType.FullName))
            {
                foreach (ConditionalObjectDefinition conditionalDefinition in _constraintRegistry[_interfaceType.FullName])
                {
                    IConfigurableObjectDefinition definition = objectDefinitionService.Factory.CreateObjectDefinition(typeof(ConditionalObjectDefinition).AssemblyQualifiedName, null, AppDomain.CurrentDomain);
                    definition.ConstructorArgumentValues.AddIndexedArgumentValue(0, conditionalDefinition.Condition);
                    definition.ConstructorArgumentValues.AddIndexedArgumentValue(1, conditionalDefinition.TypeName);
                    definition.ConstructorArgumentValues.AddIndexedArgumentValue(2, conditionalDefinition.IsDefault);

                    var ro = new RuntimeObjectReference(conditionalDefinition.TypeName);
                    definition.PropertyValues.Add("Instance", ro);

                    conditionalList.Add(definition);
                }
            }

            return(objectDefinition);
        }
Exemple #15
0
        public void ManagedList_CheckCollectionRaiseEvent()
        {
            _managedList = new ManagedList <int>();
            _managedList.CollectionChanged += HandleCollectionChange;

            _managedList.Add(1);
            AssertChangeIsRaised(1);

            _managedList.AddRange(new List <int>()
            {
                2, 3, 4, 5, 6, 7, 8, 9
            });
            AssertChangeIsRaised(9);

            _managedList.Remove(3);
            AssertChangeIsRaised(8);

            _managedList.RemoveAt(2);
            AssertChangeIsRaised(7);

            _managedList.Insert(2, 3);
            AssertChangeIsRaised(8);

            _managedList.RemoveAll(s => s == 3);
            AssertChangeIsRaised(7);

            _managedList.RemoveRange(2, 3);
            AssertChangeIsRaised(4);

            _managedList.InsertRange(2, new List <int>()
            {
                1, 2, 3
            });
            AssertChangeIsRaised(7);

            _managedList.Clear();
            AssertChangeIsRaised(0);
        }
        /// <summary>
        /// Collects all available video outputs from the device.
        /// </summary>
        private void fetchOutputs()
        {
            outputs = new ManagedList<V4LOutput>();
            v4l2_output cur = new v4l2_output();

            cur.index = 0;
            while (ioControl.EnumerateOutputs(ref cur) == 0)
            {
                outputs.Add(new V4LOutput(cur));
                cur.index++;
            }
        }
        private void ParseListener(XmlElement listenerEle, XmlElement containerEle, ParserContext parserContext)
        {
            var listenerDef = new RootObjectDefinition();

            // listenerDef.setSource(parserContext.extractSource(listenerEle));
            var aRef = listenerEle.GetAttribute(REF_ATTRIBUTE);

            if (string.IsNullOrWhiteSpace(aRef))
            {
                parserContext.ReaderContext.ReportFatalException(listenerEle, "Listener 'ref' attribute contains empty value.");
            }
            else
            {
                listenerDef.PropertyValues.Add("HandlerObject", new RuntimeObjectReference(aRef));
            }

            string method = null;

            if (listenerEle.HasAttribute(METHOD_ATTRIBUTE))
            {
                method = listenerEle.GetAttribute(METHOD_ATTRIBUTE);
                if (string.IsNullOrWhiteSpace(method))
                {
                    parserContext.ReaderContext.ReportFatalException(listenerEle, "Listener 'method' attribute contains empty value.");
                }
            }

            listenerDef.PropertyValues.Add("DefaultListenerMethod", method);

            if (containerEle.HasAttribute(MESSAGE_CONVERTER_ATTRIBUTE))
            {
                var messageConverter = containerEle.GetAttribute(MESSAGE_CONVERTER_ATTRIBUTE);
                if (string.IsNullOrWhiteSpace(messageConverter))
                {
                    parserContext.ReaderContext.ReportFatalException(containerEle, "Listener container 'message-converter' attribute contains empty value.");
                }
                else
                {
                    listenerDef.PropertyValues.Add("MessageConverter", new RuntimeObjectReference(messageConverter));
                }
            }

            var containerDef = RabbitNamespaceUtils.ParseContainer(containerEle, parserContext);

            if (listenerEle.HasAttribute(RESPONSE_EXCHANGE_ATTRIBUTE))
            {
                var responseExchange = listenerEle.GetAttribute(RESPONSE_EXCHANGE_ATTRIBUTE);
                listenerDef.PropertyValues.Add("ResponseExchange", responseExchange);
            }

            if (listenerEle.HasAttribute(RESPONSE_ROUTING_KEY_ATTRIBUTE))
            {
                var responseRoutingKey = listenerEle.GetAttribute(RESPONSE_ROUTING_KEY_ATTRIBUTE);
                listenerDef.PropertyValues.Add("ResponseRoutingKey", responseRoutingKey);
            }

            listenerDef.ObjectTypeName = "Spring.Messaging.Amqp.Rabbit.Listener.Adapter.MessageListenerAdapter";
            containerDef.PropertyValues.Add("MessageListener", listenerDef);

            var containerObjectName = containerEle.GetAttribute(ID_ATTRIBUTE);

            // If no object id is given auto generate one using the ReaderContext's ObjectNameGenerator
            if (string.IsNullOrWhiteSpace(containerObjectName))
            {
                containerObjectName = parserContext.ReaderContext.GenerateObjectName(containerDef);
            }

            if (!NamespaceUtils.IsAttributeDefined(listenerEle, QUEUE_NAMES_ATTRIBUTE) && !NamespaceUtils.IsAttributeDefined(listenerEle, QUEUES_ATTRIBUTE))
            {
                parserContext.ReaderContext.ReportFatalException(listenerEle, "Listener 'queue-names' or 'queues' attribute must be provided.");
            }

            if (NamespaceUtils.IsAttributeDefined(listenerEle, QUEUE_NAMES_ATTRIBUTE) && NamespaceUtils.IsAttributeDefined(listenerEle, QUEUES_ATTRIBUTE))
            {
                parserContext.ReaderContext.ReportFatalException(listenerEle, "Listener 'queue-names' or 'queues' attribute must be provided but not both.");
            }

            var queueNames = listenerEle.GetAttribute(QUEUE_NAMES_ATTRIBUTE);

            if (!string.IsNullOrWhiteSpace(queueNames))
            {
                var names  = StringUtils.CommaDelimitedListToStringArray(queueNames);
                var values = new ManagedList();
                foreach (var name in names)
                {
                    values.Add(new TypedStringValue(name.Trim()));
                }

                containerDef.PropertyValues.Add("QueueNames", values);
            }

            var queues = listenerEle.GetAttribute(QUEUES_ATTRIBUTE);

            if (!string.IsNullOrWhiteSpace(queues))
            {
                var names  = StringUtils.CommaDelimitedListToStringArray(queues);
                var values = new ManagedList();
                foreach (var name in names)
                {
                    values.Add(new RuntimeObjectReference(name.Trim()));
                }

                containerDef.PropertyValues.Add("Queues", values);
            }

            // Register the listener and fire event
            parserContext.Registry.RegisterObjectDefinition(containerObjectName, containerDef);
        }
        /// <summary>
        /// Collects all available audio inputs from the device.
        /// </summary>
        private void fetchAudioInputs()
        {
            audioInputs = new ManagedList<V4LAudioInput>();
            v4l2_audio cur = new v4l2_audio();

            cur.index = 0;
            while (ioControl.EnumerateAudioInputs(ref cur) == 0)
            {
                audioInputs.Add(new V4LAudioInput(this, cur));
                cur.index++;
            }
        }
Exemple #19
0
        /// <summary>
        /// Parses the validator definition.
        /// </summary>
        /// <param name="id">Validator's identifier.</param>
        /// <param name="element">The element to parse.</param>
        /// <param name="parserContext">The parser helper.</param>
        /// <returns>Validator object definition.</returns>
        private IObjectDefinition ParseValidator(string id, XmlElement element, ParserContext parserContext)
        {
            string typeName = GetTypeName(element);
            string parent   = GetAttributeValue(element, ObjectDefinitionConstants.ParentAttribute);

            string name = "validator: " + (StringUtils.HasText(id) ? id : this.definitionCount.ToString());

            MutablePropertyValues         properties = new MutablePropertyValues();
            IConfigurableObjectDefinition od
                = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition(
                      typeName, parent, parserContext.ReaderContext.Reader.Domain);

            od.PropertyValues = properties;
            od.IsSingleton    = true;
            od.IsLazyInit     = true;

            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.TestAttribute, properties, "Test");
            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.WhenAttribute, properties, "When");
            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.GroupFastValidateAttribute, properties, "FastValidate");
            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.RegexExpressionAttribute, properties, "Expression");
            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.CollectionValidateAllAttribute, properties, "ValidateAll");
            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.CollectionContextAttribute, properties, "Context");
            ParseAttributeIntoProperty(element, ValidatorDefinitionConstants.CollectionIncludeElementsErrors, properties, "IncludeElementErrors");

// TODO: (EE) - is this a mistake to check 'validateAll' but add 'context' then?
//            if (StringUtils.HasText(validateAll))
//            {
//                properties.Add("Context", context);
//            }

            ManagedList   nestedValidators   = new ManagedList();
            ManagedList   actions            = new ManagedList();
            ParserContext childParserContext = new ParserContext(parserContext.ParserHelper, od);

            foreach (XmlNode node in element.ChildNodes)
            {
                XmlElement child = node as XmlElement;
                if (child != null)
                {
                    switch (child.LocalName)
                    {
                    case ValidatorDefinitionConstants.PropertyElement:
                        string propertyName = GetAttributeValue(child, ValidatorDefinitionConstants.PropertyNameAttribute);
                        properties.Add(propertyName, base.ParsePropertyValue(child, name, childParserContext));
                        break;

                    case ValidatorDefinitionConstants.MessageElement:
                        actions.Add(ParseErrorMessageAction(child, childParserContext));
                        break;

                    case ValidatorDefinitionConstants.ActionElement:
                        actions.Add(ParseGenericAction(child, childParserContext));
                        break;

                    case ValidatorDefinitionConstants.ExceptionElement:
                        actions.Add(ParseExceptionAction(child, childParserContext));
                        break;

                    case ValidatorDefinitionConstants.ReferenceElement:
                        nestedValidators.Add(ParseValidatorReference(child, childParserContext));
                        break;

                    default:
                        nestedValidators.Add(ParseAndRegisterValidator(child, childParserContext));
                        break;
                    }
                }
            }
            if (nestedValidators.Count > 0)
            {
                properties.Add("Validators", nestedValidators);
            }
            if (actions.Count > 0)
            {
                properties.Add("Actions", actions);
            }

            return(od);
        }
Exemple #20
0
        private void Nouveau()
        {
            int    i            = 1;
            string originalName = "";

            switch (CurrentType)
            {
            case DBItemType.Template:
                ManagedItem  = Template.NewTemplate();
                originalName = ManagedItem.Name;
                while (true)
                {
                    if (ListTemplates.Any(t => t.Nom == ManagedItem.Name) || ListTemplates.Any(t => t.Nom == ManagedItem.Name + " (" + i + ")"))
                    {
                        ((Template)ManagedItem).Nom = originalName + " (" + i + ")";
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }
                FirePropertyChanged("ManagedItem");
                ListTemplates.Add((Template)ManagedItem);
                break;

            case DBItemType.Macro:
                ManagedItem  = Macro.newMacro();
                originalName = ManagedItem.Name;
                while (true)
                {
                    if (ListMacros.Any(t => t.Nom == ManagedItem.Name) || ListMacros.Any(t => t.Nom == ManagedItem.Name + " (" + i + ")"))
                    {
                        ((Macro)ManagedItem).Nom = originalName + " (" + i + ")";
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }
                ListMacros.Add((Macro)ManagedItem);
                break;

            case DBItemType.Meta:
                ManagedItem  = Meta.newMeta();
                originalName = ManagedItem.Name;
                while (true)
                {
                    if (ListMetas.Any(t => t.Nom == ManagedItem.Name) || ListMetas.Any(t => t.Nom == ManagedItem.Name + " (" + i + ")"))
                    {
                        ((Meta)ManagedItem).Nom = originalName + " (" + i + ")";
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }
                ListMetas.Add((Meta)ManagedItem);
                break;

            case DBItemType.Environment:
                ManagedItem  = LTG_Entity.Environment.newEnvironment();
                originalName = ManagedItem.Name;
                while (true)
                {
                    if (ListEnvironments.Any(t => t.Nom == ManagedItem.Name) || ListEnvironments.Any(t => t.Nom == ManagedItem.Name + " (" + i + ")"))
                    {
                        ((LTG_Entity.Environment)ManagedItem).Nom = originalName + " (" + i + ")";
                        i++;
                    }
                    else
                    {
                        break;
                    }
                }
                ListEnvironments.Add((LTG_Entity.Environment)ManagedItem);
                break;

            default:
                break;
            }

            ManagedList.Add(ManagedItem);

            try
            {
                SaveDB();
                //_dialogCoordinator.ShowMessageAsync(this, "Information", "les articles ont été sauvés");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                _dialogCoordinator.ShowMessageAsync(this, "Erreur", "Le nouvel élément n'a pas pu être créé");
            }

            //ArticleCourant = Article.NouvelArticle();
            //ListeArticles.Add(ArticleCourant);
        }
        /// <summary>
        /// Collects all available video inputs from the device.
        /// </summary>
        private void fetchInputs()
        {
            inputs = new ManagedList<V4LInput>();
            v4l2_input cur = new v4l2_input();

            cur.index = 0;
            while (ioControl.EnumerateInputs(ref cur) == 0)
            {
                inputs.Add(new V4LInput(this, cur));
                cur.index++;
            }
        }
        /// <summary>
        /// Collects all available TV standards from the device.
        /// </summary>
        private void fetchStandards()
        {
            standards = new ManagedList<V4LStandard>();
            v4l2_standard cur = new v4l2_standard();

            cur.index = 0;
            while (ioControl.EnumerateStandards(ref cur) == 0)
            {
                standards.Add(new V4LStandard(cur));
                cur.index++;
            }
        }
        /// <summary>
        /// Collects all available tuners from the device.
        /// </summary>
        private void fetchTuners()
        {
            tuners = new ManagedList<V4LTuner>();
            v4l2_tuner cur = new v4l2_tuner();

            cur.index = 0;
            while (ioControl.GetTuner(ref cur) == 0)
            {
                tuners.Add(new V4LTuner(this, cur.index, cur.type));
                cur.index++;
            }
        }