/** * Copyright 2011 OpenDDR LLC * This software is distributed under the terms of the GNU Lesser General Public License. * * * This file is part of OpenDDR Simple APIs. * OpenDDR Simple APIs is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * OpenDDR Simple APIs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Simple APIs. If not, see . * */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Oddr.Models { /// /// Superclass of identified model object. /// public class BuiltObject { /// /// Confidence of identified model object. /// public int confidence { set; get; } /// /// Dictionary of properties of identified model object. /// public Dictionary properties { protected set; get; } public BuiltObject() { this.properties = new Dictionary(); this.confidence = 0; } public BuiltObject(int confidence, Dictionary properties) { this.confidence = confidence; this.properties = properties; } public BuiltObject(Dictionary properties) { this.confidence = 0; this.properties = properties; } /// /// Retrieve a property from properties dictionary. /// /// The name of requested properties. /// Return the value of requested property. public String Get(String property) { if (properties.ContainsKey(property)) { return properties[property]; } return null; } /// /// Add a property to properties dictionary. /// /// The name of the property. /// The value of the property. public void PutProperty(String name, String value) { this.properties[name] = value; } public void PutPropertiesMap(Dictionary properties) { foreach (KeyValuePair kvp in properties) { this.properties[kvp.Key] = kvp.Value; } } } }