Example #1
0
        public void DoSomething(int x, global::System.String p = "class: ")
        {
            if (x > 0)
            {
                System.Console.WriteLine("x is greater than 0.");
                checked { ++x; }
            }
            delegate(string p) {
                Console.WriteLine("p Length is {0}", p.Length);
                WriteLine(F + p + typeof(T).FullName);
            } (p);
            const int a = 10;
            var       b = x + a,
                      c = x * a;

            b += 44;
            Console.WriteLine("b is {0}, c is {1}", b, c);

            var list = new SCG.List <int>(10)
            {
                a, b, c * 2
            };

            foreach (var x in list)
            {
                Console.WriteLine("collection element {0}", x);
            }

            object obj1 = new {};
            var    obj2 = new { a, B = b, C = c + 1, int.MaxValue };

            Console.WriteLine("Anonymous type test: obj1 {0}, obj2 {1}", obj1, obj2);
        }
        private SCG.List <string[]> parseCSV(string path)
        {
            SCG.List <string[]> parsedData = new SCG.List <string[]>();

            try
            {
                using (StreamReader readFile = new StreamReader(path))
                {
                    string   line;
                    string[] row;

                    while ((line = readFile.ReadLine()) != null)
                    {
                        row = line.Split(',');
                        parsedData.Add(row);
                    }
                }
            }
            catch (Exception e)
            {
                throw (e);
            }

            return(parsedData);
        }
Example #3
0
 public WorldLoadingThread()
 {
     objectRunningList              = new TreeDictionary <long, NifLoadJob>();
     terrainRunningList             = new TreeDictionary <long, NifLoadJob>();
     objectPositions                = new SCG.List <ObjectPosition>();
     MAX_RUNNING_THREADS            = ProgramSettings.get("MAX_RUNNING_THREADS", 2);
     this.loadingQueueSampler       = CustomSampler.Create("LoadingQueuesampler");
     this.objectRunningListSampler  = CustomSampler.Create("LoadingQueuesampler");
     this.terrainRunningListSampler = CustomSampler.Create("LoadingQueuesampler");
 }
        public Task PutAsync(K key, V value)
        {
            return(ExecCommandAsync(async cmd => {
                // Retrieve all rows
                string commandBegin = $"INSERT INTO {tableName} (";
                string commandLeftMiddle = ") VALUES (";
                string commandRightMiddle = ") ON CONFLICT (id) DO UPDATE SET (";
                string commandRightRightMidle = ") = (";
                string commandEnd = $") WHERE {tableName}.id=@id";
                var updatedColumnNames = new SCG.List <string>();

                var properties = typeof(V).GetProperties();
                foreach (var p in properties)
                {
                    var propertyValue = p.GetValue(value);
                    var columnName = p.Name.ToLower();

                    if (columnName == "id")
                    {
                        Trace.Assert(object.Equals(key, propertyValue));
                    }
                    else
                    {
                        if (columnName == "created" || columnName == "updated")
                        {
                            propertyValue = DateTime.Now;
                        }

                        var param = cmd.CreateParameter();
                        param.ParameterName = columnName;
                        param.Value = propertyValue ?? DBNull.Value;
                        cmd.Parameters.Add(param);
                        updatedColumnNames.Add(columnName);
                    }
                }

                var idParam = cmd.CreateParameter();
                idParam.ParameterName = "id";
                idParam.Value = key;
                cmd.Parameters.Add(idParam);

                cmd.CommandText = commandBegin +
                                  updatedColumnNames.Concat("id").Join(", ") +
                                  commandLeftMiddle +
                                  updatedColumnNames.Concat("id").Select(x => $"@{x}").Join(", ") +
                                  commandRightMiddle +
                                  updatedColumnNames.Join(", ") +
                                  commandRightRightMidle +
                                  updatedColumnNames.Select(x => $"@{x}").Join(", ") +
                                  commandEnd;

                var rowsAffected = await cmd.ExecuteNonQueryAsync().ConfigureAwait(false);
                Trace.Assert(1 == rowsAffected);
            }));
        }
Example #5
0
        public void TestEqualityDoubleNegativeZero()
        {
            var list1 = new SCG.List <double> {
                -0.0d
            };
            var list2 = new SCG.List <double> {
                -0.0d
            };
            var list3 = new SCG.List <double> {
                0.0d
            };

            assertTrue(ListEqualityComparer <double> .Default.Equals(list1, list2));
            assertEquals(ListEqualityComparer <double> .Default.GetHashCode(list1), ListEqualityComparer <double> .Default.GetHashCode(list2));
            assertFalse(ListEqualityComparer <double> .Default.Equals(list1, list3));
            Assert.AreNotEqual(ListEqualityComparer <double> .Default.GetHashCode(list1), ListEqualityComparer <double> .Default.GetHashCode(list3));

            // One dimensional arrays should work
            var list4 = new SCG.List <double[]> {
                new double[] { -0.0d, -0.0d, 0.0d }
            };
            var list5 = new SCG.List <double[]> {
                new double[] { -0.0d, -0.0d, 0.0d }
            };
            var list6 = new SCG.List <double[]> {
                new double[] { -0.0d, -0.0d, -0.0d }
            };

            assertTrue(ListEqualityComparer <double[]> .Default.Equals(list4, list5));
            assertEquals(ListEqualityComparer <double[]> .Default.GetHashCode(list4), ListEqualityComparer <double[]> .Default.GetHashCode(list5));
            assertFalse(ListEqualityComparer <double[]> .Default.Equals(list4, list6));
            Assert.AreNotEqual(ListEqualityComparer <double[]> .Default.GetHashCode(list4), ListEqualityComparer <double[]> .Default.GetHashCode(list6));

            // Multi dimensional arrays are not (yet) supported
            var list10 = new SCG.List <double[, ]> {
                new double[, ] {
                    { -0.0d, -0.0d }, { 0.0d, -0.0d }
                }
            };
            var list11 = new SCG.List <double[, ]> {
                new double[, ] {
                    { -0.0d, -0.0d }, { 0.0d, -0.0d }
                }
            };
            var list12 = new SCG.List <double[, ]> {
                new double[, ] {
                    { -0.0d, -0.0d }, { -0.0d, -0.0d }
                }
            };

            Assert.Throws <ArgumentException>(() => ListEqualityComparer <double[, ]> .Default.Equals(list10, list11));
            Assert.Throws <ArgumentException>(() => ListEqualityComparer <double[, ]> .Default.GetHashCode(list10));
            Assert.Throws <ArgumentException>(() => ListEqualityComparer <double[, ]> .Default.Equals(list10, list12));
            Assert.Throws <ArgumentException>(() => ListEqualityComparer <double[, ]> .Default.GetHashCode(list12));
        }
Example #6
0
            /// <summary></summary>
            public override object Read(object target, Package package, System.IO.BinaryReader reader, long end)
            {
                var count = reader.ReadInt32();
                var list  = new SCG.List <Reference>(count);

                while (count-- > 0)
                {
                    list.Add(package.ReadReference(reader));
                }
                return(list);
            }
Example #7
0
        public void Constructor_EmptySCGIList_Empty()
        {
            // Arrange
            var enumerable = new SCG.List <string>();

            // Act
            var collection = new ArrayList <string>(enumerable);

            // Assert
            Assert.That(collection, Is.Empty);
        }
Example #8
0
        public static async Task <SCG.List <ICacheFacade <K, V> > > CreateCluster <K, V>(int cohortCount, Func <CacheConfiguration <K, V> > configurationFactory = null)
        {
            configurationFactory = configurationFactory ?? (() => new CacheConfiguration <K, V>("my-cache"));
            var cacheFacades = new SCG.List <ICacheFacade <K, V> >();

            for (var i = 0; i < cohortCount; i++)
            {
                cacheFacades.Add(await CreateCohortAsync <K, V>(i, configurationFactory()).ConfigureAwait(false));
            }
            return(cacheFacades);
        }
        private Task UpdateByDiffHelperAsync(K key, V existing, V updated)
        {
            return(ExecCommandAsync(async cmd => {
                // Retrieve all rows
                string commandBegin = $"UPDATE {tableName} SET (";
                string commandMiddle = ") = (";
                string commandEnd = ") WHERE test.id=@id";
                var updatedColumnNames = new SCG.List <string>();

                var properties = typeof(V).GetProperties();
                foreach (var p in properties)
                {
                    var columnName = p.Name.ToLower();
                    if (columnName == "updated")
                    {
                        p.SetValue(updated, DateTime.Now);
                    }

                    if (object.Equals(p.GetValue(existing), p.GetValue(updated)))
                    {
                        continue;
                    }

                    var propertyValue = p.GetValue(updated);

                    if (columnName == "id")
                    {
                        throw new InvalidStateException();
                    }
                    else
                    {
                        var param = cmd.CreateParameter();
                        param.ParameterName = columnName;
                        param.Value = propertyValue ?? DBNull.Value;
                        cmd.Parameters.Add(param);
                        updatedColumnNames.Add(columnName);
                    }
                }

                var idParam = cmd.CreateParameter();
                idParam.ParameterName = "id";
                idParam.Value = key;
                cmd.Parameters.Add(idParam);

                cmd.CommandText = commandBegin +
                                  updatedColumnNames.Concat("id").Join(", ") +
                                  commandMiddle +
                                  updatedColumnNames.Concat("id").Select(x => $"@{x}").Join(", ") +
                                  commandEnd;

                var rowsModified = await cmd.ExecuteNonQueryAsync().ConfigureAwait(false);
                Trace.Assert(1 == rowsModified);
            }));
        }
