예제 #1
0
        protected internal override void Initialize(ContentTypeReaderManager manager)
        {
            base.Initialize(manager);
            this.manager = manager;
            Type baseType = this.targetType.BaseType;

            if (baseType != (Type)null && baseType != typeof(object))
            {
                this.baseType       = baseType;
                this.baseTypeReader = manager.GetTypeReader(this.baseType);
            }
            this.constructor = ContentExtensions.GetDefaultConstructor(this.targetType);
            this.properties  = ContentExtensions.GetAllProperties(this.targetType);
            this.fields      = ContentExtensions.GetAllFields(this.targetType);
        }
예제 #2
0
        private static object CreateChildObject(PropertyInfo property, FieldInfo field)
        {
            object obj  = (object)null;
            Type   type = !(property != (PropertyInfo)null) ? field.FieldType : property.PropertyType;

            if (type.IsClass && !type.IsAbstract)
            {
                ConstructorInfo defaultConstructor = ContentExtensions.GetDefaultConstructor(type);
                if (defaultConstructor != (ConstructorInfo)null)
                {
                    obj = defaultConstructor.Invoke((object[])null);
                }
            }
            return(obj);
        }
예제 #3
0
 internal ContentTypeReader[] LoadAssetReaders()
 {
   if (ContentTypeReaderManager.falseflag)
   {
     ByteReader byteReader = new ByteReader();
     SByteReader sbyteReader = new SByteReader();
     DateTimeReader dateTimeReader = new DateTimeReader();
     DecimalReader decimalReader = new DecimalReader();
     BoundingSphereReader boundingSphereReader = new BoundingSphereReader();
     BoundingFrustumReader boundingFrustumReader = new BoundingFrustumReader();
     RayReader rayReader = new RayReader();
     ListReader<char> listReader1 = new ListReader<char>();
     ListReader<Rectangle> listReader2 = new ListReader<Rectangle>();
     ArrayReader<Rectangle> arrayReader1 = new ArrayReader<Rectangle>();
     ListReader<Vector3> listReader3 = new ListReader<Vector3>();
     ListReader<StringReader> listReader4 = new ListReader<StringReader>();
     ListReader<int> listReader5 = new ListReader<int>();
     SpriteFontReader spriteFontReader = new SpriteFontReader();
     Texture2DReader texture2Dreader = new Texture2DReader();
     CharReader charReader = new CharReader();
     RectangleReader rectangleReader = new RectangleReader();
     StringReader stringReader = new StringReader();
     Vector2Reader vector2Reader = new Vector2Reader();
     Vector3Reader vector3Reader = new Vector3Reader();
     Vector4Reader vector4Reader = new Vector4Reader();
     CurveReader curveReader = new CurveReader();
     IndexBufferReader indexBufferReader = new IndexBufferReader();
     BoundingBoxReader boundingBoxReader = new BoundingBoxReader();
     MatrixReader matrixReader = new MatrixReader();
     BasicEffectReader basicEffectReader = new BasicEffectReader();
     VertexBufferReader vertexBufferReader = new VertexBufferReader();
     AlphaTestEffectReader testEffectReader = new AlphaTestEffectReader();
     EnumReader<SpriteEffects> enumReader1 = new EnumReader<SpriteEffects>();
     ArrayReader<float> arrayReader2 = new ArrayReader<float>();
     ArrayReader<Vector2> arrayReader3 = new ArrayReader<Vector2>();
     ListReader<Vector2> listReader6 = new ListReader<Vector2>();
     ArrayReader<Matrix> arrayReader4 = new ArrayReader<Matrix>();
     EnumReader<Blend> enumReader2 = new EnumReader<Blend>();
     NullableReader<Rectangle> nullableReader = new NullableReader<Rectangle>();
     EffectMaterialReader effectMaterialReader = new EffectMaterialReader();
     ExternalReferenceReader externalReferenceReader = new ExternalReferenceReader();
   }
   int length = this._reader.Read7BitEncodedInt();
   this.contentReaders = new ContentTypeReader[length];
   for (int index = 0; index < length; ++index)
   {
     string str = this._reader.ReadString();
     Func<ContentTypeReader> func;
     if (ContentTypeReaderManager.typeCreators.TryGetValue(str, out func))
     {
       this.contentReaders[index] = func();
     }
     else
     {
       string typeName = ContentTypeReaderManager.PrepareType(str);
       Type type = Type.GetType(typeName);
       if (type != (Type) null)
       {
         try
         {
           this.contentReaders[index] = ContentExtensions.GetDefaultConstructor(type).Invoke((object[]) null) as ContentTypeReader;
         }
         catch (TargetInvocationException ex)
         {
           throw new InvalidOperationException("Failed to get default constructor for ContentTypeReader. To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() with the following failed type string: " + str);
         }
       }
       else
         throw new ContentLoadException("Could not find matching content reader of type " + str + " (" + typeName + ")");
     }
     this._reader.ReadInt32();
   }
   return this.contentReaders;
 }