Exemple #1
0
            ///////////////////////////////////////////////////////////////////

            private static CreateFlags GetCreateFlags(
                NameValueCollection appSettings,
                CreateFlags @default
                )
            {
                try
                {
                    string value = Utility.GetEnvironmentVariable(
                        CreateFlags, true, true);

                    if (String.IsNullOrEmpty(value) && (appSettings != null))
                    {
                        value = appSettings[CreateFlags];
                    }

                    //
                    // NOTE: Were we able to get the value from somewhere?
                    //
                    if (!String.IsNullOrEmpty(value))
                    {
                        Result error = null;

                        object enumValue = Utility.TryParseFlagsEnum(
                            null, typeof(CreateFlags), @default.ToString(),
                            value, null, true, true, true, ref error);

                        if (enumValue is CreateFlags)
                        {
                            return((CreateFlags)enumValue);
                        }
                    }
                }
                catch
                {
                    // do nothing.
                }

                return(@default);
            }
Exemple #2
0
        public string Save(string title,
                           string section,
                           string text,
                           string summary,
                           MinorFlags minor,
                           CreateFlags create,
                           WatchFlags watch,
                           SaveFlags mode,
                           bool bot,
                           string basetimestamp,
                           string starttimestamp,
                           string token)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentException("Title shouldn't be empty.", "title");
            }
            if (string.IsNullOrEmpty(token))
            {
                throw new ArgumentException("Token shouldn't be empty.", "token");
            }

            ParameterCollection parameters = new ParameterCollection
            {
                { "title", title },
                { "token", token }
            };
            if (mode == SaveFlags.Replace && !string.IsNullOrEmpty(section))
            {
                parameters.Add("section", section);
            }
            if (minor != MinorFlags.None)
            {
                parameters.Add(minor.ToString().ToLower());
            }
            if (create != CreateFlags.None)
            {
                parameters.Add(create.ToString().ToLower());
            }
            if (watch != WatchFlags.None)
            {
                parameters.Add("watchlist", watch.ToString().ToLower());
            }
            if (mode == SaveFlags.Append)
            {
                parameters.Add("appendtext", text);
            }
            else if (mode == SaveFlags.Prepend)
            {
                parameters.Add("prependtext", text);
            }
            else
            {
                parameters.Add("text", text);
            }
            if (bot)
            {
                parameters.Add("bot");
            }
            if (!string.IsNullOrEmpty(basetimestamp))
            {
                parameters.Add("basetimestamp", basetimestamp);
            }
            if (!string.IsNullOrEmpty(starttimestamp))
            {
                parameters.Add("starttimestamp", starttimestamp);
            }
            if (!string.IsNullOrEmpty(summary))
            {
                parameters.Add("summary", summary);
            }

            try
            {
                XmlDocument xml = MakeRequest(Action.Edit, parameters);
                XmlNode result = xml.SelectSingleNode("//edit[@newrevid]");
                if (result != null)
                {
                    return result.Attributes["newrevid"].Value;
                }
            }
            catch (WebException e)
            {
                throw new WikiException("Saving failed", e);
            }
            return null;
        }
Exemple #3
0
        ///////////////////////////////////////////////////////////////////////

        #region System.Object Overrides
        public override string ToString()
        {
            StringList list = new StringList();

            list.Add("args");
            list.Add((args != null) ? args.ToString() : null);

            list.Add("culture");
            list.Add(culture);

            list.Add("createFlags");
            list.Add(createFlags.ToString());

            list.Add("initializeFlags");
            list.Add(initializeFlags.ToString());

            list.Add("scriptFlags");
            list.Add(scriptFlags.ToString());

            list.Add("interpreterFlags");
            list.Add(interpreterFlags.ToString());

            list.Add("appDomain");
            list.Add((appDomain != null) ? appDomain.ToString() : null);

            list.Add("host");
            list.Add((host != null) ? host.ToString() : null);

            list.Add("profile");
            list.Add(profile);

            list.Add("owner");
            list.Add((owner != null) ? owner.ToString() : null);

            list.Add("applicationObject");
            list.Add((applicationObject != null) ?
                     applicationObject.ToString() : null);

            list.Add("policyObject");
            list.Add((policyObject != null) ?
                     policyObject.ToString() : null);

            list.Add("resolverObject");
            list.Add((resolverObject != null) ?
                     resolverObject.ToString() : null);

            list.Add("userObject");
            list.Add((userObject != null) ? userObject.ToString() : null);

            list.Add("policies");
            list.Add((policies != null) ? policies.ToString() : null);

            list.Add("traces");
            list.Add((traces != null) ? traces.ToString() : null);

            list.Add("text");
            list.Add(text);

            list.Add("libraryPath");
            list.Add(libraryPath);

            list.Add("autoPathList");
            list.Add((autoPathList != null) ? autoPathList.ToString() : null);

            return(list.ToString());
        }