当前位置: 首页>>代码示例>>C#>>正文


C# Group.ToString方法代码示例

本文整理汇总了C#中Group.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Group.ToString方法的具体用法?C# Group.ToString怎么用?C# Group.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: when_created


//.........这里部分代码省略.........
                };

                handle(_eA1);
                willRemoveEA1();
                didDispatch.should_be(1);
            };

            it["doesn't dispatch OnEntityWillBeRemoved when group doesn't contain entity"] = () => {
                _group.OnEntityWillBeRemoved += (group, entity) => this.Fail();
                handle(_eA1);
                _group.WillRemoveEntity(new Entity(0));
            };

            it["dispatches OnEntityRemoved and OnEntityAdded when updating"] = () => {
                handle(_eA1);
                var removed = 0;
                var added = 0;
                _group.OnEntityRemoved += (group, entity) => removed++;
                _group.OnEntityWillBeRemoved += (group, entity) => this.Fail();
                _group.OnEntityAdded += (group, entity) => added++;

                _group.UpdateEntity(_eA1);

                removed.should_be(1);
                added.should_be(1);
            };

            it["doesn't dispatch OnEntityRemoved and OnEntityAdded when updating when group doesn't contain entity"] = () => {
                _group.OnEntityRemoved += (group, entity) => this.Fail();
                _group.OnEntityWillBeRemoved += (group, entity) => this.Fail();
                _group.OnEntityAdded += (group, entity) => this.Fail();
                _group.UpdateEntity(_eA1);
            };
        };

        context["internal caching"] = () => {
            it["gets cached entities"] = () => {
                handle(_eA1);
                _group.GetEntities().should_be_same(_group.GetEntities());
            };

            it["updates cache when adding a new matching entity"] = () => {
                handle(_eA1);
                var g = _group.GetEntities();
                handle(_eA2);
                g.should_not_be_same(_group.GetEntities());
            };

            it["doesn't update cache when attempting to add a not matching entity"] = () => {
                handle(_eA1);
                var g = _group.GetEntities();
                var e = this.CreateEntity();
                handle(e);
                g.should_be_same(_group.GetEntities());
            };

            it["updates cache when removing an entity"] = () => {
                handle(_eA1);
                var g = _group.GetEntities();
                _eA1.RemoveComponentA();
                handle(_eA1);
                g.should_not_be_same(_group.GetEntities());
            };

            it["doesn't update cache when attempting to remove an entity that wasn't added before"] = () => {
                var g = _group.GetEntities();
                _eA1.RemoveComponentA();
                handle(_eA1);
                g.should_be_same(_group.GetEntities());
            };

            it["gets cached singleEntities"] = () => {
                handle(_eA1);
                _group.GetSingleEntity().should_be_same(_group.GetSingleEntity());
            };

            it["updates cache when new single entity was added"] = () => {
                handle(_eA1);
                var s = _group.GetSingleEntity();
                _eA1.RemoveComponentA();
                handle(_eA1);
                handle(_eA2);
                s.should_not_be_same(_group.GetSingleEntity());
            };

            it["updates cache when single entity is removed"] = () => {
                handle(_eA1);
                var s = _group.GetSingleEntity();
                _eA1.RemoveComponentA();
                handle(_eA1);
                s.should_not_be_same(_group.GetSingleEntity());
            };
        };

        it["can ToString"] = () => {
            var m = Matcher.NoneOf(Matcher.AllOf(0), Matcher.AnyOf(1));
            var group = new Group(m);
            group.ToString().should_be("Group(NoneOf(AllOf(0), AnyOf(1)))");
        };
    }
开发者ID:fversnel,项目名称:Entitas-CSharp,代码行数:101,代码来源:describe_Group.cs

示例2: when_created