Example #10
0
        public void Constructor_RandomSCGIList_Equal()
        {
            // Arrange
            var items      = GetStrings(Random);
            var enumerable = new SCG.List <string>(items);

            // Act
            var collection = new ArrayList <string>(enumerable);

            // Assert
            Assert.That(collection, Is.EqualTo(items).Using(ReferenceEqualityComparer));
        }
Example #11
0
        public void SetComparer_SetEqualsTests()
        {
            SCG.List <T> objects = new SCG.List <T>()
            {
                CreateT(1), CreateT(2), CreateT(3), CreateT(4), CreateT(5), CreateT(6)
            };

            var set = new LinkedHashSet <LinkedHashSet <T> >()
            {
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var noComparerSet = new LinkedHashSet <LinkedHashSet <T> >()
            {
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var comparerSet1 = new LinkedHashSet <LinkedHashSet <T> >(SetEqualityComparer <T> .Default)
            {
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var comparerSet2 = new LinkedHashSet <LinkedHashSet <T> >(SetEqualityComparer <T> .Default)
            {
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                },
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                }
            };

            Assert.True(noComparerSet.SetEquals(set)); // Our implementation is structurally equatable by default
            Assert.True(comparerSet1.SetEquals(set));
            Assert.True(comparerSet2.SetEquals(set));
        }
Example #12
0
        public void SetComparer_SetEqualsTests()
        {
            SCG.List <T> objects = new SCG.List <T>()
            {
                CreateT(1), CreateT(2), CreateT(3), CreateT(4), CreateT(5), CreateT(6)
            };

            var set = new SCG.HashSet <SortedSet <T> >()
            {
                new SortedSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new SortedSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var noComparerSet = new SCG.HashSet <SortedSet <T> >()
            {
                new SortedSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new SortedSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var comparerSet1 = new SCG.HashSet <SortedSet <T> >(SortedSet <T> .CreateSetComparer())
            {
                new SortedSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new SortedSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var comparerSet2 = new SCG.HashSet <SortedSet <T> >(SortedSet <T> .CreateSetComparer())
            {
                new SortedSet <T> {
                    objects[3], objects[4], objects[5]
                },
                new SortedSet <T> {
                    objects[0], objects[1], objects[2]
                }
            };

            Assert.True(noComparerSet.SetEquals(set)); // Unlike .NET's SortedSet, ours is structurally equatable by default
            Assert.True(comparerSet1.SetEquals(set));
            Assert.True(comparerSet2.SetEquals(set));
        }
Example #13
0
 public void Init()
 {
     ObstacleParent         = GameObject.FindGameObjectWithTag("ObstacleParent");
     weapons                = new SCG.List <WeaponInstance>();
     WeaponFireCooldown     = new Cooldown_counter();
     WeaponReloadCooldown   = new Cooldown_counter();
     WeaponEquipCooldown    = new Cooldown_counter();
     InActionStanceCooldown = new Cooldown_counter();
     PickCooldown.Reset();
     ObstacleCooldown.Reset();
     SetTool(PlayerTool.None);
     ObstaclePreviewMesh = ObstaclePreview.GetComponentInChildren <MeshFilter>().mesh;
     Respawn();
 }
Example #14
0
 private void processJobAdds()
 {
     while (true)
     {
         NifLoadJob job;
         lock (jobsToAdd)
         {
             if (jobsToAdd.IsEmpty)
             {
                 break;
             }
             job = jobsToAdd.Dequeue();
         }
         Vector3 pos    = job.parentPos;
         float[] floatf = new float[] { pos.x, pos.z };
         SCG.List <NifLoadJob> nList;
         if (job.filename.Contains("terrain"))
         {
             lock (terraintree)
             {
                 if (!this.terraintree.TryFindValueAt(floatf, out nList))
                 {
                     nList = new SCG.List <NifLoadJob>();
                     nList.Add(job);
                     this.terraintree.Add(floatf, nList);
                 }
                 else
                 {
                     nList.Add(job);
                 }
             }
         }
         else
         {
             lock (postree)
             {
                 if (!this.postree.TryFindValueAt(floatf, out nList))
                 {
                     nList = new SCG.List <NifLoadJob>();
                     nList.Add(job);
                     this.postree.Add(floatf, nList);
                 }
                 else
                 {
                     nList.Add(job);
                 }
             }
         }
     }
 }
        public Task <Entry <K, V> > InsertAsync(V item)
        {
            return(ExecCommandAsync(async cmd => {
                // Retrieve all rows
                var commandStart = $"INSERT INTO {tableName} (";
                var commandMiddle = ") VALUES (";
                var commandEnd = ") RETURNING *";
                var insertedColumnNames = new SCG.List <string>();

                foreach (var property in typeof(V).GetProperties())
                {
                    var columnName = property.Name.ToLower();
                    if (columnName == "id")
                    {
                        continue;
                    }

                    var propertyValue = property.GetValue(item);
                    var defaultPropertyValue = property.PropertyType.IsValueType ? Activator.CreateInstance(property.PropertyType) : null;

                    if (!Equals(propertyValue, defaultPropertyValue))
                    {
                        insertedColumnNames.Add(columnName);

                        var parameter = cmd.CreateParameter();
                        parameter.ParameterName = columnName;
                        parameter.Value = propertyValue;
                        cmd.Parameters.Add(parameter);
                    }
                }
                cmd.CommandText = commandStart +
                                  insertedColumnNames.Join(", ") +
                                  commandMiddle +
                                  insertedColumnNames.Select(c => $"@{c}").Join(", ") +
                                  commandEnd;

                using (var reader = await cmd.ExecuteReaderAsync().ConfigureAwait(false)) {
                    Trace.Assert(reader.HasRows);
                    var readSuccessful = await reader.ReadAsync().ConfigureAwait(false);
                    Trace.Assert(readSuccessful);

                    var entry = ReadToEntry(reader);
                    readSuccessful = await reader.ReadAsync().ConfigureAwait(false);
                    Trace.Assert(!readSuccessful);

                    return entry;
                }
            }));
        }
Example #16
0
        public void EnsureCapacity_Generic_RequestingLargerCapacity_DoesNotInvalidateEnumeration(int setLength)
        {
            LinkedHashSet <T> set      = (LinkedHashSet <T>)(GenericISetFactory(setLength));
            var         capacity       = set.EnsureCapacity(0);
            IEnumerator valuesEnum     = set.GetEnumerator();
            IEnumerator valuesListEnum = new SCG.List <T>(set).GetEnumerator();

            set.EnsureCapacity(capacity + 1); // Verify EnsureCapacity does not invalidate enumeration

            while (valuesEnum.MoveNext())
            {
                valuesListEnum.MoveNext();
                Assert.Equal(valuesListEnum.Current, valuesEnum.Current);
            }
        }
Example #17
0
        public void TestEqualityDoubleNaN()
        {
            sbyte[] nan1s = { 5, 84, 21, 61, -39, -20, -8, -1 };
            sbyte[] nan2s = { -65, 78, -21, -6, 47, 123, -4, 127 };
            byte[]  nan1  = new byte[8];
            byte[]  nan2  = new byte[8];
            Buffer.BlockCopy(nan1s, 0, nan1, 0, 8);
            Buffer.BlockCopy(nan2s, 0, nan2, 0, 8);

            var list1 = new SCG.List <double> {
                BitConverter.ToDouble(nan1, 0)
            };
            var list2 = new SCG.List <double> {
                BitConverter.ToDouble(nan2, 0)
            };

            assertTrue(ListEqualityComparer <double> .Default.Equals(list1, list2));
            assertEquals(ListEqualityComparer <double> .Default.GetHashCode(list1), ListEqualityComparer <double> .Default.GetHashCode(list2));

            // One dimensional arrays should work
            var list3 = new SCG.List <double[]> {
                new double[] { BitConverter.ToDouble(nan1, 0), BitConverter.ToDouble(nan1, 0), BitConverter.ToDouble(nan2, 0) }
            };
            var list4 = new SCG.List <double[]> {
                new double[] { BitConverter.ToDouble(nan1, 0), BitConverter.ToDouble(nan1, 0), BitConverter.ToDouble(nan2, 0) }
            };

            assertTrue(ListEqualityComparer <double[]> .Default.Equals(list3, list4));
            assertEquals(ListEqualityComparer <double[]> .Default.GetHashCode(list3), ListEqualityComparer <double[]> .Default.GetHashCode(list4));

            // Multi dimensional arrays are not (yet) supported
            var list5 = new SCG.List <double[, ]> {
                new double[, ] {
                    { BitConverter.ToDouble(nan1, 0), BitConverter.ToDouble(nan2, 0) }, { BitConverter.ToDouble(nan2, 0), BitConverter.ToDouble(nan1, 0) }
                }
            };
            var list6 = new SCG.List <double[, ]> {
                new double[, ] {
                    { BitConverter.ToDouble(nan1, 0), BitConverter.ToDouble(nan2, 0) }, { BitConverter.ToDouble(nan2, 0), BitConverter.ToDouble(nan1, 0) }
                }
            };

            Assert.Throws <ArgumentException>(() => ListEqualityComparer <double[, ]> .Default.Equals(list5, list6));
            Assert.Throws <ArgumentException>(() => ListEqualityComparer <double[, ]> .Default.GetHashCode(list5));
        }
Example #18
0
        public void TestEqualityFloatNaN()
        {
            sbyte[] nan1s = { -111, 28, -95, -1 };
            sbyte[] nan2s = { 76, -83, -47, 127 };
            byte[]  nan1  = new byte[4];
            byte[]  nan2  = new byte[4];
            Buffer.BlockCopy(nan1s, 0, nan1, 0, 4);
            Buffer.BlockCopy(nan2s, 0, nan2, 0, 4);

            var list1 = new SCG.List <float> {
                BitConverter.ToSingle(nan1, 0)
            };
            var list2 = new SCG.List <float> {
                BitConverter.ToSingle(nan2, 0)
            };

            assertTrue(ListEqualityComparer <float> .Default.Equals(list1, list2));
            assertEquals(ListEqualityComparer <float> .Default.GetHashCode(list1), ListEqualityComparer <float> .Default.GetHashCode(list2));

            // One dimensional arrays should work
            var list3 = new SCG.List <float[]> {
                new float[] { BitConverter.ToSingle(nan1, 0), BitConverter.ToSingle(nan1, 0), BitConverter.ToSingle(nan2, 0) }
            };
            var list4 = new SCG.List <float[]> {
                new float[] { BitConverter.ToSingle(nan1, 0), BitConverter.ToSingle(nan1, 0), BitConverter.ToSingle(nan2, 0) }
            };

            assertTrue(ListEqualityComparer <float[]> .Default.Equals(list3, list4));
            assertEquals(ListEqualityComparer <float[]> .Default.GetHashCode(list3), ListEqualityComparer <float[]> .Default.GetHashCode(list4));

            // Multi dimensional arrays are not (yet) supported
            var list5 = new SCG.List <float[, ]> {
                new float[, ] {
                    { BitConverter.ToSingle(nan1, 0), BitConverter.ToSingle(nan2, 0) }, { BitConverter.ToSingle(nan2, 0), BitConverter.ToSingle(nan1, 0) }
                }
            };
            var list6 = new SCG.List <float[, ]> {
                new float[, ] {
                    { BitConverter.ToSingle(nan1, 0), BitConverter.ToSingle(nan2, 0) }, { BitConverter.ToSingle(nan2, 0), BitConverter.ToSingle(nan1, 0) }
                }
            };

            Assert.Throws <ArgumentException>(() => ListEqualityComparer <float[, ]> .Default.Equals(list5, list6));
            Assert.Throws <ArgumentException>(() => ListEqualityComparer <float[, ]> .Default.GetHashCode(list5));
        }
        private bool LoadProgram()
        {
            bool success = false;

            try
            {
                string program = CurrentProgram.Value;

                //read file
                //1. Read data from a Dataset
                rawCRUDArrayRows = parseCSV(program);
                //for each data structure
            }
            catch (Exception ex)
            {
            }

            return(success);
        }
Example #20
0
        public void TestEqualityListShallow_Aggressive()
        {
            var control = new SCG.List <int> {
                1, 2, 3, 4, 5
            };
            var equal = new SCG.List <int> {
                1, 2, 3, 4, 5
            };
            var equalDifferentType  = new int[] { 1, 2, 3, 4, 5 };
            var equalDifferentOrder = new SCG.List <int> {
                1, 2, 3, 5, 4
            };

            Assert.AreEqual(ListEqualityComparer <int> .Aggressive.GetHashCode(control), ListEqualityComparer <int> .Aggressive.GetHashCode(control));
            Assert.AreEqual(ListEqualityComparer <int> .Aggressive.GetHashCode(control), ListEqualityComparer <int> .Aggressive.GetHashCode(equal));
            Assert.AreEqual(ListEqualityComparer <int> .Aggressive.GetHashCode(control), ListEqualityComparer <int> .Aggressive.GetHashCode(equalDifferentType));
            // Lists and arrays are order-sensitive
            Assert.AreNotEqual(ListEqualityComparer <int> .Aggressive.GetHashCode(control), ListEqualityComparer <int> .Aggressive.GetHashCode(equalDifferentOrder));
        }
Example #21
0
        public SCG.IEnumerable<Athlete> Query(string sql)
        {
            command.CommandText = sql;
             var list = new SCG.List<Athlete>();
             using (var reader = command.ExecuteReader()) {
            while (reader.Read()) {
               var at = new Athlete();

               at.Id = reader.GetInt32(0);
               at.Name = reader.GetString(1);
               at.Surname = reader.GetString(2);
               at.Year = reader.GetInt32(3);
               at.Gender  = reader.GetString(4);
               at.Time  = reader.GetString(5);
               list.Add(at);
            }
             }
             return list;
        }
Example #22
0
            /// <summary></summary>
            public override object Read(object target, Package package, BinaryReader reader, long end)
            {
                int count = reader.ReadInt32();

                if (count == 0)
                {
                    return(null);
                }
                var result = new SCG.List <T>(count);

                for (var index = 0; index < count; index++)
                {
                    var value = new T();
                    value.Package = package;
                    value.Load(reader, end);
                    result.Add(value);
                }

                return(result);
            }
        public void TestEqualsTypeMismatch()
        {
            var list = new SCG.List <int> {
                1, 2, 3, 4, 5
            };
            var set = new SCG.HashSet <int> {
                1, 2, 3, 4, 5
            };
            var dictionary = new SCG.Dictionary <int, int> {
                { 1, 0 }, { 2, 0 }, { 3, 0 }, { 4, 0 }, { 5, 0 }
            };
            var array = new int[] { 1, 2, 3, 4, 5 };

            Assert.IsFalse(CollectionUtil.Equals(list, set));
            Assert.IsFalse(CollectionUtil.Equals(list, dictionary));
            Assert.IsTrue(CollectionUtil.Equals(list, array)); // Types are compatible - array implements IList<T>

            Assert.IsFalse(CollectionUtil.Equals(set, dictionary));
            Assert.IsFalse(CollectionUtil.Equals(set, array));
        }
Example #24
0
        public void SetComparer_SequenceEqualTests()
        {
            SCG.List <T> objects = new SCG.List <T>()
            {
                CreateT(1), CreateT(2), CreateT(3), CreateT(4), CreateT(5), CreateT(6)
            };

            var set = new LinkedHashSet <LinkedHashSet <T> >()
            {
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var noComparerSet = new LinkedHashSet <LinkedHashSet <T> >()
            {
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            var comparerSet = new LinkedHashSet <LinkedHashSet <T> >(SetEqualityComparer <T> .Default)
            {
                new LinkedHashSet <T> {
                    objects[0], objects[1], objects[2]
                },
                new LinkedHashSet <T> {
                    objects[3], objects[4], objects[5]
                }
            };

            Assert.True(noComparerSet.SequenceEqual(set)); // Unlike the .NET LinkedHashSet, ours is structurally equatable by default
            Assert.True(noComparerSet.SequenceEqual(set, SetEqualityComparer <T> .Default));
            Assert.True(comparerSet.SequenceEqual(set));   // Unlike the .NET LinkedHashSet, ours is structurally equatable by default
        }
Example #25
0
        void processCDRQueue()
        {
            int tileX = Mathf.FloorToInt(telaraWorldCamPos.x / 256.0f);
            int tileY = Mathf.FloorToInt(telaraWorldCamPos.z / 256.0f);

            cdrJobQueue = cdrJobQueue.OrderBy(x => Vector2.Distance(new Vector2(tileX, tileY), new Vector2(x.Key, x.Value))).ToList();
            while (runningTerrainThreads < MAX_TERRAIN_THREADS && cdrJobQueue.Count() > 0)
            {
                KeyValuePair <int, int> job = cdrJobQueue[0];
                cdrJobQueue.RemoveAt(0);
                int tx = job.Key;
                int ty = job.Value;
                runningTerrainThreads++;
                //Debug.Log("Starting thread for CDR job[" + tx + "," + ty + "]");

                System.Threading.Thread m_Thread = new System.Threading.Thread(() =>
                {
                    try
                    {
                        SCG.List <ObjectPosition> objs = new SCG.List <ObjectPosition>();
                        CDRParse.doWorldTile(AssetDatabaseInst.DB, DBInst.inst, GameWorld.worldName, tx * 256, ty * 256, (p) =>
                        {
                            objs.Add(p);
                        });
                        lock (objectPositions)
                        {
                            objectPositions.AddRange(objs);
                        }
                    }
                    finally
                    {
                        runningTerrainThreads--;
                    }
                });
                m_Thread.Priority = (System.Threading.ThreadPriority)ProgramSettings.get("MAP_LOAD_THREAD_PRIORITY", (int)System.Threading.ThreadPriority.Normal);
                m_Thread.Start();
            }
        }
Example #26
0
        public void SortedSet_Generic_GetViewBetween_MiddleOfSet(int setLength)
        {
            if (setLength >= 3)
            {
                SCG.IComparer <T> comparer = GetIComparer() ?? Comparer <T> .Default;
                SortedSet <T>     set      = (SortedSet <T>)GenericISetFactory(setLength);
                T firstElement             = set.ElementAt(1);
                T lastElement = set.ElementAt(setLength - 2);

                SCG.List <T> expected = new SCG.List <T>(setLength - 2);
                foreach (T value in set)
                {
                    if (comparer.Compare(value, firstElement) >= 0 && comparer.Compare(value, lastElement) <= 0)
                    {
                        expected.Add(value);
                    }
                }

                SortedSet <T> view = set.GetViewBetween(firstElement, lastElement);
                Assert.Equal(expected.Count, view.Count);
                Assert.True(view.SetEquals(expected));
            }
        }
        public GreenC5UserControl(string greenC5Name, bool infiniteExecution, int k1, double k2)
        {
            InitializeComponent();
            Status                = "Idle";
            IsInfiniteMode        = infiniteExecution;
            GreenC5Name           = greenC5Name;
            lbName.Text           = "Instance ID: " + GreenC5Name;
            InternalDataStructure = new GreenC5 <string>();
            K1 = k1;
            K2 = k2;


            //set datastructure list by groups for validation
            SCG.List <C5DataStructure> iCollection = new SCG.List <C5DataStructure>();
            iCollection.Add(C5DataStructure.ArrayList);
            iCollection.Add(C5DataStructure.HashBag);
            iCollection.Add(C5DataStructure.HashedArrayList);
            iCollection.Add(C5DataStructure.HashedLinkedList);
            iCollection.Add(C5DataStructure.HashSet);
            iCollection.Add(C5DataStructure.LinkedList);
            iCollection.Add(C5DataStructure.SortedArray);
            iCollection.Add(C5DataStructure.TreeBag);
            iCollection.Add(C5DataStructure.TreeSet);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollection, iCollection));

            SCG.List <C5DataStructure> iCollectionBag = new SCG.List <C5DataStructure>();
            iCollectionBag.Add(C5DataStructure.HashBag);
            iCollectionBag.Add(C5DataStructure.TreeBag);
            iCollectionBag.Add(C5DataStructure.ArrayList);
            iCollectionBag.Add(C5DataStructure.LinkedList);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollectionBag, iCollectionBag));

            SCG.List <C5DataStructure> iCollectionSet = new SCG.List <C5DataStructure>();
            iCollectionSet.Add(C5DataStructure.HashSet);
            iCollectionSet.Add(C5DataStructure.TreeSet);
            iCollectionSet.Add(C5DataStructure.HashedArrayList);
            iCollectionSet.Add(C5DataStructure.HashedLinkedList);
            iCollectionSet.Add(C5DataStructure.SortedArray);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.ICollectionSet, iCollectionSet));

            SCG.List <C5DataStructure> iList = new SCG.List <C5DataStructure>();
            iList.Add(C5DataStructure.ArrayList);
            iList.Add(C5DataStructure.LinkedList);
            iList.Add(C5DataStructure.HashedArrayList);
            iList.Add(C5DataStructure.HashedLinkedList);
            iList.Add(C5DataStructure.SortedArray);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IList, iList));

            SCG.List <C5DataStructure> iListBag = new SCG.List <C5DataStructure>();
            iListBag.Add(C5DataStructure.ArrayList);
            iListBag.Add(C5DataStructure.LinkedList);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IListBag, iListBag));

            SCG.List <C5DataStructure> iListSet = new SCG.List <C5DataStructure>();
            iListSet.Add(C5DataStructure.HashedArrayList);
            iListSet.Add(C5DataStructure.HashedLinkedList);
            iListSet.Add(C5DataStructure.SortedArray);
            dataStructuresByGroup.Add(new KeyValuePair <DataStructureGroup, SCG.List <C5DataStructure> >(DataStructureGroup.IListSet, iListSet));


            //set data structure groups
            SCG.List <KeyValuePair <DataStructureGroup, C5DataStructure> > dsGroupAndWorstDataStructures = new SCG.List <KeyValuePair <DataStructureGroup, C5DataStructure> >();
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollection, C5DataStructure.ArrayList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollectionBag, C5DataStructure.LinkedList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.ICollectionSet, C5DataStructure.SortedArray));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IList, C5DataStructure.LinkedList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IListBag, C5DataStructure.LinkedList));
            dsGroupAndWorstDataStructures.Add(new KeyValuePair <DataStructureGroup, C5DataStructure>(DataStructureGroup.IListSet, C5DataStructure.SortedArray));

            //cbDataStructureGroup.DisplayMember = "Key";
            //cbDataStructureGroup.ValueMember = "Value";
            cbDataStructureGroup.DataSource = dsGroupAndWorstDataStructures;


            SCG.List <KeyValuePair <string, string> > crudWorkloadPrograms = new SCG.List <KeyValuePair <string, string> >();
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #1", @"CRUD Workloads\SmallRandomApplication1.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #2", @"CRUD Workloads\SmallRandomApplication2.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #3", @"CRUD Workloads\SmallRandomApplication3.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Small Program #4", @"CRUD Workloads\SmallRandomApplication4.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #1", @"CRUD Workloads\RandomApplication1.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #2", @"CRUD Workloads\RandomApplication2.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #3", @"CRUD Workloads\RandomApplication3.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #4", @"CRUD Workloads\RandomApplication4.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #5", @"CRUD Workloads\RandomApplication5.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #6", @"CRUD Workloads\RandomApplication6.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #7", @"CRUD Workloads\RandomApplication7.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #8", @"CRUD Workloads\RandomApplication8.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #9", @"CRUD Workloads\RandomApplication9.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Simulated Program #10", @"CRUD Workloads\RandomApplication10.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Custom", @"CRUD Workloads\AStarPathFinderProgram_Custom_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Diagnal Shortcut", @"CRUD Workloads\AStarPathFinderProgram_DiagonalShortcut_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Euclidean", @"CRUD Workloads\AStarPathFinderProgram_Euclidean_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Manhatan", @"CRUD Workloads\AStarPathFinderProgram_Manhatan_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("A* Path Finder - Max Dx Dy", @"CRUD Workloads\AStarPathFinderProgram_MaxDXDY_Formula.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - Fitness Table", @"CRUD Workloads\GA-FittnessTableProgram.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - Next Generation", @"CRUD Workloads\GA-NextGenerationProgram.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Genetic Algorithm - This Generation", @"CRUD Workloads\GA-ThisGenerationProgram.csv"));
            crudWorkloadPrograms.Add(new KeyValuePair <string, string>("Huffman Encoding", @"CRUD Workloads\HuffmanCodingProgram.csv"));


            cbPrograms.DataSource    = new BindingSource(crudWorkloadPrograms, null);
            cbPrograms.DisplayMember = "Key";
            //cbPrograms.ValueMember = "Value";
            //set the values to the program potion dropdownlist

            //set data structure options to a Static Mode selection
            cbStartDataStructure.DataSource = c5DSs;

            //Set run mode
            cbRunMode.DataSource   = Enum.GetValues(typeof(DataStructureMode));
            cbRunMode.SelectedItem = DataStructureMode.Dynamic;


            if (cbDataStructureGroup.SelectedItem != null)
            {
                KeyValuePair <DataStructureGroup, C5DataStructure> dsg = (KeyValuePair <DataStructureGroup, C5DataStructure>)cbDataStructureGroup.SelectedItem;
                CurrentDataStructureGroup         = dsg.Key;
                StartDataStructure                = dsg.Value;
                CurrentC5DataStructure            = dsg.Value;
                lbCurrentDataStructure.Text       = "Current Data Structure: " + CurrentC5DataStructure.ToString();
                cbStartDataStructure.SelectedItem = StartDataStructure;
            }

            if (cbPrograms.SelectedItem != null)
            {
                CurrentProgram = (KeyValuePair <string, string>)cbPrograms.SelectedItem;
            }

            startMode = false;
            bool ok = LoadProgram();
        }
      /// <summary>
      /// Processes an inbound data event. 
      /// This is assumed to be invoked on an IOCP thread so a goal is to do as little as possible.
      /// </summary>
      public void HandleInboundDataEvent(InboundDataEvent e, Action<InboundDataEvent> returnInboundDataEvent) {
#if DEBUG
         Interlocked.Increment(ref DebugRuntimeStats.in_de);
#endif

         // Deserialize inbound payloads
         SCG.List<object> payloads = new SCG.List<object>();
         try {
            using (var ms = new MemoryStream(e.Data, e.DataOffset, e.DataLength, false, true)) {
               while (ms.Position < ms.Length) {
                  payloads.Add(Deserialize.From(ms));
               }
            }
         } catch (Exception ex) {
            if (!isShutdown) {
               logger.Warn("Error at payload deserialize", ex);
            }
            return;
         }
         returnInboundDataEvent(e);
#if DEBUG
         Interlocked.Add(ref DebugRuntimeStats.in_payload, payloads.Count);
#endif

         // Categorize inbound payloads
         var acknowledgements = new SCG.List<AcknowledgementDto>();
         var announcements = new SCG.List<AnnouncementDto>();
         var reliablePackets = new SCG.List<PacketDto>();
         var unreliablePackets = new SCG.List<PacketDto>();
         foreach (var payload in payloads) {
            if (payload is AcknowledgementDto) {
               acknowledgements.Add((AcknowledgementDto)payload);
            } else if (payload is AnnouncementDto) {
               announcements.Add((AnnouncementDto)payload);
            } else if (payload is PacketDto) {
               // Filter packets not destined to us.
               var packet = (PacketDto)payload;
               if (!identity.Matches(packet.ReceiverId, IdentityMatchingScope.Broadcast)) {
                  tossedCounter.Increment();
                  continue;
               }

               // Bin into reliable vs unreliable.
               if (packet.IsReliable()) {
                  reliablePackets.Add(packet);
               } else {
                  unreliablePackets.Add(packet);
               }
            }
         }

         // Process acks to prevent resends.
         foreach (var ack in acknowledgements) {
#if DEBUG
            Interlocked.Increment(ref DebugRuntimeStats.in_ack);
#endif
            acknowledgementCoordinator.ProcessAcknowledgement(ack);
#if DEBUG
            Interlocked.Increment(ref DebugRuntimeStats.in_ack_done);
#endif
         }

         // Process announcements as they are necessary for routing.
         foreach (var announcement in announcements) {
#if DEBUG
            Interlocked.Increment(ref DebugRuntimeStats.in_ann);
#endif
            HandleAnnouncement(e.RemoteInfo, announcement);
         }

         // Ack inbound reliable messages to prevent resends.
         foreach (var packet in reliablePackets) {
#if DEBUG
            Interlocked.Increment(ref DebugRuntimeStats.in_out_ack);
#endif
            var ack = AcknowledgementDto.Create(packet.Id);
            RoutingContext routingContext;
            if (routingContextsByPeerId.TryGetValue(packet.SenderId, out routingContext)) {
               routingContext.SendAcknowledgementAsync(packet.SenderId, ack).Forget();
            } else {
               payloadSender.BroadcastAsync(ack).Forget();
            }
#if DEBUG
            Interlocked.Increment(ref DebugRuntimeStats.in_out_ack_done);
#endif
         }

         // Test reliable packets' guids against bloom filter.
         var isNewByPacketId = duplicateFilter.TestPacketIdsAreNew(new HashSet<Guid>(reliablePackets.Select(p => p.Id)));
         var standalonePacketsToProcess = new SCG.List<PacketDto>(unreliablePackets);
         var chunksToProcess = new SCG.List<MultiPartChunkDto>();
         foreach (var packet in reliablePackets) {
            // Toss out duplicate packets
            if (!isNewByPacketId[packet.Id]) {
               duplicateReceivesCounter.Increment();
               continue;
            } 

            // Bin into multipart chunk vs not
            var multiPartChunk = packet.Message.Body as MultiPartChunkDto;
            if (multiPartChunk != null) {
               multiPartChunksBytesReceivedAggregator.Put(multiPartChunk.BodyLength);
               chunksToProcess.Add(multiPartChunk);
            } else {
               standalonePacketsToProcess.Add(packet);
            }
         }

         // Kick off async stanadalone packet process on thread pool.
         foreach (var packet in standalonePacketsToProcess) {
            inboundMessageDispatcher.DispatchAsync(packet.Message).Forget();
         }

         // Synchronously handle multipart chunk processing.
         foreach (var chunk in chunksToProcess) {
            multiPartPacketReassembler.HandleInboundMultiPartChunk(chunk);
         }
      }
