示例#1
0
        public XmlAspectMemberList(ClassAcessor acessor, string localName, bool mandatory)
            : base(acessor, localName, mandatory)
        {
            Type[] genericTypes = base.DataType.GetGenericArguments();
            if (genericTypes.Length != 1)
            {
                throw new ArgumentException("List serialization must be with IList of one generic type: " + DataType);
            }

            _Constructor = genericTypes[0].GetConstructor(Type.EmptyTypes);
            if (_Constructor == null)
            {
                throw new ArgumentException("List serialization requires that the components have a default constructor: " + genericTypes[0]);
            }

            this._Aspect = XmlAspect.GetInstance(genericTypes[0]);
        }
示例#2
0
        public static XmlAspect GetInstance(Type dataType)
        {
            XmlAspect aspect;

            if (_Instances == null)
            {
                _Instances = new Dictionary <Type, XmlAspect>();
                aspect     = new XmlAspect(dataType);
                _Instances.Add(dataType, aspect);
            }
            else
            {
                if (!_Instances.TryGetValue(dataType, out aspect))
                {
                    aspect = new XmlAspect(dataType);
                    _Instances.Add(dataType, aspect);
                }
            }

            return(aspect);
        }
 public XmlAspectMemberComposite(ClassAcessor acessor, string localName, bool mandatory, XmlAspect aspect, ConstructorInfo constructor)
     : base(acessor, localName, mandatory)
 {
     this._Aspect      = aspect;
     this._Constructor = constructor;
 }