Пример #1
0
	    internal Object GetArgumentValue(ICommandInterpreter interpreter, ArgumentList args, string[] allArguments)
		{
			object value = null;

			if (IsInterpreter)
				return interpreter;

			if (IsAllArguments)
			{
				args.Clear();
				args.Unnamed.Clear();
				return allArguments;
			}

			foreach (string name in AllNames)
			{
				ArgumentList.Item argitem;
				if (args.TryGetValue(name, out argitem))
				{
					if (Parameter.ParameterType == typeof(string[]))
						value = argitem.Values;
					else if (IsFlag)
					{
						bool result;
						value = (String.IsNullOrEmpty(argitem.Value) || (bool.TryParse(argitem.Value, out result) && result));
					}
					else
						value = argitem.Value;
					args.Remove(name);
				}
			}

			return base.ChangeType(value, Parameter.ParameterType, Required, DefaultValue); 
		}
Пример #2
0
        public void TestUnnamed()
        {
            ArgumentList args = new ArgumentList("some", "/thing", "else");

            Assert.AreEqual(2, args.Unnamed.Count);
            Assert.AreEqual(1, args.Count);
            Assert.IsTrue(args.Contains("thing"));
            Assert.AreEqual("some", args.Unnamed[0]);
            Assert.AreEqual("else", args.Unnamed[1]);

            args.Unnamed.RemoveAt(0);
            Assert.AreEqual(1, args.Unnamed.Count);
            Assert.AreEqual("else", args.Unnamed[0]);

            args.Clear();
            Assert.AreEqual(0, args.Count);
            Assert.AreEqual(1, args.Unnamed.Count);

            args.Unnamed.Clear();
            Assert.AreEqual(0, args.Unnamed.Count);
        }
Пример #3
0
        private void InitFromNameDeclaration(CSharpPropertyNameDeclaration declaration)
        {
            RaiseChangedEvent = false;

            try {
                IsExplicitImplementation = declaration.IsExplicitImplementation;
                ValidName = declaration.Name;

                if (Name == "this")   // Indexer
                {
                    if (!HasParameter)
                    {
                        ArgumentList.Add("int index");
                    }
                }
                else if (HasParameter)   // Not an indexer
                {
                    ArgumentList.Clear();
                }
            }
            finally {
                RaiseChangedEvent = true;
            }
        }
Пример #4
0
		public void TestUnnamed()
		{
			ArgumentList args = new ArgumentList("some", "/thing", "else");
			Assert.AreEqual(2, args.Unnamed.Count);
			Assert.AreEqual(1, args.Count);
			Assert.IsTrue(args.Contains("thing"));
			Assert.AreEqual("some", args.Unnamed[0]);
			Assert.AreEqual("else", args.Unnamed[1]);

			args.Unnamed.RemoveAt(0);
			Assert.AreEqual(1, args.Unnamed.Count);
			Assert.AreEqual("else", args.Unnamed[0]);

			args.Clear();
			Assert.AreEqual(0, args.Count);
			Assert.AreEqual(1, args.Unnamed.Count);

			args.Unnamed.Clear();
			Assert.AreEqual(0, args.Unnamed.Count);
		}
Пример #5
0
        ///////////////////////////////////////////////////////////////////////

        public void Free(
            bool global
            )
        {
            //
            // HACK: *SPECIAL CASE* We cannot dispose the global call frame
            //       unless we are [also] disposing of the interpreter itself.
            //
            if (global ||
                !FlagOps.HasFlags(flags, CallFrameFlags.NoFree, true))
            {
                kind        = IdentifierKind.None;
                id          = Guid.Empty;
                name        = null;
                group       = null;
                description = null;
                clientData  = null;
                frameId     = 0;
                frameLevel  = 0;
                flags       = CallFrameFlags.None;

                ///////////////////////////////////////////////////////////////

                if (tags != null)
                {
                    tags.Clear();
                    tags = null;
                }

                ///////////////////////////////////////////////////////////////

                index = 0;
                level = 0;

                ///////////////////////////////////////////////////////////////

                if (arguments != null)
                {
                    //
                    // BUGFIX: We can only mutate argument lists that we own.
                    //
                    if (ownArguments)
                    {
                        arguments.Clear();
                    }

                    arguments = null;
                }

                ///////////////////////////////////////////////////////////////

                ownArguments = false;

                ///////////////////////////////////////////////////////////////

                if (procedureArguments != null)
                {
                    procedureArguments.Clear();
                    procedureArguments = null;
                }

                ///////////////////////////////////////////////////////////////

                if (variables != null)
                {
                    variables.Clear();
                    variables = null;
                }

                ///////////////////////////////////////////////////////////////

                other    = null; /* NOTE: Not owned, do not dispose. */
                previous = null; /* NOTE: Not owned, do not dispose. */
                next     = null; /* NOTE: Not owned, do not dispose. */

                ///////////////////////////////////////////////////////////////

                engineData    = null; /* NOTE: Not owned, do not dispose. */
                auxiliaryData = null; /* NOTE: Not owned, do not dispose. */
                resolveData   = null; /* NOTE: Not owned, do not dispose. */
                extraData     = null; /* NOTE: Not owned, do not dispose. */
            }
        }