//TODO: This should probably be called "Add" as it seems to // update/add to the model rather than replace all the entries. public DataModel <CT, DT> Set(Dictionary <string, CT> data, bool silent) { string changedProp; // Setup temporary copy of attributes to be assigned // to the previousAttributes register if a change occurs Dictionary <string, CT> prev = Clone(this.attributes); // Reset the internal register attributes = new Dictionary <string, CT> (); foreach (string propKey in data.Keys) { this.attributes [propKey] = data[propKey]; if (!prev.ContainsKey(propKey) || (!Comparer <CT> .Equals(prev[propKey], data[propKey]))) { this.hasChanged = true; changedProp = propKey; RoarManager.OnComponentAttributeChange(this.name, changedProp); } } if (hasChanged) { if (!silent) { RoarManager.OnComponentChange(this.name); } } // Broadcasts a `change` event if the model changed if (HasChanged && !silent) { this.previousAttributes = prev; this.Change(); } return(this); }