コード例 #1
0
        private IEnumerable <CompletionData> GetElementNamesInPropertyContext(ControlPropertyMetadata controlProperty)
        {
            IEnumerable <CompletionData> filteredControls;

            if (CheckType(controlProperty.Type, typeof(ITemplate)))
            {
                // all controls can appear in a template
                filteredControls = metadata.Select(c => new CompletionData(c.Key, c.Key));
            }
            else
            {
                // resolve element type
                var iEnumerable = CompletionHelper.FindIEnumerableType(controlProperty.Type);
                var elementType = iEnumerable != null ? iEnumerable.TypeArguments[0] : controlProperty.Type;

                // filter the allControls collection
                var filteredControlMetadata = metadata.Where(m => CompletionHelper.IsAssignable(m.Value.Type, elementType));
                filteredControls = filteredControlMetadata.Select(c => new CompletionData(c.Key, c.Key));
            }
            return(filteredControls);
        }