public static DCDriverInfo[] GetDriversInAssembly(string assemblyPath)
 {
     using (DomainIsolator isolator = new DomainIsolator("DataContextDriver prober"))
     {
         return isolator.GetInstance<ThirdPartyDriverProber>().GetDriversInAssemblyInternal(assemblyPath);
     }
 }
Exemplo n.º 2
0
 private List <ExplorerItem> GetExplorerItems()
 {
     using (DomainIsolator isolator = new DomainIsolator(base.Repository.CreateSchemaAndRunnerDomain("Custom schema resolver", false, false)))
     {
         return(isolator.GetInstance <SchemaRetriever>().GetSchema(base.Repository) ?? new List <ExplorerItem>());
     }
 }
 public static DCDriverInfo[] GetThirdPartyDrivers()
 {
     using (DomainIsolator isolator = new DomainIsolator("DataContextDriver prober"))
     {
         return isolator.GetInstance<ThirdPartyDriverProber>().GetThirdPartyDriversInternal();
     }
 }
Exemplo n.º 4
0
 private void GetConstructorInfo(out bool parameterlessCtor, out string stringCtorParamName)
 {
     using (DomainIsolator isolator = this.GetDomainIsolatorForProber("EF Assembly Prober", false))
     {
         isolator.GetInstance <AssemblyProber>().GetConstructorInfo(this.txtAssemblyPath.Text.Trim(), this.txtTypeName.Text.Trim(), out parameterlessCtor, out stringCtorParamName);
     }
 }
Exemplo n.º 5
0
 private string[] GetCustomTypeNames()
 {
     using (DomainIsolator isolator = this.GetDomainIsolatorForProber("EF Assembly Prober", false))
     {
         return(isolator.GetInstance <AssemblyProber>().GetCustomTypeNames(this.txtAssemblyPath.Text.Trim()));
     }
 }
Exemplo n.º 6
0
 public static DCDriverInfo[] GetThirdPartyDrivers()
 {
     using (DomainIsolator isolator = new DomainIsolator("DataContextDriver prober"))
     {
         return(isolator.GetInstance <ThirdPartyDriverProber>().GetThirdPartyDriversInternal());
     }
 }
Exemplo n.º 7
0
 public static DCDriverInfo[] GetDriversInAssembly(string assemblyPath)
 {
     using (DomainIsolator isolator = new DomainIsolator("DataContextDriver prober"))
     {
         return(isolator.GetInstance <ThirdPartyDriverProber>().GetDriversInAssemblyInternal(assemblyPath));
     }
 }
Exemplo n.º 8
0
 internal string ShowConnectionDialog(string repositoryData, bool isNewRepository)
 {
     using (DomainIsolator isolator = new DomainIsolator(this.CreateNewDriverDomain("ShowConnectionDialog for " + this.SimpleAssemblyName, null, null)))
     {
         return(isolator.GetInstance <Instantiator>().Instantiate(this.GetAssemblyPath(), this.FullTypeName).ShowConnectionDialog(repositoryData, isNewRepository));
     }
 }
Exemplo n.º 9
0
 public static string FindPath(string fullName)
 {
     lock (_lookup)
     {
         if (!_lookup.ContainsKey(fullName))
         {
             using (DomainIsolator isolator = new DomainIsolator("GAC Resolver"))
             {
                 isolator.Domain.SetData("fullname", fullName);
                 isolator.Domain.SetData("path", null);
                 isolator.Domain.DoCallBack(new CrossAppDomainDelegate(GacResolver.Resolve));
                 return(_lookup[fullName] = (string)isolator.Domain.GetData("path"));
             }
         }
         return(_lookup[fullName]);
     }
 }