Example #29
0
        public void TestEqualityListDeep_Aggressive()
        {
            var deepControl = new SCG.List <IDictionary <string, string> >
            {
                new SCG.Dictionary <string, string> {
                    { "1", "one" }, { "2", "two" }, { "3", "three" }
                },
                new SCG.Dictionary <string, string> {
                    { "4", "four" }, { "5", "five" }, { "6", "six" }
                },
                new SCG.Dictionary <string, string> {
                    { "7", "seven" }, { "8", "eight" }, { "9", "nine" }
                },
            };
            var deepEqual = new SCG.List <IDictionary <string, string> >
            {
                new SCG.Dictionary <string, string> {
                    { "1", "one" }, { "2", "two" }, { "3", "three" }
                },
                new SCG.Dictionary <string, string> {
                    { "4", "four" }, { "5", "five" }, { "6", "six" }
                },
                new SCG.Dictionary <string, string> {
                    { "7", "seven" }, { "8", "eight" }, { "9", "nine" }
                },
            };
            var deepEqualDifferentType = new IDictionary <string, string>[]
            {
                new SCG.Dictionary <string, string> {
                    { "1", "one" }, { "2", "two" }, { "3", "three" }
                },
                new SCG.Dictionary <string, string> {
                    { "4", "four" }, { "5", "five" }, { "6", "six" }
                },
                new SCG.Dictionary <string, string> {
                    { "7", "seven" }, { "8", "eight" }, { "9", "nine" }
                },
            };
            var deepEqualDifferentOrder = new SCG.List <IDictionary <string, string> >
            {
                new SCG.Dictionary <string, string> {
                    { "7", "seven" }, { "8", "eight" }, { "9", "nine" }
                },
                new SCG.Dictionary <string, string> {
                    { "1", "one" }, { "2", "two" }, { "3", "three" }
                },
                new SCG.Dictionary <string, string> {
                    { "4", "four" }, { "5", "five" }, { "6", "six" }
                },
            };
            var deepLevel1EqualLevel2Unequal = new SCG.List <IDictionary <string, string> >
            {
                new SCG.Dictionary <string, string> {
                    { "1", "one" }, { "2", "two" }, { "3", "three" }
                },
                new SCG.Dictionary <string, string> {
                    { "4", "four" }, { "5", "five" }, { "6", "six" }
                },
                new SCG.Dictionary <string, string> {
                    { "7", "seven" }, { "8", "eight" }, { "9", "nine99" }
                },
            };

            Assert.AreEqual(ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepControl), ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepControl));
            Assert.AreEqual(ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepControl), ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepEqual));
            Assert.AreEqual(ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepControl), ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepEqualDifferentType));
            // Lists and arrays are order-sensitive
            Assert.AreNotEqual(ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepControl), ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepEqualDifferentOrder));
            Assert.AreNotEqual(ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepControl), ListEqualityComparer <IDictionary <string, string> > .Aggressive.GetHashCode(deepLevel1EqualLevel2Unequal));
        }
