Example #1
0
        public void AddDifferentWithSameKeyTwice()
        {
            var cache = new StringMap <string>();

            cache.Add("abc", "d");
            Assert.Throws <InvalidOperationException>(() => cache.Add("abc", "e"));
        }
Example #2
0
        public void AddSameTwice()
        {
            var cache = new StringMap <string>();

            cache.Add("abc", "d");
            cache.Add("abc", "d");
            var cachedItems = GetInnerCache(cache);

            Assert.AreEqual(1, cachedItems.Length);
        }
Example #3
0
        public void Sorts()
        {
            var cache    = new StringMap <string>();
            var item1    = cache.Add("abcde", "1");
            var item2    = cache.Add("abc", "2");
            var item3    = cache.Add("abcd", "3");
            var item4    = cache.Add("bar", "4");
            var actual   = GetInnerCache(cache);
            var expected = new[] { item2, item3, item1, item4 };

            CollectionAssert.AreEqual(expected, actual);
        }
Example #4
0
File: Env.cs Project: ikvm/test
 public void putEformFieldValue(string fieldName, object fieldValue)
 {
     if (fieldName == null)
     {
         formFieldValueMap.Add(fieldName.ToLower(), null);
     }
     else
     {
         fieldName = fieldName.ToLower();
         formFieldValueMap.Add(fieldName, fieldValue);
     }
 }
Example #5
0
        public void TryGetSuccess(string key, string expected)
        {
            var cache = new StringMap <string>();

            cache.Add("abcde", "1");
            cache.Add("abc", "2");
            cache.Add("abcd", "3");
            cache.Add("bar", "4");
            var success = cache.TryGet(key, out var actual);

            Assert.AreEqual(true, success);
            Assert.AreEqual(expected, actual);
        }
Example #6
0
        public void AddThenGetFail(string key, int pos)
        {
            var cache = new StringMap <string>();

            cache.Add("abc", "d");
            cache.Add("foo", "e");
            cache.Add("bar", "f");
            var success = cache.TryGetBySubString(key, pos, out var actual);

            Assert.AreEqual(false, success);
            Assert.AreEqual(null, actual);
            Assert.AreEqual(null, actual);
        }
Example #7
0
File: Env.cs Project: ikvm/test
 public void setParameter(string name, string svalue)
 {
     if (name != null)
     {
         parameters.Add(name, svalue);
     }
 }
 /// <summary>
 ///    returns the id cached for the given string or add the string to the cache and returns the id
 /// </summary>
 public string IdForString(string stringToCache)
 {
     if (!StringMap.Contains(stringToCache))
     {
         int id = StringMap.Count();
         IdStringMap.Add(id, stringToCache);
         StringMap.Add(stringToCache, id);
     }
     return(StringMap[stringToCache].ToString(CultureInfo.InvariantCulture));
 }
Example #9
0
        public void TryFindSubStringSuccess(string key, int pos, string expectedKey, string expectedValue)
        {
            var cache = new StringMap <string>();

            cache.Add("abcde", "1");
            cache.Add("abc", "2");
            cache.Add("abcd", "3");
            cache.Add("bar", "4");
            string actual;
            string actualKey;
            var    success = cache.TryGetBySubString(key, pos, out actualKey, out actual);

            Assert.AreEqual(true, success);
            Assert.AreEqual(expectedKey, actualKey);
            Assert.AreEqual(expectedValue, actual);

            success = cache.TryGetBySubString(key, pos, out actual);
            Assert.AreEqual(true, success);
            Assert.AreEqual(expectedValue, actual);
        }
Example #10
0
        public void TestWriteExternalAndPutGet()
        {
            StringMap[] m = new StringMap[4];
            SetUp(out m[0], out m[1], out m[2], out m[3]);


            for (int i = 0; i < m.Length; i++)
            {
                MemoryStream memoryBytes = new MemoryStream();
                m[i].WriteExternal(memoryBytes);
                memoryBytes.Position = 0;
                m[i] = new StringMap();
                m[i].ReadExternal(memoryBytes);
            }


            StringMap m0  = m[0];
            StringMap m1  = m[1];
            StringMap m5  = m[2];
            StringMap m5i = m[3];

            Assert.AreEqual("2", m5["abc"]);
            Assert.AreEqual(null, m5["aBc"]);
            Assert.AreEqual("2", m5i["abc"]);
            Assert.AreEqual("2", m5i["aBc"]);

            m5.Add(null, "x");
            m5.Add("aBc", "x");
            m5i.Add("AbC", "x");

            StringBuilder buffer = new StringBuilder();

            buffer.Append("aBc");
            Assert.AreEqual("2", m5["abc"]);
            Assert.AreEqual("x", m5[buffer]);
            Assert.AreEqual("x", m5i[(object)"abc"]);
            Assert.AreEqual("x", m5i["aBc"]);

            Assert.AreEqual("x", m5[null]);
            Assert.AreEqual("0", m5i[null]);
        }
