Пример #1
0
 public static DemoModel Create(ISynchronizeInvoke syncObject)
 {
     var visualContext = new VisualContext();
     var shaders = new Shaders(visualContext, () => new ShaderFile(visualContext, syncObject));
     var textures = new Textures(visualContext);
     return new DemoModel(visualContext, shaders, textures, true);
 }
		public MainFormController(ICCTrayMultiConfiguration configuration, ISynchronizeInvoke owner, MainForm mainForm)
		{
            this.mainForm = mainForm;
			this.configuration = configuration;

			serverMonitors = configuration.GetServerMonitors();
			for (int i = 0; i < serverMonitors.Length; i++)
			{
				serverMonitors[i] = new SynchronizedServerMonitor(serverMonitors[i], owner);
			}
			aggregatedServerMonitor = new AggregatingServerMonitor(serverMonitors);
			queueIconProvider = new ResourceIntegrationQueueIconProvider();

			projectMonitors = configuration.GetProjectStatusMonitors(serverMonitors);
			execRunners = new BuildTransitionExecRunner[projectMonitors.Length];
			for (int i = 0; i < projectMonitors.Length; i++)
			{
				execRunners[i] = new BuildTransitionExecRunner(projectMonitors[i], configuration.Execs);
				projectMonitors[i] = new SynchronizedProjectMonitor(projectMonitors[i], owner);
			}
			aggregatedProjectMonitor = new AggregatingProjectMonitor(projectMonitors);
			projectStateIconProvider = new ConfigurableProjectStateIconProvider(configuration.Icons);
			projectStateIconAdaptor = new ProjectStateIconAdaptor(aggregatedProjectMonitor, projectStateIconProvider);
			soundPlayer = new BuildTransitionSoundPlayer(aggregatedProjectMonitor, new AudioPlayer(), configuration.Audio);
			LampController lampController = new LampController(configuration.X10,null);
			x10Controller = new X10Controller(aggregatedProjectMonitor,new DateTimeProvider(),configuration.X10,lampController);
			
			growlController = new GrowlController(aggregatedProjectMonitor, configuration.Growl);

#if !DISABLE_COM
			IBalloonMessageProvider balloonMessageProvider = new ConfigurableBalloonMessageProvider(configuration.BalloonMessages);
			speakerForTheDead = new SpeakingProjectMonitor(aggregatedProjectMonitor, balloonMessageProvider, configuration.Speech);
#endif
		}
Пример #3
0
        public PathWatcher(string watched)
        {
            _watched = watched;
            _synchronizingObject = null;

            _lastChange = DateTime.MinValue;
            _checker = new Timer(delegate(object state)
            {
                CheckPath();
            });

            _watcher = new FileSystemWatcher(Path.GetDirectoryName(watched), Path.GetFileName(watched));
            _watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
            _watcher.Changed += delegate(object sender, FileSystemEventArgs eventArgs)
            {
                /* check now */
                CheckPath();
            };
            _watcher.Created += delegate(object sender, FileSystemEventArgs eventArgs)
            {
                /* check now */
                CheckPath();
            };
            _watcher.Renamed += delegate(object sender, RenamedEventArgs eventArgs)
            {
                /* if file got changed to our name, check now */
                if (eventArgs.Name == _watcher.Filter)
                    CheckPath();
            };
        }
