예제 #1
0
        /// <summary>
        /// The step execution method
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public override Task <InstallSetupResult> ExecuteAsync(bool?model)
        {
            if (model.HasValue && model.Value == false)
            {
                return(Task.FromResult <InstallSetupResult>(null));
            }

            //install the machine key
            var fileName = Current.IOHelper.MapPath($"{SystemDirectories.Root}/web.config");
            var xml      = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);

            // we only want to get the element that is under the root, (there may be more under <location> tags we don't want them)
            var systemWeb = xml.Root.Element("system.web");

            // Update appSetting if it exists, or else create a new appSetting for the given key and value
            var machineKey = systemWeb.Descendants("machineKey").FirstOrDefault();

            if (machineKey != null)
            {
                return(Task.FromResult <InstallSetupResult>(null));
            }

            var generator        = new MachineKeyGenerator();
            var generatedSection = generator.GenerateConfigurationBlock();

            systemWeb.Add(XElement.Parse(generatedSection));

            xml.Save(fileName, SaveOptions.DisableFormatting);

            return(Task.FromResult <InstallSetupResult>(null));
        }
        /// <summary>
        /// The step execution method
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public override InstallSetupResult Execute(bool?model)
        {
            if (model.HasValue && model.Value == false)
            {
                return(null);
            }

            //install the machine key
            var fileName = IOHelper.MapPath(string.Format("{0}/web.config", SystemDirectories.Root));
            var xml      = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);

            var systemWeb = xml.Root.DescendantsAndSelf("system.web").Single();

            // Update appSetting if it exists, or else create a new appSetting for the given key and value
            var machineKey = systemWeb.Descendants("machineKey").FirstOrDefault();

            if (machineKey != null)
            {
                return(null);
            }

            var generator        = new MachineKeyGenerator();
            var generatedSection = generator.GenerateConfigurationBlock();

            systemWeb.Add(XElement.Parse(generatedSection));

            xml.Save(fileName, SaveOptions.DisableFormatting);

            return(null);
        }
예제 #3
0
        public void GenerateMachineDecryptionKey()
        {
            var gen = new MachineKeyGenerator();

            Value = gen.GenerateDecryptionKey();
        }
예제 #4
0
        public void GenerateMachineValidationKey()
        {
            var gen = new MachineKeyGenerator();

            Value = gen.GenerateValidationKey();
        }