GetAssemblyShortName() public static method

Given an assembly full name, generates an assembly short name.
public static GetAssemblyShortName ( string fullName ) : string
fullName string The assembly full name.
return string
Beispiel #1
0
        /// <summary>
        ///  Creates a new instance of the species class initialized with
        ///  the given CLR Type pulling various fields out of the Type's
        ///  attributes.
        /// </summary>
        /// <param name="clrType">The CLR Type to initialize this species.</param>
        protected Species(Type clrType)
        {
            MarkingColor      = KnownColor.Black;
            _typeName         = clrType.AssemblyQualifiedName;
            _assemblyFullName = clrType.Assembly.FullName;

            // Cache attributes because it is expensive to load them
            var energyAttribute =
                (MaximumEnergyPointsAttribute)
                Attribute.GetCustomAttribute(clrType, typeof(MaximumEnergyPointsAttribute));

            if (energyAttribute == null)
            {
                throw new AttributeRequiredException("MaximumEnergyPointsAttribute");
            }
            _maximumEnergyPerUnitRadius = energyAttribute.MaximumEnergyPerUnitRadius;

            var matureSizeAttribute =
                (MatureSizeAttribute)Attribute.GetCustomAttribute(clrType, typeof(MatureSizeAttribute));

            if (matureSizeAttribute == null)
            {
                throw new AttributeRequiredException("MatureSizeAttribute");
            }
            MatureRadius = matureSizeAttribute.MatureRadius;

            var markingColorAttribute =
                (MarkingColorAttribute)Attribute.GetCustomAttribute(clrType, typeof(MarkingColorAttribute));

            if (markingColorAttribute != null)
            {
                MarkingColor = markingColorAttribute.MarkingColor;
            }

            var authInfo =
                (AuthorInformationAttribute)
                Attribute.GetCustomAttribute(clrType.Assembly, typeof(AuthorInformationAttribute));

            if (authInfo == null || authInfo.AuthorName.Length == 0)
            {
                throw new AttributeRequiredException("AuthorInformationAttribute");
            }

            AuthorName  = authInfo.AuthorName;
            AuthorEmail = authInfo.AuthorEmail;

            // The assembly name is the name of the organism
            Name = PrivateAssemblyCache.GetAssemblyShortName(clrType.Assembly.FullName);
        }