示例#1
0
        public void DeserializeInventoryFromXmlString()
        {
            NetReflectorTypeTable t = new NetReflectorTypeTable();

            t.Add(typeof(Field));
            t.Add(typeof(ViewTemplate));

            ViewTemplate f = new ViewTemplate();

            f.LoadFromString(TestResources.viewTemplate);
            CheckInventoryMatchesDefinitionInResource(f);
        }
示例#2
0
/*
		private List<Parameter> GetParameters(XPathNavigator component)
		{
			List<Parameter> parameters = new List<Parameter>();

			if (component.HasChildren)
			{
				XPathNodeIterator children = component.SelectChildren(string.Empty, string.Empty);
				foreach (XPathNavigator child in children)
				{
					if (child.GetAttribute("UseInConstructor", string.Empty) == "false")
						continue;
					parameters.Add(GetSimpleParameter(child));
				}
			}
			return parameters;
		}

		private Parameter GetSimpleParameter(XPathNavigator child)
		{

			switch (child.GetAttribute("class", string.Empty))
			{
				case "":
					return new NamedParameter(child.Name, child.Value);
					break;
				case "string":
					return new NamedParameter(child.Name, child.Value);
					break;
				case "bool":
					return new NamedParameter(child.Name, child.ValueAsBoolean);
					break;
				case "DateTime":
					return new NamedParameter(child.Name, child.ValueAsDateTime);
					break;
				case "double":
					return new NamedParameter(child.Name, child.ValueAsDouble);
					break;
				case "int":
					return new NamedParameter(child.Name, child.ValueAsInt);
					break;
				case "long":
					return new NamedParameter(child.Name, child.ValueAsLong);
					break;
				default:
					throw new ConfigurationException("Didn't understand this type of paramter in the config file: '{0}'", child.GetAttribute("class", string.Empty));
					break;
			}
		}
		*/
		// review: this might belong in a nother file...
		public static IEnumerable<ViewTemplate> CreateViewTemplates(string xmlConfiguration)
		{
			XPathDocument doc = new XPathDocument(new StringReader(xmlConfiguration));

			XPathNavigator navigator = doc.CreateNavigator();
			navigator = navigator.SelectSingleNode("//components");
			if (navigator != null)
			{
				bool hasviewTemplate = false;
				XPathNodeIterator componentList = navigator.SelectChildren(string.Empty,
																		   string.Empty);
				foreach (XPathNavigator component in componentList)
				{
					Debug.Assert(component.Name == "viewTemplate");
					hasviewTemplate = true;
					ViewTemplate template = new ViewTemplate();
					template.LoadFromString(component.OuterXml);

					yield return template;
				}
				Debug.Assert(hasviewTemplate,
							 "Currently, there must be at least 1 viewTemplate in the WeSayConfig file");
			}
		}
		public void DeserializeInventoryFromXmlString()
		{
			NetReflectorTypeTable t = new NetReflectorTypeTable();
			t.Add(typeof (Field));
			t.Add(typeof (ViewTemplate));

			ViewTemplate f = new ViewTemplate();
			f.LoadFromString(TestResources.viewTemplate);
			CheckInventoryMatchesDefinitionInResource(f);
		}