zoukankan      html  css  js  c++  java
  • ABP 内置 NameValue 对象

    这个类的最主要作用就是节约一个类,其他没发现有什么特别的。而且像 键/值 队的这种场景也确实却在一些。

    using System;
    
    namespace Abp
    {
        /// <summary>
        /// Can be used to store Name/Value (or Key/Value) pairs.
        /// </summary>
        [Serializable]
        public class NameValue : NameValue<string>
        {
            /// <summary>
            /// Creates a new <see cref="NameValue"/>.
            /// </summary>
            public NameValue()
            {
    
            }
    
            /// <summary>
            /// Creates a new <see cref="NameValue"/>.
            /// </summary>
            public NameValue(string name, string value)
            {
                Name = name;
                Value = value;
            }
        }
    
        /// <summary>
        /// Can be used to store Name/Value (or Key/Value) pairs.
        /// </summary>
        [Serializable]
        public class NameValue<T>
        {
            /// <summary>
            /// Name.
            /// </summary>
            public string Name { get; set; }
    
            /// <summary>
            /// Value.
            /// </summary>
            public T Value { get; set; }
    
            /// <summary>
            /// Creates a new <see cref="NameValue"/>.
            /// </summary>
            public NameValue()
            {
    
            }
    
            /// <summary>
            /// Creates a new <see cref="NameValue"/>.
            /// </summary>
            public NameValue(string name, T value)
            {
                Name = name;
                Value = value;
            }
        }
    }

    下面来试试怎么用:

    var list = new List<NameValue<int>>();

    这样就可以输入一个供报表使用的数据合集了。在没有使用 NameValue 之前 Dictionary 用得比较多,直到有一天在给 iOS 提供数据时对方反馈 iOS 中 使用 NSDictionary 接收 Dictionary 并且是无序的。这就导致无法按照预期显示数据。所以发掘了 NameValue 并且统一了返回数据的风格。

  • 相关阅读:
    第九周
    第八周
    第七周
    代码复审核查表
    对软件开发的理解
    第六周
    网站流量分析架构及实现
    hive的sql语句
    精简客户端搭建Oracle数据库
    idaa搭建maven发布tomcat
  • 原文地址:https://www.cnblogs.com/fxck/p/13076603.html
Copyright © 2011-2022 走看看