public void _AppSettings_SettingChanging(object sender, PropertyChangedEventArgs e) { if (!_saving) { try { var newSetting = PropertyDictionary <string, object> .Convert(sender); object newVal = newSetting[e.PropertyName]; if (newVal != null) { if (!newVal.Equals(OldSettings[e.PropertyName])) { try { if (!_changedSettings.ContainsKey(e.PropertyName)) { AppSettings[e.PropertyName] = newVal; _changedSettings.Add(e.PropertyName, newVal); } } catch { AppSettings[e.PropertyName] = newVal; _changedSettings.Add(e.PropertyName, newVal); } } else { try { _changedSettings.Remove(e.PropertyName); } catch { } } if (!_applyAlwaysEnabled) { ApplyBtn.Enabled = _changedSettings.Count > 0; } } } catch { } } }
protected virtual PropertyDictionary ReadProperties(XElement element) { PropertyDictionary properties = new PropertyDictionary(); var propertiesElement = element.Element("properties"); if (propertiesElement != null) { var props = from prop in propertiesElement.Elements("property") let typeValue = (string)prop.Attribute("type") select new Property { Name = (string)prop.Attribute("name"), Type = ParseEnum <PropertyType>(typeValue), RawValue = (string)prop.Attribute("value"), }; foreach (var prop in props) { properties.Add(prop.Name, prop); } } return(options.GetCollectionOrDefault(properties)); }
public void SetVariable(string name, string value) { PropertyDictionary properties = Project.Properties; if (properties.Contains(name)) { properties[name] = value; } else { properties.Add(name, value); } }
public static void SetInt(PropertyDictionary instance, string key, int value) { Ensure.ArgumentIsNotNull(instance, "instance"); Ensure.ArgumentIsNotNullOrEmptyString(key, "key"); string valueToSet = value.ToString(CultureInfo.InvariantCulture); if (instance.Contains(key)) { instance[key] = valueToSet; } else { instance.Add(key, valueToSet); } }
private static void SetUpProperties(ArrayList attributeList, Task task, XmlNode xml, PropertyDictionary oldPropertyValues) { var projectProperties = task.Project.Properties; var logMessage = new StringBuilder(); foreach (MacroAttribute macroAttribute in attributeList) { var attributeName = macroAttribute.AttributeName; var xmlAttribute = xml.Attributes[attributeName]; string value = null; if (xmlAttribute != null) { value = projectProperties.ExpandProperties(xmlAttribute.Value, null); } else if (macroAttribute.DefaultValue != null) { value = macroAttribute.DefaultValue; } var localPropertyName = macroAttribute.LocalPropertyName; task.Log(Level.Debug, "Setting property {0} to {1}", localPropertyName, value); if (logMessage.Length > 0) { logMessage.Append(", "); } logMessage.AppendFormat("{0} = '{1}'", localPropertyName, value); if (projectProperties.Contains(localPropertyName)) { oldPropertyValues.Add(localPropertyName, projectProperties[localPropertyName]); projectProperties.Remove(localPropertyName); } if (value != null) { projectProperties.Add(localPropertyName, value); } } task.Log(Level.Info, logMessage.ToString()); }
private static void RestoreProperties(ArrayList attributeList, Task task, PropertyDictionary oldValues) { PropertyDictionary projectProperties = task.Project.Properties; foreach (MacroAttribute macroAttribute in attributeList) { string localPropertyName = macroAttribute.LocalPropertyName; string oldValue = oldValues[localPropertyName]; if (projectProperties.Contains(localPropertyName)) { projectProperties.Remove(localPropertyName); } if (oldValue != null) { projectProperties.Add(localPropertyName, oldValue); } } }
public string Serialize() { var persistentProperties = new PropertyDictionary(); foreach (var entry in properties) { if ((string)entry.Key == "Initializing") { continue; } if ((string)entry.Key == "Mute") { continue; } if ((string)entry.Key == "Context") { continue; } if ((string)entry.Key == "Id") { continue; } persistentProperties.Add(entry.Key, entry.Value); } SerializedObject so = new SerializedObject(); so.Data = persistentProperties; so.Type = target.GetType().BaseType; return(JSONSerializer.Serialize(so)); }
public void BuildGraph() { PropertyDictionary = new PropertyDictionary(); foreach (var property in Properties) { PropertyDictionary.Add(property.Guid, property); } NodeDictionary = new NodeDictionary(); foreach (var node in Nodes) { NodeDictionary.Add(node.Guid, node); } // Link node lines with actual properties, find previous node and actor node where necessary var propertyNodes = Nodes.Where(node => node.Type == NodeType.PROP).ToDictionary(node => node.Guid, node => node); // convert each conversation line reference from port to property lists using edge list foreach (var node in Nodes) { if (node.Type != NodeType.SELF && node.Type != NodeType.NPC) { continue; } foreach (var line in node.Lines) { line.Checks = new List <string>(); line.Triggers = new List <string>(); string setNext = null; foreach (var edge in Edges) { // Find triggers if (line.TriggerPort == edge.FromPort) { var nodeGuid = edge.ToNode; line.Triggers.Add(propertyNodes[nodeGuid].Temp_PropertyNodeGuid); } // Find checks, only for NPC nodes if (node.Type == NodeType.NPC && line.CheckPort == edge.ToPort && NodeDictionary[edge.FromNode].Type == NodeType.PROP) { var nodeGuid = edge.FromNode; line.Checks.Add(propertyNodes[nodeGuid].Temp_PropertyNodeGuid); } // Find next node if (edge.FromNode == node.Guid && line.Next == edge.FromPort) { setNext = edge.ToNode; } } line.Next = setNext; } foreach (var edge in Edges) { // Find actor node if (edge.ToNode == node.Guid && node.Type == NodeType.NPC && propertyNodes.ContainsKey(edge.FromNode) && PropertyDictionary[propertyNodes[edge.FromNode].Temp_PropertyNodeGuid].Type == PropertyType.Actor) { node.ActorGuid = propertyNodes[edge.FromNode].Temp_PropertyNodeGuid; } // Find previous node if (edge.ToNode == node.Guid && (NodeDictionary[edge.FromNode].Type == NodeType.NPC || NodeDictionary[edge.FromNode].Type == NodeType.SELF)) { node.Previous = edge.FromNode; } } } // Remove property nodes from Nodes and NodeDictionary var copyOfNodes = Nodes.ToList(); copyOfNodes.ForEach(node => { if (node.Type == NodeType.NPC || node.Type == NodeType.SELF) { return; } NodeDictionary.Remove(node.Guid); Nodes.Remove(node); }); // Find start node foreach (var node in Nodes) { if (!string.IsNullOrEmpty(node.Previous)) { continue; } if (!string.IsNullOrEmpty(StartNode) && StartNode != node.Guid) { Debug.LogWarning("Multiple nodes without a previous node detected! Defaulting to the first one found to be the start node."); continue; } StartNode = node.Guid; } }
public void TestAdd_ICollection_ThrowsException() { ICollection <KeyValuePair <string, object> > collection = new PropertyDictionary(new object()); collection.Add(new KeyValuePair <string, object>("Name", "Bob")); }
public void TestAdd_IDictionary_ThrowsException() { IDictionary <string, object> dictionary = new PropertyDictionary(new object()); dictionary.Add("Name", "Bob"); }
public string Serialize() { var persistentProperties = new PropertyDictionary(); foreach (var entry in properties) { if ((string)entry.Key == "Initializing") continue; if ((string)entry.Key == "Mute") continue; if ((string)entry.Key == "Context") continue; if ((string)entry.Key == "Id") continue; persistentProperties.Add(entry.Key, entry.Value); } SerializedObject so = new SerializedObject(); so.Data = persistentProperties; so.Type = target.GetType().BaseType; return JSONSerializer.Serialize (so) ; }