Пример #4
0
        public Explorer(ISynchronizeInvoke sync, object searchField, Label searchOverlay, Timer timer, Label status, TreeView fileList, string[] extensions, string runnerID, bool splitIntoDirectories)
        {
            this.target = sync;
            this.searchOverlay = searchOverlay;
            this.status = status;
            this.fileList = fileList;
            this.extensions = extensions;
            this.runnerID = runnerID;
            this.splitIntoDirectories = splitIntoDirectories;
            this.FilterTimer = timer;

            // If we have a search field, monitor it for changes.
            if (searchField != null)
            {
                if (searchField is TextBox)
                {
                    if (timer == null)
                        throw new Exception("Explorer tasked without a timer! Bad Hannah.");

                    this.searchField = (TextBox)searchField;

                    timer.Tick += OnFilterTimerTick;
                    this.searchField.TextChanged += OnFilterChanged;

                    if (searchOverlay != null)
                        searchOverlay.MouseUp += OnOverlayMouseUp;
                }
                else
                {
                    hardFilter = searchField.ToString().ToLower();
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncCreateXSD"/> class.
 /// </summary>
 /// <param name="isi">The isi.</param>
 /// <param name="xmlDoc">The XML doc.</param>
 /// <param name="FileName">Name of the file.</param>
 public AsyncCreateXSD(ISynchronizeInvoke isi, XmlDocument xmlDoc, string FileName)
     : base(isi)
 {
     // populate private vars
     _xmlDoc = xmlDoc;
     _fileName = FileName;
 }
Пример #6
0
 public WizardSolutionProcessor(ISynchronizeInvoke target, ConfigFile config, DTE applicationObject, AddInSettings settings)
     : base(target)
 {
     m_configuration = config;
     m_applicationObject = applicationObject;
     m_settings = settings;
 }
        public GameMonitorDisplayViewModel(ISynchronizeInvoke synchronizeInvoke, string fileNameAndPath, PollWatcherFactory pollWatcherFactory, Func<Type, ILog> loggerFactory)
        {
            this.synchronizeInvoke = synchronizeInvoke;
            logger = loggerFactory(typeof(GameMonitorDisplayViewModel));

            LoadGameToBeMonitored(fileNameAndPath, pollWatcherFactory);
        }
Пример #8
0
		public FwFdoUI(IHelpTopicProvider helpTopicProvider, ISynchronizeInvoke synchronizeInvoke)
		{
			m_helpTopicProvider = helpTopicProvider;
			m_synchronizeInvoke = synchronizeInvoke;
			m_activityMonitor = new UserActivityMonitor();
			m_activityMonitor.StartMonitoring();
		}
Пример #9
0
 public ShaderFile(VisualContext visualContext, ISynchronizeInvoke syncObject)
 {
     this.visualContext = visualContext;
     //establish watcher
     shaderWatcher.Changed += (object sender, FileSystemEventArgs e) => LoadShader(e.FullPath);
     shaderWatcher.SynchronizingObject = syncObject;
 }
 /// <summary>
 /// Downloads a page and all its references into a Site Storage
 /// </summary>
 /// <param name="url">The url of the page to download</param>
 /// <param name="storage">The storage into which to store the page and its references</param>
 /// <param name="rootFileName">The rootfile name for the ISiteStorage</param>
 /// <param name="target">An object implementing the
 /// ISynchronizeInvoke interface.  All events will be delivered
 /// through this target, ensuring that they are delivered to the
 /// correct thread.</param>
 public AsyncPageDownload(
     string url,
     ISiteStorage storage,
     string rootFileName,
     ISynchronizeInvoke target) : this (url, storage, rootFileName, "", target)
 {
 }
Пример #11
0
	// Constructors.
	public Timer()
			{
				this.autoReset = true;
				this.enabled = false;
				this.interval = 100.0;
				this.synchronizingObject = null;
			}
Пример #12
0
 private static void InvokeIfRequired(ISynchronizeInvoke control, MethodInvoker action)
 {
     if (control.InvokeRequired)
         control.Invoke(action, new object[0]);
     else
         action();
 }
Пример #13
0
		public DelegateAsynchronousOperation(
			ISynchronizeInvoke target,
			AsyncrhonousOperationHandler handler)
			:base(target)
		{
			this.m_handler = handler;
		}
Пример #14
0
 public SBOBet(string text1, ISynchronizeInvoke invoke1, string text2, string text3, string text4, bool flag1, bool flag2, bool flag3, bool flag4, bool flag5, bool flag6, bool flag7, bool flag8, EnumCollection.eSpiderMethod method1, int num2, int num3, int num4, int num1)
 {
     this._strLoginName = "";
     this._strSynidNextRunning = "-1";
     this._strSynidNextToday = "-1";
     this._strSynidNextEarly = "-1";
     this._strSynidNextRunningTmp = "-1";
     this._strSynidNextTodayTmp = "-1";
     this._strSynidNextEarlyTmp = "-1";
     this._objMatchOutRightList = new List<MatchOutRight>();
     this._objMatchOddEvenList = new List<MatchOddEven>();
     this._objMatchTotalGoalList = new List<MatchTotalGoal>();
     this._isToSaveBetList = false;
     try
     {
         this.DoNew(text1, "SBOBet", num1, invoke1, text2, text3, text4);
         this.Init(flag1, flag2, flag3, flag4, flag5, flag6, flag7, flag8, method1, num2, num3, num4);
     }
     catch (Exception exception1)
     {
         ProjectData.SetProjectError(exception1);
         Exception exception = exception1;
         base._objErrorLogger.write(base._strName + ": EXCEPTION IN New: " + exception.Message);
         this.WriteProgramLogger(base._strName + ": EXCEPTION IN New: " + exception.Message);
         ProjectData.ClearProjectError();
     }
 }
Пример #15
0
        public static void InitializeCompile(ISynchronizeInvoke _isi, RichTextBox _rtMain, Button _Compile)
        {
            CompileRich     = _rtMain;
            MainForm        = _isi;
            CompileButton   = _Compile;

            if (!Directory.Exists("Source"))
                Directory.CreateDirectory("Source");

            if (Settings.Default.CoreGit == "")
            {
                CompileRich.AppendText("Core will not compile\nReason: No Core git settings");
                CompileButton.Enabled = true;
                return;
            }

            if (!File.Exists("Source\\Core\\CMakeLists.txt"))
                CloneGit(GitTypes.Core);
            else
                PullGit(GitTypes.Core);

            if (!Directory.Exists("Database"))
                CloneGit(GitTypes.Database);
            else
                PullGit(GitTypes.Database);
        }
Пример #16
0
		public ProgressCollector(ISynchronizeInvoke eventThread, CancellationToken cancellationToken)
		{
			if (eventThread == null)
				throw new ArgumentNullException("eventThread");
			this.eventThread = eventThread;
			this.cancellationToken = cancellationToken;
			this.root = new MonitorImpl(this, null, 1);
		}
Пример #17
0
        /// <summary>
        /// ThreadController constructor.
        /// </summary>
        public ThreadController(ISynchronizeInvoke invokeObject)
        {
            this.threadRunning = false;
            this.threadAborted = false;
            this.threadPaused = false;

            this.invokeObject = invokeObject;
        }
Пример #18
0
        public simulatedPICNetwork(string newPipeName, ISynchronizeInvoke eInvoke)
        {
            _pipename = newPipeName;

            _eventHandler = eInvoke;
            _pipe = new NamedPipeServerStream(_pipename, PipeDirection.InOut, 10, PipeTransmissionMode.Byte,
                                              PipeOptions.Asynchronous);
        }
Пример #19
0
 public void TestInitialize()
 {
     AutoReset = true;
     Interval = 123;
     SynchronizingObject = new ASynchronizinObject();
     Timer = new Timer(AutoReset, Interval, SynchronizingObject);
     NativeTimer = (System.Timers.Timer)Timer;
 }
        public SynchronizedProjectMonitor(IProjectMonitor projectMonitor, ISynchronizeInvoke synchronizeInvoke)
        {
            this.projectMonitor = projectMonitor;
            this.synchronizeInvoke = synchronizeInvoke;

            projectMonitor.Polled += new MonitorPolledEventHandler(ProjectMonitor_Polled);
            projectMonitor.BuildOccurred += new MonitorBuildOccurredEventHandler(ProjectMonitor_BuildOccurred);
        }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventProvider"/> class.
 /// </summary>
 /// <param name="dataProvider">The data provider to get data from</param>
 /// <param name="interval">The interval in milliseconds the timer should fetch the data.</param>
 /// <param name="synchronizingObject">The synchronizing object. Specify your Form or Control here so that you don't have to invoke when handling events.</param>
 /// <param name="enabled">if set to <c>true</c> this class will immediately start fetching data from Spotify.</param>
 public EventProvider(DataProvider dataProvider, double interval, ISynchronizeInvoke synchronizingObject, bool enabled)
 {
     this.DataProvider = dataProvider;
     this.timer = new Timer(interval) { AutoReset = false };
     this.timer.Elapsed += (s, e) => this.UpdateData();
     this.EventSynchronizingObject = synchronizingObject;
     this.Enabled = enabled;
 }
Пример #22
0
        public RuntimeEnvironment(string extension, ISynchronizeInvoke synchronizingObject, TimeSpan workFolderStateMinimumIdle)
        {
            AxCryptExtension = extension;

            _workFolderWatcher = CreateFileWatcher(WorkFolder.FullName);
            _workFolderWatcher.FileChanged += HandleWorkFolderFileChangedEvent;

            _delayedWorkFolderStateChanged = new DelayedAction(OnWorkFolderStateChanged, workFolderStateMinimumIdle, synchronizingObject);
        }
Пример #23
0
        public static void InitializeCompile(ISynchronizeInvoke _isi, RichTextBox _rtMain, Button _btnCompile)
        {
            MainForm    = _isi;
            MainRich    = _rtMain;
            MainButton  = _btnCompile;

            CompileCore();
            frmMain.SetStatus("Compiling");
        }
Пример #24
0
 public ThumbnailManager(ISynchronizeInvoke syncContext)
 {
     this.syncContext = syncContext;
     this.updateLock = new object();
     this.quitRenderThread = false;
     this.renderQueue = new Stack<ThumbnailStackItem>();
     this.renderThread = new Thread(new ThreadStart(RenderThread));
     this.renderThread.Start();
     this.renderingInactive = new ManualResetEvent(true);
 }
        public VideoSmartContentWaitOperation(ISynchronizeInvoke context, SmartContentOperationType checkType, IExtensionData[] extendionDataList)
            : base(context)
        {
            validState = VideoPublishStatus.Completed;
            invalidState = VideoPublishStatus.Error;

            if (checkType == SmartContentOperationType.Close)
                validState |= VideoPublishStatus.RemoteProcessing;

            _extensionDataList = extendionDataList;
        }
Пример #26
0
 private void InvokeIfRequired(Action action, ISynchronizeInvoke control)
 {
     if (control.InvokeRequired)
     {
         Invoke(action);
     }
     else
     {
         action();
     }
 }
Пример #27
0
 /// <summary>
 /// Instantiates a new <see cref="Timer"/> with the specified
 /// properties.
 /// </summary>
 /// <param name="autoReset">The desired value of
 /// <see cref="AutoReset"/>.</param>
 /// <param name="interval">The desired value of
 /// <see cref="Interval"/>.</param>
 /// <param name="synchronizingObject">The desired value of
 /// <see cref="SynchronizingObject"/>; optional.</param>
 public Timer(bool autoReset,
              double interval,
              ISynchronizeInvoke synchronizingObject)
 {
     native = new System.Timers.Timer
     {
         AutoReset = autoReset,
         Interval = interval,
         SynchronizingObject = synchronizingObject
     };
 }
 public static void BeginInvoke(ISynchronizeInvoke synchronizeInvoke, Action action)
 {
     if (synchronizeInvoke.InvokeRequired)
     {
         synchronizeInvoke.BeginInvoke(action, null);
     }
     else
     {
         action();
     }
 }
 /// <summary>
 /// Create a listener whose behavior is defined by the given actions. Any action may be null
 /// </summary>
 public EEGDataListener(ISynchronizeInvoke invoker,
     Action<IEEGDataSource> onSourceConnected,
     Action<IArrayView<EEGDataEntry>> onListen,
     Action<IEEGDataSource> onSourceDisconnected,
     Action onDispose = null)
 {
     this.invoker = invoker;
     this.onSourceConnected = onSourceConnected;
     this.onListen = onListen;
     this.onSourceDisconnected = onSourceDisconnected;
     this.onDispose = onDispose;
 }
Пример #30
0
 /// <summary>
 /// Invokes the specified action on the thread that the specified sync object was created on.
 /// </summary>
 public static void Invoke(ISynchronizeInvoke sync, Action action)
 {
     if (!sync.InvokeRequired)
     {
         action();
     }
     else
     {
         object[] args = new object[] { };
         sync.Invoke(action, args);
     }
 }
Пример #31
0
    private void OnLogReceived(string condition, string stackTrace, LogType type)
    {
        if (this._disposed)
        {
            throw new Exception(string.Format("LogService used after being disposed. (content:{0})", (object)condition));
        }
        if (this._reentranceGuard)
        {
            throw new Exception(string.Format("LogService Reentrance occurred. (content:{0})", (object)condition));
        }
        this._reentranceGuard = true;
        ++this._seqID;
        switch ((int)type)
        {
        case 0:
            ++this._errorCount;
            break;

        case 1:
            ++this._assertCount;
            break;

        case 4:
            ++this._exceptionCount;
            break;
        }
        try
        {
            if (type == 4)
            {
                condition = string.Format("{0}\r\n  {1}", (object)condition, (object)stackTrace.Replace("\n", "\r\n  "));
            }
            if (condition == this._lastWrittenContent)
            {
                ++this._foldedCount;
            }
            else
            {
                this.FlushFoldedMessage();
                this.WriteLog(string.Format("{0:0.00} {1}: {2}\r\n", (object)Time.get_realtimeSinceStartup(), (object)type, (object)condition), type);
                this._lastWrittenContent = condition;
                this._lastWrittenType    = type;
            }
            if (this.LogTargets == null)
            {
                return;
            }
            foreach (LogTargetHandler invocation in this.LogTargets.GetInvocationList())
            {
                ISynchronizeInvoke target = invocation.Target as ISynchronizeInvoke;
                LogEventArgs       args   = new LogEventArgs((int)this._seqID, type, condition, stackTrace, Time.get_realtimeSinceStartup());
                if (target != null && target.InvokeRequired)
                {
                    target.Invoke((Delegate)invocation, new object[2]
                    {
                        (object)this,
                        (object)args
                    });
                }
                else
                {
                    invocation((object)this, args);
                }
            }
        }
        catch (Exception ex)
        {
            Log.Exception(ex);
        }
        finally
        {
            this._reentranceGuard = false;
        }
    }
Пример #32
0
 public static void Init(ISynchronizeInvoke sync)
 {
     _sync = sync;
 }
Пример #33
0
 public ExecutorHandler(ISynchronizeInvoke owner, string clientName, string host, int port)
     : base(owner, clientName, host, port)
 {
 }
 public FileProcessViewModel(ISynchronizeInvoke context, FileProcessInfo info) : base(context)
 {
     Info = info;
 }
Пример #35
0
 internal static void RunActionInSynchronizer(ISynchronizeInvoke usingSynchronizer, Action action)
 {
 }
Пример #36
0
        private void Download(object parameters)
        {
            this.mDownloading = true;
            string[]    array       = (string[])parameters;
            byte[]      array2      = null;
            XmlNodeList xmlNodeList = null;
            string      text        = array[0];
            string      text2       = array[1];

            if (!string.IsNullOrEmpty(text2))
            {
                text = text + "/" + text2;
            }
            string text3    = array[2];
            bool   flag     = bool.Parse(array[3]);
            bool   useCache = bool.Parse(array[4]);
            ulong  num      = ulong.Parse(array[5]);

            try
            {
                XmlDocument indexFile = this.GetIndexFile(text + "/index.xml", useCache);
                if (indexFile == null)
                {
                    ISynchronizeInvoke arg_AE_0 = this.mFE;
                    Delegate           arg_AE_1 = this.mDownloadFailed;
                    object[]           args     = new object[1];
                    arg_AE_0.BeginInvoke(arg_AE_1, args);
                }
                else
                {
                    long num2 = long.Parse(indexFile.SelectSingleNode("/index/header/length").InnerText);
                    long num3 = 0L;
                    long num4;
                    if (num == 0uL)
                    {
                        num4 = long.Parse(indexFile.SelectSingleNode("/index/header/compressed").InnerText);
                    }
                    else
                    {
                        num4 = (long)num;
                    }
                    long      num5      = 0L;
                    WebClient webClient = new WebClient();
                    webClient.Headers.Add("Accept", "text/html,text/xml,application/xhtml+xml,application/xml,application/*,*/*;q=0.9,*/*;q=0.8");
                    webClient.Headers.Add("Accept-Language", "en-us,en;q=0.5");
                    webClient.Headers.Add("Accept-Encoding", "gzip,deflate");
                    webClient.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                    int num6 = 1;
                    array2      = null;
                    xmlNodeList = indexFile.SelectNodes("/index/fileinfo");
                    this.mDownloadManager.Initialize(indexFile, text);
                    if (flag)
                    {
                        HashManager.Instance.Clear();
                        HashManager.Instance.Start(indexFile, text3, text2 + ".hsh", this.mHashThreads);
                    }
                    int           num7  = 0;
                    List <string> list  = new List <string>();
                    int           i     = 0;
                    bool          flag2 = false;
                    int           num11;
                    foreach (XmlNode xmlNode in xmlNodeList)
                    {
                        XmlNodeList xmlNodeList2 = xmlNode.SelectNodes("compressed");
                        int         num8;
                        if (xmlNodeList2.Count == 0)
                        {
                            num8 = int.Parse(xmlNode.SelectNodes("length")[0].InnerText);
                        }
                        else
                        {
                            num8 = int.Parse(xmlNodeList2[0].InnerText);
                        }
                        num7 = ((num8 > num7) ? num8 : num7);
                        string text4 = xmlNode.SelectSingleNode("path").InnerText;
                        if (!string.IsNullOrEmpty(text3))
                        {
                            int num9 = text4.IndexOf("/");
                            if (num9 >= 0)
                            {
                                text4 = text4.Replace(text4.Substring(0, num9), text3);
                            }
                            else
                            {
                                text4 = text3;
                            }
                        }
                        string innerText = xmlNode.SelectSingleNode("file").InnerText;
                        string fileName  = text4 + "/" + innerText;
                        int    num10     = int.Parse(xmlNode.SelectSingleNode("section").InnerText);
                        num11 = int.Parse(xmlNode.SelectSingleNode("offset").InnerText);
                        if (flag)
                        {
                            if (list.Count == 0)
                            {
                                i = num10;
                            }
                            while (i <= num10)
                            {
                                list.Insert(0, string.Format("{0}/section{1}.dat", text, i));
                                i++;
                            }
                        }
                        else if (!HashManager.Instance.HashesMatch(fileName))
                        {
                            if (i <= num10)
                            {
                                if (list.Count == 0)
                                {
                                    i = num10;
                                }
                                while (i <= num10)
                                {
                                    list.Insert(0, string.Format("{0}/section{1}.dat", text, i));
                                    i++;
                                }
                            }
                            flag2 = true;
                        }
                        else
                        {
                            if (flag2)
                            {
                                int num12 = num10;
                                if (num11 == 0)
                                {
                                    num12--;
                                }
                                while (i <= num12)
                                {
                                    list.Insert(0, string.Format("{0}/section{1}.dat", text, i));
                                    i++;
                                }
                            }
                            if (i < num10)
                            {
                                i = num10;
                            }
                            flag2 = false;
                        }
                    }
                    foreach (string current in list)
                    {
                        this.mDownloadManager.ScheduleFile(current);
                    }
                    list.Clear();
                    list  = null;
                    num11 = 0;
                    this.mDownloadManager.Start();
                    byte[] array3 = new byte[num7];
                    byte[] array4 = new byte[13];
                    int    num13  = 0;
                    foreach (XmlNode xmlNode2 in xmlNodeList)
                    {
                        if (Downloader.mStopFlag)
                        {
                            break;
                        }
                        string text5      = xmlNode2.SelectSingleNode("path").InnerText;
                        string innerText2 = xmlNode2.SelectSingleNode("file").InnerText;
                        if (!string.IsNullOrEmpty(text3))
                        {
                            int num14 = text5.IndexOf("/");
                            if (num14 >= 0)
                            {
                                text5 = text5.Replace(text5.Substring(0, num14), text3);
                            }
                            else
                            {
                                text5 = text3;
                            }
                        }
                        string  text6    = text5 + "/" + innerText2;
                        int     num15    = int.Parse(xmlNode2.SelectSingleNode("length").InnerText);
                        int     num16    = 0;
                        XmlNode xmlNode3 = xmlNode2.SelectSingleNode("compressed");
                        if (xmlNode2.SelectSingleNode("section") != null && num6 < int.Parse(xmlNode2.SelectSingleNode("section").InnerText))
                        {
                            num6 = int.Parse(xmlNode2.SelectSingleNode("section").InnerText);
                        }
                        string text7 = null;
                        if (xmlNode2.SelectSingleNode("hash") != null && HashManager.Instance.HashesMatch(text6))
                        {
                            num16 += num15;
                            if (xmlNode3 != null)
                            {
                                if (num == 0uL)
                                {
                                    num3 += (long)int.Parse(xmlNode3.InnerText);
                                }
                                num5  += (long)int.Parse(xmlNode3.InnerText);
                                num11 += int.Parse(xmlNode3.InnerText);
                            }
                            else
                            {
                                if (num == 0uL)
                                {
                                    num3 += (long)num15;
                                }
                                num5  += (long)num15;
                                num11 += num15;
                            }
                            if (this.mProgressUpdated != null)
                            {
                                object[] args2 = new object[]
                                {
                                    num2,
                                    num3,
                                    num4,
                                    text6
                                };
                                this.mFE.Invoke(this.mProgressUpdated, args2);
                            }
                            int num17 = int.Parse(xmlNode2.SelectSingleNode("section").InnerText);
                            if (num13 != num17)
                            {
                                for (int j = num13 + 1; j < num17; j++)
                                {
                                    this.mDownloadManager.CancelDownload(string.Format("{0}/section{1}.dat", text, j));
                                }
                                num13 = num17 - 1;
                            }
                        }
                        else
                        {
                            Directory.CreateDirectory(text5);
                            FileStream fileStream = File.Create(text6);
                            int        num18      = num15;
                            if (xmlNode3 != null)
                            {
                                num18 = int.Parse(xmlNode3.InnerText);
                            }
                            int  k     = 0;
                            bool flag3 = false;
                            int  num19 = 13;
                            while (k < num18)
                            {
                                if (array2 == null || num11 >= array2.Length)
                                {
                                    if (xmlNode2.SelectSingleNode("offset") != null && !flag3)
                                    {
                                        num11 = int.Parse(xmlNode2.SelectSingleNode("offset").InnerText);
                                    }
                                    else
                                    {
                                        num11 = 0;
                                    }
                                    text7 = string.Format("{0}/section{1}.dat", text, num6);
                                    for (int l = num13 + 1; l < num6; l++)
                                    {
                                        this.mDownloadManager.CancelDownload(string.Format("{0}/section{1}.dat", text, l));
                                    }
                                    array2 = null;
                                    GC.Collect();
                                    array2 = this.mDownloadManager.GetFile(text7);
                                    if (array2 == null)
                                    {
                                        //MessageBox.Show("DownloadManager returned a null buffer for file '" + text7 + "', aborting");
                                        if (this.mDownloadFailed != null)
                                        {
                                            if (!Downloader.mStopFlag)
                                            {
                                                this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                                                {
                                                    new Exception("DownloadManager returned a null buffer")
                                                });
                                            }
                                            else
                                            {
                                                ISynchronizeInvoke arg_887_0 = this.mFE;
                                                Delegate           arg_887_1 = this.mDownloadFailed;
                                                object[]           args      = new object[1];
                                                arg_887_0.BeginInvoke(arg_887_1, args);
                                            }
                                        }
                                        return;
                                    }
                                    num13 = num6;
                                    num5 += (long)array2.Length;
                                    num6++;
                                    if (!this.mDownloadManager.GetStatus(string.Format("{0}/section{1}.dat", text, num6)).HasValue&& num5 < num4)
                                    {
                                        this.mDownloadManager.ScheduleFile(string.Format("{0}/section{1}.dat", text, num6));
                                    }
                                }
                                else
                                {
                                    if (num18 - k > array2.Length - num11)
                                    {
                                        text7 = string.Format("{0}/section{1}.dat", text, num6);
                                        this.mDownloadManager.ScheduleFile(text7);
                                        flag3 = true;
                                    }
                                    int num20 = Math.Min(array2.Length - num11, num18 - k);
                                    if (num19 != 0)
                                    {
                                        if (xmlNode3 != null)
                                        {
                                            int num21 = Math.Min(num19, num20);
                                            Buffer.BlockCopy(array2, num11, array4, 13 - num19, num21);
                                            Buffer.BlockCopy(array2, num11 + num21, array3, 0, num20 - num21);
                                            num19 -= num21;
                                        }
                                        else
                                        {
                                            Buffer.BlockCopy(array2, num11, array3, 0, num20);
                                            num19 = 0;
                                        }
                                    }
                                    else
                                    {
                                        Buffer.BlockCopy(array2, num11, array3, k - ((xmlNode3 != null) ? 13 : 0), num20);
                                    }
                                    num11 += num20;
                                    k     += num20;
                                    num3  += (long)num20;
                                }
                                if (this.mProgressUpdated != null)
                                {
                                    object[] args3 = new object[]
                                    {
                                        num2,
                                        num3,
                                        num4,
                                        text6
                                    };
                                    this.mFE.BeginInvoke(this.mProgressUpdated, args3);
                                }
                            }
                            if (xmlNode3 != null)
                            {
                                if (!Downloader.IsLzma(array4))
                                {
                                    MessageBox.Show("Compression algorithm not recognized" + text7);
                                    throw new DownloaderException("Compression algorithm not recognized: " + text7);
                                }
                                fileStream.Close();
                                fileStream.Dispose();
                                //(IntPtr)num15;
                                IntPtr outPropsSize = new IntPtr(5);
                                byte[] array5       = new byte[5];
                                for (int m = 0; m < 5; m++)
                                {
                                    array5[m] = array4[m];
                                }
                                long num22 = 0L;
                                for (int n = 0; n < 8; n++)
                                {
                                    num22 += (long)((long)array4[n + 5] << 8 * n);
                                }
                                if (num22 != (long)num15)
                                {
                                    MessageBox.Show("Compression data length in header '" + num22 + "' != than in metadata '" + num15 + "'");
                                    throw new DownloaderException("Compression data length in header '" + num22 + "' != than in metadata '" + num15 + "'");
                                }
                                int num23 = num18;
                                num18 -= 13;
                                IntPtr intPtr = new IntPtr(num18);
                                IntPtr value  = new IntPtr(num22);
                                int    num24  = LZMA.LzmaUncompressBuf2File(text6, ref value, array3, ref intPtr, array5, outPropsSize);

                                if (num24 != 0)
                                {
                                    MessageBox.Show("Decompression returned " + num24);
                                    throw new UncompressionException(num24, "Decompression returned " + num24);
                                }
                                if (value.ToInt32() != num15)
                                {
                                    MessageBox.Show("Decompression returned different size '" + value.ToInt32() + "' than metadata '" + num15 + "'");
                                    throw new DownloaderException("Decompression returned different size '" + value.ToInt32() + "' than metadata '" + num15 + "'");
                                }
                                num16 += (int)value;
                            }
                            else
                            {
                                fileStream.Write(array3, 0, num15);
                                num16 += num15;
                            }
                            if (fileStream != null)
                            {
                                fileStream.Close();
                                fileStream.Dispose();
                            }
                        }
                    }
                    if (!Downloader.mStopFlag)
                    {
                        HashManager.Instance.WriteHashCache(text2 + ".hsh", false);
                    }
                    if (Downloader.mStopFlag)
                    {
                        if (this.mDownloadFailed != null)
                        {
                            ISynchronizeInvoke arg_D16_0 = this.mFE;
                            Delegate           arg_D16_1 = this.mDownloadFailed;
                            object[]           args      = new object[1];
                            arg_D16_0.BeginInvoke(arg_D16_1, args);
                        }
                    }
                    else if (this.mDownloadFinished != null)
                    {
                        this.mFE.BeginInvoke(this.mDownloadFinished, null);
                    }
                }
            }
            catch (DownloaderException ex)
            {
                MessageBox.Show("Download DownloaderException: " + ex.ToString());
                if (this.mDownloadFailed != null)
                {
                    try
                    {
                        this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                        {
                            ex
                        });
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex2)
            {
                MessageBox.Show("Download Exception: " + ex2.ToString());
                if (this.mDownloadFailed != null)
                {
                    try
                    {
                        this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                        {
                            ex2
                        });
                    }
                    catch
                    {
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    HashManager.Instance.Clear();
                }
                this.mDownloadManager.Clear();
                array2      = null;
                xmlNodeList = null;
                GC.Collect();
                this.mDownloading = false;
            }
        }
Пример #37
0
 public object InvokeGetProperty(ISynchronizeInvoke obj, string objId, string propertyName)
 {
     return(InvokeMethod(obj, objId, "get_" + propertyName, null));
 }
Пример #38
0
 public Downloader(ISynchronizeInvoke fe) : this(fe, 3, 3, 16)
 {
 }
Пример #39
0
 public Downloader(ISynchronizeInvoke fe, int hashThreads, int downloadThreads, int downloadChunks)
 {
     this.mHashThreads     = hashThreads;
     this.mFE              = fe;
     this.mDownloadManager = new DownloadManager(downloadThreads, downloadChunks);
 }
Пример #40
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public Document(ISynchronizeInvoke form)
 {
     _form       = form;
     _translator = new StandardTranslator();
 }
 public BlogClientUIContextImpl(IWin32Window dialogOwner, ISynchronizeInvoke invokeContext)
 {
     _dialogOwner = dialogOwner; _invokeTarget = invokeContext;
 }
Пример #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StorageLinkConnection"/> class. This constructor allows a mock
 /// web service to be passed in.
 /// </summary>
 /// <param name="synchronizer">The synchronizer used for synchronizing the cache update. Usually <see cref="MainWindow"/>.</param>
 /// <param name="service">The web service.</param>
 public StorageLinkConnection(ISynchronizeInvoke synchronizer, IStorageLinkWebService service) :
     this(synchronizer, service.Host, service.Username, service.Password)
 {
     Util.ThrowIfParameterNull(service, "service");
     _service = service;
 }
Пример #43
0
 public QueueTimer(int delayInterval = 500, int sleepInterval = 5000, ISynchronizeInvoke listSynchronizingObject = null) : base(delayInterval, sleepInterval, listSynchronizingObject)
 {
 }
Пример #44
0
        private void Verify(object parameters)
        {
            string[] array = (string[])parameters;
            string   str   = array[0].Trim();
            string   text  = array[1].Trim();

            if (!string.IsNullOrEmpty(text))
            {
                str = str + "/" + text;
            }
            string text2 = array[2].Trim();
            bool   flag  = bool.Parse(array[3]);
            bool   flag2 = bool.Parse(array[4]);
            bool   flag3 = bool.Parse(array[5]);
            bool   flag4 = false;

            try
            {
                XmlDocument indexFile = this.GetIndexFile(str + "/index.xml", false);
                if (indexFile == null)
                {
                    ISynchronizeInvoke arg_B9_0 = this.mFE;
                    Delegate           arg_B9_1 = this.mDownloadFailed;
                    object[]           args     = new object[1];
                    arg_B9_0.BeginInvoke(arg_B9_1, args);
                }
                else
                {
                    long      num       = long.Parse(indexFile.SelectSingleNode("/index/header/length").InnerText);
                    WebClient webClient = new WebClient();
                    webClient.Headers.Add("Accept", "text/html,text/xml,application/xhtml+xml,application/xml,application/*,*/*;q=0.9,*/*;q=0.8");
                    webClient.Headers.Add("Accept-Language", "en-us,en;q=0.5");
                    webClient.Headers.Add("Accept-Encoding", "gzip,deflate");
                    webClient.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                    XmlNodeList xmlNodeList = indexFile.SelectNodes("/index/fileinfo");
                    HashManager.Instance.Clear();
                    HashManager.Instance.Start(indexFile, text2, text + ".hsh", this.mHashThreads);
                    long  num2 = 0L;
                    ulong num3 = 0uL;
                    ulong num4 = 0uL;
                    foreach (XmlNode xmlNode in xmlNodeList)
                    {
                        string text3     = xmlNode.SelectSingleNode("path").InnerText;
                        string innerText = xmlNode.SelectSingleNode("file").InnerText;
                        if (!string.IsNullOrEmpty(text2))
                        {
                            int num5 = text3.IndexOf("/");
                            if (num5 >= 0)
                            {
                                text3 = text3.Replace(text3.Substring(0, num5), text2);
                            }
                            else
                            {
                                text3 = text2;
                            }
                        }
                        string text4 = text3 + "/" + innerText;
                        int    num6  = int.Parse(xmlNode.SelectSingleNode("length").InnerText);
                        if (xmlNode.SelectSingleNode("hash") != null)
                        {
                            if (!HashManager.Instance.HashesMatch(text4))
                            {
                                num3 += ulong.Parse(xmlNode.SelectSingleNode("length").InnerText);
                                ulong num7;
                                if (xmlNode.SelectSingleNode("compressed") != null)
                                {
                                    num7 = ulong.Parse(xmlNode.SelectSingleNode("compressed").InnerText);
                                }
                                else
                                {
                                    num7 = ulong.Parse(xmlNode.SelectSingleNode("length").InnerText);
                                }
                                num4 += num7;
                                if (flag)
                                {
                                    this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                                    {
                                    });
                                    return;
                                }
                                flag4 = true;
                            }
                        }
                        else
                        {
                            if (flag)
                            {
                                throw new DownloaderException("Without hash in the metadata I cannot verify the download");
                            }
                            flag4 = true;
                        }
                        if (Downloader.mStopFlag)
                        {
                            ISynchronizeInvoke arg_367_0 = this.mFE;
                            Delegate           arg_367_1 = this.mDownloadFailed;
                            object[]           args2     = new object[1];
                            arg_367_0.BeginInvoke(arg_367_1, args2);
                            return;
                        }
                        num2 += (long)num6;
                        object[] args3 = new object[]
                        {
                            num,
                            num2,
                            0,
                            innerText
                        };
                        this.mFE.BeginInvoke(this.mProgressUpdated, args3);
                    }
                    if (flag3)
                    {
                        //Downloader.mLogger.Info("Writing hash cache");
                        HashManager.Instance.WriteHashCache(text + ".hsh", true);
                    }
                    if (flag4)
                    {
                        this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                        {
                        });
                    }
                    else
                    {
                        this.mFE.BeginInvoke(this.mDownloadFinished, null);
                    }
                }
            }
            catch (DownloaderException ex)
            {
                this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                {
                    ex
                });
            }
            catch (Exception ex2)
            {
                this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                {
                    ex2
                });
            }
            finally
            {
                if (flag2)
                {
                    HashManager.Instance.Clear();
                }
                GC.Collect();
            }
        }
