Ejemplo n.º 1
0
        public void Resolve_a_big_amount_of_singletons()
        {
            var container = new Container();

            const int count = 32 * 2 + 1;

            for (var i = 0; i < count; i++)
            {
                var serviceKey = new IntKey(i);
                container.Register <AD>(Reuse.Singleton, serviceKey: serviceKey);
            }

            var services = container.Resolve <KeyValuePair <IntKey, AD>[]>();

            for (var i = 0; i < count; i++)
            {
                var pair = services[i];
                Assert.IsNotNull(pair.Value);
                Assert.AreEqual(i, pair.Key.Index);
            }

            container.Dispose();
            for (var i = 0; i < count; ++i)
            {
                Assert.IsTrue(services[i].Value.IsDisposed);
            }
        }
Ejemplo n.º 2
0
        private IntKey[] FindPlaneIntersectionForTriangle(Vector3[] points, Vector3[] normals, Vector2[] uv, Plane p, int a, int b, int c, ref Dictionary <IntKey, VertexInfo> CollisionPoints)
        {
            int contactCounter = 0;
            var ContactPoints  = new IntKey[2];
            var testKeys       = new IntKey[] { new IntKey(a, b), new IntKey(b, c), new IntKey(a, c) };

            for (int i = 0; i < testKeys.Length; i++)
            {
                if (CollisionPoints.ContainsKey(testKeys[i]))
                {
                    ContactPoints[contactCounter] = testKeys[i];
                    contactCounter++;
                }
                else
                {
                    Vector3 contactPoint;
                    if (GetPointIntersection(points[testKeys[i].A], points[testKeys[i].B], p, out contactPoint))
                    {
                        CollisionPoints[testKeys[i]]  = new VertexInfo(contactPoint, (normals[testKeys[i].A] + normals[testKeys[i].B]).normalized, (uv[testKeys[i].A] + uv[testKeys[i].B]) / 2);
                        ContactPoints[contactCounter] = testKeys[i];
                        contactCounter++;
                    }
                }
            }
            return(ContactPoints);
        }
        public override string ToLC(bool printDefaultParams = false)
        {
            /*
             *   KEYCHAIN SUCCESS OR
             *     STRINGKEY @myVariable Contains "abc"
             *     DICTKEY @data.COOKIES HasKey "my-cookie"
             *   KEYCHAIN FAIL AND
             *     LISTKEY @myList Contains "item"
             *     FLOATKEY 1 GreaterThan 2
             */

            using var writer = new LoliCodeWriter(base.ToLC(printDefaultParams));

            // Write all the keychains
            foreach (var keychain in Keychains)
            {
                writer
                .AppendToken("KEYCHAIN", 2)
                .AppendToken(keychain.ResultStatus)
                .AppendLine(keychain.Mode.ToString());

                foreach (var key in keychain.Keys)
                {
                    (string keyName, string comparison) = key switch
                    {
                        BoolKey x => ("BOOLKEY", x.Comparison.ToString()),
                        StringKey x => ("STRINGKEY", x.Comparison.ToString()),
                        IntKey x => ("INTKEY", x.Comparison.ToString()),
                        FloatKey x => ("FLOATKEY", x.Comparison.ToString()),
                        DictionaryKey x => ("DICTKEY", x.Comparison.ToString()),
                        ListKey x => ("LISTKEY", x.Comparison.ToString()),
                        _ => throw new Exception("Unknown key type")
                    };

                    writer
                    .AppendToken(keyName, 4)
                    .AppendToken(LoliCodeWriter.GetSettingValue(key.Left))
                    .AppendToken(comparison)
                    .AppendLine(LoliCodeWriter.GetSettingValue(key.Right));
                }
            }

            return(writer.ToString());
        }
Ejemplo n.º 4
0
 public bool Equals(IntKey other)
 {
     return(this.first == other.first && this.second == other.second);
 }