Example #11
0
        /// <summary>
        /// Imports a single file as a delimited file with a header. Row 1 is always parsed as a header, and is used to construct resulting dictionaries
        /// by row. Each dict is row 1 as the keys and each following row of the file as the values.
        /// </summary>
        /// <param name="fileName">The full path of the file to import</param>
        /// <param name="delimiter">What is the delimiting character? i.e. comma, pipe, tab, etc.</param>
        /// <param name="useQuotes">Are there quotes around values?</param>
//        /// <param name="primaryKey">Primary key -- major index of composite if composite.</param>
        /// <param name="headers">A preloaded set of headers -- optional.</param>
        /// <returns>A List of Dictionary per row where KEY=Row1</returns>
        private static HeaderSource <List <StringMap>, List <string> > ImportCSVWithHeader(
            string fileName
//            , string primaryKey
            , string delimiter
            , bool useQuotes
            , IList <string> headers = null)
        {
            using (Stream readFile = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                // CSV Parsing
                var csvRead = new TextFieldParser(readFile)
                {
                    CommentTokens             = new[] { "#" },
                    Delimiters                = new[] { delimiter },
                    HasFieldsEnclosedInQuotes = useQuotes,
                    TextFieldType             = FieldType.Delimited,
                    TrimWhiteSpace            = true
                };

                // if header is null, replace header with csvRead.ReadFields(), or with empty string if that's null.

                if (headers == null)
                {
                    headers = csvRead.ReadFields();
                }
                if (headers == null)
                {
                    headers = new string[] { };
                }

                List <StringMap> records = new List <StringMap>();
                while (!csvRead.EndOfData)
                {
                    string[] rowData = csvRead.ReadFields() ?? new string[] { };
                    var      newRow  = new StringMap();
                    for (int n = 0; n < rowData.Length; ++n) // len = number of fields.
                    {
                        newRow.Add(headers[n], rowData[n]);
                    }
                    records.Add(newRow);
                }

                List <string> headerList = new List <string>(headers);
                HeaderSource <List <StringMap>, List <string> > ret =
                    new HeaderSource <List <StringMap>, List <string> > (records, headerList.ToArray());


                return(ret);
            }
        }
Example #12
0
        protected void SetUp(out StringMap m0,
                             out StringMap m1,
                             out StringMap m5,
                             out StringMap m5i)
        {
            m0 = new StringMap();
            m1 = new StringMap(false);
            m1.Add("abc", "0");

            m5 = new StringMap(false);
            m5.Add("a", "0");
            m5.Add("ab", "1");
            m5.Add("abc", "2");
            m5.Add("abb", "3");
            m5.Add("bbb", "4");

            m5i = new StringMap(true);
            m5i.Add(null, "0");
            m5i.Add("ab", "1");
            m5i.Add("abc", "2");
            m5i.Add("abb", "3");
            m5i.Add("bbb", null);
        }
        bool IModuleResolver.TryGetModule(ModuleRequest moduleRequest, out Module result)
        {
            var cacheKey = GetCacheKey(moduleRequest);

            if (_modulesCache.TryGetValue(cacheKey, out result))
            {
                return(true);
            }

            if (TryGetModule(moduleRequest, out result))
            {
                _modulesCache.Add(cacheKey, result);
                return(true);
            }

            return(false);
        }
Example #14
0
        internal static PaddedFormat GetOrCreate(string?format)
        {
            if (string.IsNullOrEmpty(format))
            {
                return(PaddedFormat.NullFormat);
            }

            if (Cache.TryGet(format, out var match))
            {
                return(match);
            }

            var pos          = 0;
            var paddedFormat = GetOrCreate(format, ref pos);

            if (!WhiteSpaceReader.IsRestWhiteSpace(format, pos))
            {
                paddedFormat = paddedFormat.AsUnknownFormat();
            }

            _ = Cache.Add(format, paddedFormat);
            return(paddedFormat);
        }
