private void AddReference(Microsoft.PythonTools.Parsing.Ast.CallExpression node, Func <string, Assembly> partialLoader)
        {
            // processes a call to clr.AddReference updating project state
            // so that it contains the newly loaded assembly.
            foreach (var arg in node.Args)
            {
                var cexpr = arg.Expression as Microsoft.PythonTools.Parsing.Ast.ConstantExpression;
                if (cexpr == null || !(cexpr.Value is string || cexpr.Value is byte[]))
                {
                    // can't process this add reference
                    continue;
                }

                // TODO: Should we do a .NET reflection only load rather than
                // relying on the CLR module here?  That would prevent any code from
                // running although at least we don't taint our own modules which
                // are loaded with this current code.
                var asmName = cexpr.Value as string;
                if (asmName == null)
                {
                    // check for byte string
                    var bytes = cexpr.Value as byte[];
                    if (bytes != null)
                    {
                        StringBuilder tmp = new StringBuilder();
                        for (int i = 0; i < bytes.Length; i++)
                        {
                            tmp.Append((char)bytes[i]);
                        }
                        asmName = tmp.ToString();
                    }
                }
                if (asmName != null && _assemblyLoadSet.Add(asmName))
                {
                    Assembly asm = null;
                    try {
                        if (partialLoader != null)
                        {
                            asm = partialLoader(asmName);
                        }
                        else
                        {
                            try {
                                asm = ClrModule.LoadAssemblyByName(_codeContext, asmName);
                            } catch {
                                asm = ClrModule.LoadAssemblyByPartialName(asmName);
                            }
                        }
                    } catch {
                    }
                    AddAssembly(asm);
                }
            }
        }
        private ISet <Namespace> AddReference(CallExpression node, Func <string, Assembly> partialLoader)
        {
            // processes a call to clr.AddReference updating project state
            // so that it contains the newly loaded assembly.
            foreach (var arg in node.Args)
            {
                var cexpr = arg.Expression as ConstantExpression;
                if (cexpr == null || !(cexpr.Value is string))
                {
                    // can't process this add reference
                    continue;
                }

                // TODO: Should we do a .NET reflection only load rather than
                // relying on the CLR module here?  That would prevent any code from
                // running although at least we don't taint our own modules which
                // are loaded with this current code.
                var asmName = cexpr.Value as string;
                if (asmName != null && _assemblyLoadList.Add(asmName))
                {
                    Assembly asm = null;
                    try {
                        if (partialLoader != null)
                        {
                            asm = partialLoader(asmName);
                        }
                        else
                        {
                            try {
                                asm = ClrModule.LoadAssemblyByName(_codeContext, asmName);
                            } catch {
                                asm = ClrModule.LoadAssemblyByPartialName(asmName);
                            }
                        }
                    } catch {
                    }
                    AddAssembly(asm);
                }
            }
            return(null);
        }