// Token: 0x06008D46 RID: 36166 RVA: 0x002590E0 File Offset: 0x002572E0 internal string GetContentProperty(string assemblyName, string fullTypeName) { string clrNamespace = string.Empty; string typeShortName = fullTypeName; int num = fullTypeName.LastIndexOf('.'); if (num >= 0) { clrNamespace = fullTypeName.Substring(0, num); typeShortName = fullTypeName.Substring(num + 1); } short knownTypeIdFromName = BamlMapTable.GetKnownTypeIdFromName(assemblyName, clrNamespace, typeShortName); if (knownTypeIdFromName != 0) { KnownElements knownElement = (KnownElements)(-(KnownElements)knownTypeIdFromName); return(KnownTypes.GetContentPropertyName(knownElement)); } string text = null; if (this._contentPropertyTable != null && this._contentPropertyTable.TryGetValue(fullTypeName, out text)) { return(text); } Assembly assembly = Assembly.Load(assemblyName); Type type = assembly.GetType(fullTypeName); if (type != null) { object[] customAttributes = type.GetCustomAttributes(typeof(ContentPropertyAttribute), true); if (customAttributes.Length != 0) { ContentPropertyAttribute contentPropertyAttribute = customAttributes[0] as ContentPropertyAttribute; text = contentPropertyAttribute.Name; if (this._contentPropertyTable == null) { this._contentPropertyTable = new Dictionary <string, string>(8); } this._contentPropertyTable.Add(fullTypeName, text); } } return(text); }
/// <remarks> /// The method retrieves the Content property name for the given type. It first looks into /// the KnownTypes table for the value. If not found, it will do a reflection to grab the /// ContentPropertyAttribute on the type. Custom-control assembly is alrady required to be /// present for BamlWriter to generate baml. /// </remarks> internal string GetContentProperty(string assemblyName, string fullTypeName) { // // go to KnownTypes to find the content property first // string nameSpace = string.Empty; string typeName = fullTypeName; int lastDot = fullTypeName.LastIndexOf('.'); if (lastDot >= 0) { nameSpace = fullTypeName.Substring(0, lastDot); typeName = fullTypeName.Substring(lastDot + 1); } short id = BamlMapTable.GetKnownTypeIdFromName(assemblyName, nameSpace, typeName); if (id != 0) { KnownElements knownElement = (KnownElements)(-id); return(KnownTypes.GetContentPropertyName(knownElement)); } string contentProperty = null; // // Look into cached values. // if (_contentPropertyTable != null && _contentPropertyTable.TryGetValue(fullTypeName, out contentProperty)) { return(contentProperty); } // // Need to do reflection for it. // // Assembly.Load will throw exception if it fails. Assembly assm = Assembly.Load(assemblyName); Type type = assm.GetType(fullTypeName); if (type != null) { object[] contentPropertyAttributes = type.GetCustomAttributes( typeof(ContentPropertyAttribute), true // search for inherited value ); if (contentPropertyAttributes.Length > 0) { ContentPropertyAttribute contentPropertyAttribute = contentPropertyAttributes[0] as ContentPropertyAttribute; contentProperty = contentPropertyAttribute.Name; // Cach the value for future use. if (_contentPropertyTable == null) { _contentPropertyTable = new Dictionary <string, string>(8); } _contentPropertyTable.Add(fullTypeName, contentProperty); } } return(contentProperty); }