/// <summary>
        ///  Creates a new species object from a CLR Type by
        ///  pulling information off of the type's attributes.
        /// </summary>
        /// <param name="clrType">The Type representing the Plant class.</param>
        public PlantSpecies(Type clrType)
            : base(clrType)
        {
            Debug.Assert(clrType != null, "Null type passed to PlantSpecies");
            Debug.Assert(typeof(Plant).IsAssignableFrom(clrType));

            PlantSkinAttribute skinAttribute = (PlantSkinAttribute) Attribute.GetCustomAttribute(clrType, typeof(PlantSkinAttribute));
            if (skinAttribute != null)
            {
                skinFamily = skinAttribute.SkinFamily;
                animalSkin = skinAttribute.Skin;
            }

            SeedSpreadDistanceAttribute seedSpreadAttribute = (SeedSpreadDistanceAttribute) Attribute.GetCustomAttribute(clrType, typeof(SeedSpreadDistanceAttribute));
            if (seedSpreadAttribute == null)
            {
                throw new AttributeRequiredException("SeedSpreadDistanceAttribute");
            }

            seedSpreadDistance = seedSpreadAttribute.SeedSpreadDistance;
        }
 /// <summary>
 ///    <para>Use this overload if you want to specify a custom skin, and specify the
 ///       family it belongs to so that something reasonable gets displayed if the skin
 ///       can't be loaded.</para>
 /// </summary>
 /// <param name='skinFamily'>An AnimalSkinFamily value that specifies the skin to use for this organism if the custom one can't be loaded.</param>
 /// <param name='skin'>The name of the assembly the contains the skin you want to use.</param>
 public PlantSkinAttribute(PlantSkinFamily skinFamily, string skin)
 {
     this.skinFamily = skinFamily;
     this.skin = skin;
 }
 /// <summary>
 ///    <para>Use this constructor if you don't have a custom skin you want to use with
 ///       your organism.</para>
 /// </summary>
 /// <param name='skinFamily'>A PlantSkinFamilyEnum value that specifies the skin to use for this organism.</param>
 public PlantSkinAttribute(PlantSkinFamily skinFamily)
 {
     this.skinFamily = skinFamily;
 }
Example #4
0
 /// <summary>
 ///    <para>Use this constructor if you don't have a custom skin you want to use with
 ///       your organism.</para>
 /// </summary>
 /// <param name='skinFamily'>A PlantSkinFamilyEnum value that specifies the skin to use for this organism.</param>
 public PlantSkinAttribute(PlantSkinFamily skinFamily)
 {
     Skin = string.Empty;
     SkinFamily = skinFamily;
 }