Пример #45
0
 public object InvokeSetProperty(ISynchronizeInvoke obj, string objId, string propertyName, params object[] paramValues)
 {
     return(InvokeMethod(obj, objId, "set_" + propertyName, paramValues));
 }
Пример #46
0
 public void Connect(int pollingInterval, ISynchronizeInvoke synchronizingObject)
 {
     throw new NotImplementedException();
 }
Пример #47
0
 public static void InvokeNoWaitIfRequired(this ISynchronizeInvoke control, MethodInvoker action)
 {
     InvokeIfRequired(control, action, false);
 }
Пример #48
0
 /// <summary>
 /// Initialises an AsyncOperation with an association to the
 /// supplied ISynchronizeInvoke.  All events raised from this
 /// object will be delivered via this target.  (This might be a
 /// Control object, so events would be delivered to that Control's
 /// UI thread.)
 /// </summary>
 /// <param name="target">An object implementing the
 /// ISynchronizeInvoke interface.  All events will be delivered
 /// through this target, ensuring that they are delivered to the
 /// correct thread.</param>
 public AsyncOperation(ISynchronizeInvoke target)
 {
     isiTarget = target;
     isRunning = false;
 }
Пример #49
0
 internal static bool RunInSynchronizer(ISynchronizeInvoke usingSynchronizer, Func <bool> p)
 {
     return(true);
 }
 protected SynchronizableViewModelBase(ISynchronizeInvoke context)
 {
     Context = context ?? throw new ArgumentNullException(nameof(context));
 }
