开发中灵活使用属性类

简介:

什么是属性类?

        从抽象类System.Attribute派生出来的类(无论是直接的还是间接的)都称为属性类(MSDN中的定义)。



        属性类的名称一般都带有Attribute后缀,但使用的时候可以包含也可以忽略,如果你自己起的名字没有这个后缀,则需要全称来区分了。如果不怕输入麻烦,建议还是不管是否有后缀,都输入全称为好,这样可以减少歧义。

        在.NET框架中差不多定义了200个Attribute相关类,可见Attribute的应用十分广泛,它的全图在MSDN中如下:

None.gifSystem.Object
None.gif   System.Attribute
None.gif      System.AttributeUsageAttribute
None.gif      System.CLSCompliantAttribute
None.gif      System.ComponentModel.AmbientValueAttribute
None.gif      System.ComponentModel.BindableAttribute
None.gif      System.ComponentModel.BrowsableAttribute
None.gif      System.ComponentModel.CategoryAttribute
None.gif      System.ComponentModel.DefaultEventAttribute
None.gif      System.ComponentModel.DefaultPropertyAttribute
None.gif      System.ComponentModel.DefaultValueAttribute
None.gif      System.ComponentModel.DescriptionAttribute
None.gif      System.ComponentModel.Design.Serialization.DesignerSerializerAttribute
None.gif      System.ComponentModel.Design.Serialization.RootDesignerSerializerAttribute
None.gif      System.ComponentModel.DesignerAttribute
None.gif      System.ComponentModel.DesignerCategoryAttribute
None.gif      System.ComponentModel.DesignerSerializationVisibilityAttribute
None.gif      System.ComponentModel.DesignOnlyAttribute
None.gif      System.ComponentModel.DesignTimeVisibleAttribute
None.gif      System.ComponentModel.EditorAttribute
None.gif      System.ComponentModel.EditorBrowsableAttribute
None.gif      System.ComponentModel.ImmutableObjectAttribute
None.gif      System.ComponentModel.InheritanceAttribute
None.gif      System.ComponentModel.InstallerTypeAttribute
None.gif      System.ComponentModel.LicenseProviderAttribute
None.gif      System.ComponentModel.ListBindableAttribute
None.gif      System.ComponentModel.LocalizableAttribute
None.gif      System.ComponentModel.MergablePropertyAttribute
None.gif      System.ComponentModel.NotifyParentPropertyAttribute
None.gif      System.ComponentModel.ParenthesizePropertyNameAttribute
None.gif      System.ComponentModel.PropertyTabAttribute
None.gif      System.ComponentModel.ProvidePropertyAttribute
None.gif      System.ComponentModel.ReadOnlyAttribute
None.gif      System.ComponentModel.RecommendedAsConfigurableAttribute
None.gif      System.ComponentModel.RefreshPropertiesAttribute
None.gif      System.ComponentModel.RunInstallerAttribute
None.gif      System.ComponentModel.ToolboxItemAttribute
None.gif      System.ComponentModel.ToolboxItemFilterAttribute
None.gif      System.ComponentModel.TypeConverterAttribute
None.gif      System.ContextStaticAttribute
None.gif      System.Diagnostics.ConditionalAttribute
None.gif      System.Diagnostics.DebuggableAttribute
None.gif      System.Diagnostics.DebuggerHiddenAttribute
None.gif      System.Diagnostics.DebuggerStepThroughAttribute
None.gif      System.Drawing.ToolboxBitmapAttribute
None.gif      System.EnterpriseServices.ApplicationAccessControlAttribute
None.gif      System.EnterpriseServices.ApplicationActivationAttribute
None.gif      System.EnterpriseServices.ApplicationIDAttribute
None.gif      System.EnterpriseServices.ApplicationNameAttribute
None.gif      System.EnterpriseServices.ApplicationQueuingAttribute
None.gif      System.EnterpriseServices.AutoCompleteAttribute
None.gif      System.EnterpriseServices.CompensatingResourceManager.ApplicationCrmEnabledAttribute
None.gif      System.EnterpriseServices.ComponentAccessControlAttribute
None.gif      System.EnterpriseServices.COMTIIntrinsicsAttribute
None.gif      System.EnterpriseServices.ConstructionEnabledAttribute
None.gif      System.EnterpriseServices.DescriptionAttribute
None.gif      System.EnterpriseServices.EventClassAttribute
None.gif      System.EnterpriseServices.EventTrackingEnabledAttribute
None.gif      System.EnterpriseServices.ExceptionClassAttribute
None.gif      System.EnterpriseServices.IISIntrinsicsAttribute
None.gif      System.EnterpriseServices.InterfaceQueuingAttribute
None.gif      System.EnterpriseServices.JustInTimeActivationAttribute
None.gif      System.EnterpriseServices.LoadBalancingSupportedAttribute
None.gif      System.EnterpriseServices.MustRunInClientContextAttribute
None.gif      System.EnterpriseServices.ObjectPoolingAttribute
None.gif      System.EnterpriseServices.PrivateComponentAttribute
None.gif      System.EnterpriseServices.SecureMethodAttribute
None.gif      System.EnterpriseServices.SecurityRoleAttribute
None.gif      System.EnterpriseServices.SynchronizationAttribute
None.gif      System.EnterpriseServices.TransactionAttribute
None.gif      System.FlagsAttribute
None.gif      System.LoaderOptimizationAttribute
None.gif      System.Management.Instrumentation.IgnoreMemberAttribute
None.gif      System.Management.Instrumentation.InstrumentationClassAttribute
None.gif      System.Management.Instrumentation.InstrumentedAttribute
None.gif      System.Management.Instrumentation.ManagedNameAttribute
None.gif      System.MTAThreadAttribute
None.gif      System.NonSerializedAttribute
None.gif      System.ObsoleteAttribute
None.gif      System.ParamArrayAttribute
None.gif      System.Reflection.AssemblyAlgorithmIdAttribute
None.gif      System.Reflection.AssemblyCompanyAttribute
None.gif      System.Reflection.AssemblyConfigurationAttribute
None.gif      System.Reflection.AssemblyCopyrightAttribute
None.gif      System.Reflection.AssemblyCultureAttribute
None.gif      System.Reflection.AssemblyDefaultAliasAttribute
None.gif      System.Reflection.AssemblyDelaySignAttribute
None.gif      System.Reflection.AssemblyDescriptionAttribute
None.gif      System.Reflection.AssemblyFileVersionAttribute
None.gif      System.Reflection.AssemblyFlagsAttribute
None.gif      System.Reflection.AssemblyInformationalVersionAttribute
None.gif      System.Reflection.AssemblyKeyFileAttribute
None.gif      System.Reflection.AssemblyKeyNameAttribute
None.gif      System.Reflection.AssemblyProductAttribute
None.gif      System.Reflection.AssemblyTitleAttribute
None.gif      System.Reflection.AssemblyTrademarkAttribute
None.gif      System.Reflection.AssemblyVersionAttribute
None.gif      System.Reflection.DefaultMemberAttribute
None.gif      System.Resources.NeutralResourcesLanguageAttribute
None.gif      System.Resources.SatelliteContractVersionAttribute
None.gif      System.Runtime.CompilerServices.AccessedThroughPropertyAttribute
None.gif      System.Runtime.CompilerServices.CompilationRelaxationsAttribute
None.gif      System.Runtime.CompilerServices.CompilerGlobalScopeAttribute
None.gif      System.Runtime.CompilerServices.CustomConstantAttribute
None.gif      System.Runtime.CompilerServices.DecimalConstantAttribute
None.gif      System.Runtime.CompilerServices.DiscardableAttribute
None.gif      System.Runtime.CompilerServices.IndexerNameAttribute
None.gif      System.Runtime.CompilerServices.MethodImplAttribute
None.gif      System.Runtime.CompilerServices.RequiredAttributeAttribute
None.gif      System.Runtime.InteropServices.AutomationProxyAttribute
None.gif      System.Runtime.InteropServices.BestFitMappingAttribute
None.gif      System.Runtime.InteropServices.ClassInterfaceAttribute
None.gif      System.Runtime.InteropServices.CoClassAttribute
None.gif      System.Runtime.InteropServices.ComAliasNameAttribute
None.gif      System.Runtime.InteropServices.ComCompatibleVersionAttribute
None.gif      System.Runtime.InteropServices.ComConversionLossAttribute
None.gif      System.Runtime.InteropServices.ComEventInterfaceAttribute
None.gif      System.Runtime.InteropServices.ComImportAttribute
None.gif      System.Runtime.InteropServices.ComRegisterFunctionAttribute
None.gif      System.Runtime.InteropServices.ComSourceInterfacesAttribute
None.gif      System.Runtime.InteropServices.ComUnregisterFunctionAttribute
None.gif      System.Runtime.InteropServices.ComVisibleAttribute
None.gif      System.Runtime.InteropServices.DispIdAttribute
None.gif      System.Runtime.InteropServices.DllImportAttribute
None.gif      System.Runtime.InteropServices.FieldOffsetAttribute
None.gif      System.Runtime.InteropServices.GuidAttribute
None.gif      System.Runtime.InteropServices.IDispatchImplAttribute
None.gif      System.Runtime.InteropServices.ImportedFromTypeLibAttribute
None.gif      System.Runtime.InteropServices.InAttribute
None.gif      System.Runtime.InteropServices.InterfaceTypeAttribute
None.gif      System.Runtime.InteropServices.LCIDConversionAttribute
None.gif      System.Runtime.InteropServices.MarshalAsAttribute
None.gif      System.Runtime.InteropServices.OptionalAttribute
None.gif      System.Runtime.InteropServices.OutAttribute
None.gif      System.Runtime.InteropServices.PreserveSigAttribute
None.gif      System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute
None.gif      System.Runtime.InteropServices.ProgIdAttribute
None.gif      System.Runtime.InteropServices.StructLayoutAttribute
None.gif      System.Runtime.InteropServices.TypeLibFuncAttribute
None.gif      System.Runtime.InteropServices.TypeLibTypeAttribute
None.gif      System.Runtime.InteropServices.TypeLibVarAttribute
None.gif      System.Runtime.InteropServices.TypeLibVersionAttribute
None.gif      System.Runtime.Remoting.Messaging.OneWayAttribute
None.gif      System.Runtime.Remoting.Metadata.SoapAttribute
None.gif      System.Runtime.Remoting.Proxies.ProxyAttribute
None.gif      System.Security.AllowPartiallyTrustedCallersAttribute
None.gif      System.Security.Permissions.SecurityAttribute
None.gif      System.Security.SuppressUnmanagedCodeSecurityAttribute
None.gif      System.Security.UnverifiableCodeAttribute
None.gif      System.SerializableAttribute
None.gif      System.STAThreadAttribute
None.gif      System.ThreadStaticAttribute
None.gif      System.Web.Services.Configuration.XmlFormatExtensionAttribute
None.gif      System.Web.Services.Configuration.XmlFormatExtensionPointAttribute
None.gif      System.Web.Services.Configuration.XmlFormatExtensionPrefixAttribute
None.gif      System.Web.Services.Protocols.HttpMethodAttribute
None.gif      System.Web.Services.Protocols.MatchAttribute
None.gif      System.Web.Services.Protocols.SoapDocumentMethodAttribute
None.gif      System.Web.Services.Protocols.SoapDocumentServiceAttribute
None.gif      System.Web.Services.Protocols.SoapExtensionAttribute
None.gif      System.Web.Services.Protocols.SoapHeaderAttribute
None.gif      System.Web.Services.Protocols.SoapRpcMethodAttribute
None.gif      System.Web.Services.Protocols.SoapRpcServiceAttribute
None.gif      System.Web.Services.WebMethodAttribute
None.gif      System.Web.Services.WebServiceAttribute
None.gif      System.Web.Services.WebServiceBindingAttribute
None.gif      System.Web.UI.ConstructorNeedsTagAttribute
None.gif      System.Web.UI.ControlBuilderAttribute
None.gif      System.Web.UI.DataBindingHandlerAttribute
None.gif      System.Web.UI.ParseChildrenAttribute
None.gif      System.Web.UI.PartialCachingAttribute
None.gif      System.Web.UI.PersistChildrenAttribute
None.gif      System.Web.UI.PersistenceModeAttribute
None.gif      System.Web.UI.TagPrefixAttribute
None.gif      System.Web.UI.TemplateContainerAttribute
None.gif      System.Web.UI.ToolboxDataAttribute
None.gif      System.Web.UI.ValidationPropertyAttribute
None.gif      System.Xml.Serialization.SoapAttributeAttribute
None.gif      System.Xml.Serialization.SoapElementAttribute
None.gif      System.Xml.Serialization.SoapEnumAttribute
None.gif      System.Xml.Serialization.SoapIgnoreAttribute
None.gif      System.Xml.Serialization.SoapIncludeAttribute
None.gif      System.Xml.Serialization.SoapTypeAttribute
None.gif      System.Xml.Serialization.XmlAnyAttributeAttribute
None.gif      System.Xml.Serialization.XmlAnyElementAttribute
None.gif      System.Xml.Serialization.XmlArrayAttribute
None.gif      System.Xml.Serialization.XmlArrayItemAttribute
None.gif      System.Xml.Serialization.XmlAttributeAttribute
None.gif      System.Xml.Serialization.XmlChoiceIdentifierAttribute
None.gif      System.Xml.Serialization.XmlElementAttribute
None.gif      System.Xml.Serialization.XmlEnumAttribute
None.gif      System.Xml.Serialization.XmlIgnoreAttribute
None.gif      System.Xml.Serialization.XmlIncludeAttribute
None.gif      System.Xml.Serialization.XmlNamespaceDeclarationsAttribute
None.gif      System.Xml.Serialization.XmlRootAttribute
None.gif      System.Xml.Serialization.XmlTextAttribute
None.gif      System.Xml.Serialization.XmlTypeAttribute