Example #15
0
        public void TestWriteExternalAndTestSize()
        {
            StringMap[] m = new StringMap[4];
            SetUp(out m[0], out m[1], out m[2], out m[3]);


            for (int i = 0; i < m.Length; i++)
            {
                MemoryStream bout = new MemoryStream();
                m[i].WriteExternal(bout);
                bout.Position = 0;
                m[i]          = new StringMap();
                m[i].ReadExternal(bout);
            }


            StringMap m0  = m[0];
            StringMap m1  = m[1];
            StringMap m5  = m[2];
            StringMap m5i = m[3];



            Assert.AreEqual(0, m0.Count);
            Assert.AreEqual(1, m1.Count);
            Assert.AreEqual(5, m5.Count);
            Assert.AreEqual(5, m5i.Count);

            m1.Remove("abc");
            m5.Remove("abc");
            m5.Add("bbb", "x");
            m5i.Add("ABC", "x");
            Assert.AreEqual(0, m0.Count);
            Assert.AreEqual(0, m1.Count);
            Assert.AreEqual(4, m5.Count);
            Assert.AreEqual(5, m5i.Count);
        }
Example #16
0
        protected void SetUp(out StringMap m0,
            out StringMap m1,
            out StringMap m5,
            out StringMap m5i)
        {
            m0=new StringMap();
            m1=new StringMap(false);
            m1.Add("abc", "0");

            m5=new StringMap(false);
            m5.Add("a", "0");
            m5.Add("ab", "1");
            m5.Add("abc", "2");
            m5.Add("abb", "3");
            m5.Add("bbb", "4");

            m5i=new StringMap(true);
            m5i.Add(null, "0");
            m5i.Add("ab", "1");
            m5i.Add("abc", "2");
            m5i.Add("abb", "3");
            m5i.Add("bbb", null);
        }
Example #17
0
        public void TryFindSubStringWorstCase()
        {
            // this is not a really meaningful comparison as Find does much more work
            // finding the end while substring gets the end for free.
            // interesting as a base line.
            var cache = new StringMap <string>();

            cache.Add("abc0", "d");
            cache.Add("abc01", "e");
            cache.Add("abc1", "e");
            cache.Add("abc11", "e");
            cache.Add("abc2", "f");
            cache.Add("abc21", "f");

            const string text0 = "   abc0   ";
            const string text1 = "   abc1   ";
            const string text2 = "   abc2   ";
            string       cached;

            cache.TryGetBySubString(text0, 4, out cached);

            var subString = text0.Substring(3, 4);

            var sw = Stopwatch.StartNew();
            var n  = 1000000;

            for (int i = 0; i < n; i++)
            {
                switch (i % 3)
                {
                case 0:
                    cache.TryGetBySubString(text0, 4, out cached);
                    continue;

                case 1:
                    cache.TryGetBySubString(text1, 4, out cached);
                    continue;

                case 2:
                    cache.TryGetBySubString(text2, 4, out cached);
                    continue;

                default:
                    throw new Exception();
                }
            }

            sw.Stop();
            Console.WriteLine($"// {DateTime.Today.ToShortDateString()}| cache.TryFind(text, 4, out cached) {n:N0} times with cache took: {sw.ElapsedMilliseconds} ms");

            sw.Restart();
            for (int i = 0; i < n; i++)
            {
                switch (i % 3)
                {
                case 0:
                    subString = text0.Substring(3, 4);
                    continue;

                case 1:
                    subString = text1.Substring(3, 4);
                    continue;

                case 2:
                    subString = text2.Substring(3, 4);
                    continue;

                default:
                    throw new Exception();
                }
            }

            sw.Stop();
            Console.WriteLine($"// {DateTime.Today.ToShortDateString()}| text.Substring(3, 4)               {n:N0} times            took: {sw.ElapsedMilliseconds} ms");
        }