Exemplo n.º 10
0
 public static string FindPath(string fullName)
 {
     lock (_lookup)
     {
         if (!_lookup.ContainsKey(fullName))
         {
             using (DomainIsolator isolator = new DomainIsolator("GAC Resolver"))
             {
                 isolator.Domain.SetData("fullname", fullName);
                 isolator.Domain.SetData("path", null);
                 isolator.Domain.DoCallBack(new CrossAppDomainDelegate(GacResolver.Resolve));
                 return (_lookup[fullName] = (string) isolator.Domain.GetData("path"));
             }
         }
         return _lookup[fullName];
     }
 }
Exemplo n.º 11
0
        private static string GetEfPath(IConnectionInfo cxInfo, bool convertFullNameToGacPath)
        {
            string efVersion;
            string customAssemblyPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;

            if (string.IsNullOrEmpty(customAssemblyPath))
            {
                return(null);
            }
            try
            {
                string path = Path.Combine(Path.GetDirectoryName(customAssemblyPath), "EntityFramework.dll");
                if (File.Exists(path))
                {
                    return(path);
                }
            }
            catch (ArgumentException)
            {
            }
            if (customAssemblyPath == _lastEfPathInput)
            {
                return(convertFullNameToGacPath ? _lastEfPathGac : _lastEfPath);
            }
            _lastEfPath = null;
            string   shortName      = Path.GetFileNameWithoutExtension(customAssemblyPath);
            Assembly customAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault <Assembly>(a => a.GetName().Name.Equals(shortName, StringComparison.InvariantCultureIgnoreCase));

            if (customAssembly != null)
            {
                efVersion = new EFVersionProber().GetEfVersion(customAssembly);
            }
            else
            {
                using (DomainIsolator isolator = new DomainIsolator("Probe EF version"))
                {
                    efVersion = isolator.GetInstance <EFVersionProber>().GetEfVersion(customAssemblyPath);
                }
            }
            _lastEfPath = efVersion;
            string str5 = _lastEfPathGac = GacResolver.FindPath(efVersion);

            _lastEfPathInput = customAssemblyPath;
            return(convertFullNameToGacPath ? str5 : efVersion);
        }
Exemplo n.º 12
0
 public static bool IsLINQPadGaced()
 {
     bool flag;
     try
     {
         using (DomainIsolator isolator = new DomainIsolator("LINQPad GAC Tester"))
         {
             flag = isolator.GetInstance<LINQPadGacTester>().IsGaced(new LINQPadGacTester().GetFileVersion());
         }
     }
     catch (TypeLoadException)
     {
         flag = true;
     }
     catch
     {
         flag = false;
     }
     return flag;
 }
