コード例 #1
0
        private void DoInstall(InstallSource source, InstallDestination installDestination)
        {
            source.InstallEnvironment             = environment;
            installDestination.InstallEnvironment = environment;

            ApplicationDesc app = source.OpenForReading <ApplicationDesc>().Object;

            using (TypedStream <ApplicationDesc> appstream = installDestination.OpenForWriting <ApplicationDesc>())
            {
                appstream.Object = app;
            }

            /* register default bindings */
            foreach (string type in app.DefaultBindings.Keys)
            {
                documentManagement.RegisterDocumentUsage(
                    type, installDestination.ToString(), app.DefaultBindings[type]);
            }
        }
コード例 #2
0
        void DoCopy(InstallSource source, InstallDestination destination)
        {
            source.InstallEnvironment      = environment;
            destination.InstallEnvironment = environment;

            /* -- no, we don't do that anymore
             * if (destination.Exists)
             * {
             *  destination.Delete();
             * }
             */

            foreach (Type t in source.Types)
            {
                // Console.Out.WriteLine("{0}[{1}] -> {1}", source, t.Name, destination);
                TypedStream <object> dstStream = destination.OpenForWriting(t);
                using (TypedStream <object> srcStream = source.OpenForReading(t))
                {
                    dstStream.Array = srcStream.Array;
                    dstStream.Dispose();
                }
            }
        }
コード例 #3
0
        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));
        }