Example #18
0
        /// <summary>
        /// Get a List of statement document lines from an array of strings.
        /// </summary>
        /// <param name="lines">Array of text lines in the format specified by Atrio as a statement file.</param>
        /// <returns></returns>
        public static HeaderSource <List <StringMap>, List <string> > ParseM691(string[] lines)
        {
            List <StringMap> tempMapList = new List <StringMap>();
            List <string>    headerList  = new List <string>();

            foreach (string line in lines)
            {
                StringMap docLine = new StringMap();
                docLine.Add("Group Billing Acct ID", Parse.TrimSubstring(line, 29, 9));
                headerList.Add("Group Billing Acct ID");
                docLine.Add("accountNumberGroup", docLine["Group Billing Acct ID"]);
                docLine.Add("AccountNumberGroup", docLine["Group Billing Acct ID"]);

                docLine.Add("Invoice Number", Parse.TrimSubstring(line, 20, 9));
                headerList.Add("Invoice Number");
                docLine.Add("invoiceNum", docLine["Invoice Number"]);
                docLine.Add("InvoiceNum", docLine["Invoice Number"]);

                docLine.Add("Invoice Amount", Parse.TrimSubstring(line, 47, 19));
                headerList.Add("Invoice Amount");
                docLine.Add("invoiceAmount", docLine["Invoice Amount"]);
                docLine.Add("InvoiceAmount", docLine["Invoice Amount"]);
                docLine.Add("InvoiceAmt", docLine["Invoice Amount"]);

                docLine.Add("Low-Income Subsidy Amount", Parse.TrimSubstring(line, 66, 19));
                headerList.Add("Low-Income Subsidy Amount");
                docLine.Add("Low Income Subsidy Amount", docLine["Low-Income Subsity Amount"]);
                docLine.Add("lowIncomeSubsidy", docLine["Low-Income Subsity Amount"]);
                docLine.Add("LowIncomeSubsidy", docLine["Low-Income Subsity Amount"]);

                docLine.Add("Late-Enrollment Penalty Amount", Parse.TrimSubstring(line, 85, 19));
                headerList.Add("Late-Enrollment Penalty Amount");
                docLine.Add("Late Enrollment Penalty Amount", docLine["Late-Enrollment Penalty Amount"]);
                docLine.Add("lateEnrollmentPenalty", docLine["Late-Enrollment Penalty Amount"]);
                docLine.Add("LateEnrollmentPenalty", docLine["Late-Enrollment Penalty Amount"]);

                docLine.Add("Invoice Period From Date", Parse.TrimSubstring(line, 10, 10));
                headerList.Add("Invoice Period From Date");
                docLine.Add("fromDate", docLine["Invoice Period From Date"]);
                docLine.Add("FromDate", docLine["Invoice Period From Date"]);
                docLine.Add("Invoice Start Date", docLine["Invoice Period From Date"]);

                docLine.Add("Invoice Period To Date", Parse.TrimSubstring(line, 10, 10));
                headerList.Add("Invoice Period To Date");
                docLine.Add("Invoice End Date", docLine["Invoice Period To Date"]);
                docLine.Add("toDate", docLine["Invoice Period To Date"]);
                docLine.Add("ToDate", docLine["Invoice Period To Date"]);

                tempMapList.Add(docLine);
            }
            HeaderSource <List <StringMap>, List <string> > ret =
                new HeaderSource <List <StringMap>, List <string> >(tempMapList, headerList.ToArray());

            // return type: headerSource<List<StringMap>, string>
            return(ret);
        }
 static ApixuWeatherService()
 {
     WeatherIconMap.Add("1000", "\xF00D");
     WeatherIconMap.Add("1003", "\xF002");
     WeatherIconMap.Add("1006", "\xF013");
     WeatherIconMap.Add("1009", "\xF013");
     WeatherIconMap.Add("1030", "\xF014");
     WeatherIconMap.Add("1063", "\xF008");
     WeatherIconMap.Add("1066", "\xF00A");
     WeatherIconMap.Add("1069", "\xF004");
     WeatherIconMap.Add("1072", "\xF019");
     WeatherIconMap.Add("1087", "\xF005");
     WeatherIconMap.Add("1114", "\xF01B");
     WeatherIconMap.Add("1117", "\xF01B");
     WeatherIconMap.Add("1135", "\xF014");
     WeatherIconMap.Add("1147", "\xF014");
     WeatherIconMap.Add("1150", "\xF019");
     WeatherIconMap.Add("1153", "\xF019");
     WeatherIconMap.Add("1168", "\xF019");
     WeatherIconMap.Add("1171", "\xF019");
     WeatherIconMap.Add("1180", "\xF008");
     WeatherIconMap.Add("1183", "\xF019");
     WeatherIconMap.Add("1186", "\xF008");
     WeatherIconMap.Add("1189", "\xF019");
     WeatherIconMap.Add("1192", "\xF008");
     WeatherIconMap.Add("1195", "\xF019");
     WeatherIconMap.Add("1198", "\xF019");
     WeatherIconMap.Add("1201", "\xF019");
     WeatherIconMap.Add("1204", "\xF015");
     WeatherIconMap.Add("1207", "\xF015");
     WeatherIconMap.Add("1210", "\xF00A");
     WeatherIconMap.Add("1213", "\xF01B");
     WeatherIconMap.Add("1216", "\xF00A");
     WeatherIconMap.Add("1219", "\xF01B");
     WeatherIconMap.Add("1222", "\xF00A");
     WeatherIconMap.Add("1225", "\xF01B");
     WeatherIconMap.Add("1237", "\xF017");
     WeatherIconMap.Add("1240", "\xF008");
     WeatherIconMap.Add("1243", "\xF008");
     WeatherIconMap.Add("1246", "\xF008");
     WeatherIconMap.Add("1249", "\xF004");
     WeatherIconMap.Add("1252", "\xF004");
     WeatherIconMap.Add("1255", "\xF00A");
     WeatherIconMap.Add("1258", "\xF00A");
     WeatherIconMap.Add("1261", "\xF009");
     WeatherIconMap.Add("1264", "\xF009");
     WeatherIconMap.Add("1273", "\xF005");
     WeatherIconMap.Add("1276", "\xF01D");
     WeatherIconMap.Add("1279", "\xF00E");
     WeatherIconMap.Add("1282", "\xF01D");
 }
