public DictionaryParameters Convert <TAttribute>(ConvertibleBaseDto convertibleDto, bool includeAllProperties) where TAttribute : ConversionKeyBaseAttribute { Contract.Requires(null != convertibleDto); Contract.Ensures(null != Contract.Result <DictionaryParameters>()); return(default(DictionaryParameters)); }
public DictionaryParameters Convert <TAttribute>(ConvertibleBaseDto convertibleDto, bool includeAllProperties) where TAttribute : ConversionKeyBaseAttribute { // create Dto to be returned var dictionaryParameters = new DictionaryParameters(); // get all defined properties in Dto var propertyInfos = convertibleDto .GetType() .GetProperties ( BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy ); Contract.Assert(null != propertyInfos); foreach (var propertyInfo in propertyInfos) { // get annotation of property var attribute = (TAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(TAttribute)); // skip if no attribute found ... if (null == attribute) { // but add property if we should include all properties if (includeAllProperties) { dictionaryParameters.Add(propertyInfo.Name, propertyInfo.GetValue(convertibleDto, null)); } continue; } // assert that we do not have the annotated property in our dictionary Contract.Assert(!dictionaryParameters.ContainsKey(attribute.Name)); // add value to dictionary dictionaryParameters.Add(attribute.Name, propertyInfo.GetValue(convertibleDto, null)); } return(dictionaryParameters); }
public DictionaryParameters Convert <TAttribute>(ConvertibleBaseDto convertibleDto) where TAttribute : ConversionKeyBaseAttribute { return(Convert <TAttribute>(convertibleDto, false)); }
public DictionaryParameters Convert <TAttribute>(ConvertibleBaseDto convertibleDto) where TAttribute : ConversionKeyBaseAttribute { return(default(DictionaryParameters)); }