Пример #51
0
 internal static IBLTag RunFuncInSynchronizer(ISynchronizeInvoke usingSynchronizer, Func <ICoreObject, IBLTag> func, ICoreObject tagRef)
 {
     throw new NotImplementedException();
 }
Пример #52
0
 /// <summary>
 /// 延迟timesMs后执行。
 /// </summary>
 public void Delay(int timeMs, ISynchronizeInvoke invoker, Action action)
 {
     Debounce(timeMs, invoker, action);
 }
Пример #53
0
 /// <summary>
 ///     Because filewatcher is created before the main form in GUI thread.
 ///     This lets to fire the file system watcher events in GUI thread.
 /// </summary>
 public static void AssignSynchronizationObject(ISynchronizeInvoke synchronizer)
 {
     fileWatcher.AssignSynchronizer(synchronizer);
 }
Пример #54
0
 public MyController(ISynchronizeInvoke syn)
 {
     _syn = syn;
 }
Пример #55
0
 public PreferenceService(ISerializer <PreferenceData> serializer, IMemoryCache cache, ISynchronizeInvoke synchronizingObject)
 {
     this.serializer   = serializer;
     this.cache        = cache;
     fileSystemWatcher = new FileSystemWatcherExtended(AppPaths.Preferences, "*.json")
     {
         NotifyFilter        = NotifyFilters.LastWrite,
         SynchronizingObject = synchronizingObject,
         EnableRaisingEvents = true
     };
     fileSystemWatcher.FileChanged += FileSystemWatcher_FileChanged;
     CachePreferences();
 }
