Exemple #1
0
        /// <summary>
        /// This function build a valid registry path in dependecy to the
        /// assembly information
        /// </summary>
        public virtual string BuildRegistryPath()
        {
            if (!string.IsNullOrEmpty(_registryPath))
            {
                return(_registryPath);
            }
            else
            {
                AssemblyAccessor accessor = new AssemblyAccessor(ReferenceAssembly, UseReflectionBasedAssemblyAccessor);

                if (string.IsNullOrEmpty(accessor.AssemblyCompany) || string.IsNullOrEmpty(accessor.AssemblyProduct))
                {
                    throw new NetSparkleException("Error: NetSparkle is missing the company or productname tag in " + ReferenceAssembly);
                }

                _registryPath = "Software\\" + accessor.AssemblyCompany + "\\" + accessor.AssemblyProduct + "\\AutoUpdate";
                return(_registryPath);
            }
        }
Exemple #2
0
        /// <summary>
        /// Constructor for Configuration -- should load values by the end of the constructor!
        /// </summary>
        /// <param name="referenceAssembly">the name of the reference assembly</param>
        /// <param name="isReflectionBasedAssemblyAccessorUsed"><c>true</c> if reflection is used to access the assembly.</param>
        protected Configuration(string referenceAssembly, bool isReflectionBasedAssemblyAccessorUsed)
        {
            // set default values
            InitWithDefaultValues();

            // set the value
            UseReflectionBasedAssemblyAccessor = isReflectionBasedAssemblyAccessorUsed;
            // save the reference assembly
            ReferenceAssembly = referenceAssembly;

            try
            {
                // set some value from the binary
                AssemblyAccessor accessor = new AssemblyAccessor(referenceAssembly, UseReflectionBasedAssemblyAccessor);
                ApplicationName  = accessor.AssemblyProduct;
                InstalledVersion = accessor.AssemblyVersion;
            }
            catch
            {
                CheckForUpdate = false;
            }
        }
        /// <summary>
        /// This function build a valid registry path in dependecy to the
        /// assembly information
        /// </summary>
        public virtual string GetSavePath()
        {
            if (!string.IsNullOrEmpty(_savePath))
            {
                return(_savePath);
            }
            else
            {
                AssemblyAccessor accessor = new AssemblyAccessor(ReferenceAssembly, UseReflectionBasedAssemblyAccessor);

                if (string.IsNullOrEmpty(accessor.AssemblyCompany) || string.IsNullOrEmpty(accessor.AssemblyProduct))
                {
                    throw new NetSparkleException("Error: SparkleUpdater is missing the company or productname tag in " + ReferenceAssembly);
                }
                var applicationFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify);
                var saveFolder        = Path.Combine(applicationFolder, accessor.AssemblyCompany, accessor.AssemblyProduct, "NetSparkleUpdater");
                if (!Directory.Exists(saveFolder))
                {
                    Directory.CreateDirectory(saveFolder);
                }
                var saveLocation = Path.Combine(saveFolder, "data.json");
                return(saveLocation);
            }
        }