Beispiel #1
0
        public Buildings()
        {
            InitializeComponent();

            add.Click += (o, e) => {
                lock (PropertyManager) Property = PropertyManager.Create();
            };
        }
Beispiel #2
0
        public static IPropertyState <T> RegisterOption <T>(OptionCategory category, string name, T defaultValue)
        {
            if (!Enum.IsDefined(typeof(OptionCategory), category))
            {
                throw new ArgumentException("Invalid category.");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Option registration is empty.", "name");
            }

            if (name.IndexOfAny(new[] { '.', '\\', ' ', ':' }) > 0)
            {
                throw new ArgumentException("Option registration contains invalid characters.", "name");
            }

            string categoryName = Enum.GetName(typeof(OptionCategory), category);
            string optionName   = String.Format("{0}.{1}", categoryName, name);

            IPropertyState <T> state = null;
            var propertyName         = PropertyManager.CreatePropertyName(optionName);

            if (c_registeredProperties.ContainsKey(propertyName))
            {
                state = c_registeredProperties[propertyName] as IPropertyState <T>;
                if (state == null)
                {
                    throw new Exception("Duplicate option registration with a different type for {0}.");
                }

                WriteLine("Duplicate option registration: ", propertyName);
            }
            else
            {
                state = PropertyManager.Create(propertyName, defaultValue);
                c_registeredProperties.Add(propertyName, state);
                c_registeredPropertiesList.Add(state);
            }

            return(state);
        }
Beispiel #3
0
        public static void Read(string filepath, PropertyManager properties, ReferenceTable references, IdTable ids)
        {
            var xml = new XPathDocument(filepath).CreateNavigator();
            var pi  = xml.Select("/Properties/Property");

            while (pi.MoveNext())
            {
                var pnode = pi.Current;
                var p     = properties.Create();
                ids[p] = new Guid(pnode.GetAttribute("id", ""));
                AssignProperties(pnode, p, references);
                var fi = pnode.Select("Flats/Flat");
                while (fi.MoveNext())
                {
                    var fnode = fi.Current;
                    var f     = p.CreateFlat();
                    ids[f] = new Guid(fnode.GetAttribute("id", ""));
                    AssignProperties(fnode, f, references);
                }
            }
        }
Beispiel #4
0
		public static void Read(string filepath, PropertyManager properties, ReferenceTable references, IdTable ids) {
			var xml = new XPathDocument(filepath).CreateNavigator();
			var pi = xml.Select("/Properties/Property");
			while ( pi.MoveNext() ) {
				var pnode = pi.Current;
				var p = properties.Create();
				ids[p] = new Guid(pnode.GetAttribute("id", ""));
				AssignProperties(pnode, p, references);
				var fi = pnode.Select("Flats/Flat");
				while ( fi.MoveNext() ) {
					var fnode = fi.Current;
					var f = p.CreateFlat();
					ids[f] = new Guid(fnode.GetAttribute("id", ""));
					AssignProperties(fnode, f, references);
				}
			}
		}