public bool Update(TValue value)
        {
            var keyResult = _keySelector(value);

            if (!_valuesDic.TryGetValue(keyResult, out var item))
            {
                throw new KeyNotFoundException($"Key '{keyResult}' not found");
            }

            if (ReferenceEquals(value, item) || Equals(value, item))
            {
                return(false);
            }

            if (string.Equals(JsonConvert.SerializeObject(value, Formatting.None),
                              JsonConvert.SerializeObject(item, Formatting.None), StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            _valuesDic[keyResult] = value;

            OnUpdated?.Invoke(this, value);

            return(true);
        }
示例#2
0
    public static void Load()
    {
        if (Application.isPlaying)
        {
            return;
        }

        loadedAssets.Clear();
        assetCategories.Clear();
        AssetBundle.UnloadAllAssetBundles(true);

        ResourceManager.Reset();
        ResourceManager.SetAssetGetPathCallback(GetBundleAssetPath);

        var categoriesSet = new HashSet <string>();

        LoadBundles(Application.streamingAssetsPath, categoriesSet);

        var gdir = PlayerPrefs.GetString("GAME_CONTENT_DIR", "");

        LoadBundles(gdir, categoriesSet);

        assetCategories.AddRange(categoriesSet.OrderBy(x => x));
        EditorUtility.ClearProgressBar();

        IsLoaded = true;
        OnUpdated?.Invoke();
    }
        private static void OnOperationsStateChanged(int[] ids)
        {
            if (!s_Initialized)
            {
                return;
            }
            if (ids.Length == 0)
            {
                return;
            }

            var items = new ProgressItem[ids.Length];
            var i     = 0;

            foreach (var id in ids)
            {
                var item = GetProgressById(id);
                Assert.IsNotNull(item);
                item.Dirty();
                items[i++] = item;
            }
            s_ProgressDirty = true;

            OnUpdated?.Invoke(items);
        }
示例#4
0
文件: Script.cs 项目: corbane/Ghx
        private void OnSourceChanged(LanguageService.CompilationResult result)
        {
            if (result.Error != null)
            {
                OnError?.Invoke(result.Error);
                return;
            }

            if (result.Assembly == null)
            {
                return;
            }

            m_assembly   = null;
            m_ctor       = null;
            m_entrypoint = null;
            m_program    = null;
            m_inputs.Clear();
            m_outputs.Clear();

            m_assembly = result.Assembly;

            var cls = (from t in m_assembly.GetExportedTypes()
                       where t.IsClass && t.Name == "Program"
                       select t).FirstOrDefault();

            if (cls == null)
            {
                OnError?.Invoke("Cant not find the entry class");
                return;
            }

            m_ctor = cls.GetConstructors().FirstOrDefault();

            if (m_ctor == null)
            {
                OnError?.Invoke("Cant not find the entry program");
                return;
            }

            m_entrypoint = cls.GetTypeInfo().GetDeclaredMethod("<Initialize>");

            if (m_entrypoint == null)
            {
                OnError?.Invoke("Cant not find the entry point");
                return;
            }

            m_outputs.AddRange(from field in cls.GetFields()
                               let attr = field.GetCustomAttribute(typeof(Output))
                                          where attr != null
                                          select new CsxField(field, attr as ICsxAttribute, this));

            m_inputs.AddRange(from field in cls.GetFields()
                              let attr = field.GetCustomAttribute(typeof(Input))
                                         where attr != null
                                         select new CsxField(field, attr as ICsxAttribute, this));

            OnUpdated?.Invoke();
        }
示例#5
0
    public SectionSearchHandler()
    {
        scenesSearchHandler = new SearchHandler <ISearchInfo>(scenesSortTypes, (item) =>
        {
            bool result = true;
            if (filterContributor)
            {
                result = item.isContributor;
            }
            if (filterOperator && result)
            {
                result = item.isOperator;
            }
            if (filterOwner && result)
            {
                result = item.isOwner;
            }
            return(result);
        });

        scenesSearchHandler.OnSearchChanged += list =>
        {
            OnUpdated?.Invoke();
            OnResult?.Invoke(list);
        };
    }
示例#6
0
 protected void InvokeOnUpdated()
 {
     if (OnUpdated != null)
     {
         OnUpdated.Invoke();
     }
 }
 public void Remove(Type type, ulong id)
 {
     if (entities.TryGetValue(type, out var collection))
     {
         collection.Remove(id);
     }
     OnUpdated?.Invoke();
 }
示例#8
0
 private void UpdateModelComplete()
 {
     _updateStatus.InProgress = false;
     logger.Trace("Model update complete!");
     OnUpdated?.Invoke(_updateStatus);
     logger.Trace("Notified model listeners");
     _updateTimer.Start();
 }
 public void Add(BaseDbEntity entity)
 {
     entity.Id           = lastId++;
     entity.CreationTime = DateTime.Now;
     entities.GetOrAdd(entity.GetType(), () => new Dictionary <ulong, BaseDbEntity>())
     .Add(entity.Id, entity.Clone());
     OnUpdated?.Invoke();
 }
示例#10
0
    public static void Load()
    {
        loadedAssets.Clear();
        assetCategories.Clear();
        AssetBundle.UnloadAllAssetBundles(true);

        ResourceManager.Reset();
        ResourceManager.SetAssetGetPathCallback(GetBundleAssetPath);

        var categoriesSet = new HashSet <string>();

        foreach (string f in Directory.GetFiles(Application.streamingAssetsPath))
        {
            try
            {
                if (!Path.HasExtension(f))
                {
                    AssetBundle bundle = AssetBundle.LoadFromFile(f);
                    ResourceManager.AddBundle("", bundle);

                    string[] allAssetNames = bundle.GetAllAssetNames();
                    int      progress      = 0;
                    foreach (var asset in allAssetNames)
                    {
                        Object obj = bundle.LoadAsset(asset);
                        if (obj is ScriptableObject || obj is TextAsset)
                        {
                            var category = GetCategoryFromAssetName(asset);
                            loadedAssets.Add(new LoadedAsset
                            {
                                Asset         = obj,
                                AssetName     = asset,
                                AssetCategory = category,
                            });
                            categoriesSet.Add(category);
                        }

                        if (EditorUtility.DisplayCancelableProgressBar("Asset bundle", "Load Asset", (float)progress / allAssetNames.Length))
                        {
                            break;
                        }

                        ++progress;
                    }
                }
            }
            catch
            {
                Debug.Log("Bundle skip");
            }
        }

        assetCategories.AddRange(categoriesSet.OrderBy(x => x));
        EditorUtility.ClearProgressBar();

        IsLoaded = true;
        OnUpdated?.Invoke();
    }
        public void Update(SlamTrackedObject item)
        {
            lock (_objects)
            {
                PureUpdate(item);
            }

            OnUpdated?.Invoke(this, new UpdatedEventArgs <SlamTrackedObject>(new[] { item }));
        }
示例#12
0
 public async Task UpdateTypeAsync(GameType newType)
 {
     Type = newType;
     RecalculateGhostStates();
     if (OnUpdated is not null)
     {
         await OnUpdated.Invoke();
     }
 }
        private void AssignNewData(RemoteControlData data)
        {
            if (this.data.Equals(data) == false)
            {
                OnUpdated?.Invoke(data);
            }

            this.data = data;
        }
示例#14
0
        internal static void Communicate()
        {
            var working = true;

            while (working)
            {
                try
                {
                    Thread.Sleep(Math.Max(25, Settings.Network.UpdateInterval));

                    if (!AutoFollow.Enabled)
                    {
                        Server.ShutdownServer();
                        Client.ShutdownClient();
                        continue;
                    }

                    if (!BotMain.IsRunning || BotMain.IsPausedForStateExecution)
                    {
                        continue;
                    }

                    if (!IsConnected)
                    {
                        Connect(ConnectionMode);
                    }

                    if (OnUpdatePreview != null)
                    {
                        OnUpdatePreview.Invoke();
                    }

                    if (ConnectionMode == ConnectionMode.Server)
                    {
                        Server.ServerUpdate();
                    }
                    else
                    {
                        Client.ClientUpdate();
                    }

                    if (OnUpdated != null)
                    {
                        OnUpdated.Invoke();
                    }
                }
                catch (ThreadAbortException e)
                {
                    Thread.ResetAbort();
                    working = false;
                }
                catch (Exception ex)
                {
                    Log.Info("Error in Communicate Thread: {0}", ex);
                }
            }
        }
        public void Update(SlamLine item)
        {
            lock (_lines)
            {
                var index = _lines.FindIndex(l => l.Id == item.Id);
                _lines[index] = item;
            }

            OnUpdated?.Invoke(this, new UpdatedEventArgs <SlamLine>(new[] { item }));
        }
示例#16
0
        void DeserialiseJson(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return;
            }

            JsonUtility.FromJsonOverwrite(json, this);
            OnUpdated?.Invoke();
        }
示例#17
0
        /// <summary>
        /// Updates the zoom by delta, clamping it between a min and max value
        /// </summary>
        /// <param name="delta"></param>
        private void UpdateZoom(float delta)
        {
            float zoomValue = Mathf.Clamp(_origin.transform.scale.x + delta, _minZoomValue, _maxZoomValue);

            _origin.transform.scale = new Vector3(zoomValue, zoomValue, zoomValue);

            UpdateBackground();
            OnUpdated?.Invoke();
            _contentContainer.MarkDirtyRepaint();
            MarkDirtyRepaint();
        }
示例#18
0
        private void UserStatsReceived(UserStatsReceived_t stats, bool isError)
        {
            if (isError)
            {
                return;
            }

            Refresh();

            OnUpdated?.Invoke();
        }
        private void UserStatsStored(UserStatsStored_t stats)
        {
            if (stats.GameID != client.AppId)
            {
                return;
            }

            Refresh();

            OnUpdated?.Invoke();
        }
示例#20
0
 public void UpdateExistingMeshAtIndex(Mesh mesh, uint meshFilterIndex = 0)
 {
     if (meshFilters != null && meshFilters.Length > meshFilterIndex)
     {
         meshFilters[meshFilterIndex].sharedMesh = mesh;
         OnUpdated?.Invoke();
     }
     else
     {
         Debug.LogError($"MeshFilter index {meshFilterIndex} out of bounds - MeshesInfo.UpdateExistingMesh failed");
     }
 }
示例#21
0
            public void UpdateRenderersCollection()
            {
                if (meshRootGameObjectValue != null)
                {
                    renderers   = meshRootGameObjectValue.GetComponentsInChildren <Renderer>(true);
                    meshFilters = meshRootGameObjectValue.GetComponentsInChildren <MeshFilter>(true);

                    RecalculateBounds();

                    OnUpdated?.Invoke();
                }
            }
        private void UpdateBones(float deltaTime)
        {
            if (wrapee.IsHandHighConfidence())
            {
                _ready = true;
                if (_wasHighConfidence)
                {
                    UpdateVelocity(_cleanHand, wrapee.Hand, deltaTime);
                }
                else
                {
                    ResetVelocity();
                    _startHighConfidenceTime = Time.timeSinceLevelLoad;
                }

                if (_startHighConfidenceTime.HasValue &&
                    Time.timeSinceLevelLoad - _startHighConfidenceTime.Value < CATCH_UP_TIME)
                {
                    float t = Mathf.Clamp01((Time.timeSinceLevelLoad - _startHighConfidenceTime.Value) / CATCH_UP_TIME);
                    _cleanHand = BonePose.Lerp(_cleanHand, wrapee.Hand, t).Value;
                }
                else
                {
                    _startHighConfidenceTime = null;
                    _cleanHand = wrapee.Hand;
                }

                _wasHighConfidence = true;
            }
            else if (_ready)
            {
                _cleanHand = ApplyVelocity(_handVelocity, _cleanHand, deltaTime);
                DampVelocity(deltaTime);
                _wasHighConfidence = false;
            }
            else
            {
                _cleanHand.rotation = wrapee.Hand.rotation;
                _cleanHand.position = wrapee.Hand.position;
            }

            for (int i = 0; i < wrapee.Fingers.Length; i++)
            {
                BonePose rawBone = wrapee.Fingers[i];
                if (wrapee.IsFingerHighConfidence(rawBone.boneID) ||
                    !_ready)
                {
                    _cleanFingers[i] = rawBone;
                }
            }
            OnUpdated?.Invoke(deltaTime);
        }
示例#23
0
        private void ConsolidateRemotePowershellResult(string machineName, bool result)
        {
            finishedWorksCount++;

            MachineConnectivity connectivity = connectivityResults[machineName];

            lock (connectivity)
            {
                connectivity.CanRemotePowershell = result;
            }

            OnUpdated?.Invoke(this, new MachineConnectivityEventArgs(connectivity));
        }
示例#24
0
 public void Update(TCloudItem item)
 {
     lock (_items)
     {
         CreateTraces(new[] { item });
         if (!_items.ContainsKey(item.Id))
         {
             return;
         }
         _items[item.Id] = item;
         OnUpdated?.Invoke(this, new UpdatedEventArgs <TCloudItem>(new[] { item }));
     }
 }
示例#25
0
        //======================================================================
        // Begin updating RWC
        //======================================================================
        private async void BtnUpdate_Click(object sender, EventArgs e)
        {
            Logger.Instance.LogMessageToFile("Updating Reddit Wallpaper Changer.", LogLevel.Information);

            btnUpdate.Enabled   = false;
            progressBar.Visible = true;

            try
            {
                using (var wc = HelperMethods.CreateWebClient())
                {
                    wc.DownloadProgressChanged += (s, a) =>
                    {
                        progressBar.Value = a.ProgressPercentage;
                    };

                    var temp = Path.GetTempPath();

                    var updateSourceUrl = new Uri("https://github.com/qwertydog/Reddit-Wallpaper-Changer/releases/download/release/Reddit.Wallpaper.Changer.msi");

                    var securityVersion = ServicePointManager.SecurityProtocol;
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                    // Download the latest MSI instaler to the users Temp folder
                    await wc.DownloadFileTaskAsync(updateSourceUrl, temp + "Reddit.Wallpaper.Changer.msi");

                    ServicePointManager.SecurityProtocol = securityVersion;

                    Logger.Instance.LogMessageToFile("Update successfully downloaded.", LogLevel.Information);

                    progressBar.Visible = false;

                    try
                    {
                        Logger.Instance.LogMessageToFile("Launching installer and exiting.", LogLevel.Information);

                        Process.Start(temp + "Reddit.Wallpaper.Changer.msi").Dispose();

                        OnUpdated?.Invoke(this, EventArgs.Empty);
                    }
                    catch (Exception ex)
                    {
                        HandleUpdateError(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                HandleUpdateError(ex);
            }
        }
示例#26
0
        /////////////////////////////////////////////////////////////////////
        // UPDATING
        /////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Updates a server description from an announce packet.
        /// Must be from the same sender (GUID, address and listen port must match).
        /// Not all aspects of the server can be changed; some properties are fixed for the session
        /// (e.g. file path, temporary). If differences are detected in these properies, an exception will be thrown.
        /// Does not update Ping, that is updated separately.
        /// </summary>
        /// <param name="listenEndpoint">Endpoint of the sender (listen server, NOT the announce source)</param>
        /// <param name="packet">Packet that was sent</param>
        /// <exception cref="ArgumentException" />
        /// <exception cref="ArgumentNullException" />
        internal void Update(IPEndPoint listenEndpoint, ServerDescription packet)
        {
            if (packet == null)
            {
                throw new ArgumentNullException("packet", "packet cannot be null");
            }
            if (listenEndpoint == null)
            {
                throw new ArgumentNullException("listenEndpoint", "sender cannot be null");
            }
            if (!packet.ID.Equals(id))
            {
                throw new ArgumentException("packet ID did not match", "packet");
            }
            if (packet.Port != port)
            {
                throw new ArgumentException("packet port did not match", "packet");
            }
            if (!listenEndpoint.Equals(endPoint))
            {
                throw new ArgumentException("listenEndpoint port did not match", "listenEndpoint");
            }
            if (temporaryDocument != packet.temporaryDocument)
            {
                throw new ArgumentException("temporaryDocument did not match", "temporaryDocument");
            }

            bool changed = false;

            if (changed = (packet.ClientCount != clientCount))
            {
                clientCount = packet.ClientCount;
            }
            if (changed = (packet.MaxClients != maxClients))
            {
                maxClients = packet.MaxClients;
            }
            if (changed = (packet.RequiresPassword != requiresPassword))
            {
                requiresPassword = packet.RequiresPassword;
            }
            if (changed = (!name.Equals(packet.Name)))
            {
                name = packet.Name ?? "";
            }
            lastUpdateTimer.Reset();
            if (changed)
            {
                OnUpdated?.Invoke(this);
            }
        }
示例#27
0
        /// <summary>
        /// Attempts to delete the value with the given id.
        /// </summary>
        public bool Delete(StringHash32 inId)
        {
            int idx = IndexOf(inId);

            if (idx >= 0)
            {
                m_Values.FastRemoveAt(idx);
                OnUpdated?.Invoke(new NamedVariant(inId, null));
                m_Optimized = false;
                return(true);
            }

            return(false);
        }
        private void UserStatsReceived(UserStatsReceived_t stats, bool isError)
        {
            if (isError)
            {
                return;
            }
            if (stats.GameID != client.AppId)
            {
                return;
            }

            Refresh();

            OnUpdated?.Invoke();
        }
        private void OnMouseMove(MouseMoveEvent evt)
        {
            if (!_active || !target.HasMouseCapture())
            {
                return;
            }

            Vector2 delta = target.ChangeCoordinatesTo(_moveTarget, evt.localMousePosition) - StartPosition;

            _moveTarget.style.top  = _moveTarget.layout.yMin + delta.y;
            _moveTarget.style.left = _moveTarget.layout.xMin + delta.x;

            OnUpdated?.Invoke(delta);
            evt.StopPropagation();
        }
        private static void OnOperationStateChanged(int id)
        {
            if (!s_Initialized)
            {
                return;
            }

            ProgressItem item = GetProgressById(id);

            Assert.IsNotNull(item);

            s_ProgressDirty = true;
            item.Dirty();

            OnUpdated?.Invoke(new[] { item });
        }