Esempio n. 1
0
        /// <summary>
        /// Sets the view arguments.
        /// </summary>
        public virtual void SetArgs(string args)
        {
            Args.Clear();

            if (!string.IsNullOrEmpty(args))
            {
                Args = new SortedList <string, string>();
                string[] parts = args.Split('&');

                foreach (string part in parts)
                {
                    string key;
                    string val;
                    int    idx = part.IndexOf("=");

                    if (idx >= 0)
                    {
                        key = part.Substring(0, idx).Trim();
                        val = part.Substring(idx + 1).Trim();
                    }
                    else
                    {
                        key = part.Trim();
                        val = "";
                    }

                    Args[key] = val;
                }
            }
        }
Esempio n. 2
0
        public void TestStaticNameSpace()
        {
            Service service = Connect();

            Args splunkNameSpace = new Args();

            splunkNameSpace.Add("app", "search");
            Assert.AreEqual("/servicesNS/-/search/", service.Fullpath("", splunkNameSpace), "Expected the path URL to be /servicesNS/-/search/");

            splunkNameSpace.Clear();
            splunkNameSpace.Add("owner", "Bob");
            Assert.AreEqual("/servicesNS/Bob/-/", service.Fullpath("", splunkNameSpace), "Expected path URL to be /servicesNS/Bob/-/");

            splunkNameSpace.Clear();
            splunkNameSpace.Add("sharing", "app");
            Assert.AreEqual("/servicesNS/nobody/-/", service.Fullpath("", splunkNameSpace), "Expected path URL to be /servicesNS/nobody/-/");

            splunkNameSpace.Clear();
            splunkNameSpace.Add("sharing", "system");
            Assert.AreEqual("/servicesNS/nobody/system/", service.Fullpath("", splunkNameSpace), "Expected path URL to be /servicesNS/nobody/system/");
        }
Esempio n. 3
0
        protected override void CompileOptions(ToolbarGump toolbar, GumpButton clicked, Point loc, MenuGumpOptions opts)
        {
            if (toolbar == null)
            {
                return;
            }

            base.CompileOptions(toolbar, clicked, loc, opts);

            PlayerMobile user = toolbar.User;

            if (!CanEdit && user.AccessLevel < Toolbars.Access)
            {
                return;
            }

            opts.Replace(
                "Set Value",
                new ListGumpEntry(
                    "Set Command",
                    b => SuperGump.Send(
                        new InputDialogGump(user, toolbar)
            {
                Title     = "Set Command",
                Html      = "Set the command for this Command entry.",
                InputText = base.Value,
                Callback  = (cb, text) =>
                {
                    Value = text;
                    toolbar.Refresh(true);
                }
            }),
                    toolbar.HighlightHue));

            opts.AppendEntry(
                new ListGumpEntry(
                    "Set Args",
                    b => SuperGump.Send(
                        new InputDialogGump(user, toolbar)
            {
                Title     = "Set Command Arguments",
                Html      = "Set the Arguments for this Command entry.\nSeparate your entries with a semi-colon- ;",
                InputText = String.Join(";", Args),
                Callback  = (cb, text) =>
                {
                    Args.Clear();
                    Args.AddRange(text.Split(';'));
                    toolbar.Refresh(true);
                }
            }),
                    toolbar.HighlightHue));
        }