Example #30
0
        public void TestEqualityListSimple_Aggressive()
        {
            var control = new SCG.List <IList <string> >
            {
                new SCG.List <string> {
                    "one", "two", "three"
                },
                new SCG.List <string> {
                    "four", "five", "six"
                },
                new SCG.List <string> {
                    "seven", "eight", "nine"
                },
            };
            var equal = new SCG.List <IList <string> >
            {
                new SCG.List <string> {
                    "one", "two", "three"
                },
                new SCG.List <string> {
                    "four", "five", "six"
                },
                new SCG.List <string> {
                    "seven", "eight", "nine"
                },
            };
            var equalDifferentType = new IList <string>[]
            {
                new SCG.List <string> {
                    "one", "two", "three"
                },
                new SCG.List <string> {
                    "four", "five", "six"
                },
                new SCG.List <string> {
                    "seven", "eight", "nine"
                },
            };
            var equalDifferentOrder = new SCG.List <IList <string> >
            {
                new SCG.List <string> {
                    "four", "five", "six"
                },
                new SCG.List <string> {
                    "seven", "eight", "nine"
                },
                new SCG.List <string> {
                    "one", "two", "three"
                },
            };
            var level1EqualLevel2Unequal = new SCG.List <IList <string> >
            {
                new SCG.List <string> {
                    "one", "two", "three"
                },
                new SCG.List <string> {
                    "four", "five", "six"
                },
                new SCG.List <string> {
                    "seven", "eight", "nine-nine"
                },
            };

            Assert.AreEqual(ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(control), ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(control));
            Assert.IsTrue(ListEqualityComparer <IList <string> > .Aggressive.Equals(control, control));

            Assert.AreEqual(ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(control), ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(equal));
            Assert.IsTrue(ListEqualityComparer <IList <string> > .Aggressive.Equals(control, equal));

            Assert.AreEqual(ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(control), ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(equalDifferentType));
            Assert.IsTrue(ListEqualityComparer <IList <string> > .Aggressive.Equals(control, equalDifferentType));

            // Lists and arrays are order - sensitive
            Assert.AreNotEqual(ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(control), ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(equalDifferentOrder));
            Assert.IsFalse(ListEqualityComparer <IList <string> > .Aggressive.Equals(control, equalDifferentOrder));

            Assert.AreNotEqual(ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(control), ListEqualityComparer <IList <string> > .Aggressive.GetHashCode(level1EqualLevel2Unequal));
            Assert.IsFalse(ListEqualityComparer <IList <string> > .Aggressive.Equals(control, level1EqualLevel2Unequal));
        }
 //FIXME: should we receive a IRawElementProviderFragment instead? this way we can drop ArgumentExceptions in derived classes' ctors
 public ComponentParentAdapter(IRawElementProviderSimple provider) : base(provider)
 {
     RadioButtons    = new SCG.List <RadioButton> ();
     componentExpert = new ComponentImplementorHelper(this);
 }
