Example #1
0
        public static AutoUpdateProductDescriptor FromAssembly(Assembly assembly, Version version)
        {
            // create a product descriptor
            AutoUpdateProductDescriptor pd = new AutoUpdateProductDescriptor();

            // grab its assembly name
            AssemblyName assemblyName = assembly.GetName();

            // set the name of the product
            pd.Name = assemblyName.Name.Replace(".exe", null);

            // the version will be the starting folder name parsed to a version
            pd.Version = version;

            // create an assembly attribute reader
            AssemblyAttributeReader reader = new AssemblyAttributeReader(assembly);

            // set the product id
            ProductIdentifierAttribute pia = reader.GetProductIdentifierAttribute();

            if (pia != null)
            {
                pd.Id = pia.Id;
            }

            // set whether the exe requires registration
            RequiresRegistrationAttribute rra = reader.GetRequiresRegistrationAttribute();

            if (rra != null)
            {
                pd.RequiresRegistration = rra.RequiresRegistration;
            }

            return(pd);
        }
        /// <summary>
        /// Creates a descriptor that describes the product from it's assembly and version.
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        public static AutoUpdateProductDescriptor FromAssembly(Assembly assembly, Version version)
        {
            // create a product descriptor
            AutoUpdateProductDescriptor productDescriptor = new AutoUpdateProductDescriptor();

            // grab its assembly name
            AssemblyName assemblyName = assembly.GetName();

            // set the name of the product
            productDescriptor.Name = assemblyName.Name.Replace(".exe", null);

            // the version will be the starting folder name parsed to a version
            // this is based on the bootstrap's ability to look at folders and determine the appropriate
            // version. we view the versions of the product as a collection of assemblies as a whole, not
            // just individual assemblies. we do this to keep compiliation references together, we compile
            // for releases of versions, and therefore when one changes, we view that single changes as applying to a
            // particular update, which taken in context represents a version of the product.
            productDescriptor.Version = version;

            // snag the product id attribute from the assembly
            ProductIdentifierAttribute pia = ProductIdentifierAttribute.FromAssembly(assembly);

            if (pia != null)
            {
                productDescriptor.Id = pia.Id;
            }

            // snag the product requires registration attribute from the assembly
            ProductRequiresRegistrationAttribute rra = ProductRequiresRegistrationAttribute.FromAssembly(assembly);

            if (rra != null)
            {
                productDescriptor.RequiresRegistration = rra.RequiresRegistration;
            }

            return(productDescriptor);
        }