Пример #1
0
        // Session Key is optional parameter
        // Session Key could be obtained from RenrenClient
        public GetInfoRequest(int userId, string sessionKey, FieldsFlag fields = FieldsFlag.Default)
        {
            AddParameter(UIDS_PARAM_NAME, userId);

            var fieldsParamValue = BuildFieldsParamValue(fields);
            AddParameter(FIELDS_PARAM_NAME, fieldsParamValue);

            //optional
            if (!string.IsNullOrEmpty(sessionKey))
                AddParameter(SESSION_KEY_PARAM_NAME, sessionKey);
        }
Пример #2
0
        // Session Key is optional parameter
        // Session Key could be obtained from RenrenClient
        public GetInfoRequest(int userId, string sessionKey, FieldsFlag fields = FieldsFlag.Default)
        {
            AddParameter(UIDS_PARAM_NAME, userId);

            var fieldsParamValue = BuildFieldsParamValue(fields);

            AddParameter(FIELDS_PARAM_NAME, fieldsParamValue);

            //optional
            if (!string.IsNullOrEmpty(sessionKey))
            {
                AddParameter(SESSION_KEY_PARAM_NAME, sessionKey);
            }
        }
Пример #3
0
        private static string BuildFieldsParamValue(FieldsFlag fields)
        {
            var sb = new StringBuilder();

            foreach (var name in Enum.GetNames(typeof(FieldsFlag)))
            {
                if (name == "Default" || name == "All")
                {
                    continue;
                }

                var f = (FieldsFlag)Enum.Parse(typeof(FieldsFlag), name);
                if ((f & fields) != 0)
                {
                    sb.AppendFormat("{0},", FieldsEnumStringMapper[f]);
                }
            }
            return(sb.ToString());
        }
Пример #4
0
        private static string BuildFieldsParamValue(FieldsFlag fields)
        {
            var sb = new StringBuilder();
            foreach (var name in Enum.GetNames(typeof(FieldsFlag)))
            {
                if (name == "Default" || name == "All") continue;

                var f = (FieldsFlag)Enum.Parse(typeof(FieldsFlag), name);
                if ((f & fields) != 0) sb.AppendFormat("{0},", FieldsEnumStringMapper[f]);
            }
            return sb.ToString();
        }