Example #32
0
 internal void SetAndResolveInstructions(CILInstruction[] insts)
 {
     offset = 0;
       SCG.List<CILLabel> labels = new SCG.List<CILLabel>();
       foreach (CILInstruction inst in insts)
       {
       inst.offset = offset;
       offset += inst.size;
       if (inst is BranchInstr) {
       ((BranchInstr)inst).MakeTargetLabel(labels);
       }
       else if (inst is SwitchInstr) {
       ((SwitchInstr)inst).MakeTargetLabels(labels);
       }
       }
       if (exceptions != null) {
     for (int i = 0; i < exceptions.Count; i++) {
       exceptions[i] = ((EHClause)exceptions[i]).MakeTryBlock(labels);
     }
       }
       if (labels.Count == 0) { buffer = insts; tide = buffer.Length; return; }
       buffer = new CILInstruction[insts.Length + labels.Count];
       int currentPos = 0;
       tide = 0;
       foreach (CILLabel lbl in labels)
       {
       CILLabel lab = lbl;
       while ((currentPos < insts.Length) && (insts[currentPos].offset < lab.offset))
       buffer[tide++] = insts[currentPos++];
       buffer[tide++] = lab;
       }
       while (currentPos < insts.Length) {
     buffer[tide++] = insts[currentPos++];
       }
 }