Example #20
0
    // Suppress the deprecation warning for _SetId, since the DB is intended to use it
#pragma warning disable 612, 618
    public void UpdateDatabase()
    {
        if (!defaultItem)
        {
            Debug.LogError("Cannot update the database. A default item MUST be assigned.");
            return;
        }

        // Add the default item
        registeredItems.Remove(0);
        defaultItem._SetId(this, 0);
        registeredItems.Add(0, defaultItem);

        // Add new items
        var existingValues = registeredItems.Values;

        foreach (ItemBase newItem in addItems)
        {
            // No double registering
            if (existingValues.Contains(newItem))
            {
                continue;
            }

            newItem._SetId(this, idCounter);
            registeredItems.Add(idCounter, newItem);
            idCounter++;
        }
        addItems.Clear();

        //Remap missing items that have been filled out
        //

        // Remove missing items/ids
        List <uint> missingValues = new List <uint>(10);

        foreach (var pair in registeredItems)
        {
            if (!pair.Value)
            {
                missingValues.Add(pair.Key);
            }
        }
        foreach (uint key in missingValues)
        {
            registeredItems.Remove(key);
        }

        // Add the missing items' ids for remapping
        foreach (uint id in missingValues)
        {
            string name = "Unknown";
            nameMap.TryGetValue(id, out name);

            missingIds.Add(id);
            missingNameMap.Add(id, name);
        }

        // Regenerate name map
        nameMap.Clear();
        foreach (var pair in registeredItems)
        {
            nameMap.Add(pair.Key, pair.Value.GetName());
        }
    }
Example #21
0
 /// <summary>
 /// StringMap
 /// </summary>
 private static void benchmark7(int size)
 {
     GC.Collect();
     var dictionary = new StringMap<int>();
     var keys = new string[size];
     for (int i = 0; i < keys.Length; i++)
         keys[i] = i.ToString();
     var sw = new Stopwatch();
     sw.Start();
     for (int i = 0; i < keys.Length; i++)
         dictionary.Add(keys[(long)i * psrandmul % keys.Length], (int)(((long)i * psrandmul) % keys.Length));
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     GC.GetTotalMemory(true);
     sw.Restart();
     foreach (var t in dictionary)
     {
         // System.Diagnostics.Debugger.Break(); // порядок не соблюдается. Проверка бессмыслена
     }
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     GC.GetTotalMemory(true);
     sw.Restart();
     for (int i = 0; i < keys.Length; i++)
     {
         if (dictionary[keys[i]] != i)
             throw new Exception();
     }
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     Console.WriteLine(StringMap<int>.missCount);
 }
