/*private static void debug(ContainerRoot result)
        {
            var fact = new DefaultKevoreeFactory();
            var serializer = fact.createJSONSerializer();
            var modelStr = serializer.serialize(result);

            Console.WriteLine(modelStr);
        }*/
        private ContainerRoot Analyse(string typeDefName, string typeDefVersion, string typeDefPackage, string packageName, string packageVersion)
        {
            KevoreeFactory kevoreeFactory = new DefaultKevoreeFactory();
            ContainerRoot containerRoot = null;

            var filteredAssemblyTypes = new HashSet<DeployUnit>(_exports).Where(x => _annotationHelper.FilterByAttribute(x.GetType(), EXPECTED_TYPES)).ToList();
            if (!filteredAssemblyTypes.Any())
            {
                log.Error("None of the expected types have been found (Component, Channel, Node, Group)");
            }
            else if (filteredAssemblyTypes.Count > 0)
            {
                containerRoot = kevoreeFactory.createContainerRoot();
                kevoreeFactory.root(containerRoot);
                // A type found (nominal)
                /*
                 * Initialisation a type definition (container root) with information common to all the components types.
                 */
                var typedefinedObject = filteredAssemblyTypes[0];
                TypeDefinition typeDefinitionType = GenericComponentDefinition(typeDefName, typeDefVersion, typeDefPackage, packageName, packageVersion, kevoreeFactory, containerRoot, typedefinedObject);

                /* each of those types inherits from TypeDefinition.
                 Only ChannelType and ComponentType are specialized.
                 NodeType and GroupType inherits from TypeDefinition without any specificity */
                if (typeDefinitionType is ComponentTypeImpl)
                {
                    log.Debug("Component type");
                    CompleteComponentTypeDefinition(typedefinedObject, (ComponentTypeImpl)typeDefinitionType, kevoreeFactory);
                }
                else if (typeDefinitionType is ChannelTypeImpl)
                {
                    log.Debug("Channel type");
                    CompleteChannelTypeDefinition(typedefinedObject, (ChannelTypeImpl)typeDefinitionType, kevoreeFactory);
                }
                else if (typeDefinitionType is NodeTypeImpl)
                {
                    // nothing to do
                    log.Debug("Node type");
                    CompleteNodeTypeDefinition(typedefinedObject, (NodeTypeImpl)typeDefinitionType, kevoreeFactory);
                }
                else if (typeDefinitionType is GroupTypeImpl)
                {
                    // nothing to do
                    log.Debug("Group type");
                    CompleteGroupTypeDefinition(typedefinedObject, (GroupTypeImpl)typeDefinitionType, kevoreeFactory);
                }

                if (typeDefinitionType.getDictionaryType() == null)
                {
                    typeDefinitionType.setDictionaryType(kevoreeFactory.createDictionaryType());
                }

                if (typeDefinitionType.getDictionaryType().getAttributes() == null)
                {
                    typeDefinitionType.getDictionaryType().setAttributes(new ArrayList());
                }
            }

            return containerRoot;
        }