Example #33
0
Test_CollectionFromSystemStringBuilderAdapter()
{
    Print( "Create" );
    var c =
        new StringBuilder( "abcde" )
        .AsHalfdecentCollection();

    Print( ".Stream()" );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'b', 'c', 'd', 'e' ) ) );

    Print( ".GetAndReplaceWhere( Predicate< char > )" );
    var to = new SCG.List< char >();
    Stream.Create( 'B' )
        .To( c.GetAndReplaceWhere( ch => ch == 'b' ) )
        .EmptyTo( to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'B', 'c', 'd', 'e' ) ) );
    to.Sort();
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 'b' ) ) );

    Print( ".GetAndRemoveWhere( Predicate< char > )" );
    to.Clear();
    c.GetAndRemoveWhere( ch => ch == 'B' )
        .EmptyTo( to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'c', 'd', 'e' ) ) );
    to.Sort();
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 'B' ) ) );

    Print( ".Get( IInteger )" );
    Assert( c.Get( 0 ) == 'a' );
    Assert( c.Get( 1 ) == 'c' );
    Assert( c.Get( 2 ) == 'd' );
    Assert( c.Get( 3 ) == 'e' );

    Print( ".Replace( IInteger, char )" );
    c.Replace( 1, 'C' );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'C', 'd', 'e' ) ) );

    Print( ".Remove( IInteger )" );
    c.Remove( 1 );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'd', 'e' ) ) );

    Print( ".Contains( IInteger )" );
    Assert( !c.Contains( -1 ) );
    Assert( c.Contains( 0 ) );
    Assert( c.Contains( 1 ) );
    Assert( c.Contains( 2 ) );
    Assert( !c.Contains( 3 ) );

    Print( ".Stream( IInteger )" );
    Assert(
        c.Stream( 1 )
        .SequenceEqual(
            Stream.Create( 'd' ) ) );

    Print( ".GetAndReplaceAll( IInteger )" );
    to.Clear();
    Stream.Create( 'D' )
        .To( c.GetAndReplaceAll( 1 ) )
        .EmptyTo( to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'D', 'e' ) ) );
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 'd' ) ) );

    Print( ".GetAndRemoveAll( IInteger )" );
    to.Clear();
    c.GetAndRemoveAll( 1 )
        .EmptyTo( to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'e' ) ) );
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 'D' ) ) );

    Print( ".Add( IInteger, char )" );
    c.Add( 1, 'b' );
    c.Add( 2, 'c' );
    c.Add( 3, 'd' );
    c.Add( 5, 'f' );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 'a', 'b', 'c', 'd', 'e', 'f' ) ) );

    Print( ".Count" );
    Assert( c.Count == 6 );

    Print( ".StreamPairs()" );
    var ts = c.StreamPairs();
    Assert( ts.Pull().BothEqual( 0L, 'a' ) );
    Assert( ts.Pull().BothEqual( 1L, 'b' ) );
    Assert( ts.Pull().BothEqual( 2L, 'c' ) );
    Assert( ts.Pull().BothEqual( 3L, 'd' ) );
    Assert( ts.Pull().BothEqual( 4L, 'e' ) );
    Assert( ts.Pull().BothEqual( 5L, 'f' ) );
    Assert( !ts.TryPull().A );
}
Example #34
0
        /// <summary>
        /// Returns the maximum stack depth required by these CIL instructions.
        /// </summary>
        /// <returns>The integer value of the stck depth.</returns>
        public int GetMaxStackDepthRequired()
        {
            if (tide == 0) return 0;

            // Store the code blocks we find
            SCG.List<CodeBlock> codeBlocks = new SCG.List<CodeBlock>();
            SCG.Dictionary<CILLabel, CodeBlock> cbTable = new SCG.Dictionary<CILLabel, CodeBlock>();
            SCG.List<CodeBlock> extraStartingBlocks = new SCG.List<CodeBlock>();

            // Start a default code block
            CodeBlock codeBlock = new CodeBlock(this);
            codeBlock.StartIndex = 0;

            //
            // Identify the code blocks
            //
            for (int i = 0; i < tide; i++) {

                /* Handling the tail instruction:
                 * The tail instruction has not been handled even though
                 * it indicates the end of a code block is coming.  The
                 * reason for this is because any valid tail instruction
                 * must be followed by a call* instruction and then a ret
                 * instruction.  Given a ret instruction must be the second
                 * next instruction anyway it has been decided to just let
                 * the end block be caught then.
                 */

                // If we reach a branch instruction or a switch instruction
                // then end the current code block inclusive of the instruction.
                if ((buffer[i] is BranchInstr) || (buffer[i] is SwitchInstr)) {

                    // Close the old block
                    codeBlock.EndIndex = i;
                    if (codeBlock.EndIndex >= codeBlock.StartIndex) // Don't add empty blocks
                        codeBlocks.Add(codeBlock);

                    // Open a new block
                    codeBlock = new CodeBlock(this);
                    codeBlock.StartIndex = i + 1;

                    // If we reach a label then we need to start a new
                    // code block as the label is an entry point.
                } else if (buffer[i] is CILLabel) {

                    // Close the old block
                    codeBlock.EndIndex = i - 1;
                    if (codeBlock.EndIndex >= codeBlock.StartIndex) // Don't add empty blocks
                        codeBlocks.Add(codeBlock);

                    // Open a new block
                    codeBlock = new CodeBlock(this);
                    codeBlock.StartIndex = i;

                    // Set this label as the entry point for the code block
                    codeBlock.EntryLabel = (CILLabel)buffer[i];
                    // AND ... list in the dictionary.
                    cbTable.Add(codeBlock.EntryLabel, codeBlock);

                    // Check for the ret, throw, rethrow, or jmp instruction as they also end a block
                } else if (buffer[i] is Instr) {
                    if (
                        (((Instr)buffer[i]).GetOp() == Op.ret) ||
                        (((Instr)buffer[i]).GetOp() == Op.throwOp) ||
                        (((Instr)buffer[i]).GetOp() == Op.rethrow) ||
                        ((buffer[i] is MethInstr) && (((MethInstr)buffer[i]).GetMethodOp() == MethodOp.jmp))
                       ) {

                        // Close the old block
                        codeBlock.EndIndex = i;
                        if (codeBlock.EndIndex >= codeBlock.StartIndex) // Don't add empty blocks
                            codeBlocks.Add(codeBlock);

                        // Open a new block
                        // In theory this should never happen but just in case
                        // someone feels like adding dead code it is supported.
                        codeBlock = new CodeBlock(this);
                        codeBlock.StartIndex = i + 1;

                    }

                }

            }

            // Close the last block
            codeBlock.EndIndex = tide - 1;
            if (codeBlock.EndIndex >= codeBlock.StartIndex) // Don't add empty blocks
                codeBlocks.Add(codeBlock);
            codeBlock = null;

            // Check how many code blocks there are.  If an blocks return 0.
            if (codeBlocks.Count == 0) return 0;

            //
            // Loop through each code block and calculate the delta distance
            //
            for (int j = 0; j < codeBlocks.Count; j++) {
                CodeBlock block = codeBlocks[j];

                int maxDepth = 0;
                int currentDepth = 0;

                // Loop through each instruction to work out the max depth
                for (int i = block.StartIndex; i <= block.EndIndex; i++) {

                    // Get the depth after the next instruction
                    currentDepth += buffer[i].GetDeltaDistance();

                    // If the new current depth is greater then the maxDepth adjust the maxDepth to reflect
                    if (currentDepth > maxDepth)
                        maxDepth = currentDepth;

                }

                // Set the depth of the block
                block.MaxDepth = maxDepth;
                block.DeltaDistance = currentDepth;

                //
                // Link up the next blocks
                //

                // If the block ends with a branch statement set the jump and fall through.
                if (buffer[block.EndIndex] is BranchInstr) {
                    BranchInstr branchInst = (BranchInstr)buffer[block.EndIndex];

                    // If this is not a "br" or "br.s" then set the fall through code block
                    if ((branchInst.GetBranchOp() != BranchOp.br) &&
                        (branchInst.GetBranchOp() != BranchOp.br_s))
                        // If there is a following code block set it as the fall through
                        if (j < (codeBlocks.Count - 1))
                            block.NextBlocks.Add(codeBlocks[j + 1]);

                    // Set the code block we are jumping to
                    CodeBlock cb = null;
                    cbTable.TryGetValue(branchInst.GetDest(), out cb);
                    if (cb == null)
                        throw new Exception("Missing Branch Label");
                    block.NextBlocks.Add(cb);

                    // If the block ends in a switch instruction work out the possible next blocks
                } else if (buffer[block.EndIndex] is SwitchInstr) {
                    SwitchInstr switchInstr = (SwitchInstr)buffer[block.EndIndex];

                    // If there is a following code block set it as the fall through
                    if (j < (codeBlocks.Count - 1))
                        block.NextBlocks.Add(codeBlocks[j + 1]);

                    // Add each destination block
                    foreach (CILLabel label in switchInstr.GetDests()) {

                        // Check all of the code blocks to find the jump destination
                        CodeBlock cb = null;
                        cbTable.TryGetValue(label, out cb);
                        if (cb == null) throw new Exception("Missing Case Label");
                        block.NextBlocks.Add(cb);

                    }

                    // So long as the block doesn't end with a terminating instruction like ret or throw, just fall through to the next block
                } else if (!IsTerminatingInstruction(buffer[block.EndIndex])) {

                    // If there is a following code block set it as the fall through
                    if (j < (codeBlocks.Count - 1))
                        block.NextBlocks.Add(codeBlocks[j + 1]);
                }

            }

            //
            // Join up any exception blocks
            //

            if (exceptions != null) {
                foreach (TryBlock tryBlock in exceptions) {

                    // Try to find the code block where this try block starts
                    CodeBlock tryCodeBlock;
                    cbTable.TryGetValue(tryBlock.Start, out tryCodeBlock);

                    // Declare that the entry to this code block must be empty
                    tryCodeBlock.RequireEmptyEntry = true;

                    // Work with each of the handlers
                    foreach (HandlerBlock hb in tryBlock.GetHandlers()) {

                        // Find the code block where this handler block starts.
                        CodeBlock handlerCodeBlock;
                        cbTable.TryGetValue(hb.Start, out handlerCodeBlock);

                        // If the code block is a catch or filter block increment the delta
                        // distance by 1. This is to factor in the exception object that will
                        // be secretly placed on the stack by the runtime engine.
                        // However, this also means that the MaxDepth is up by one also!
                        if (hb is Catch || hb is Filter)
                        {
                            handlerCodeBlock.DeltaDistance++;
                            handlerCodeBlock.MaxDepth++;
                        }

                        // If the code block is a filter block increment the delta distance by 1
                        // This is to factor in the exception object that will be placed on the stack.
                        // if (hb is Filter) handlerCodeBlock.DeltaDistance++;

                        // Add this handler to the list of starting places
                        extraStartingBlocks.Add(handlerCodeBlock);

                    }

                }
            }

            //
            // Traverse the code blocks and get the depth
            //

            // Get the max depth at the starting entry point
            int finalMaxDepth = this.TraverseMaxDepth(codeBlocks[0]);

            // Check the additional entry points
            // If the additional points have a greater depth update the max depth
            foreach (CodeBlock cb in extraStartingBlocks) {
                // int tmpMaxDepth = cb.TraverseMaxDepth();
                int tmpMaxDepth = this.TraverseMaxDepth(cb);
                if (tmpMaxDepth > finalMaxDepth) finalMaxDepth = tmpMaxDepth;
            }

            // Return the max depth we have found
            return finalMaxDepth;
        }
Example #35
0
Test_CollectionFromSystemListAdapter()
{
    Print( "Create" );
    var c =
        SystemEnumerable.Create( 1, 2, 3, 4, 5, 6 )
        .ToList()
        .AsHalfdecentCollection();

    Print( ".Stream()" );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 1, 2, 3, 4, 5, 6 ) ) );

    Print( ".GetAndReplaceWhere( Predicate< T > )" );
    var to = new SCG.List< int >();
    Stream.Create( 20, 40, 60, 80, 100 )
        .To( c.GetAndReplaceWhere( i => i % 2 == 0 ) )
        .EmptyTo(
            to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 1, 20, 3, 40, 5, 60 ) ) );
    to.Sort();
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 2, 4, 6 ) ) );

    Print( ".GetAndRemoveWhere( Predicate< T > )" );
    to.Clear();
    c.GetAndRemoveWhere( i => i >= 10 )
        .EmptyTo( to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 1, 3, 5 ) ) );
    to.Sort();
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 20, 40, 60 ) ) );

    Print( ".Get( TKey )" );
    Assert( c.Get( 0 ) == 1 );
    Assert( c.Get( 1 ) == 3 );
    Assert( c.Get( 2 ) == 5 );

    Print( ".Replace( TKey, T )" );
    c.Replace( 1, 2 );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 1, 2, 5 ) ) );

    Print( ".Remove( TKey )" );
    c.Remove( 1 );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 1, 5 ) ) );

    Print( ".Contains( TKey )" );
    Assert( c.Contains( 0 ) );
    Assert( c.Contains( 1 ) );
    Assert( !c.Contains( 2 ) );

    Print( ".Stream( TKey )" );
    Assert(
        c.Stream( 1 )
        .SequenceEqual(
            Stream.Create( 5 ) ) );

    Print( ".GetAndReplaceAll( TKey )" );
    to.Clear();
    Stream.Create( 6 )
        .To( c.GetAndReplaceAll( 1 ) )
        .EmptyTo( to.AsSink() );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 1, 6 ) ) );
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 5 ) ) );

    Print( ".GetAndRemoveAll( TKey )" );
    to.Clear();
    c.GetAndRemoveAll( 1 )
        .EmptyTo(
            to.AsSink() );
    Assert(
        c.Stream().SequenceEqual(
            Stream.Create( 1 ) ) );
    Assert(
        to.SequenceEqual(
            SystemEnumerable.Create( 6 ) ) );

    Print( ".Add( TKey, T )" );
    c.Add( 0, 0 );
    c.Add( 2, 2 );
    c.Add( 1, 1 );
    Assert(
        c.Stream()
        .SequenceEqual(
            Stream.Create( 0, 1, 1, 2 ) ) );

    Print( ".Count" );
    Assert( c.Count == 4 );

    Print( ".StreamPairs()" );
    var ts = c.StreamPairs();
    Assert( ts.Pull().BothEqual( 0L, 0 ) );
    Assert( ts.Pull().BothEqual( 1L, 1 ) );
    Assert( ts.Pull().BothEqual( 2L, 1 ) );
    Assert( ts.Pull().BothEqual( 3L, 2 ) );
    Assert( !ts.TryPull().A );
}
        /// <summary>
        /// Processes an inbound data event.
        /// This is assumed to be invoked on an IOCP thread so a goal is to do as little as possible.
        /// </summary>
        public void HandleInboundDataEvent(InboundDataEvent e, Action <InboundDataEvent> returnInboundDataEvent)
        {
#if DEBUG
            Interlocked.Increment(ref DebugRuntimeStats.in_de);
#endif

            // Deserialize inbound payloads
            SCG.List <object> payloads = new SCG.List <object>();
            try {
                using (var ms = new MemoryStream(e.Data, e.DataOffset, e.DataLength, false, true)) {
                    while (ms.Position < ms.Length)
                    {
                        payloads.Add(Deserialize.From(ms));
                    }
                }
            } catch (Exception ex) {
                if (!isShutdown)
                {
                    logger.Warn("Error at payload deserialize", ex);
                }
                return;
            }
            returnInboundDataEvent(e);
#if DEBUG
            Interlocked.Add(ref DebugRuntimeStats.in_payload, payloads.Count);
#endif

            // Categorize inbound payloads
            var acknowledgements  = new SCG.List <AcknowledgementDto>();
            var announcements     = new SCG.List <AnnouncementDto>();
            var reliablePackets   = new SCG.List <PacketDto>();
            var unreliablePackets = new SCG.List <PacketDto>();
            foreach (var payload in payloads)
            {
                if (payload is AcknowledgementDto)
                {
                    acknowledgements.Add((AcknowledgementDto)payload);
                }
                else if (payload is AnnouncementDto)
                {
                    announcements.Add((AnnouncementDto)payload);
                }
                else if (payload is PacketDto)
                {
                    // Filter packets not destined to us.
                    var packet = (PacketDto)payload;
                    if (!identity.Matches(packet.ReceiverId, IdentityMatchingScope.Broadcast))
                    {
                        tossedCounter.Increment();
                        continue;
                    }

                    // Bin into reliable vs unreliable.
                    if (packet.IsReliable())
                    {
                        reliablePackets.Add(packet);
                    }
                    else
                    {
                        unreliablePackets.Add(packet);
                    }
                }
            }

            // Process acks to prevent resends.
            foreach (var ack in acknowledgements)
            {
#if DEBUG
                Interlocked.Increment(ref DebugRuntimeStats.in_ack);
#endif
                acknowledgementCoordinator.ProcessAcknowledgement(ack);
#if DEBUG
                Interlocked.Increment(ref DebugRuntimeStats.in_ack_done);
#endif
            }

            // Process announcements as they are necessary for routing.
            foreach (var announcement in announcements)
            {
#if DEBUG
                Interlocked.Increment(ref DebugRuntimeStats.in_ann);
#endif
                HandleAnnouncement(e.RemoteInfo, announcement);
            }

            // Ack inbound reliable messages to prevent resends.
            foreach (var packet in reliablePackets)
            {
#if DEBUG
                Interlocked.Increment(ref DebugRuntimeStats.in_out_ack);
#endif
                var            ack = AcknowledgementDto.Create(packet.Id);
                RoutingContext routingContext;
                if (routingContextsByPeerId.TryGetValue(packet.SenderId, out routingContext))
                {
                    routingContext.SendAcknowledgementAsync(packet.SenderId, ack).Forget();
                }
                else
                {
                    payloadSender.BroadcastAsync(ack).Forget();
                }
#if DEBUG
                Interlocked.Increment(ref DebugRuntimeStats.in_out_ack_done);
#endif
            }

            // Test reliable packets' guids against bloom filter.
            var isNewByPacketId            = duplicateFilter.TestPacketIdsAreNew(new HashSet <Guid>(reliablePackets.Select(p => p.Id)));
            var standalonePacketsToProcess = new SCG.List <PacketDto>(unreliablePackets);
            var chunksToProcess            = new SCG.List <MultiPartChunkDto>();
            foreach (var packet in reliablePackets)
            {
                // Toss out duplicate packets
                if (!isNewByPacketId[packet.Id])
                {
                    duplicateReceivesCounter.Increment();
                    continue;
                }

                // Bin into multipart chunk vs not
                var multiPartChunk = packet.Message.Body as MultiPartChunkDto;
                if (multiPartChunk != null)
                {
                    multiPartChunksBytesReceivedAggregator.Put(multiPartChunk.BodyLength);
                    chunksToProcess.Add(multiPartChunk);
                }
                else
                {
                    standalonePacketsToProcess.Add(packet);
                }
            }

            // Kick off async stanadalone packet process on thread pool.
            foreach (var packet in standalonePacketsToProcess)
            {
                inboundMessageDispatcher.DispatchAsync(packet.Message).Forget();
            }

            // Synchronously handle multipart chunk processing.
            foreach (var chunk in chunksToProcess)
            {
                multiPartPacketReassembler.HandleInboundMultiPartChunk(chunk);
            }
        }
Example #37
0
Test_ICollectionG_AsSink()
{
    ICollectionRG< int > c =
        new SCG.List< int >()
        .AsHalfdecentCollection();
    new int[] { 1, 2, 3 }
        .AsStream()
        .EmptyTo( c.AsSink() );
    Assert(
        c.Stream().AsEnumerable().SequenceEqual(
            new int[] { 1, 2, 3 } ) );
}
Example #38
0
		//FIXME: should we receive a IRawElementProviderFragment instead? this way we can drop ArgumentExceptions in derived classes' ctors
		public ComponentParentAdapter (IRawElementProviderSimple provider) : base (provider)
		{
			RadioButtons = new SCG.List <RadioButton> ();
			componentExpert = new ComponentImplementorHelper (this);
		}