private InstallDestination CreateDestination(XmlNode sdest)
        {
            string asm = defaultAssembly;

            if ((sdest as XmlElement).HasAttribute(assemblyAttribute))
            {
                asm = sdest.Attributes[assemblyAttribute].Value;
            }

            string nsp = defaultDestinationNamespace;

            if ((sdest as XmlElement).HasAttribute(namespaceAttribute))
            {
                asm = sdest.Attributes[namespaceAttribute].Value;
            }

            string fullName = String.Format("{0}.{1}, {2}", nsp, sdest.Name, asm);
            Type   t        = Type.GetType(fullName);

            if (t != null)
            {
                InstallDestination inspected = t.GetConstructor(Type.EmptyTypes).Invoke(null) as InstallDestination;

                IComponentConfiguration config = new StandardConfiguration();
                foreach (XmlAttribute attribute in sdest.Attributes)
                {
                    config.Values[attribute.Name] = new Simple(attribute.Value);
                }

                return(ConfiguredComponent.ReconfigureInstance(inspected, inspected.GetType(), componentEnvironment, config));
            }

            throw new Exception(String.Format("The Install Destination {0} is not supported.", sdest.Name));
        }
        private InstallSource CreateSource(XmlNode src)
        {
            string asm = defaultAssembly;

            if ((src as XmlElement).HasAttribute(assemblyAttribute))
            {
                asm = src.Attributes[assemblyAttribute].Value;
            }

            string nsp = defaultSourceNamespace;

            if ((src as XmlElement).HasAttribute(namespaceAttribute))
            {
                asm = src.Attributes[namespaceAttribute].Value;
            }

            string fullName = String.Format("{0}.{1}, {2}", nsp, src.Name, asm);

            Type t = Type.GetType(fullName);

            if (t != null)
            {
                InstallSource inspected = t.GetConstructor(Type.EmptyTypes).Invoke(null) as InstallSource;

                IComponentConfiguration config = new StandardConfiguration();
                foreach (XmlAttribute attribute in src.Attributes)
                {
                    config.Values[attribute.Name] = new Simple(attribute.Value);
                }

                inspected = ConfiguredComponent.ReconfigureInstance(
                    inspected, inspected.GetType(), componentEnvironment, config);


                if (src.ChildNodes.Count == 1)
                {
                    PropertyInfo pinfo = t.GetProperty(childPropertyName);
                    if (pinfo == null)
                    {
                        throw new Exception(String.Format("Source {0} does not allow child sources", src.Name));
                    }
                    InstallSource child = CreateSource(src.ChildNodes[0]);
                    pinfo.SetValue(inspected, child, null);
                }

                else if (src.ChildNodes.Count > 1)
                {
                    PropertyInfo pinfo = t.GetProperty(childPropertyName);
                    if (pinfo == null)
                    {
                        throw new Exception(String.Format("Source {0} does not allow child sources", src.Name));
                    }

                    if (pinfo.GetIndexParameters().Length == 0)
                    {
                        throw new Exception(String.Format("Source {0} does not allow multiple child sources", src.Name));
                    }
                    int i = 0;
                    foreach (XmlNode node in src.ChildNodes)
                    {
                        InstallSource child = CreateSource(src.ChildNodes[0]);
                        pinfo.SetValue(inspected, child, new object[] { i });
                    }
                }

                return(inspected);
            }

            throw new Exception(String.Format("The Install Source {0} is not supported.", src.Name));
        }