Exemplo n.º 1
0
        private void ConnectToDatabaseOrServer(CommandBarButton Ctrl)
        {
            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                if (Ctrl.Caption.Equals(CONNECT))
                {
                    ViewBase.ApplicationObject = _applicationObject;
                    Login.CreateLoginToolWindow(assembly);
                }
                else
                {
                    Helper.SaveDataIfRequired();


                    dbCreateDemoDbControl.Enabled = true;
                    AppDomain.Unload(Login.appDomain.workerAppDomain);
                    Login.appDomain.workerAppDomain = null;
                    AssemblyInspectorObject.ClearAll();
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }
        }
Exemplo n.º 2
0
        public bool LoadAppDomain(ISearchPath searchPath)
        {
            try
            {
                AppDomainSetup setup = new AppDomainSetup();
#if DEBUG
                setup.ApplicationBase = @"E:\db4object\db4o\Trunk\omn\OMADDIN\bin\";
#else
                setup.ApplicationBase = CommonForAppDomain.GetPath() + "\\";
#endif
                setup.ShadowCopyDirectories              = Path.GetTempPath();
                setup.ShadowCopyFiles                    = "true";
                workerAppDomain                          = AppDomain.CreateDomain("WorkerAppDomain", null, setup);
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

                object anObject = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                      "OMAddinDataTransferLayer.AssemblyInfo.AssemblyInspector");

                IAssemblyInspector assemblyInspector = anObject as IAssemblyInspector;
                AssemblyInspectorObject.AssemblyInspector = assemblyInspector;

                if (searchPath.Paths.Any())
                {
                    if (!assemblyInspector.LoadAssembly(searchPath))
                    {
                        AppDomain.Unload(workerAppDomain);
                        workerAppDomain = null;
                        AssemblyInspectorObject.ClearAll();
                        return(false);
                    }
                }

                object anObject1 = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                       "OMAddinDataTransferLayer.Connection.Connection");
                IConnection conn = anObject1 as IConnection;
                AssemblyInspectorObject.Connection = conn;

                object anObject2 = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                       "OMAddinDataTransferLayer.DataPopulation.PopulateData");
                IPopulateData populate = anObject2 as IPopulateData;
                AssemblyInspectorObject.DataPopulation = populate;

                object anObject3 = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                       "OMAddinDataTransferLayer.TypeMauplation.DataType");
                IDataType dataType = anObject3 as IDataType;
                AssemblyInspectorObject.DataType = dataType;

                object anObject4 = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                       "OMAddinDataTransferLayer.DataEditing.SaveData");
                ISaveData saveData = anObject4 as ISaveData;
                AssemblyInspectorObject.DataSave = saveData;

                object anObject5 = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                       "OMAddinDataTransferLayer.DataBaseDetails.ObjectProperties");
                IObjectProperties objectProp = anObject5 as IObjectProperties;
                AssemblyInspectorObject.ObjectProperties = objectProp;

                object anObject6 = CreateGlobalObjects("OMAddinDataTransferLayer",
                                                       "OMAddinDataTransferLayer.DataBaseDetails.ClassProperties");
                IClassProperties classProp = anObject6 as IClassProperties;
                AssemblyInspectorObject.ClassProperties  = classProp;
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }