C#.NET dll封装(包含UI和实现函数),通过反射调用dll实现控件的快速加载(PointListTypeAttributes.cs)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using Tztek.XBus.Task.TaskPrimMode;
using Tztek._3DSpec.Prims.PointList.Properties;

namespace Tztek._3DSpec.Prims.PointList
{
    class PointListTypeAttributes : ITaskPrimTypeAttributes
    {
        private PointListTypeAttributes()
        {
            _version = new Version(1, 0);
        }

        public static ITaskPrimTypeAttributes Instance
        {
            get
            {
                if (null == _instance)
                {
                    lock (_objSync)
                    {
                        if (null == _instance)
                        {
                            _instance = new PointListTypeAttributes();
                        }
                    }
                }
                return _instance;
            }
        }
        private static PointListTypeAttributes _instance;
        private static object _objSync = new object();

        public IEnumerable<KeyValuePair<string, object>> Attributes
        {
            get
            {
                if (0 == MyAttributes.Count)
                {
                    Type type = GetType();
                    foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
                    {
                        KeyValuePair<string, object> attribute = new KeyValuePair<string, object>(propertyInfo.Name,
                            propertyInfo.GetValue(this, null));
                        MyAttributes.Add(attribute);
                    }
                }
                return MyAttributes;
            }
        }

        public string Description
        {
            get { return Resources.IDS_DESCRIPTION; }
        }

        public string DisplayGroup
        {
            get { return "3DM"; }
        }

        public string DisplayName
        {
            get { return Resources.IDS_NAME; }
        }

        public string Group
        {
            get { return "3DM"; }
        }

        public System.Drawing.Image Icon
        {
            get { return (Image)Resources.ResourceManager.GetObject("ICON_POINTLIST"); }
        }

        public byte MajorVersion
        {
            get { return (byte)_version.Major; }
        }

        public byte MinorVersion
        {
            get { return (byte)_version.Minor; }
        }

        public string Name
        {
            get { return Resources.IDS_NAME; }
        }

        public object this[string attrName]
        {
            get
            {
                foreach (KeyValuePair<string, object> keyValuePair in MyAttributes)
                {
                    if (attrName == keyValuePair.Key)
                    {
                        return keyValuePair.Value;
                    }
                }
                return null;
            }
        }

        private readonly Version _version;
        protected readonly List<KeyValuePair<string, object>> MyAttributes = new List<KeyValuePair<string, object>>();

    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值