Example #1
0
        public AutoCopyOptions Clone(AutoCopyOptions options)
        {
            try
            {
                //
                // Don't serialize a null object, simply return the default for that object
                //
                if (Object.ReferenceEquals(options, null))
                {
                    return(null);
                }

                if (!options.GetType().IsSerializable)
                {
                    throw new ArgumentException("The type must be serializable.", "source");
                }

                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new MemoryStream();

                using (stream)
                {
                    formatter.Serialize(stream, options);
                    stream.Seek(0, SeekOrigin.Begin);

                    return((AutoCopyOptions)formatter.Deserialize(stream));
                }
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
        }
Example #2
0
        public void UpdateSettings(AdvancedSettings settings)
        {
            AutoCopyOptions clonedOptions;

            _Settings = settings;

            try
            {
                _Options = _Settings.GetAddInCustomData <AutoCopyOptions>("Auto Copy", "AutoCopyOptions");
                if (_Options == null)
                {
                    _Options = new AutoCopyOptions();
                    _Settings.SetAddInCustomData <AutoCopyOptions>("Auto Copy", "AutoCopyOptions", _Options);
                    _Settings.Save();
                }
            }
            catch (Exception e)
            {
                Logger.Global.Exception("Auto Copy", e);
                if (_Options == null)
                {
                    _Options = new AutoCopyOptions();
                }
            }

            clonedOptions = Clone(_Options);
            _view.Initialize(clonedOptions, AUTOCOPY_RELATION, _aeAccessAgent);
        }
Example #3
0
        public void SaveOptions( )
        {
            _view.UpdateOptions( );

            if (_Settings != null)
            {
                _Settings.SetAddInCustomData <AutoCopyOptions>("Auto Copy", "AutoCopyOptions", _view.Options);
                _Settings.Save();
            }
            _Options = _view.Options;
        }
Example #4
0
        public void Initialize(AutoCopyOptions options, int autocopyRelation, IAeManagementDataAccessAgent accessAgent)
        {
            AutocopyRelation = autocopyRelation;
            _Options         = options;

            if (_Options != null)
            {
                checkBoxAutoCopy.Checked   = _Options.EnableAutoCopy;
                checkBoxCustomAE.Checked   = _Options.UseCustomAE;
                textBoxCustomAE.Text       = _Options.AutoCopyAE;
                numericUpDownThreads.Value = _Options.AutoCopyThreads;
            }
            _AccessAgent = accessAgent;
            EnableAutoCopy();
        }
Example #5
0
        public void RunView(AutoCopyView view, AdvancedSettings settings)
        {
            AutoCopyOptions clonedOptions;

            _view     = view;
            _Settings = settings;


            if (!DataAccessServices.IsDataAccessServiceRegistered <IAeManagementDataAccessAgent> ( ))
            {
                throw new InvalidOperationException(typeof(IAeManagementDataAccessAgent).Name + " is not registered.");
            }

            _aeAccessAgent = DataAccessServices.GetDataAccessService <IAeManagementDataAccessAgent> ( );

            if (settings != null)
            {
                try
                {
                    _Options = _Settings.GetAddInCustomData <AutoCopyOptions>("Auto Copy", "AutoCopyOptions");
                    if (_Options == null)
                    {
                        _Options = new AutoCopyOptions();
                        _Settings.SetAddInCustomData <AutoCopyOptions>("Auto Copy", "AutoCopyOptions", _Options);
                        _Settings.Save();
                    }
                }
                catch (Exception e)
                {
                    Logger.Global.Exception("Auto Copy", e);
                    if (_Options == null)
                    {
                        _Options = new AutoCopyOptions();
                    }
                }

                clonedOptions = Clone(_Options);
                view.Initialize(clonedOptions, AUTOCOPY_RELATION, _aeAccessAgent);
                _view.SettingsChanged += new EventHandler(View_SettingsChanged);
            }

            EventBroker.Instance.Subscribe <ClientAddedEventArgs>(new EventHandler <ClientAddedEventArgs>(OnClientAdded));
            EventBroker.Instance.Subscribe <ClientRemovedEventArgs>(new EventHandler <ClientRemovedEventArgs>(OnClientRemoved));
        }