Example #22
0
        private void fillMembers()
        {
            lock (this)
            {
                if (_members != null)
                {
                    return;
                }

                var                tempMembers       = new StringMap <IList <MemberInfo> >();
                string             prewName          = null;
                IList <MemberInfo> temp              = null;
                bool               instanceAttribute = false;
#if (PORTABLE || NETCORE)
                var members = _hostedType.GetTypeInfo().DeclaredMembers
                              .Union(_hostedType.GetRuntimeMethods())
                              .Union(_hostedType.GetRuntimeProperties())
                              .Union(_hostedType.GetRuntimeFields())
                              .Union(_hostedType.GetRuntimeEvents()).ToArray();
#else
                var members = _hostedType.GetMembers();
#endif
                for (int i = 0; i < members.Length; i++)
                {
                    var member = members[i];
                    if (member.IsDefined(typeof(HiddenAttribute), false))
                    {
                        continue;
                    }

                    instanceAttribute = member.IsDefined(typeof(InstanceMemberAttribute), false);

                    if (!IsInstancePrototype && instanceAttribute)
                    {
                        continue;
                    }

                    var property = member as PropertyInfo;
                    if (property != null)
                    {
                        if ((property.GetSetMethod(true) ?? property.GetGetMethod(true)).IsStatic != !(IsInstancePrototype ^ instanceAttribute))
                        {
                            continue;
                        }
                        if ((property.GetSetMethod(true) == null || !property.GetSetMethod(true).IsPublic) &&
                            (property.GetGetMethod(true) == null || !property.GetGetMethod(true).IsPublic))
                        {
                            continue;
                        }

                        var parentProperty = property;
                        while (parentProperty != null &&
                               parentProperty.DeclaringType != typeof(object) &&
                               ((property.GetGetMethod() ?? property.GetSetMethod()).Attributes & MethodAttributes.NewSlot) == 0)
                        {
                            property = parentProperty;
#if (PORTABLE || NETCORE)
                            parentProperty = property.DeclaringType.GetTypeInfo().BaseType?.GetRuntimeProperty(property.Name);
#else
                            parentProperty = property.DeclaringType.GetTypeInfo().BaseType?.GetProperty(property.Name, BindingFlags.Public | BindingFlags.Instance);
#endif
                        }

                        member = property;
                    }

                    if (member is EventInfo &&
                        (!(member as EventInfo).GetAddMethod(true).IsPublic || (member as EventInfo).GetAddMethod(true).IsStatic != !IsInstancePrototype))
                    {
                        continue;
                    }

                    if (member is FieldInfo && (!(member as FieldInfo).IsPublic || (member as FieldInfo).IsStatic != !IsInstancePrototype))
                    {
                        continue;
                    }
#if (PORTABLE || NETCORE)
                    if ((members[i] is TypeInfo) && !(members[i] as TypeInfo).IsPublic)
                    {
                        continue;
                    }
#else
                    if (member is Type && !(member as Type).IsPublic && !(member as Type).IsNestedPublic)
                    {
                        continue;
                    }
#endif
                    var method = member as MethodBase;
                    if (method != null)
                    {
                        if (method.IsStatic != !(IsInstancePrototype ^ instanceAttribute))
                        {
                            continue;
                        }
                        if (!method.IsPublic)
                        {
                            continue;
                        }
                        if (method.DeclaringType == typeof(object) && member.Name == "GetType")
                        {
                            continue;
                        }
                        if (method is ConstructorInfo)
                        {
                            continue;
                        }

                        var parameterTypes = method.GetParameters().Select(x => x.ParameterType).ToArray();
                        if (parameterTypes.Any(x => x.IsByRef))
                        {
                            continue;
                        }

                        if (method.IsVirtual && (method.Attributes & MethodAttributes.NewSlot) == 0)
                        {
                            var parentMethod = method;
                            while (parentMethod != null && parentMethod.DeclaringType != typeof(object) && (method.Attributes & MethodAttributes.NewSlot) == 0)
                            {
                                method = parentMethod;
#if (PORTABLE || NETCORE)
                                parentMethod = method.DeclaringType.GetTypeInfo().BaseType?.GetMethod(method.Name, parameterTypes);
#else
                                parentMethod = method.DeclaringType.BaseType?.GetMethod(method.Name, BindingFlags.Public | BindingFlags.Instance, null, parameterTypes, null);
#endif
                            }
                        }

                        member = method;
                    }

                    var membername = member.Name;
                    if (member.IsDefined(typeof(JavaScriptNameAttribute), false))
                    {
                        var nameOverrideAttribute = member.GetCustomAttributes(typeof(JavaScriptNameAttribute), false).ToArray();
                        membername = (nameOverrideAttribute[0] as JavaScriptNameAttribute).Name;
                    }
                    else
                    {
                        membername = membername[0] == '.' ? membername : membername.Contains(".") ? membername.Substring(membername.LastIndexOf('.') + 1) : membername;

#if (PORTABLE || NETCORE)
                        if (members[i] is TypeInfo && membername.Contains("`"))
#else
                        if (member is Type && membername.Contains('`'))
#endif
                        {
                            membername = membername.Substring(0, membername.IndexOf('`'));
                        }
                    }

                    if (prewName != membername)
                    {
                        if (temp != null && temp.Count > 1)
                        {
                            var type = temp[0].DeclaringType;
                            for (var j = 1; j < temp.Count; j++)
                            {
                                if (type != temp[j].DeclaringType && type.IsAssignableFrom(temp[j].DeclaringType))
                                {
                                    type = temp[j].DeclaringType;
                                }
                            }
                            int offset = 0;
                            for (var j = 1; j < temp.Count; j++)
                            {
                                if (!type.IsAssignableFrom(temp[j].DeclaringType))
                                {
                                    temp.RemoveAt(j--);
                                    tempMembers.Remove(prewName + "$" + (++offset + j));
                                }
                            }
                            if (temp.Count == 1)
                            {
                                tempMembers.Remove(prewName + "$0");
                            }
                        }
                        if (!tempMembers.TryGetValue(membername, out temp))
                        {
                            tempMembers[membername] = temp = new List <MemberInfo>();
                        }
                        prewName = membername;
                    }

                    if (membername.StartsWith("@@"))
                    {
                        if (_symbols == null)
                        {
                            _symbols = new Dictionary <Symbol, JSValue>();
                        }
                        _symbols.Add(Symbol.@for(membername.Substring(2)), proxyMember(false, new[] { member }));
                    }
                    else
                    {
                        if (temp.Count == 1)
                        {
                            tempMembers.Add(membername + "$0", new[] { temp[0] });
                        }

                        temp.Add(member);

                        if (temp.Count != 1)
                        {
                            tempMembers.Add(membername + "$" + (temp.Count - 1), new[] { member });
                        }
                    }
                }

                _members = tempMembers;

                if (IsInstancePrototype)
                {
                    if (typeof(IIterable).IsAssignableFrom(_hostedType))
                    {
                        IList <MemberInfo> iterator = null;
                        if (_members.TryGetValue("iterator", out iterator))
                        {
                            if (_symbols == null)
                            {
                                _symbols = new Dictionary <Symbol, JSValue>();
                            }
                            _symbols.Add(Symbol.iterator, proxyMember(false, iterator));
                            _members.Remove("iterator");
                        }
                    }
#if NET40
                    var toStringTag = _hostedType.GetCustomAttribute <ToStringTagAttribute>();
#else
                    var toStringTag = _hostedType.GetTypeInfo().GetCustomAttribute <ToStringTagAttribute>();
#endif
                    if (toStringTag != null)
                    {
                        if (_symbols == null)
                        {
                            _symbols = new Dictionary <Symbol, JSValue>();
                        }
                        _symbols.Add(Symbol.toStringTag, toStringTag.Tag);
                    }
                }

                if (_indexersSupported)
                {
                    IList <MemberInfo> getter = null;
                    IList <MemberInfo> setter = null;
                    _members.TryGetValue("get_Item", out getter);
                    _members.TryGetValue("set_Item", out setter);

                    if (getter != null || setter != null)
                    {
                        _indexerProperty = new PropertyPair();

                        if (getter != null)
                        {
                            _indexerProperty.getter = (Function)proxyMember(false, getter);
                            _fields["get_Item"]     = _indexerProperty.getter;
                        }

                        if (setter != null)
                        {
                            _indexerProperty.setter = (Function)proxyMember(false, setter);
                            _fields["set_Item"]     = _indexerProperty.setter;
                        }
                    }
                    else
                    {
                        _indexersSupported = false;
                    }
                }
            }
        }