コード例 #1
0
        public TypeDescription(Type objectType)
            : base(objectType)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException("objectType");
            }

            this.objectType = objectType;

            var members = FindMembers(objectType);

            this.members       = members.AsReadOnly();
            this.membersByName = members.ToDictionary(m => m.Name);

            GettersAndSetters.TryGetConstructor(objectType, out this.constructorFn);
        }
コード例 #2
0
        public TypeDescription(Type objectType)
            : base(null, objectType)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException("objectType");
            }

            this.objectType      = objectType;
            this.IsDataContract  = this.Attributes.Any(attribute => attribute.GetType().Name == DATA_CONTRACT_ATTRIBUTE_NAME);
            this.IsSerializable  = IsSerializable;
            this.IsAnonymousType = objectType.IsSealed && objectType.IsNotPublic && objectType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), true).Length > 0;;

            var allMembers = this.FindMembers(objectType);

            this.members       = allMembers.AsReadOnly();
            this.membersByName = allMembers.ToDictionary(m => m.Name, StringComparer.Ordinal);

            GettersAndSetters.TryGetConstructor(objectType, out this.constructorFn);
        }