IQMap.Impl.Support.ParameterParser.GetProperties C# (CSharp) Method

GetProperties() protected method

Enumerate props/values for an object
protected GetProperties ( object obj ) : object>>.IEnumerable
obj object
return object>>.IEnumerable
        protected IEnumerable<KeyValuePair<string, object>> GetProperties(object obj)
        {
            Type type = obj.GetType();
            bool isAnon = Types.IsAnonymousType(obj.GetType());
            if (obj is IDictionary<string, object>)
            {
                foreach (var item in (IDictionary<string, object>)obj)
                {
                    yield return item;
                }
            } else {
                IEnumerable<MemberInfo> members = type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
                foreach (var member in members)
                {
                    if (member is MethodInfo && isAnon)
                    {
                        MethodInfo info = (MethodInfo)member;
                        if (info.Name.Length >= 4 && info.Name.StartsWith("get_"))
                        {
                            yield return new KeyValuePair<string, object>(info.Name, info.Invoke(obj, null));
                        }
                    }

                    else
                    {

                        if (member is PropertyInfo)
                        {
                            PropertyInfo info = (PropertyInfo)member;
                            yield return new KeyValuePair<string, object>(info.Name, info.GetValue(obj, null));
                        }
                    }
                }

            }
        }