Ejemplo n.º 1
0
        /// <summary>
        /// Does the opposite: creates a literal string from values
        /// </summary>
        private void UpdateMember()
        {
            //var pairs = from kvp in dictionary orderby kvp.Value select kvp;//按值排序,在这里忽略,因为不会使用本方法
            //var pairs = dictionary.
            int currentValue = 1;
            var keyValues    = new List <string>();

            foreach (var pair in dictionary)
            {
                string keyValue;
                if (pair.Value == currentValue)
                {
                    keyValue = pair.Key;
                }
                else
                {
                    currentValue = pair.Value;
                    keyValue     = string.Format("{0}={1}", pair.Key, pair.Value);
                }
                keyValues.Add(keyValue);
                currentValue++;
            }
            string literalType = string.IsNullOrEmpty(Name) ? "enum" : Name;

            literalType += " ";
            literalType += string.Join(", ", keyValues.ToArray());
            MemberInfoExtensions.SetMemberValue(memberInfo, owner, literalType);
        }
Ejemplo n.º 2
0
 protected void SetValue(IEnumerable value)
 {
     MemberInfoExtensions.SetMemberValue(memberInfo, owner, value);
 }