コード例 #1
0
        protected override async Task <IEnumerable <ILabelValuePair> > GetSources()
        {
            var          labels = new List <ILabelValuePair>();
            JsonProperty schemaProp;
            var          schema = await schemaBuilder.GetSchema(typeof(T));

            foreach (var prop in typeof(T).GetProperties())
            {
                if (prop.GetCustomAttributes(typeof(NoPropertyLabelAttribute), true).Any())
                {
                    continue;
                }

                //Only add properties that can be found in the schema
                var schemaPropName = schemaBuilder.GetPropertyName(prop);
                if (schema.Properties.TryGetValue(schemaPropName, out schemaProp))
                {
                    var label = schemaProp.Title ?? prop.Name;
                    labels.Add(new LabelValuePair <String>(label, prop.Name));
                }
            }
            return(labels);
        }