Exemplo n.º 1
0
        // Recompile the VBReference passed in, with its current LocationReferenceEnvironment context
        // in a weakly-typed manner (the argument VBReference's type argument is ignored)
        //[SuppressMessage(FxCop.Category.Design, FxCop.Rule.AvoidOutParameters,
        //    Justification = "Design has been approved")]
        public static Activity RecompileVisualBasicReference(ActivityWithResult visualBasicReference,
                                                             out Type returnType,
                                                             out SourceExpressionException compileError,
                                                             out VisualBasicSettings vbSettings)
        {
            ITextExpression textExpression = visualBasicReference as ITextExpression;

            if (textExpression == null || textExpression.Language != VisualBasicHelper.Language)
            {
                // the argument must be of type VisualBasicReference<>
                throw FxTrace.Exception.AsError(new ArgumentException());
            }
            string expressionText = textExpression.ExpressionText;
            LocationReferenceEnvironment environment = visualBasicReference.GetParentEnvironment();

            List <string> namespaces;
            List <string> referencedAssemblies;

            GetAllImportReferences(visualBasicReference, out namespaces, out referencedAssemblies);

            return(CreatePrecompiledVisualBasicReference(
                       null,
                       expressionText,
                       namespaces,
                       referencedAssemblies,
                       environment,
                       out returnType,
                       out compileError,
                       out vbSettings));
        }
Exemplo n.º 2
0
        public static Activity RecompileVisualBasicValue(ActivityWithResult visualBasicValue, out Type returnType, out SourceExpressionException compileError, out VisualBasicSettings vbSettings)
        {
            IVisualBasicExpression expression = visualBasicValue as IVisualBasicExpression;

            if (expression == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentException());
            }
            string expressionText = expression.ExpressionText;
            LocationReferenceEnvironment         parentEnvironment   = visualBasicValue.GetParentEnvironment();
            HashSet <VisualBasicImportReference> allImportReferences = VisualBasicHelper.GetAllImportReferences((parentEnvironment != null) ? parentEnvironment.Root : null);
            HashSet <string> namespaces           = new HashSet <string>();
            HashSet <string> referencedAssemblies = new HashSet <string>();

            foreach (VisualBasicImportReference reference in allImportReferences)
            {
                namespaces.Add(reference.Import);
                referencedAssemblies.Add(reference.Assembly);
            }
            return(CreatePrecompiledVisualBasicValue(null, expressionText, namespaces, referencedAssemblies, parentEnvironment, out returnType, out compileError, out vbSettings));
        }