//.........这里部分代码省略.........
                before = () => {
                    handleSilently(eA1);
                    cache = _groupA.GetSingleEntity();
                };

                it["gets cached singleEntities"] = () => {
                    _groupA.GetSingleEntity().should_be_same(cache);
                };

                it["updates cache when new single entity was added"] = () => {
                    eA1.RemoveComponentA();
                    handleSilently(eA1);
                    handleSilently(eA2);
                    _groupA.GetSingleEntity().should_not_be_same(cache);
                };

                it["updates cache when single entity is removed"] = () => {
                    eA1.RemoveComponentA();
                    handleSilently(eA1);
                    _groupA.GetSingleEntity().should_not_be_same(cache);
                };
            };
        };

        context["reference counting"] = () => {

            it["retains matched entity"] = () => {
                eA1.refCount.should_be(0);
                handleSilently(eA1);
                eA1.refCount.should_be(1);
            };

            it["releases removed entity"] = () => {
                handleSilently(eA1);
                eA1.RemoveComponentA();
                handleSilently(eA1);
                eA1.refCount.should_be(0);
            };

            it["invalidates entitiesCache (silent mode)"] = () => {
                eA1.OnEntityReleased += entity => {
                    _groupA.GetEntities().Length.should_be(0);
                };
                handleSilently(eA1);
                _groupA.GetEntities();
                eA1.RemoveComponentA();
                handleSilently(eA1);
            };

            it["invalidates entitiesCache"] = () => {
                eA1.OnEntityReleased += entity => {
                    _groupA.GetEntities().Length.should_be(0);
                };
                handleAddEA(eA1);
                _groupA.GetEntities();
                eA1.RemoveComponentA();
                handleRemoveEA(eA1, Component.A);
            };

            it["invalidates singleEntityCache (silent mode)"] = () => {
                eA1.OnEntityReleased += entity => {
                    _groupA.GetSingleEntity().should_be_null();
                };
                handleSilently(eA1);
                _groupA.GetSingleEntity();
                eA1.RemoveComponentA();
                handleSilently(eA1);
            };

            it["invalidates singleEntityCache"] = () => {
                eA1.OnEntityReleased += entity => {
                    _groupA.GetSingleEntity().should_be_null();
                };
                handleAddEA(eA1);
                _groupA.GetSingleEntity();
                eA1.RemoveComponentA();
                handleRemoveEA(eA1, Component.A);
            };

            it["retains entity until removed"] = () => {
                handleAddEA(eA1);
                var didDispatch = 0;
                _groupA.OnEntityRemoved += (group, entity, index, component) => {
                    didDispatch += 1;
                    entity.refCount.should_be(1);
                };
                eA1.RemoveComponentA();
                handleRemoveEA(eA1, Component.A);

                didDispatch.should_be(1);
                eA1.refCount.should_be(0);
            };
        };

        it["can ToString"] = () => {
            var m = Matcher.AllOf(Matcher.AllOf(0), Matcher.AllOf(1));
            var group = new Group(m);
            group.ToString().should_be("Group(AllOf(0, 1))");
        };
    }
开发者ID:buihuuloc,项目名称:Entitas-CSharp,代码行数:101,代码来源:describe_Group.cs

示例3: ToStringTestValidWithParent

 public void ToStringTestValidWithParent()
 {
     Group parent = new Group("Sun", GroupType.ReferenceFrame, null);
     Group target = new Group("Earth", GroupType.ReferenceFrame, parent);
     string expected = "Name = Earth , Path = /Sun/Earth";
     string actual;
     actual = target.ToString();
     Assert.AreEqual(expected, actual);
 }
开发者ID:rat-s-tar,项目名称:wwt-excel-plugin,代码行数:9,代码来源:GroupTest.cs

示例4: ToStringTestValid

 public void ToStringTestValid()
 {
     Group target = new Group("Sun", GroupType.ReferenceFrame, null);
     string expected = "Name = Sun , Path = /Sun";
     string actual;
     actual = target.ToString();
     Assert.AreEqual(expected, actual);
 }
开发者ID:rat-s-tar,项目名称:wwt-excel-plugin,代码行数:8,代码来源:GroupTest.cs

示例5: ToStringTestNullGroup

 public void ToStringTestNullGroup()
 {
     Group target = new Group(string.Empty, GroupType.ReferenceFrame, null);
     string expected = "Name =  , Path = /";
     string actual;
     actual = target.ToString();
     Assert.AreEqual(expected, actual);
 }
开发者ID:rat-s-tar,项目名称:wwt-excel-plugin,代码行数:8,代码来源:GroupTest.cs