Exemplo n.º 13
0
        public static bool IsLINQPadGaced()
        {
            bool flag;

            try
            {
                using (DomainIsolator isolator = new DomainIsolator("LINQPad GAC Tester"))
                {
                    flag = isolator.GetInstance <LINQPadGacTester>().IsGaced(new LINQPadGacTester().GetFileVersion());
                }
            }
            catch (TypeLoadException)
            {
                flag = true;
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 14
0
 private static void CreateCache(object delay)
 {
     if (delay is int)
     {
         Thread.Sleep((int) delay);
     }
     try
     {
         if (_refLookup == null)
         {
             using (DomainIsolator isolator = new DomainIsolator("AutoRef Type Populator"))
             {
                 isolator.Domain.DoCallBack(new CrossAppDomainDelegate(Program.AddLINQPadAssemblyResolver));
                 isolator.Domain.DoCallBack(new CrossAppDomainDelegate(AutoRefManager.Populate));
             }
             PopulateFromCache();
         }
     }
     catch (Exception exception)
     {
         Log.Write(exception);
     }
 }
Exemplo n.º 15
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            BackgroundWorker worker2 = new BackgroundWorker {
                WorkerSupportsCancellation = true
            };
            string     arg       = this.rbStringConstructor.Checked ? this.txtCxString.Text.Trim() : null;
            Repository testRepos = ((Repository)this._cxInfo).Clone();

            this.UpdateRepository(testRepos);
            worker2.DoWork += delegate(object sender, DoWorkEventArgs e) {
                using (DomainIsolator isolator = this.GetDomainIsolatorForProber("EF Connection Tester", true))
                {
                    isolator.GetInstance <AssemblyProber>().Test(testRepos, arg);
                }
            };
            using (WorkerForm form = new WorkerForm(worker2, "Testing...", true))
            {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            MessageBox.Show("Successful", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
Exemplo n.º 16
0
 internal string ShowConnectionDialog(string repositoryData, bool isNewRepository)
 {
     using (DomainIsolator isolator = new DomainIsolator(this.CreateNewDriverDomain("ShowConnectionDialog for " + this.SimpleAssemblyName, null, null)))
     {
         return isolator.GetInstance<Instantiator>().Instantiate(this.GetAssemblyPath(), this.FullTypeName).ShowConnectionDialog(repositoryData, isNewRepository);
     }
 }
Exemplo n.º 17
0
 private void UpdateSchema()
 {
     object obj2;
     LINQPad.Repository repository;
     lock ((obj2 = this._locker))
     {
         if ((this._worker != Thread.CurrentThread) || this._disposed)
         {
             return;
         }
         this._status = "Populating";
     }
     this.NotifyChange();
     TempFileRef random = TempFileRef.GetRandom("TypedDataContext", ".dll");
     AssemblyName assemblyToBuild = new AssemblyName(Path.GetFileNameWithoutExtension(random.FileName)) {
         CodeBase = random.FullPath
     };
     lock ((obj2 = this._locker))
     {
         if ((this._worker != Thread.CurrentThread) || this._disposed)
         {
             return;
         }
         repository = this._repository.Clone();
     }
     IEnumerable<ExplorerItem> enumerable = null;
     string nameSpace = "LINQPad.User";
     string typeName = "TypedDataContext";
     IDictionary<string, object> sessionData = null;
     using (DomainIsolator isolator = new DomainIsolator(repository.DriverLoader.CreateNewDriverDomain("LINQPad Schema Generator", null, null)))
     {
         enumerable = isolator.GetInstance<SchemaBuilder>().GetSchemaAndBuildAssembly(repository.GetStore().ToString(), assemblyToBuild, ref nameSpace, ref typeName, Program.AllowOneToOne, out sessionData);
     }
     lock ((obj2 = this._locker))
     {
         if (this._worker == Thread.CurrentThread)
         {
             this._repository.AutoGenNamespace = nameSpace;
             this._repository.AutoGenTypeName = typeName;
             this._repository.IsAutoGenAssemblyAvailable = true;
             if (sessionData != null)
             {
                 this._repository.SessionData = sessionData;
             }
             this._schema = enumerable;
             this._assemblyPath = random;
         }
     }
 }
Exemplo n.º 18
0
 private void ProbeDefaultCxString()
 {
     string str = null;
     string str2 = this.txtAssemblyPath.Text.Trim() + ".config";
     if (File.Exists(str2))
     {
         str = str2;
     }
     else
     {
         string directoryName = Path.GetDirectoryName(this.txtAssemblyPath.Text.Trim());
         string[] strArray = (from f in Directory.GetFiles(directoryName, "*.exe.config")
             where !f.Contains(".vshost.")
             select f).ToArray<string>();
         if (strArray.Length == 0)
         {
             strArray = Directory.GetFiles(directoryName, "app.config").ToArray<string>();
         }
         if (strArray.Length == 0)
         {
             try
             {
                 strArray = (from fi in new DirectoryInfo(directoryName).Parent.GetFiles("web.config") select fi.FullName).ToArray<string>();
             }
             catch
             {
             }
         }
         if (strArray.Length == 1)
         {
             str = strArray[0];
         }
     }
     Dictionary<string, string> cxStringsFromConfig = GetCxStringsFromConfig(str);
     string thirdPartyProvider = null;
     string thirdPartyProviderCxString = null;
     using (DomainIsolator isolator = new DomainIsolator("Default cx string probe", str, null))
     {
         string assemblyPath;
         AppDomain domain = isolator.Domain;
         domain.SetData("assem", this.txtAssemblyPath.Text.Trim());
         domain.SetData("type", this.txtTypeName.Text.Trim());
         domain.DoCallBack(new CrossAppDomainDelegate(CxForm.GetDefaultCxString));
         string cxString = domain.GetData("cxstring") as string;
         string data = domain.GetData("nativecxstring") as string;
         if (!string.IsNullOrEmpty(cxString))
         {
             if (data != null)
             {
                 DbConnectionStringBuilder builder = new DbConnectionStringBuilder {
                     ConnectionString = data
                 };
                 if (((builder.Count == 1) && builder.ContainsKey("name")) && cxStringsFromConfig.ContainsKey((string) builder["name"]))
                 {
                     string str5 = cxStringsFromConfig[(string) builder["name"]];
                     builder = new DbConnectionStringBuilder {
                         ConnectionString = str5
                     };
                     if (builder.ContainsKey("provider") || builder.ContainsKey("provider connection string"))
                     {
                         string a = (string) builder["provider"];
                         if (!(string.Equals(a, "System.Data.SqlClient", StringComparison.InvariantCultureIgnoreCase) || string.Equals(a, "System.Data.SqlServerCe.3.5", StringComparison.InvariantCultureIgnoreCase)))
                         {
                             thirdPartyProvider = a;
                             thirdPartyProviderCxString = (string) builder["provider connection string"];
                             if (((thirdPartyProviderCxString != null) && thirdPartyProviderCxString.Contains("|DataDirectory|")) && File.Exists(this.txtAssemblyPath.Text.Trim()))
                             {
                                 thirdPartyProviderCxString = thirdPartyProviderCxString.Replace("|DataDirectory|", Path.GetDirectoryName(this.txtAssemblyPath.Text.Trim()));
                             }
                         }
                     }
                 }
             }
             assemblyPath = Path.GetDirectoryName(this.txtAssemblyPath.Text.Trim());
             base.BeginInvoke(delegate {
                 if (!this.IsDisposed && this.AreDbDetailsBlank())
                 {
                     if (((thirdPartyProvider != null) && (thirdPartyProviderCxString != null)) && this.rbCustomCx.Visible)
                     {
                         if (((this.txtCxString.Text.Length <= 0) || (this.cboProviderName.Text.Length <= 0)) || !this.rbCustomCx.Checked)
                         {
                             this.rbCustomCx.Checked = true;
                             this.cboProviderName.Text = thirdPartyProvider;
                             this.txtCxString.Text = thirdPartyProviderCxString;
                         }
                     }
                     else
                     {
                         DbConnectionStringBuilder builder = new DbConnectionStringBuilder {
                             ConnectionString = cxString
                         };
                         string path = "";
                         if (builder.ContainsKey("Data Source"))
                         {
                             path = (string) builder["Data Source"];
                         }
                         string str2 = "";
                         if (builder.ContainsKey("Password"))
                         {
                             str2 = (string) builder["Password"];
                         }
                         if (path.Length != 0)
                         {
                             if (path.EndsWith(".sdf", StringComparison.OrdinalIgnoreCase))
                             {
                                 this.rbSqlCE.Checked = true;
                                 this.txtDbFile.Text = this.DecodeStudioAttachPath(path, assemblyPath);
                                 this.txtPassword.Text = str2;
                             }
                             else
                             {
                                 this.rbSqlServer.Checked = true;
                                 this.cboServer.Text = path;
                                 if (builder.ContainsKey("AttachDbFilename"))
                                 {
                                     this.rbAttach.Checked = true;
                                     this.txtDbFile.Text = this.DecodeStudioAttachPath((string) builder["AttachDbFilename"], assemblyPath);
                                     this.chkUserInstance.Checked = builder.ContainsKey("User Instance") && (builder["User Instance"].ToString().ToLowerInvariant() == "true");
                                 }
                                 else if (builder.ContainsKey("Database"))
                                 {
                                     this.rbSpecifyDb.Checked = true;
                                     this.cboDatabase.Text = (string) builder["Database"];
                                 }
                                 else if (builder.ContainsKey("Initial Catalog"))
                                 {
                                     this.rbSpecifyDb.Checked = true;
                                     this.cboDatabase.Text = (string) builder["Initial Catalog"];
                                 }
                                 if ((builder.ContainsKey("Username") || builder.ContainsKey("uid")) || builder.ContainsKey("user id"))
                                 {
                                     this.rbSqlAuth.Checked = true;
                                     if (builder.ContainsKey("uid"))
                                     {
                                         this.txtUserName.Text = (string) builder["uid"];
                                     }
                                     else if (builder.ContainsKey("user id"))
                                     {
                                         this.txtUserName.Text = (string) builder["user id"];
                                     }
                                     else
                                     {
                                         this.txtUserName.Text = (string) builder["Username"];
                                     }
                                 }
                                 else
                                 {
                                     this.rbWindowsAuth.Checked = true;
                                 }
                                 this.txtPassword.Text = str2;
                             }
                             this._lastSetServer = this.cboServer.Text;
                             this._lastSetDb = this.cboDatabase.Text;
                             this._lastSetFile = this.txtDbFile.Text;
                             this._lastSetUserName = this.txtUserName.Text;
                             this._lastSetPW = this.txtPassword.Text;
                             this.EnableControls();
                         }
                     }
                 }
             });
         }
     }
 }
Exemplo n.º 19
0
 private static string TestCustomType(Repository r)
 {
     try
     {
         using (DomainIsolator isolator = new DomainIsolator(r.CreateSchemaAndRunnerDomain("Custom Type Test Domain", false, false)))
         {
             isolator.Domain.SetData("repository", r);
             isolator.Domain.DoCallBack(new CrossAppDomainDelegate(CxForm.InstantiateCustomType));
         }
         return null;
     }
     catch (Exception exception)
     {
         string str2 = "The database connection is valid, but the following exception\r\nwas thrown when trying to instantiate the custom " + r.DriverLoader.Driver.ContextBaseTypeName.Split(new char[] { '.' }).Last<string>() + ":\r\n\r\n" + exception.Message;
         if (exception.InnerException != null)
         {
             str2 = str2 + "\r\n\r\nInner Exception: " + exception.InnerException.Message;
         }
         return str2;
     }
 }
Exemplo n.º 20
0
 internal static string DisassembleQuery(string assemblyPath, string[] additionalReferences)
 {
     if (string.IsNullOrEmpty(assemblyPath) || (additionalReferences == null))
     {
         return "";
     }
     using (DomainIsolator isolator = new DomainIsolator("Disassembler"))
     {
         string data;
         isolator.Domain.SetData("path", assemblyPath);
         isolator.Domain.SetData("refs", additionalReferences);
         try
         {
             isolator.Domain.DoCallBack(new CrossAppDomainDelegate(Disassembler.DisassembleQuery));
             data = (string) isolator.Domain.GetData("result");
         }
         catch (FileNotFoundException exception)
         {
             data = exception.Message;
         }
         return (data ?? "");
     }
 }
Exemplo n.º 21
0
 private void ChooseTypeName()
 {
     ThreadStart start = null;
     if (!File.Exists(this.txtAssemblyPath.Text.Trim()))
     {
         MessageBox.Show("The assembly '" + this.txtAssemblyPath.Text.Trim() + "' does not exist.");
     }
     else
     {
         string[] data;
         string[] strArray2;
         Repository r = new Repository();
         this.UpdateRepository(r);
         using (DomainIsolator isolator = new DomainIsolator("Inspect Custom Assembly"))
         {
             isolator.Domain.SetData("assem", this.txtAssemblyPath.Text.Trim());
             isolator.Domain.SetData("loader", r.DriverLoader);
             try
             {
                 isolator.Domain.DoCallBack(new CrossAppDomainDelegate(CxForm.GetCustomTypes));
                 data = (string[]) isolator.Domain.GetData("types");
                 strArray2 = (string[]) isolator.Domain.GetData("metadata");
             }
             catch (Exception exception)
             {
                 Log.Write(exception, "CxForm GetCustomTypes");
                 MessageBox.Show("Error loading custom assembly:\r\n\r\n" + exception.Message, "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 return;
             }
         }
         if (data.Length == 0)
         {
             MessageBox.Show("There are no types based on '" + r.DriverLoader.Driver.ContextBaseTypeName + "' in that assembly.");
         }
         else
         {
             if (this.cboSchema.SelectedIndex < 2)
             {
                 strArray2 = null;
             }
             using (ChooseTypeForm form = new ChooseTypeForm(this.txtAssemblyPath.Text.Trim(), data, this.txtTypeName.Text.Trim(), strArray2, this.txtMetadataPath.Text.Trim()))
             {
                 if (form.ShowDialog() == DialogResult.OK)
                 {
                     this.txtTypeName.Text = form.SelectedTypeName;
                     this.txtMetadataPath.Text = form.SelectedMetadataName;
                     if (this.AreDbDetailsBlank())
                     {
                         if (start == null)
                         {
                             start = delegate {
                                 try
                                 {
                                     this.ProbeDefaultCxString();
                                 }
                                 catch (Exception exception)
                                 {
                                     Log.Write(exception, "CxForm ProbeDefaultCxString");
                                 }
                             };
                         }
                         new Thread(start) { Name = "Default Cx String Probe", IsBackground = true }.Start();
                     }
                 }
             }
         }
     }
 }
 private static string GetEfPath(IConnectionInfo cxInfo, bool convertFullNameToGacPath)
 {
     string efVersion;
     string customAssemblyPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;
     if (string.IsNullOrEmpty(customAssemblyPath))
     {
         return null;
     }
     try
     {
         string path = Path.Combine(Path.GetDirectoryName(customAssemblyPath), "EntityFramework.dll");
         if (File.Exists(path))
         {
             return path;
         }
     }
     catch (ArgumentException)
     {
     }
     if (customAssemblyPath == _lastEfPathInput)
     {
         return (convertFullNameToGacPath ? _lastEfPathGac : _lastEfPath);
     }
     _lastEfPath = null;
     string shortName = Path.GetFileNameWithoutExtension(customAssemblyPath);
     Assembly customAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault<Assembly>(a => a.GetName().Name.Equals(shortName, StringComparison.InvariantCultureIgnoreCase));
     if (customAssembly != null)
     {
         efVersion = new EFVersionProber().GetEfVersion(customAssembly);
     }
     else
     {
         using (DomainIsolator isolator = new DomainIsolator("Probe EF version"))
         {
             efVersion = isolator.GetInstance<EFVersionProber>().GetEfVersion(customAssemblyPath);
         }
     }
     _lastEfPath = efVersion;
     string str5 = _lastEfPathGac = GacResolver.FindPath(efVersion);
     _lastEfPathInput = customAssemblyPath;
     return (convertFullNameToGacPath ? str5 : efVersion);
 }
Exemplo n.º 23
0
 private List<ExplorerItem> GetExplorerItems()
 {
     using (DomainIsolator isolator = new DomainIsolator(base.Repository.CreateSchemaAndRunnerDomain("Custom schema resolver", false, false)))
     {
         return (isolator.GetInstance<SchemaRetriever>().GetSchema(base.Repository) ?? new List<ExplorerItem>());
     }
 }
Exemplo n.º 24
0
 public static bool IsAssemblyValid(string path)
 {
     bool flag;
     using (DomainIsolator isolator = new DomainIsolator("GuineaPig"))
     {
         isolator.Domain.SetData("AssemblyToTest", path);
         try
         {
             isolator.Domain.DoCallBack(new CrossAppDomainDelegate(UpdateAgent.TestAssembly));
             flag = true;
         }
         catch
         {
             flag = false;
         }
     }
     return flag;
 }