private static void AddConfiguration(Type configurationType) { lock (SimpleConfiguration <T> .simpleConfigurationTable) { if (!SimpleConfiguration <T> .simpleConfigurationTable.ContainsKey(configurationType)) { object[] customAttributes = configurationType.GetCustomAttributes(typeof(SimpleConfigurationAttribute), false); if (customAttributes == null || customAttributes.Length == 0) { throw new OwaNotSupportedException("A SimpleConfigurationAttribute should be defined on the type"); } SimpleConfigurationAttribute simpleConfigurationAttribute = (SimpleConfigurationAttribute)customAttributes[0]; PropertyInfo[] properties = configurationType.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { object[] customAttributes2 = propertyInfo.GetCustomAttributes(typeof(SimpleConfigurationPropertyAttribute), false); if (customAttributes2 != null && customAttributes2.Length != 0) { SimpleConfigurationPropertyAttribute simpleConfigurationPropertyAttribute = (SimpleConfigurationPropertyAttribute)customAttributes2[0]; simpleConfigurationPropertyAttribute.PropertyInfo = propertyInfo; simpleConfigurationAttribute.AddProperty(simpleConfigurationPropertyAttribute); } } SimpleConfiguration <T> .simpleConfigurationTable.Add(configurationType, simpleConfigurationAttribute); } } }
private T ParseEntry(XmlTextReader reader) { T t = (default(T) == null) ? Activator.CreateInstance <T>() : default(T); ulong num = this.configurationAttribute.RequiredMask; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); SimpleConfigurationPropertyAttribute simpleConfigurationPropertyAttribute = this.configurationAttribute.TryGetProperty(reader.Name); if (simpleConfigurationPropertyAttribute == null) { this.ThrowParserException(); } object value = this.ConvertToStrongType(simpleConfigurationPropertyAttribute.Type, reader.Value); simpleConfigurationPropertyAttribute.SetValue(t, value); if (simpleConfigurationPropertyAttribute.IsRequired) { num &= ~simpleConfigurationPropertyAttribute.PropertyMask; } } reader.MoveToElement(); } if (num != 0UL) { this.ThrowParserException(); } return(t); }
// Token: 0x060013DB RID: 5083 RVA: 0x00079FFC File Offset: 0x000781FC internal SimpleConfigurationPropertyAttribute TryGetProperty(string propertyName) { SimpleConfigurationPropertyAttribute result = null; if (this.propertyTable.TryGetValue(propertyName, out result)) { return(result); } return(null); }
// Token: 0x060013DA RID: 5082 RVA: 0x00079F84 File Offset: 0x00078184 internal void AddProperty(SimpleConfigurationPropertyAttribute property) { if (this.propertyCount >= 64) { throw new OwaNotSupportedException(string.Format("SimpleConfiguration doesn't support types with more than {0} properties", 64)); } ulong num = 1UL << this.propertyCount; property.PropertyMask = num; if (property.IsRequired) { this.requiredMask |= num; } this.propertyTable.Add(property.Name, property); this.propertyCount++; }