System.STAThreadAttribute
       大家在一般使用中会留意到这个属性吗?用VS.NET新建一个项目,往往在main前面会如下面所示:
ExpandedBlockStart.gif         /// <summary>
InBlock.gif        
/// 应用程序的主入口点。
ExpandedBlockEnd.gif        
/// </summary>

None.gif        [STAThread]
None.gif         static  void Main() 
ExpandedBlockStart.gif         {
InBlock.gif            Application.Run(new frmMain());
ExpandedBlockEnd.gif        }

       其实这个就是属性类STAThreadAttribute了,它的作用表示应用程序的COM线程模型是单线程单元(STA)。


属性类的实用性:

1.利用XML相关的属性类,将相关业务类XML序列化,可以达到保存状态和远程传输交换类信息等作用。
共14个和XML相关的属性类:
System.Xml.Serialization.XmlAnyAttributeAttribute
System.Xml.Serialization.XmlAnyElementAttribute 
System.Xml.Serialization.XmlArrayAttribute
System.Xml.Serialization.XmlArrayItemAttribute
System.Xml.Serialization.XmlAttributeAttribute
System.Xml.Serialization.XmlChoiceIdentifierAttribute
System.Xml.Serialization.XmlElementAttribute
System.Xml.Serialization.XmlEnumAttribute
System.Xml.Serialization.XmlIgnoreAttribute
System.Xml.Serialization.XmlIncludeAttribute
System.Xml.Serialization.XmlNamespaceDeclarationsAttribute
System.Xml.Serialization.XmlRootAttribute
System.Xml.Serialization.XmlTextAttribute
System.Xml.Serialization.XmlTypeAttribute

        最近做一个项目,需要将一些界面输入的有一定结构规律的信息保存起来,然后下次需要时候可以调入到对应的界面位置上使用。(其实这个是很多应用都会碰到的)。结构和UI的对应关系可能会经常变动的,而且结构中需要填写的内容不是所有都必须的,直接用关系型数据库来保存似乎不是太好的方案。首先想到就是用XML文件来保存这些信息了,而界面之间的信息显示是有关联的,可以说需要一个缓冲来记录这些信息,想到的就是定义一个类来记录和操作这些信息。这自然遇到一个问题,如何保持类和XML数据的同步呢?

        生成的XML文件需要给其它业务来做处理,格式上有一定的规范,对于类来说,信息都保存在字段或者属性那里的,并没有区别,但XML中可能有些信息是Attribute,有些又是Element的。如何灵活地处理这些关系呢?用与XML相关的属性来定义这些字段和类就可以了。