Пример #56
0
 public Scrape(int index, string AnnounceURL, byte[] Hash, PeersRecievedCallback Callback, ISynchronizeInvoke syncObject)
 {
     _index      = index;
     _Callback   = Callback;
     _syncObject = syncObject;
     BeginGetScrape(AnnounceURL, Hash);
 }
Пример #57
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 public FormFiber(ISynchronizeInvoke invoker, IExecutor executor) : base(new FormAdapter(invoker), executor)
 {
 }
 public SoundEventsSynchronizerFactory(IFoldersFinder <SoundEvent, Sound> finder, ISynchronizeInvoke synchonizingObject, IFileSystem fileSystem)
 {
     this.finder             = finder;
     this.synchonizingObject = synchonizingObject;
     this.fileSystem         = fileSystem;
 }
Пример #59
0
 /// <summary>
 /// Constructor for the AsynchCallResult object
 /// </summary>
 /// <param name="method">Method being invoked</param>
 /// <param name="args">Arguments for method</param>
 /// <param name="callBack">Callback method for result</param>
 /// <param name="asyncState">Object representing state for the method call</param>
 /// <param name="syncInv">The caller</param>
 internal AsynchCallResult(Delegate method, object[] args, AsyncCallback callBack, object asyncState, ISynchronizeInvoke syncInv)
 {
     state_          = asyncState;
     method_         = method;
     args_           = args;
     asynchCallback_ = callBack;
     asynchCall_     = syncInv;
 }
Пример #60
0
 /// <summary>
 /// Constructor for applications not using the Managed Extensibility Framework (MEF)</summary>
 /// <param name="synchronizationObject">Synchronization object, for example, the main form. Is used so that
 /// FileChanged events are raised on the main UI thread. Can be null.</param>
 public FileWatcherService(ISynchronizeInvoke synchronizationObject)
 {
     m_synchObject = synchronizationObject;
 }