コード例 #1
0
        /// <summary>
        /// Returns ordered dictionary with object fields.
        /// </summary>
        /// <param name="obj">object</param>
        /// <param name="includeBase">Should include fields from object base class, default: false</param>
        /// <returns>Ordered dictionary with object fields</returns>
        public static OrderedImmutableDictionary <string, object> Fields(object obj, bool includeBase = false)
        {
            var builder = OrderedHashImmutableDictionary <string, object> .Builder();

            const BindingFlags options = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;

            AppendFields(obj, obj.GetType(), builder, options, includeBase);
            return(builder.Build());
        }
コード例 #2
0
        public void ShouldReturnKeysInPutOrder()
        {
            // given
            var dictionary = OrderedHashImmutableDictionary <string, int> .Builder()
                             .Put("Z", 1)
                             .Put("Y", 2)
                             .Put("X", 3)
                             .Build();

            // when
            var orderedKeys = dictionary.OrderedKeys;

            // then
            Check.That(orderedKeys).ContainsExactly("Z", "Y", "X");
        }