(1) 类信息序列化到XML文件中的代码

None.gif         public  void SerializeObject( string filename)
ExpandedBlockStart.gif         {
InBlock.gif            XmlSerializer s = new XmlSerializer(typeof(Tables));
InBlock.gif            TextWriter writer = new StreamWriter(filename);
InBlock.gif
InBlock.gif            Tables group = new Tables();
InBlock.gif            group.GroupID = 10.089f;
InBlock.gif            group.IsActive = false;     
ExpandedSubBlockStart.gif            group.HexBytes = new byte[1]{Convert.ToByte(100)};
InBlock.gif
InBlock.gif            Employee x = new Employee();
InBlock.gif            Employee y = new Employee();
InBlock.gif
InBlock.gif            x.Name = "Jack";
InBlock.gif            y.Name = "Jill";
InBlock.gif            
InBlock.gif            x.des2 = "Yyyydot.gif";
InBlock.gif            x.colType = new ColumnType[2];
InBlock.gif            x.colType[0] = new ColumnType();
InBlock.gif            x.colType[1] = new ColumnType();
InBlock.gif            x.colType[0].linkField = "Haaadot.gif";
InBlock.gif            x.colType[1].linkType = "Zzzzdot.gif";
InBlock.gif            y.Age[0] = 20;
InBlock.gif            y.Age[1] = 40;
InBlock.gif
InBlock.gif            y.Desc = "OK";
InBlock.gif      
ExpandedSubBlockStart.gif            group.Employees = new Employee[2]{x,y};
InBlock.gif
InBlock.gif            Manager mgr = new Manager();
InBlock.gif            mgr.Name = "Sara";
InBlock.gif            mgr.Level = 4;
InBlock.gif
InBlock.gif            mgr.Desc = "Yes";
InBlock.gif            mgr.aHead = true;
InBlock.gif            
InBlock.gif            group.Manager = mgr;
InBlock.gif             
InBlock.gif            group.ExtraInfo = new ArrayList();
InBlock.gif            group.ExtraInfo.Add(42);
InBlock.gif            group.ExtraInfo.Add("Answer");
InBlock.gif
InBlock.gif            s.Serialize(writer, group);
InBlock.gif            writer.Close();
ExpandedBlockEnd.gif        }