示例6: ParseAssignmentGroup

        /// <summary>
        /// Parses an assignment operation.
        /// </summary>
        /// <param name="group">The group to parse.</param>
        /// <returns>The assigned variable or function on success, otherwise a TException.</returns>
        TType ParseAssignmentGroup(Group group)
        {
            /* BNF for assignment:
             *      <assignment>       ::= 'let' ( <variable-assignment> | <function-declaration> )
             *      <var-assignment>   ::= <identifier> '=' <expression>
             *      <func-declaration> ::= <identifier> '(' { <parameters> } ')' '=' <statements>
             *      <parameters>       ::= <identifier> { ',' <identifier> }*
             *      <statements>       ::= <block> | <statement>
             *      <block>            ::= <new-line> (<statement> <new-line>)* 'end'
             * You can probably guess what <identifier>, <statement> and <new-line> are
             * The 'let' is assumed to have already been checked for
             */
            int equalsIndex = group.IndexOf("=");
            if (equalsIndex < 0) return new TException(this, "Variable or function could not be assigned a value");

            // Could be assigning a dereferenced variable
            TException exception = ParseReferencesOfGroup(group, equalsIndex);
            if (exception != null) return exception;

            if (group.Count == 1) return new TException(this, "Could not assign variable", "no variable name given");

            string variableName = group[1] as string;
            TVariable existingVariable = null;

            if (variableName == null)
            {
                exception = new TException(this, "Could not assign variable", "invalid variable name given");

                // Check if an existing variable or function is being assigned
                Group groupToParse = group[1] as Group;
                TType value = group[1] as TType;
                if (groupToParse != null) value = ParseGroup(groupToParse);
                if (value == null) return exception;

                TVariable variable = value as TVariable;
                if (variable != null) existingVariable = variable;
                else
                {
                    TFunction function = value as TFunction;
                    if (function != null) variableName = function.Name;
                    else return exception;
                }
            }

            if (group.Count == 2) return new TException(this, "Variable could not be assigned a value");
            string assignmentOperator = group[2] as string;
            if (assignmentOperator == null) // Now we assume that we're dealing with a function declaration
            {
                Group paramGroup = group[2] as Group;
                if (paramGroup == null) // The user probably just wanted to assign a variable but made a typo
                    return new TException(this, "Variable could not be assigned a value",
                        "value to assign to variable must be given");

                // Get the identifiers of all the parameters within the brackets, keeping strict watch on comma usage
                TParameterList paramList = new TParameterList();
                bool commaExpected = false;
                for (int i = 0; i < paramGroup.Count; ++i)
                {
                    if (commaExpected && (i == paramGroup.Count - 1))
                        return new TException(this, "Parameters could not be parsed", "last parameter missing");

                    string paramName = paramGroup[i] as string;

                    if (commaExpected && (paramName != ",")) paramName = null;

                    if (paramName == null) return new TException(this, "Parameters could not be parsed",
                        "invalid parameter name given");

                    if (!commaExpected) paramList.Add(paramName);
                    commaExpected = !commaExpected;
                }

                exception = new TException(this, "Function could not be given a body", "function body must be given");
                if (group.Count == 3) return exception;
                assignmentOperator = group[3] as string;
                if (assignmentOperator == null) return exception;
                else if (assignmentOperator != "=") return exception;

                TFunction function;
                if (group.Count == 4) // statement is just 'let <i><params> =', so get a block
                {
                    TBlock block = new TBlock(this, out exception, false);
                    if (exception != null) return exception;
                    function = new TFunction(variableName ?? existingVariable.Identifier, block,
                        paramList.ParameterNames, null);
                }
                else // Create a single line function
                {
                    Group funcBody = new Group(null);
                    funcBody.AddRange(group.GetRange(4, group.Count - 4));
                    function = new TFunction(variableName ?? existingVariable.Identifier, funcBody.ToString(),
                        paramList.ParameterNames, null);
                }

                exception = TFunction.AddFunction(this, function);
//.........这里部分代码省略.........
开发者ID:supermaximo93,项目名称:Toast-Prototype-Interpreter,代码行数:101,代码来源:Interpreter.cs

示例7: DoEvaluatePredicate

	private bool DoEvaluatePredicate(Group g)
	{
	    Contract.Requires(g != null);
	    bool result = true;
		
		if (g.Success)
		{
			try
			{
				Predicate predicate = m_predicate.Parse(g.ToString());
				result = predicate.EvaluateBool(m_context);
//				Console.WriteLine("{0} => {1}", g, result);
			}
			catch (Exception e)
			{
				Console.Error.WriteLine("Failed to parse predicate: {0}", g);
				Console.Error.WriteLine(e.Message);
				Environment.Exit(1);
			}
		}
		
		return result;
	}
开发者ID:dbremner,项目名称:peg-sharp,代码行数:23,代码来源:TemplateEngine.cs


注:本文中的Group.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。