Esempio n. 1
0
        public static SPDeployOptions GetStartParams(SPDeployOptions options)
        {
            var Result = new SPDeployOptions();

            var SyncProps    = GetPropsToSync();
            var SavedOptions = LoadSettings(options);
            var InlineParams = options.inlineparams;

            if (SavedOptions == null)
            {
                InlineParams = true;
                SavedOptions = new SPDeployOptions();
            }

            foreach (var SyncProp in SyncProps)
            {
                var SavedValue = SyncProp.GetValue(SavedOptions, null);
                var Value      = SyncProp.GetValue(options, null);

                if (SyncProp.PropertyType == typeof(Boolean))
                {
                    var ResultValueBool = (bool)Value ? Value : SavedValue;
                    SyncProp.SetValue(Result, ResultValueBool);
                }
                else
                {
                    var ResultValue = !String.IsNullOrEmpty((string)Value) ? Value : SavedValue;
                    SyncProp.SetValue(Result, ResultValue);
                }
            }
            Result.inlineparams = InlineParams;
            return(Result);
        }
Esempio n. 2
0
        public static void EchoCurrentParams(SPDeployOptions options)
        {
            if (GetConsoleWindow() != IntPtr.Zero)
            {
                Console.Clear();

                var SyncProps   = GetPropsToSync();
                var StartParams = GetStartParams(options);

                foreach (var SyncProp in SyncProps)
                {
                    var HelpTextString = SyncProp.Name;
                    var Value          = SyncProp.GetValue(options, null);

                    if ((SyncProp.Name.ToLower() != "password") && (Value != null))
                    {
                        var Attribute = SyncProp.CustomAttributes.Where(a => a.AttributeType == typeof(CommandLine.OptionAttribute)).FirstOrDefault();
                        if (Attribute != null)
                        {
                            var HelpText = Attribute.NamedArguments.Where(a => a.MemberName == "HelpText").FirstOrDefault();

                            if (HelpText != null)
                            {
                                HelpTextString = HelpText.TypedValue.ToString();
                            }
                        }
                        Console.Write(HelpTextString + ": ");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(Value);
                        Console.ResetColor();
                        Console.WriteLine();
                    }
                }
            }
        }
Esempio n. 3
0
        public static SPDeployOptions GetSettings(SPDeployOptions options)
        {
            var SyncProps   = GetPropsToSync();
            var StartParams = GetStartParams(options);

            if (GetConsoleWindow() != IntPtr.Zero)
            {
                if (StartParams.inlineparams)
                {
                    foreach (var SyncProp in SyncProps)
                    {
                        var HelpTextString = SyncProp.Name;
                        var Value          = SyncProp.GetValue(StartParams, null);

                        var Attribute = SyncProp.CustomAttributes.Where(a => a.AttributeType == typeof(CommandLine.OptionAttribute)).FirstOrDefault();
                        if (Attribute != null)
                        {
                            var HelpText = Attribute.NamedArguments.Where(a => a.MemberName == "HelpText").FirstOrDefault();

                            if (HelpText != null)
                            {
                                HelpTextString = HelpText.TypedValue.ToString();
                            }
                        }
                        Console.Write(HelpTextString);

                        if (SyncProp.PropertyType == typeof(Boolean))
                        {
                            var SavedValueBool = Convert.ToBoolean(Value);
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.Write(" (" + (SavedValueBool ? "Y" : "N") + ")");
                            Console.ResetColor();
                            Console.Write(": ");

                            var ConsoleValue = Console.ReadLine();
                            if (ConsoleValue == null)
                            {
                                ConsoleValue = "";
                            }
                            var SaveValueBool = (ConsoleValue.ToLower() == "y") ? true : ((ConsoleValue.ToLower() == "n") ? false : SavedValueBool);

                            SyncProp.SetValue(StartParams, SaveValueBool);
                        }
                        else
                        {
                            if (SyncProp.Name.ToLower() == "password")
                            {
                                if (!String.IsNullOrEmpty((string)Value))
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.Write(" (" + Value + ")");
                                    Console.ResetColor();
                                }
                                Console.Write(": ");

                                var ConsoleValue = GetPassword();
                                if (ConsoleValue == null)
                                {
                                    ConsoleValue = "";
                                }
                                var Encrypted = ConsoleValue;
                                if (Encrypted.Trim().Length > 0)
                                {
                                    var Decrypted = (new SpSimpleAES()).DecryptString(ConsoleValue);
                                    Encrypted = (new SpSimpleAES()).EncryptToString(Decrypted);
                                }
                                else
                                {
                                    if (!String.IsNullOrEmpty((string)Value))
                                    {
                                        var Decrypted = (new SpSimpleAES()).DecryptString((string)Value);
                                        Encrypted = (new SpSimpleAES()).EncryptToString(Decrypted);
                                    }
                                }
                                SyncProp.SetValue(StartParams, Encrypted);
                                Console.WriteLine();
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty((string)Value))
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.Write(" (" + Value + ")");
                                    Console.ResetColor();
                                }
                                Console.Write(": ");

                                var ConsoleValue = Console.ReadLine();
                                if (ConsoleValue == null)
                                {
                                    ConsoleValue = "";
                                }
                                ConsoleValue = ConsoleValue.Length > 0 ? ConsoleValue : (string)Value;

                                SyncProp.SetValue(StartParams, ConsoleValue);
                            }
                        }
                    }
                }
            }
            SaveSettings(StartParams);
            return(StartParams);
        }