Beispiel #1
0
        private Type GetResolvedTypeFromViewVariables(string fragment, IViewExplorer viewExplorer)
        {
            Type resolvedType = null;
            var  locals       = viewExplorer.GetLocalVariableChunks();
            var  viewData     = viewExplorer.GetViewDataVariableChunks();

            if (locals != null)
            {
                var localFound = locals.Where(x => x.Value == fragment).FirstOrDefault();
                if (localFound != null)
                {
                    resolvedType = Type.GetType(localFound.Type, false);
                }
            }
            if (viewData != null)
            {
                var viewDataFound = viewData.Where(x => x.Key == fragment).FirstOrDefault();
                if (resolvedType == null && viewDataFound != null)
                {
                    resolvedType = Type.GetType(viewDataFound.Type, false);
                }
            }

            return(resolvedType);
        }
        public IEnumerable <Completion> ToCompletionList(string codeSnippit)
        {
            Type   resolvedType;
            string remainingCode;

            if (_typeNavigator.TryResolveType(_viewExplorer, codeSnippit, out resolvedType, out remainingCode))
            {
                if (string.IsNullOrEmpty(remainingCode))
                {
                    return(ResolveTypeMemberCompletions(resolvedType));
                }
                return(ResolveInstanceMemberCompletions(resolvedType, remainingCode));
            }

            IEnumerable <string> namespaceElements =
                _typeNavigator.Types.Select(t => _typeNavigator.GetMatchingNamespaceElements(t, codeSnippit));
            IEnumerable <ViewDataChunk>      viewDataElements  = _viewExplorer.GetViewDataVariableChunks();
            IEnumerable <LocalVariableChunk> viewLocalElements = _viewExplorer.GetLocalVariableChunks();

            if (string.IsNullOrEmpty(codeSnippit))
            {
                IEnumerable <Type>       triggerTypes = _typeNavigator.GetTriggerTypes();
                IEnumerable <MemberInfo> viewMembers  = _typeNavigator.GetViewInstanceMembers(triggerTypes);
                return(triggerTypes
                       .Union(viewMembers).ToCompletionList()
                       .Union(namespaceElements.ToCompletionList())
                       .Union(viewDataElements.ToCompletionList())
                       .Union(viewLocalElements.ToCompletionList()));
            }
            return(namespaceElements.ToCompletionList());
        }
Beispiel #3
0
        private Type GetResolvedTypeFromViewVariables(string fragment, IViewExplorer viewExplorer)
        {
            Type resolvedType = null;
            var locals = viewExplorer.GetLocalVariableChunks();
            var viewData = viewExplorer.GetViewDataVariableChunks();
            if (locals != null)
            {
                var localFound = locals.Where(x => x.Value == fragment).FirstOrDefault();
                if (localFound != null) resolvedType = Type.GetType(localFound.Type, false);
            }
            if (viewData != null)
            {
                var viewDataFound = viewData.Where(x => x.Key == fragment).FirstOrDefault();
                if (resolvedType == null && viewDataFound != null) resolvedType = Type.GetType(viewDataFound.Type, false);
            }

            return resolvedType;
        }