예제 #1
0
        private static object GetValueFromAttribute(IType attributeType, ReferenceStep referenceStep, Type type, bool inherits)
        {
            object        obj = null;
            PlatformTypes platformMetadata = (PlatformTypes)attributeType.PlatformMetadata;

            Attribute[] customAttributes = platformMetadata.GetCustomAttributes(type, attributeType.RuntimeType, inherits);
            int         num = 0;

            if (num < (int)customAttributes.Length)
            {
                obj = customAttributes[num];
            }
            if (obj == null)
            {
                return(null);
            }
            return(referenceStep.GetValue(obj));
        }
예제 #2
0
 protected virtual void InitializeAlternateContentPropertiesIfNecessary()
 {
     if (!this.alternateContentPropertiesAreInitialized)
     {
         List <IPropertyId> propertyIds = new List <IPropertyId>();
         Type type = typeof(AlternateContentPropertyAttribute);
         foreach (IProperty property in this.Properties)
         {
             ReferenceStep referenceStep = property as ReferenceStep;
             if (referenceStep == null || referenceStep.Attributes == null || referenceStep.Attributes[type] == null && !PlatformNeutralAttributeHelper.AttributeExists(referenceStep.Attributes, PlatformTypes.AlternateContentPropertyAttribute))
             {
                 continue;
             }
             propertyIds.Add(property);
         }
         this.alternateContentProperties = new ReadOnlyCollection <IPropertyId>(propertyIds);
     }
     this.alternateContentPropertiesAreInitialized = true;
 }
예제 #3
0
 internal static IConstructorArgumentProperties GetConstructorArgumentProperties(IType typeId)
 {
     if (!(typeId.RuntimeType != (Type)null) || !typeId.IsExpression)
     {
         return(PlatformTypeHelper.EmptyConstructorArgumentProperties);
     }
     PlatformTypeHelper.ConstructorArgumentProperties argumentProperties = new PlatformTypeHelper.ConstructorArgumentProperties();
     foreach (IProperty property in typeId.Metadata.Properties)
     {
         ReferenceStep referenceStep = property as ReferenceStep;
         if (referenceStep != null)
         {
             string constructorArgument = referenceStep.ConstructorArgument;
             if (constructorArgument != null)
             {
                 argumentProperties[constructorArgument] = property;
             }
         }
     }
     return((IConstructorArgumentProperties)argumentProperties);
 }
예제 #4
0
        private static string GetNameFromNearestNonEmptyContentPropertyAttribute(IPlatformMetadata platformMetadata, Type type, out bool anySkipped)
        {
            anySkipped = false;
            IType         type1              = platformMetadata.ResolveType(PlatformTypes.ContentPropertyAttribute);
            ReferenceStep member             = (ReferenceStep)type1.GetMember(MemberType.Property, "Name", MemberAccessTypes.Public);
            string        valueFromAttribute = ClrObjectMetadata.GetValueFromAttribute(type1, member, type, true) as string;

            if (!string.IsNullOrEmpty(valueFromAttribute))
            {
                return(valueFromAttribute);
            }
            while (type != null)
            {
                valueFromAttribute = ClrObjectMetadata.GetValueFromAttribute(type1, member, type, false) as string;
                if (!string.IsNullOrEmpty(valueFromAttribute))
                {
                    anySkipped = true;
                    return(valueFromAttribute);
                }
                type = type.BaseType;
            }
            return(null);
        }