示例#1
0
        /// <summary>
        /// Retrieves the <see cref="Type"/> corresponding to the first <see cref="CodeClass"/> found in the
        /// <paramref name="codeModel"/>
        /// </summary>
        public static Type ToType(FileCodeModel codeModel)
        {
            Guard.ArgumentNotNull(codeModel, "codeModel");

            CodeClass cc = CodeModelHelper.FindFirstClass(codeModel.CodeElements);

            return(ToType(cc));
        }
示例#2
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            DTE vs = GetService <DTE>(true);

            newValue = null;
            if (vs.SelectedItems.Item(1).Project == null)
            {
                ProjectItem webRef = vs.SelectedItems.Item(1).ProjectItem;
                if (webRef == null)
                {
                    throw new InvalidOperationException(Properties.Resources.NoProxyFound);
                }

                ProjectItem proxyItem = FindProxyClass(webRef.ProjectItems);
                if (proxyItem == null)
                {
                    throw new InvalidOperationException(Properties.Resources.NoProxyFound);
                }
                if (proxyItem.FileCodeModel == null)
                {
                    throw new InvalidOperationException(Properties.Resources.NoProxyFound);
                }

                bool   built      = true;
                object builtValue = ExpressionEvaluationHelper.EvaluateExpression((IDictionaryService)GetService(typeof(IDictionaryService)),
                                                                                  builtExpression);
                if (builtValue != null)
                {
                    built = (bool)builtValue;
                }

                if (built)
                {
                    CodeClass proxyTypeCodeClass = CodeModelHelper.FindFirstClass(proxyItem.FileCodeModel.CodeElements, CodeModelHelper.IsProxyClass);
                    newValue = DteConverter.ToType(proxyTypeCodeClass);
                }
            }
            return(true);
        }