Esempio n. 4
0
        public void Compile(GMAssets _assets)
        {
            switch (Kind)
            {
            case eAction.ACT_VARIABLE:
                if (Relative)
                {
                    Code = Code + Args[0] + " += " + Args[1];
                }
                else
                {
                    Code = Code + Args[0] + " = " + Args[1];
                }
                Kind = eAction.ACT_NORMAL;
                Args.Clear();
                break;

            case eAction.ACT_CODE:
                Code = Args[0];
                Kind = eAction.ACT_NORMAL;
                Args.Clear();
                if (Program.RemoveDND)
                {
                    List <GMLError> _errors            = null;
                    bool            inhibitErrorOutput = Program.InhibitErrorOutput;
                    Program.InhibitErrorOutput = true;
                    GMLCompile.Compile(_assets, "test_compile", Code, out _errors);
                    Program.InhibitErrorOutput = inhibitErrorOutput;
                    if (_errors.Count > 0)
                    {
                        foreach (GMLError item2 in _errors)
                        {
                            eErrorKind kind = item2.Kind;
                            if (kind == eErrorKind.Warning_Unclosed_Comment)
                            {
                                Code += "*/";
                            }
                        }
                    }
                }
                break;
            }
            if (IsQuestion && ExeType == eExecuteTypes.EXE_CODE)
            {
                Name = string.Format("__script{0}__", countScript);
                GMScript value = new GMScript(Code);
                KeyValuePair <string, GMScript> item = new KeyValuePair <string, GMScript>(Name, value);
                _assets.Scripts.Add(item);
                countScript++;
                ExeType = eExecuteTypes.EXE_FUNCTION;
            }
        }
Esempio n. 5
0
        public override void Reset(ToolbarGump toolbar)
        {
            base.Reset(toolbar);

            if (toolbar == null)
            {
                return;
            }

            PlayerMobile user = toolbar.User;

            if (CanEdit || user.AccessLevel >= Toolbars.Access)
            {
                Args.Clear();
            }
        }
Esempio n. 6
0
        public void ScriptInputCRUD()
        {
            Service service = Connect();
            InputCollection inputCollection = service.GetInputs();
            ServiceInfo info = service.GetInfo();

            // CRUD Script input
            string filename;
            if (info.OsName.Equals("Windows"))
            {
                filename = "echo.bat";
            }
            else
            {
                filename = "echo.sh";
            }

            Args args = new Args();
            args.Clear();
            args.Add("interval", "60");
            if (inputCollection.Get(filename) != null)
            {
                inputCollection.Remove(filename);
            }

            inputCollection.Create(filename, InputKind.Script, args);
            Assert.IsTrue(inputCollection.ContainsKey(filename), assertRoot + "#11");
            ScriptInput scriptInput = (ScriptInput)inputCollection.Get(filename);

            scriptInput.Host = "three.four.com";
            scriptInput.Index = "main";
            scriptInput.Interval = "120";
            if (service.VersionCompare("4.2.4") >= 0)
            {
                scriptInput.PassAuth = "admin";
            }

            scriptInput.RenameSource = "renamedSource";
            scriptInput.Source = "source";
            scriptInput.SourceType = "script";
            scriptInput.Update();

            Assert.AreEqual("three.four.com", scriptInput.Host, assertRoot + "#12");
            Assert.AreEqual("main", scriptInput.Index, assertRoot + "#13");
            Assert.AreEqual("120", scriptInput.Interval, assertRoot + "#14");
            if (service.VersionCompare("4.2.4") >= 0)
            {
                Assert.AreEqual("admin", scriptInput.PassAuth, assertRoot + "#15");
            }

            if (service.VersionCompare("5.0") >= 0)
            {
                Assert.AreEqual("source", scriptInput.Source, assertRoot + "#16");
            }
            else
            {
                Assert.AreEqual("renamedSource", scriptInput.Source, assertRoot + "#16");
            }

            Assert.AreEqual("script", scriptInput.SourceType, assertRoot + "#17");

            scriptInput.Remove();
            inputCollection.Refresh();
            Assert.IsFalse(inputCollection.ContainsKey(filename), assertRoot + "#18");
        }
Esempio n. 7
0
 /// <summary>
 /// Completely clears all optional fields set for the UriBuilder.
 /// </summary>
 public void Clear()
 {
     Endpoint = string.Empty;
     Args.Clear();
 }
Esempio n. 8
0
 /// <summary>
 /// Clears all of the arguments set for the URI.
 /// </summary>
 public void ClearArgs()
 => Args.Clear();