None.gif
(2) XML文件信息变成类的信息的代码
None.gif         public  void DeserializeObject( string filename)
ExpandedBlockStart.gif         {
InBlock.gif            FileStream fs = new FileStream(filename, FileMode.Open);
InBlock.gif            XmlSerializer x = new XmlSerializer(typeof(Tables));
InBlock.gif            Tables g = (Tables) x.Deserialize(fs);
InBlock.gif            int i=0;
InBlock.gif              foreach(Employee e in g.Employees)
ExpandedSubBlockStart.gif            {
InBlock.gif                i = i + 1;
InBlock.gif                Console.WriteLine("No {0} Name: {1}",i.ToString(),e.Name);
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            Console.WriteLine(g.Manager.Name);
InBlock.gif            Console.WriteLine(g.GroupID);
InBlock.gif            Console.WriteLine(g.HexBytes[0]);
ExpandedBlockEnd.gif        }
(3)例子中相关类信息生成的XML文件
None.gif <? xml version="1.0" encoding="utf-8" ?>
None.gif < Tables  xmlns:xsd ="http://www.w3.org/2001/XMLSchema"  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" >
None.gif   < Member >
None.gif     < Employee  AHead ="false" >
None.gif       < Name >Jack </ Name >
None.gif       < Age >0 </ Age >
None.gif       < Age >0 </ Age >
None.gif       < des2 >Yyyy dot.gif </ des2 >
None.gif       < ColumnType  LinkField ="Haaadot.gif"   />
None.gif       < ColumnType  LinkType ="Zzzzdot.gif"   />
None.gif     </ Employee >
None.gif     < Employee  Desc ="OK"  AHead ="false" >
None.gif       < Name >Jill </ Name >
None.gif       < Age >20 </ Age >
None.gif       < Age >40 </ Age >
None.gif     </ Employee >
None.gif   </ Member >
None.gif   < Building >10.088999748229981 </ Building >
None.gif   < HexBytes >64 </ HexBytes >
None.gif   < IsActive >false </ IsActive >
None.gif   < Manager  Desc ="Yes"  AHead ="true" >
None.gif     < Name >Sara </ Name >
None.gif     < Age >0 </ Age >
None.gif     < Age >0 </ Age >
None.gif     < Level >4 </ Level >
None.gif   </ Manager >
None.gif   < ObjectNumber >42 </ ObjectNumber >
None.gif   < ObjectString >Answer </ ObjectString >
None.gif </ Tables >
(4) XML总体框架如何用XML相关属性类描述
None.gif     public  class Tables
ExpandedBlockStart.gif     {
InBlock.gif        [XmlArray(ElementName = "Member")]
InBlock.gif        public Employee[] Employees;
InBlock.gif      
InBlock.gif        [XmlElement(DataType = "double",
InBlock.gif             ElementName = "Building")]
InBlock.gif        public double GroupID;
InBlock.gif
InBlock.gif        [XmlElement(DataType = "hexBinary")]
InBlock.gif        public byte [] HexBytes;
InBlock.gif
InBlock.gif
InBlock.gif        [XmlElement(DataType = "boolean")]
InBlock.gif        public bool IsActive;
InBlock.gif
InBlock.gif        [XmlElement(Type = typeof(Manager))]
InBlock.gif        public Employee Manager;
InBlock.gif
InBlock.gif        [XmlElement(typeof(int),
InBlock.gif             ElementName = "ObjectNumber"),
InBlock.gif        XmlElement(typeof(string),
InBlock.gif            ElementName = "ObjectString")]
InBlock.gif        public ArrayList ExtraInfo;
ExpandedBlockEnd.gif    }
   
None.gif
(5) 类的字段信息表示为属性的方法
None.gif     public  class Employee
ExpandedBlockStart.gif     {
InBlock.gif        public string Name;
InBlock.gif        [XmlElement(typeof(int))]
InBlock.gif        public int[] Age = new int[2];
InBlock.gif        [XmlAttribute(AttributeName = "Desc")]
InBlock.gif        public string Desc;
InBlock.gif        [XmlAttribute(AttributeName = "AHead")]
InBlock.gif        public bool aHead;
InBlock.gif
InBlock.gif        public string des2;
InBlock.gif        
InBlock.gif        [XmlElement(ElementName="ColumnType")]
InBlock.gif        public ColumnType[] colType;
ExpandedBlockEnd.gif    }

None.gif


2.自己根据需要定义自己的属性类,例如定义相关业务类和UI的关系。
在使用中,信息不是一个UI就完成的,可能经过了几个UI,或者几个页面去交互,但可能业务的调整,显示的位置或者一些参数可能需要调整的,这些UI的信息能否也定义为类的某些属性?
从.NET的Attribute派生一个客户定制类可以轻松做到这点,定制类只需要从System.Attribute派生即可。

None.gif    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Class,AllowMultiple= true)]
None.gif     public  class LayoutAttribute : Attribute
ExpandedBlockStart.gif     {
InBlock.gif        string m_desc;
InBlock.gif        public string OwnPage;
InBlock.gif        public string GetDesc()
ExpandedSubBlockStart.gif        {
InBlock.gif            return m_desc;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        public LayoutAttribute(string strDesc)
ExpandedSubBlockStart.gif        {
InBlock.gif           m_desc = strDesc;
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedBlockEnd.gif    }

None.gif

       AttributeUsage这个类定义了LayoutAttribute的一些基本信息,例如这里定义了LayoutAttribute适用于字段,类,并且允许重复定义的。

       在应用中,可以利用反射机制,将这些定义的信息获取,从而判断应该在界面上如何处理了。

None.gif            Type myType = Type.GetType("testXmlAttr.Manager");
None.gif            Console.WriteLine(myType.FullName);
None.gif            FieldInfo myFieldInfo = myType.GetField("Level");
None.gif            
None.gif             object[] atts = myFieldInfo.GetCustomAttributes( false);            
None.gif             for ( int i=0;i<atts.Length;i++)
None.gif                Console.WriteLine(((LayoutAttribute)atts[i]).OwnPage);
None.gif

例子运行结果:(同时在当前目录下生成testXmlAttr.xml)
testAttr1.JPG


本文转自风前絮~~博客园博客,原文链接:http://www.cnblogs.com/windsails/archive/2004/09/08/41006.html,如需转载请自行联系原作者

相关文章
|
1月前
|
设计模式 uml C++
C++中的装饰器模式:灵活地扩展功能
C++中的装饰器模式:灵活地扩展功能
42 0
|
1月前
|
编译器 C++
【C++】—— c++11新的类功能
【C++】—— c++11新的类功能
|
1月前
|
设计模式 Java
装饰者模式:打破继承限制,实现灵活的功能扩展
装饰者模式:打破继承限制,实现灵活的功能扩展
46 0
|
15天前
|
程序员 C语言 C++
【C++语言】继承:类特性的扩展,重要的类复用!
【C++语言】继承:类特性的扩展,重要的类复用!
|
8月前
|
设计模式 Java 数据库连接
JAVA设计模式8:装饰模式,动态地将责任附加到对象上,扩展对象的功能
JAVA设计模式8:装饰模式,动态地将责任附加到对象上,扩展对象的功能
|
9月前
|
Oracle 架构师 关系型数据库
C#反射应用之实现动态可配置可扩展框架的简单示例
C#反射应用之实现动态可配置可扩展框架的简单示例
|
10月前
|
存储 编译器 C语言
了解C++类的特性
了解C++类的特性
69 0
|
设计模式 Java
深入理解装饰器模式:在保持灵活性的同时扩展对象功能
深入理解装饰器模式:在保持灵活性的同时扩展对象功能
137 0
|
存储 API 容器
类式组件三大核心属性
类式组件三大核心属性