public static bool parseFromFile(Entity entity, XmlReader reader) { // Fill info into provided entity string tag; int id, x, y; try { id = int.Parse(reader.GetAttribute("id")); x = int.Parse(reader.GetAttribute("x")); y = int.Parse(reader.GetAttribute("y")); tag = reader.GetAttribute("tag"); } catch (Exception err) { Console.WriteLine(err.Message); return false; } entity.id = id; entity.tag = tag; entity.x = x; entity.y = y; return true; }
public override void DeserializeNetwork(XmlReader xmlReader) { base.DeserializeNetwork(xmlReader); var expander = ControlElements[0] as SliderExpanderDouble; if (expander == null) return; var attribute = xmlReader.GetAttribute("SliderMax"); if (attribute != null) expander.SliderMax = Convert.ToDouble(attribute.Replace(".", ",")); var attribute1 = xmlReader.GetAttribute("SliderMin"); if (attribute1 != null) expander.SliderMin = Convert.ToDouble(attribute1.Replace(".", ",")); var attribute2 = xmlReader.GetAttribute("SliderValue"); if (attribute2 != null) expander.SliderValue = Convert.ToDouble(attribute2.Replace(".", ",")); var attribute3 = xmlReader.GetAttribute("SliderStep"); if (attribute3 != null) expander.SliderStep = Convert.ToDouble(attribute3.Replace(".", ",")); var attribute4 = xmlReader.GetAttribute("IsExpanded"); if (attribute4 != null) expander.IsExpanded = Convert.ToBoolean(attribute4.Replace(".", ",")); }
public void ReadXml(System.Xml.XmlReader reader) { reader.MoveToElement(); reader.ReadStartElement(); Type instanceType = base.GetType().BaseType; while (reader.IsStartElement()) { if (reader.HasAttributes) { XmlNodeType nodeType = reader.NodeType; Type t = typeof(FileProcessingJournalEntryData <>); t = t.MakeGenericType(Type.GetType(reader.GetAttribute("type"))); string name = reader.GetAttribute("name"); var ser = XmlSerializerCache.GetOrAdd(t, name); object obj = ser.Deserialize(reader.ReadSubtree()); reader.ReadEndElement(); this.EntryData.Add((FileProcessingJournalEntryDataBase)obj); } else { PropertyInfo Prop = instanceType.GetProperty(reader.Name); if (Prop != null) { var h = reader.ReadElementContentAsObject(Prop.Name, ""); Prop.SetValue(this, Convert.ChangeType(h, Prop.PropertyType), null); } } } }
internal static ApplicationManifestTaskNodeBase ParseXml(XmlReader reader) { switch (reader.Name) { case "DefaultTask": var node = new ApplicationManifestDefaultTaskNode() { Name = reader.GetAttribute("Name"), NavigationPage = reader.GetAttribute("NavigationPage") }; reader.Skip(); return node; case "ExtendedTask": var node2 = new ApplicationManifestExtendedTaskNode { Name = reader.GetAttribute("Name"), BackgroundServiceAgents = reader.ReadElementContentAsArray(ApplicationManifestBackgroundServiceAgentNode.ParseXml) }; return node2; default: reader.Skip(); return null; } }
private World <bool> LoadWorld(System.Xml.XmlReader reader) { // Write Map Root reader.ReadToDescendant("map"); if (reader.Name != "map") { throw new ApplicationException("no map found."); } // Load Dimensions var width = int.Parse(reader.GetAttribute("width")); var height = int.Parse(reader.GetAttribute("height")); var world = new World <bool>(width, height, true); reader.Read(); while (reader.Name == "cell") { var x = int.Parse(reader.GetAttribute("x")); var y = int.Parse(reader.GetAttribute("y")); var v = bool.Parse(reader.GetAttribute("v")); world[x, y] = v; reader.Read(); } reader.Read(); return(world); }
/// <summary> /// Since our conditions implement a behavior (interface) and not a state (base class), serialization must be done /// manually. /// </summary> public void ReadXml(XmlReader reader) { var name = reader.GetAttribute("Name"); var entry = reader.GetAttribute("Entry"); var myState = reader.GetAttribute("MyState"); var enabled = reader.GetAttribute("Enabled"); reader.Read(); Name = name; int outEntry; if (!int.TryParse(entry, out outEntry)) { Log.Gui( string.Format( "WARNING: Unable to load item \"{0}\" because the entry id is missing. This is due to having an older version of the Paws-Items.xml settings file. Please either delete the Paws-Items.xml file under your settings folder, or re-add items using the Items tab in the Paws user interface.", name)); return; } Entry = outEntry; MyState outMyState; Enum.TryParse(myState, out outMyState); MyState = outMyState; Enabled = bool.Parse(enabled); var serializer = new XmlSerializer(Conditions.GetType()); Conditions = (List<ItemCondition>) serializer.Deserialize(reader); reader.ReadEndElement(); }
private void ExtractDefinitions(XmlReader reader, ResultFile trx) { if (reader.ReadToFollowing("TestDefinitions")) { if (reader.ReadToDescendant("UnitTest")) { do { var testId = Guid.Parse(reader.GetAttribute("id")); var tempResult = trx.Results.First(result => result.TestId == testId); tempResult.Storage = reader.GetAttribute("storage"); if (reader.ReadToFollowing("TestMethod")) { tempResult.CodeBase = reader.GetAttribute("codeBase"); tempResult.AdapterTypeName = reader.GetAttribute("adapterTypeName"); tempResult.ClassName = reader.GetAttribute("className"); } reader.ReadToNextSibling("UnitTest"); } while (reader.ReadToNextSibling("UnitTest")); } } }
public static Dictionary<int, string> readCommandsFromConfig(string configurationFileName) { Dictionary<int, string> portCommandDictionary = new Dictionary<int, string>(); string defaultDirectoryPath = Directory.GetCurrentDirectory(); DirectoryInfo di = new DirectoryInfo((((new DirectoryInfo(defaultDirectoryPath).Parent).Parent).Parent).FullName + "\\Configs"); configurationFilePath = setupDirectoryPath(di.ToString(), configurationFileName); using ( configReader = XmlReader.Create(configurationFilePath)) try { while (configReader.Read()) { if ((configReader.NodeType == XmlNodeType.Element) && (configReader.Name == "port")) { if (configReader.HasAttributes) { portCommandDictionary.Add(int.Parse(configReader.GetAttribute("value")), configReader.GetAttribute("command")); } } } return portCommandDictionary; } catch (Exception e) { return null; } }
void createPlayer(XmlReader reader) { Vector2 pos = Vector2.Zero; TextureMap t = new TextureMap(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "position": { reader.ReadToDescendant("x"); float x = (float)float.Parse((reader.GetAttribute(0))); reader.ReadToNextSibling("y"); float y = (float)float.Parse((reader.GetAttribute(0))); pos = new Vector2(x, y); } break; default: int o = 0;//fer teh deboog break; } } } Player p = new Player(pos, t); }
/// <summary> /// Creates this TestData /// </summary> /// <param name="reader">XML reader pointing to the element containing the test description</param> /// <param name="testFileDir">The directory that the test lives in</param> public TestData(XmlReader reader, string testFileDir) { string nameStr = reader.GetAttribute("name"); string descriptionStr = reader.GetAttribute("description"); string enforceStr = reader.GetAttribute("enforce"); string iterationsStr = reader.GetAttribute("iterations"); string requestPathStr = reader.GetAttribute("requestPath"); if (string.IsNullOrEmpty(nameStr)) { throw new InvalidOperationException("Test did not contain name (\"name\" attribute)"); } if (string.IsNullOrEmpty(descriptionStr)) { throw new InvalidOperationException("Test did not contain description (\"description\" attribute)"); } if (string.IsNullOrEmpty(requestPathStr)) { throw new InvalidOperationException("Test did not contain a request file path (\"requestPath\" attribute)"); } m_Name = nameStr; m_Description = descriptionStr; m_Enforce = string.IsNullOrEmpty(enforceStr) ? false : bool.Parse(enforceStr); m_Iterations = string.IsNullOrEmpty(iterationsStr) ? 1 : int.Parse(iterationsStr); m_RequestPath = Path.Combine(testFileDir, requestPathStr); if (m_Iterations <= 0) { throw new InvalidOperationException(string.Format("Must have 1 or more iterations specified in test \"{0}\"", m_Name)); } }
/// <summary> /// Setup constructor /// </summary> /// <param name="parameters">Load parameters</param> /// <param name="errors">Error collection</param> /// <param name="reader">XML reader positioned at the element that created this builder</param> /// <param name="parentBuilder">Parent builder</param> public TypeBuilder( ComponentLoadParameters parameters, ErrorCollection errors, XmlReader reader, BaseBuilder parentBuilder ) : base(parameters, errors, reader, parentBuilder) { // Retrieve type name and optional assembly name from the element string typeName = reader.GetAttribute( "value" ); string assemblyName = reader.GetAttribute( "assembly" ); if ( typeName == null ) { throw new ApplicationException( string.Format( "Element \"{0}\" requires a \"type\" attribute", reader.Name ) ); } Type objectType = null; if ( assemblyName == null ) { // Get the object type from the currently loaded set of assemblies objectType = AppDomainUtils.FindType( typeName ); if ( objectType == null ) { throw new ApplicationException( string.Format( "Failed to find type \"{0}\" in app domain" , typeName ) ); } } else { // Get the object type from the specified assembly Assembly assembly = AppDomain.CurrentDomain.Load( assemblyName ); objectType = assembly.GetType( typeName ); if ( objectType == null ) { throw new ApplicationException( string.Format( "Failed to find type \"{0}\" in assembly \"{1}\"", typeName, assemblyName ) ); } } BuildObject = objectType; }
public MappingOption(XmlReader xml) { Schema = xml.GetAttribute("Schema"); Prefix = xml.GetAttribute("Prefix"); Class = xml.GetAttribute("Class"); Pattern = xml.GetAttribute("Pattern"); }
/// <summary> /// Obtains the type and value of a parameter from an XML Error file. /// </summary> /// <param name="reader">XML Error file.</param> /// <param name="parameter">Parameter to obtain.</param> /// <returns>Parameter.</returns> public static Parameter Deserialize(XmlReader reader, Parameter parameter) { if (reader.IsStartElement(DTD.Error.ErrorParams.TagErrorParam)) { if (parameter == null) { parameter = new Parameter(); } // Read Attributes of Node. parameter.Key = reader.GetAttribute(DTD.Error.ErrorParams.TagKey); switch (reader.GetAttribute(DTD.Error.ErrorParams.TagType)) { case ResponseException.ErrorKey: parameter.Type = ErrorParamType.Key; break; case ResponseException.ErrorLiteral: parameter.Type = ErrorParamType.Literal; break; } if (!reader.IsEmptyElement) { parameter.Text = reader.ReadString(); } else { reader.Skip(); } } return parameter; }
private void expandNamespace_function(TreeNodeCollection outNodes, string strSection, string strNamespace, XmlReader reader) { bool bContinue = reader.ReadToDescendant("function"); while (bContinue) { NodeDocPythonFunction node = newnode(strSection, strNamespace, reader.GetAttribute("name")); outNodes.Add(node); bool bInstance = reader.GetAttribute("instance") == "true"; node.bIsInstanceMethod = bInstance; string strSyntax = reader.GetAttribute("fullsyntax"); if (strSyntax != null && strSyntax != "") node.strFullSyntax = strSyntax; node.strDocumentation = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example if (this.emphasizeStaticness()) { if (!bInstance) { //change visible node text to emphasize static-ness node.Text = node.strNamespacename + "." + node.strFunctionname; } } bContinue = ReadToNextSibling(reader, "function"); } reader.Close(); }
internal static ItemSecurity FromXml(Repository repository, XmlReader reader) { ItemSecurity itemSecurity = new ItemSecurity(); string elementName = reader.Name; itemSecurity.serverItem = reader.GetAttribute("item"); itemSecurity.writable = Convert.ToBoolean(reader.GetAttribute("writable")); List<AccessEntry> entries = new List<AccessEntry>(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement && reader.Name == elementName) break; if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "AccessEntry": entries.Add(AccessEntry.FromXml(repository, reader)); break; } } } itemSecurity.entries = entries.ToArray(); return itemSecurity; }
public void ReadFromXml(XmlReader reader) { reader.MoveToContent(); type = reader.GetAttribute("type"); code = reader.GetAttribute("code"); location = reader.GetAttribute("location"); string time = reader.GetAttribute("time"); if (time.Length == 5) { hours = int.Parse(time.Substring(0, 2)); minutes = int.Parse(time.Substring(3, 2)); } else if (time.Length == 4) { hours = int.Parse(time.Substring(0, 1)); minutes = int.Parse(time.Substring(2, 2)); } string weekStr; if ((weekStr = reader.GetAttribute("week")) != null) week = int.Parse(weekStr); else week = 0; if ((group = reader.GetAttribute("group")) == null) group = ""; reader.Skip(); }
void IFlickrParsable.Load(XmlReader reader) { this.FavoriteThumbnailUrl = reader.GetAttribute("thumb"); this.FavoriteUrl = reader.GetAttribute("url"); this.Load(reader, true); reader.Skip(); }
public static bool parseFromFile(Door entity, XmlReader reader) { // Fill info into provided entity int x, y; string orientation; try { x = int.Parse(reader.GetAttribute("x")); y = int.Parse(reader.GetAttribute("y")); orientation = reader.GetAttribute("orientation"); } catch (Exception err) { Console.WriteLine(err.Message); return false; } entity.x = x; entity.y = y; if (orientation == "Front") entity.orientation = Orientation.Front; else entity.orientation = Orientation.Side; return true; }
public ExamQuestion(XmlReader reader) : this() { QuestionIdentifier = reader.GetAttribute("identifier"); Question = reader.GetAttribute("question"); Image = reader.GetAttribute("image"); while (!reader.EOF) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "Answer") Answer = reader.ReadElementContentAsString(); else if (reader.Name == "Distractor") Distractors.Add(reader.ReadElementContentAsString()); else reader.Read(); break; case XmlNodeType.EndElement: return; default: reader.Read(); break; } } }
/// <summary> /// Reads the error data in XML attributes. /// </summary> private static void ReadXmlAttributes(XmlReader reader, Error error) { if (reader == null) { throw new ArgumentNullException("reader"); } if (!reader.IsStartElement()) { throw new ArgumentException("Reader is not positioned at the start of an element.", "reader"); } error.ApplicationName = reader.GetAttribute("application"); error.HostName = reader.GetAttribute("host"); error.Type = reader.GetAttribute("type"); error.Message = reader.GetAttribute("message"); error.Source = reader.GetAttribute("source"); error.Detail = reader.GetAttribute("detail"); error.User = reader.GetAttribute("user"); string timeString = Mask.NullString(reader.GetAttribute("time")); error.Time = timeString.Length == 0 ? new DateTime() : XmlConvert.ToDateTime(timeString); string statusCodeString = Mask.NullString(reader.GetAttribute("statusCode")); error.StatusCode = statusCodeString.Length == 0 ? 0 : XmlConvert.ToInt32(statusCodeString); error.WebHostHtmlMessage = reader.GetAttribute("webHostHtmlMessage"); }
private void ReadState(ref XmlReadState state, System.Xml.XmlReader node) { node.Read(); var shader = node.GetAttribute("shader"); var dicing_rate = node.GetAttribute("dicing_rate"); var interpolation = node.GetAttribute("interpolation"); var displacement_method = node.GetAttribute("displacement_method"); if (!string.IsNullOrEmpty(shader)) { state.Shader = state.Scene.ShaderWithName(shader); } if (!string.IsNullOrEmpty(dicing_rate)) { state.DicingRate = float.Parse(dicing_rate, NumberFormatInfo); } if (!string.IsNullOrEmpty(interpolation)) { state.Smooth = interpolation.Equals("smooth", StringComparison.OrdinalIgnoreCase); } bool boolval = false; if (Utilities.Instance.get_bool(ref boolval, node.GetAttribute("is_shadow_catcher"))) { state.IsShadowCatcher = boolval; } if (!string.IsNullOrEmpty(displacement_method)) { /* \todo wrap displacement method stuff */ } }
void IFlickrParsable.Load(XmlReader reader) { while (reader.NodeType != XmlNodeType.EndElement) { switch (reader.LocalName) { case "set": ContextSet set = new ContextSet(); set.PhotosetId = reader.GetAttribute("id"); set.Title = reader.GetAttribute("title"); Sets.Add(set); reader.Read(); break; case "pool": ContextGroup group = new ContextGroup(); group.GroupId = reader.GetAttribute("id"); group.Title = reader.GetAttribute("title"); Groups.Add(group); reader.Read(); break; default: break; } } }
public void ReadXml(XmlReader reader) { Name = reader.GetAttribute("name"); Super = reader.GetAttribute("super"); Version = reader.GetAttribute("version"); reader.ReadStartElement("class"); }
public bool Read(XmlReader reader) { if(reader.IsStartElement() && reader.Name == "Fixture") { Fixture fixture = new Fixture(); //...Any attributes go here... fixture.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip")); fixture.Name = reader.GetAttribute("name"); // This needs to hold off until after channels are loaded. string fixtureDefinitionName = reader.GetAttribute("fixtureDefinitionName"); if(reader.ElementsExistWithin("Fixture")) { // Entity element // Channels if(reader.ElementsExistWithin("Channels")) { // Container element for child entity ChannelReader<OutputChannel> channelReader = new ChannelReader<OutputChannel>(); while(channelReader.Read(reader)) { fixture.InsertChannel(channelReader.Channel); } reader.ReadEndElement(); // Channels } // With channels loaded, the fixture template reference can be set. fixture.FixtureDefinitionName = fixtureDefinitionName; reader.ReadEndElement(); // Fixture this.Fixture = fixture; } return true; } return false; }
public Searchers(XmlReader reader) { this.Choices = new List<Choice>(); this.CurrentSearch = ""; reader.Read(); if (reader.Name != "TheSearchers") return; // bail out reader.Read(); while (!reader.EOF) { if ((reader.Name == "TheSearchers") && !reader.IsStartElement()) break; // all done if (reader.Name == "Current") this.CurrentSearch = reader.ReadElementContentAsString(); else if (reader.Name == "Choice") { string url = reader.GetAttribute("URL"); if (url == null) url = reader.GetAttribute("URL2"); else { // old-style URL, replace "!" with "{ShowName}+{Season}+{Episode}" url = url.Replace("!", "{ShowName}+{Season}+{Episode}"); } this.Add(reader.GetAttribute("Name"), url); reader.ReadElementContentAsString(); } else reader.ReadOuterXml(); } }
private void expandNamespace_function(TreeNodeCollection outNodes, TreeNode outInstanceMethods, string strSection, string strNamespace, XmlReader reader) { bool bContinue = reader.ReadToDescendant("function"); while (bContinue) { // if (reader.GetAttribute("args") != null) MessageBox.Show("instance?"); NodeDocLnzFunction node = new NodeDocLnzFunction(strSection, strNamespace, reader.GetAttribute("name")); bool bInstance = reader.GetAttribute("instance") == "true"; node.bIsInstanceMethod = bInstance; string strArgs = reader.GetAttribute("args"); if (strArgs != null && strArgs != "") node.strArguments = strArgs; string strReturns = reader.GetAttribute("returns"); if (strReturns != null && strReturns != "") node.strReturns = strReturns; node.strDocumentationAndExample = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example if (bInstance) { //MessageBox.Show("instance found"); outInstanceMethods.Nodes.Add(node); } else outNodes.Add(node); bContinue = ReadToNextSibling(reader, "function"); } reader.Close(); }
public static KeyValuePair<string, Property> ReadXml(XmlReader reader) { var key = reader.GetAttribute("Key"); var type = reader.GetAttribute("Type"); reader.MoveToElement(); reader.ReadStartElement("PropertyEntry"); Property value = null; try { var t = Type.GetType(type); value = (Property)GetSerializer(t).Deserialize(reader); } catch (Exception ex) { Console.WriteLine("Deserialization failed: " + ex.Message); Console.WriteLine("Property Key: " + key); Console.WriteLine("Property Type Qualified Name: " + type); Console.WriteLine("Stacktrace: " + ex.StackTrace); } reader.ReadEndElement(); reader.MoveToContent(); if (value == null) throw new Exception(); return new KeyValuePair<string, Property>(key, value); }
public override void ReadXml(XmlReader reader) { reader.MoveToContent(); CRS = reader.GetAttribute("CRS"); double val; if (double.TryParse(reader.GetAttribute("minx"), NumberStyles.Any, NumberFormatInfo.InvariantInfo, out val)) MinX = val; if (double.TryParse(reader.GetAttribute("maxx"), NumberStyles.Any, NumberFormatInfo.InvariantInfo, out val)) MaxX = val; if (double.TryParse(reader.GetAttribute("miny"), NumberStyles.Any, NumberFormatInfo.InvariantInfo, out val)) MinY = val; if (double.TryParse(reader.GetAttribute("maxy"), NumberStyles.Any, NumberFormatInfo.InvariantInfo, out val)) MaxY = val; var res = reader.GetAttribute("resx"); if (res != null && double.TryParse(res, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out val)) ResX = val; res = reader.GetAttribute("resy"); if (res != null && double.TryParse(res, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out val)) ResY = val; var isEmptyElement = reader.IsEmptyElement; reader.ReadStartElement(); if (!isEmptyElement) { reader.ReadEndElement(); } }
public void ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); Url = reader.GetAttribute("Url"); ServiceName = reader.GetAttribute("ServiceName"); Boolean isEmptyElement = reader.IsEmptyElement; // (1) reader.ReadStartElement(); if (!isEmptyElement) // (1) { HostedServiceProperties = reader.ReadContentAs(typeof(AzureHostedServiceProperties), null) as AzureHostedServiceProperties; reader.ReadEndElement(); } isEmptyElement = reader.IsEmptyElement; // (1) reader.ReadStartElement(); if (!isEmptyElement) // (1) { Deployments = reader.ReadContentAs(typeof(List <AzureDeployment>), null) as List <AzureDeployment>; reader.ReadEndElement(); } }
void IFlickrParsable.Load(XmlReader reader) { while (reader.NodeType != XmlNodeType.EndElement) { switch (reader.LocalName) { case "set": this.Sets.Add(new ContextSet() { PhotosetId = reader.GetAttribute("id"), Title = reader.GetAttribute("title") }); reader.Read(); continue; case "pool": this.Groups.Add(new ContextGroup() { GroupId = reader.GetAttribute("id"), Title = reader.GetAttribute("title") }); reader.Read(); continue; default: continue; } } }
private Link createLink(XmlReader configReader) { List<NetworkNodeSender> senders = new List<NetworkNodeSender>(); List<AbstractAddress> addresses = new List<AbstractAddress>(); while (configReader.Read()) { if (configReader.NodeType == XmlNodeType.Element) { if (configReader.Name.Equals("port")) { int tcpPort = int.Parse(configReader.GetAttribute("tcp")); int localPort = int.Parse(configReader.GetAttribute("local")); string nodeId = configReader.GetAttribute("node"); addresses.Add(new AbstractAddress(localPort, nodeId)); senders.Add(new NetworkNodeSender(tcpPort)); } } } if (senders.Count != 2) { throw new Exception("Error in config file : wrong number of ports in link"); } Dictionary<AbstractAddress, NetworkNodeSender> linkConnections = new Dictionary<AbstractAddress, NetworkNodeSender>(); linkConnections.Add(addresses[0], senders[1]); linkConnections.Add(addresses[1], senders[0]); return new Link(linkConnections); }
/// <summary> /// Creates an instance of the ReadWriteAttributeAssignment using the provided XmlReader. /// </summary> /// <param name="reader">The XmlReader positioned at the AttributeAssignament node.</param> /// <param name="schemaVersion">The version of the schema that was used to validate.</param> public AttributeAssignmentElementReadWrite(XmlReader reader, XacmlVersion schemaVersion) : base(XacmlSchema.Policy, schemaVersion) { if (reader == null) throw new ArgumentNullException("reader"); if (reader.LocalName == Consts.Schema1.ObligationElement.AttributeAssignment && ValidateSchema(reader, schemaVersion)) { if (reader.HasAttributes) { // Load all the attributes while (reader.MoveToNextAttribute()) { if (reader.LocalName == Consts.Schema1.AttributeValueElement.DataType) { _dataType = reader.GetAttribute(Consts.Schema1.AttributeValueElement.DataType); } else if (reader.LocalName == Consts.Schema1.AttributeAssignmentElement.AttributeId) { _attributeId = reader.GetAttribute(Consts.Schema1.AttributeAssignmentElement.AttributeId); } } reader.MoveToElement(); } // Load the node contents _contents = reader.ReadInnerXml(); } else { throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName)); } }
/// <summary> /// Generate object from its XML representation</summary> /// <param name="reader">XmlReader stream from which object is deserialized</param> public void ReadXml(System.Xml.XmlReader reader) { reader.Read(); if (reader.LocalName == this.GetType().Name || reader.LocalName == "MultiContent") // MultiContent is old name and is used here for compatibility with old saved layouts { String selectedUcid = reader.GetAttribute("SelectedUID"); DockContent found = null; reader.ReadStartElement(); if (reader.LocalName == "Content") { do { String ucid = reader.GetAttribute("UCID"); DockContent content = Root.GetContent(ucid); if (content != null) { AddOneItem(null, content); if (selectedUcid == ucid) { found = content; } } } while (reader.ReadToNextSibling("Content")); if (found != null) { SelectedItem = found; } } reader.ReadEndElement(); } }
public void ReadXml(System.Xml.XmlReader reader) { ReadXmlInvoked = true; reader.MoveToContent(); StringValue = reader.GetAttribute("StringValue"); BoolValue = bool.Parse(reader.GetAttribute("BoolValue")); }
protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) { string assembly = reader.GetAttribute("assembly"); string settings = reader.GetAttribute("settings"); config = Activator.CreateInstance(Assembly.Load(assembly).GetType(settings)) as DriverConfig; config.ConfigDeserializeElement(reader, serializeCollectionKey); }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="configuration">The XML reader from which to get the configuration</param> public TypeFilter(XmlReader configuration) { if(configuration.NodeType != XmlNodeType.Element || configuration.Name != "type") throw new InvalidOperationException("The configuration element must be named 'type'"); memberFilters = new List<MemberFilter>(); name = configuration.GetAttribute("name"); exposed = Convert.ToBoolean(configuration.GetAttribute("expose"), CultureInfo.InvariantCulture); // If not exposed, check for a required attribute which forces it to be exposed. This allows a // way to expose it and indicate that it should always be exposed in the configuration file. if(!exposed) { required = Convert.ToBoolean(configuration.GetAttribute("required"), CultureInfo.InvariantCulture); if(required) exposed = true; } XmlReader subtree = configuration.ReadSubtree(); while(subtree.Read()) if(subtree.NodeType == XmlNodeType.Element && subtree.Name == "member") memberFilters.Add(new MemberFilter(subtree)); subtree.Close(); }
/// <summary> /// Since our abilities implement a behavior (interface) and not a state (base class), serialization must be done /// manually. /// </summary> public void ReadXml(XmlReader reader) { var name = reader.GetAttribute("Name"); var specialization = reader.GetAttribute("Specialization"); var hotKey = reader.GetAttribute("Hotkey"); var modifierKey = reader.GetAttribute("Modifier"); reader.Read(); Name = name; WoWSpec outSpec; Enum.TryParse(specialization, out outSpec); Specialization = outSpec; Keys outHotKey; Enum.TryParse(hotKey, out outHotKey); HotKey = outHotKey; ModifierKeys outModifierKey; Enum.TryParse(modifierKey, out outModifierKey); ModiferKey = outModifierKey; var serializer = new XmlSerializer(ChainedAbilities.GetType()); ChainedAbilities = (List<ChainedAbility>) serializer.Deserialize(reader); reader.ReadEndElement(); }
public void ReadXml(System.Xml.XmlReader reader) { bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { CustomProperty cp = new CustomProperty(); cp.name = reader.GetAttribute("Name"); cp.description = reader.GetAttribute("Description"); string type = reader.GetAttribute("Type"); if (type == "string") { cp.type = typeof(string); } if (type == "bool") { cp.type = typeof(bool); } if (type == "Vector2") { cp.type = typeof(Vector2); } if (type == "Color") { cp.type = typeof(Color); } if (type == "Item") { cp.type = typeof(Component); } if (cp.type == typeof(Component)) { cp.value = reader.ReadInnerXml(); this.Add(cp.name, cp); } else { reader.ReadStartElement("Property"); XmlSerializer valueSerializer = new XmlSerializer(cp.type); object obj = valueSerializer.Deserialize(reader); cp.value = Convert.ChangeType(obj, cp.type); this.Add(cp.name, cp); reader.ReadEndElement(); } reader.MoveToContent(); } reader.ReadEndElement(); }
public void ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); Name = reader.GetAttribute("Name"); ColumnGuid = Guid.Parse(reader.GetAttribute("ColumnGuid")); ColumnPid = int.Parse(reader.GetAttribute("ColumnPid")); Width = int.Parse(reader.GetAttribute("Width")); ColumnDisplayIndex = int.Parse(reader.GetAttribute("ColumnDisplayIndex")); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public T ParseAttributes <T>(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) where T : ANY, IQuantity, new() { ANYFormatter baseFormatter = new ANYFormatter(); T retVal = baseFormatter.Parse <T>(s); // attributes if (s.GetAttribute("uncertaintyType") != null) { retVal.UncertaintyType = Util.Convert <QuantityUncertaintyType>(s.GetAttribute("uncertaintyType")); } return(retVal); }
public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { BL retVal = base.Parse <BL>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("value") != null) { retVal.Value = XmlConvert.ToBoolean(s.GetAttribute("value")); } base.Validate(retVal, s.ToString(), result); return(retVal); }
/// <summary> /// Reads Xml when the <see cref="ConsoleForm">ConsoleForm</see> is to be deserialized /// from a stream.</summary> /// <param name="reader">The stream from which the object will be deserialized.</param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { // Read the name of the form. _name = reader.GetAttribute("Name"); // Get the width and height of the form, if they're specified. if (reader.GetAttribute("Width") != null) { _width = Int32.Parse(reader.GetAttribute("Width")); } if (reader.GetAttribute("Height") != null) { _height = Int32.Parse(reader.GetAttribute("Height")); } // Move to the node after the <ConsoleForm> node. reader.Read(); // Expect to see a node of Line objects. if (reader.Name == "Lines") { ((IXmlSerializable)_lines).ReadXml(reader); } else { throw new InvalidOperationException("<Lines> element missing from form definition."); } // Now expect to see a node containing the Label objects. if (reader.Name == "Labels") { ((IXmlSerializable)_labels).ReadXml(reader); } else { throw new InvalidOperationException("<Labels> element missing from form definition."); } // Finally, we expect to see the node containing the Textbox objects. if (reader.Name == "Textboxes") { ((IXmlSerializable)_textboxes).ReadXml(reader); } else { throw new InvalidOperationException("<Textboxes> element missing from form definition."); } }
/// <summary> /// Reads Xml when the <see cref="Point">Point</see> is to be deserialized /// from a stream.</summary> /// <param name="reader">The stream from which the object will be deserialized.</param> void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { string x = reader.GetAttribute("X"); string y = reader.GetAttribute("Y"); if (x.Length > 0) { _x = Int32.Parse(x); } if (y.Length > 0) { _y = Int32.Parse(y); } }
public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer serializer = new XmlSerializer(typeof(string)); if (reader.IsEmptyElement || !reader.Read()) { return; } while (reader.NodeType != XmlNodeType.EndElement) { if (reader.NodeType == XmlNodeType.Comment) { reader.ReadEndElement(); reader.MoveToContent(); continue; } string key = reader.GetAttribute("key"); reader.ReadStartElement("item"); string value = reader.ReadContentAsString(); reader.ReadEndElement(); reader.MoveToContent(); properties.Add(key, value); } reader.ReadEndElement(); }
private static T CreateFromXml <T>(System.Xml.XmlReader reader) where T : IGenericRecord { // reader stays on "record" string recordType = reader.GetAttribute("type"); IGenericRecord record = null; if (recordType == "moduleConfigParamRecord") { record = new MT.pHLab.SE.V1.moduleConfigParamRecord(); record.ReadXml(reader); } if (record is T) { return((T)record); } else { try { return((T)Convert.ChangeType(record, typeof(T))); } catch (InvalidCastException) { return(default(T)); } } }
public Ingestion Deserialize(Stream input) { bool isIngestion = false; using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(input)) { while (reader.Read()) { if (reader.IsStartElement()) { if (!isIngestion) { if (reader.Name != "ingestion") { throw new FormatException("Invalid XML relationship element."); } isIngestion = true; string overwrite = reader.GetAttribute("overwrite"); if (!string.IsNullOrWhiteSpace(overwrite)) { Overwrite = bool.Parse(overwrite); } else { Overwrite = false; } } switch (reader.Name) { case "ingestion": break; case "metadata-sets": DeserializeMetadatasets(reader); break; case "aggregations": DeserializeAggregations(reader); break; case "relationships": DeserializeRelationships(reader); break; case "entity-types": DeserializeEntityTypes(reader); break; default: throw new FormatException("Invalid XML element: " + reader.Name); } } } } return(this); }
private Ingestion DeserializeMetadatasets(System.Xml.XmlReader reader) { while (reader.Read()) { if (reader.IsStartElement()) { if (reader.Name == "metadata-set") { string strGuid = reader.GetAttribute("guid"); CFMetadataSet set = new CFMetadataSet(); set.Content = reader.ReadOuterXml(); set.Guid = strGuid; set.MappedGuid = strGuid; MetadataSets.Add(set); } else { throw new FormatException("Invalid XML element: " + reader.Name); } } if (reader.NodeType == System.Xml.XmlNodeType.EndElement) { if (reader.Name == "metadata-sets") { return(this); } } } return(this); }
public void ReadXml(System.Xml.XmlReader reader) { // Cast the Data back from the Abstract Type. string typeAttrib = reader.GetAttribute("xsi:type"); // Ensure the Type was Specified if (typeAttrib == null) { throw new ArgumentNullException("Unable to Read Xml Data for Abstract Type '" + typeof(AbstractType).Name + "' because no 'type' attribute was specified in the XML."); } if (typeAttrib.StartsWith("GXDLMSDirector.")) { typeAttrib = typeAttrib.Replace("GXDLMSDirector.", "Gurux.DLMS.Objects."); } Type type = typeof(Gurux.DLMS.GXDLMSClient).Assembly.GetType(typeAttrib); if (type == null) { type = Type.GetType(typeAttrib); } //Type type = Type.GetType(typeAttrib); // Check the Type is Found. if (type == null) { throw new InvalidCastException("Unable to Read Xml Data for Abstract Type '" + typeof(AbstractType).Name + "' because the type specified in the XML was not found."); } // Check the Type is a Subclass of the AbstractType. if (!type.IsSubclassOf(typeof(AbstractType))) { throw new InvalidCastException("Unable to Read Xml Data for Abstract Type '" + typeof(AbstractType).Name + "' because the Type specified in the XML differs ('" + type.Name + "')."); } // Read the Data, Deserializing based on the (now known) concrete type. reader.ReadStartElement(); // Exception: The assembly with display name 'Gurux.GraphView.XmlSerializers'... // is a part of the XmlSerializer's normal operation. It is expected and will be caught and // handled inside of the Framework code. Just ignore it and continue. // If it bothers you during debugging, set the Visual Studio debugger to only stop on // unhandled exceptions instead of all exceptions. XmlSerializer t; if (!s.ContainsKey(type)) { t = new XmlSerializer(type, Gurux.DLMS.GXDLMSClient.GetObjectTypes()); s[type] = t; } else { t = s[type]; } this.Data = (AbstractType)t.Deserialize(reader); reader.ReadEndElement(); }
public void ReadXmlContent(System.Xml.XmlReader reader, Func <Type, WSTableSource> getTSource) { base.ReadXmlContent(reader); bool done = false; while (reader.MoveToContent() == XmlNodeType.Element) { switch (reader.Name) { case "params": { if (reader.ReadToDescendant("param")) { while (reader.MoveToContent() == XmlNodeType.Element) { string pName = reader.GetAttribute("name"); WSParam param = GetXParam(pName, null, getTSource); if (param == null) { reader.Skip(); continue; } else { if (param is WSTableParam) { ((WSTableParam)param).ReadXml(reader); } else { param.ReadXml(reader); } } reader.MoveToContent(); if (!reader.Read()) { break; } } } break; } default: { done = true; break; } } reader.MoveToContent(); if (done || !reader.Read()) { break; } } }
/// <summary> /// Updates an existing <see cref="NameValueCollection" /> object from /// its XML representation. /// </summary> private static void UpcodeTo(XmlReader reader, NameValueCollection collection) { if (collection == null) { throw new ArgumentNullException("collection"); } if (reader == null) { throw new ArgumentNullException("reader"); } reader.Read(); // // Add entries into the collection as <item> elements // with child <value> elements are found. // while (reader.IsStartElement("item")) { string name = reader.GetAttribute("name"); bool isNull = reader.IsEmptyElement; reader.Read(); // <item> if (!isNull) { while (reader.IsStartElement("value")) // <value ...> { string value = reader.GetAttribute("string"); collection.Add(name, value); reader.Read(); } reader.ReadEndElement(); // </item> } else { collection.Add(name, null); } } reader.ReadEndElement(); }
/// <summary> /// Parse an SXCM from the wire /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Determine the generic type formatter var formatter = DatatypeFormatter.GetFormatter(GenericArguments[0]); // Create the return value Type sxcmType = typeof(SXCM <>); Type genType = sxcmType.MakeGenericType(GenericArguments); ConstructorInfo ci = genType.GetConstructor(Type.EmptyTypes); Object retVal = null; if (ci != null) { retVal = ci.Invoke(null); } else { throw new ArgumentException("Constructor on type must have a parameterless constructor"); } // Operator if (s.GetAttribute("operator") != null) { genType.GetProperty("Operator").SetValue(retVal, Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator)), null); } // Value if (formatter != null) { formatter.Host = this.Host; var value = formatter.Parse(s, result); genType.GetProperty("Value").SetValue(retVal, value, null); if (value != null) { ((ANY)retVal).NullFlavor = ((ANY)value).NullFlavor; ((ANY)retVal).Flavor = ((ANY)value).Flavor; ((ANY)value).NullFlavor = null; ((ANY)value).Flavor = null; } } return(retVal); }
protected override List <HotSearchInfo> AnalysisData(System.Xml.XmlReader reader) { var list = new List <HotSearchInfo>(20); while (reader.Read()) { while (reader.NodeType == XmlNodeType.Element && reader.Name == "keyword") { int nodeValue = 0; list.Add(new HotSearchInfo() { Type = int.TryParse(reader.GetAttribute("type"), out nodeValue) ? nodeValue : 0, Count = int.TryParse(reader.GetAttribute("count"), out nodeValue) ? nodeValue : 0, Name = reader.ReadElementContentAsString() }); } } return(list); }
protected override void ReadXmlBase(System.Xml.XmlReader reader) { base.ReadXmlBase(reader); // read for the attributes in this local class Check.Assert(reader.LocalName == "uid", "Expected LocalName as uid rather than " + reader.LocalName); this.uid = new OpenEhr.RM.Support.Identification.ObjectVersionId(); this.uid.ReadXml(reader); if (reader.LocalName == "data") { string dataType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace); OpenEhr.RM.Common.Archetyped.Impl.Locatable locatableData = OpenEhr.RM.Common.Archetyped.Impl.Locatable.GetLocatableObjectByType(dataType); locatableData.ReadXml(reader); this.data = locatableData as T; } if (reader.LocalName == "preceding_version_uid") { this.precedingVersionUid = new OpenEhr.RM.Support.Identification.ObjectVersionId(); this.precedingVersionUid.ReadXml(reader); } if (reader.LocalName == "other_input_version_uids") { this.otherInputVersionUids = new AssumedTypes.Set <ObjectVersionId>(); do { ObjectVersionId objectVersionId = new ObjectVersionId(); objectVersionId.ReadXml(reader); this.otherInputVersionUids.Add(objectVersionId); } while (reader.LocalName == "other_input_version_uids"); } if (reader.LocalName == "attestations") { this.attestations = new OpenEhr.AssumedTypes.List <OpenEhr.RM.Common.Generic.Attestation>(); do { Generic.Attestation a = new OpenEhr.RM.Common.Generic.Attestation(); a.ReadXml(reader); this.attestations.Add(a); } while (reader.LocalName == "attestations"); } Check.Assert(reader.LocalName == "lifecycle_state", "Expected LocalName is lifecycle_state not " + reader.LocalName); this.lifecycleState = new OpenEhr.RM.DataTypes.Text.DvCodedText(); this.lifecycleState.ReadXml(reader); }
/// <summary> /// Deserializes list /// </summary> /// <param name="outputStream">Ouput stream to write the serialized data</param> public static void XmlToCollection<T>(System.Xml.XmlReader inputStream, ICollection<T> interfaceList) { if (inputStream.IsEmptyElement) { //Move to next element inputStream.Read(); return; } //Get the base node name of generic list of items of type Collection object string parentNodeName = inputStream.Name; //Stopwatch watch = new Stopwatch(); //watch.Start(); //Move to first child inputStream.Read(); while (inputStream.NodeType != XmlNodeType.EndElement || inputStream.Name != parentNodeName) { if (inputStream.NodeType == XmlNodeType.Element) { string typeName = inputStream.GetAttribute("TypeName", Serializer.TypeNameNamespace); Type objectType = Type.GetType(typeName); if (objectType != null) { inputStream.Read(); if (inputStream.NodeType != XmlNodeType.EndElement) { //XmlAttributeOverrides xOver = XmlAttributeOverridesFactory.Create(objectType); XmlSerializer xs = factory.CreateSerializer(objectType); T item = (T)xs.Deserialize(inputStream); interfaceList.Add(item); } } else { throw new ApplicationException("Error in XmlToCollection method. Node unhandled: " + inputStream.Name); } } else { // Move to the next element inputStream.Read(); } } // Move to the next element inputStream.Read(); //watch.Stop(); //Trace.WriteLine(String.Format("XmlToCollection took {0} Milliseconds", watch.ElapsedMilliseconds)); }
/// <summary> /// Initializes a new instance of the <see cref="PostOpportunityUpdate"/> class. /// </summary> /// <param name="unsecure">Contains public (unsecure) configuration information.</param> /// <param name="secure">Contains non-public (secure) configuration information. /// When using Microsoft Dynamics CRM for Outlook with Offline Access, /// the secure string is not passed to a plug-in that executes while the client is offline.</param> public PostOpportunityUpdate(string unsecure, string secure) : base(typeof(PostOpportunityUpdate)) { base.RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(40, "Update", "opportunity", new Action <LocalPluginContext>(ExecutePostOpportunityUpdate))); // Note : you can register for more events here if this plugin is not specific to an individual entity and message combination. // You may also need to update your RegisterFile.crmregister plug-in registration file to reflect any change. try { // TODO: Implement your custom configuration handling. using (System.Xml.XmlReader reader = XmlReader.Create(new StringReader(unsecure))) { // Load fields from settings reader.MoveToContent(); reader.MoveToAttribute("APIKey"); NexmoApiKey = Convert.ToString(reader.GetAttribute("APIKey")); reader.MoveToAttribute("APISecret"); NexmoApiSecret = Convert.ToString(reader.GetAttribute("APISecret")); //reader.MoveToAttribute("FromUser"); //FromUser = Convert.ToString(reader.GetAttribute("FromUser")); reader.MoveToAttribute("EnableNexmoSMS"); EnableSMS = Convert.ToString(reader.GetAttribute("EnableNexmoSMS")); reader.MoveToAttribute("Threshold"); if (!string.IsNullOrEmpty(reader.GetAttribute("Threshold"))) { Threshold = Convert.ToDouble(reader.GetAttribute("Threshold")); } } } catch (Exception ex) { throw new InvalidPluginExecutionException(string.Format("An error occured in ExecutePostOpportunityCreate plugin: {0} {1} {2}", ex.ToString(), ex.InnerException, ex.StackTrace)); } }
private void RestoreValues(Excel.Worksheet thisSheet, CheckBox thisBox, string propname) { string vals = Utilities.ExcelHelpers.getWorksheetCustomProperty(thisSheet, propname); if (vals != null) { System.Xml.XmlReader xvals = System.Xml.XmlReader.Create(new System.IO.StringReader(vals)); while (xvals.Read()) { if (xvals.Name == propname) { Boolean x; if (Boolean.TryParse(xvals.GetAttribute("Checked").ToString(), out x)) { thisBox.Checked = Boolean.Parse(xvals.GetAttribute("Checked").ToString()); } } } } }
/// <summary> /// Read a transform from XML. /// /// If all are available then they are read and applied to transform according formula: /// /// transform = ((matrix * translate) * rotate) * scale /// </summary> /// <param name="node"></param> /// <param name="transform"></param> private void ReadTransform(System.Xml.XmlReader node, ref Transform transform) { var mat = node.GetAttribute("matrix"); var f4 = new float4(0.0f); var t = new Transform(); if (Utilities.Instance.get_transform(t, mat)) { transform = t; } var trans = node.GetAttribute("translate"); if (Utilities.Instance.get_float4(f4, trans)) { transform = transform * Transform.Translate(f4); } var rotate = node.GetAttribute("rotate"); if (Utilities.Instance.get_float4(f4, rotate)) { var a = DegToRad(f4[0]); var axis = new float4(f4[1], f4[2], f4[3]); transform = transform * ccl.Transform.Rotate(a, axis); } var scale = node.GetAttribute("scale"); if (!string.IsNullOrEmpty(scale)) { var components = Utilities.Instance.parse_floats(scale); if (components.Length == 3) { transform = transform * ccl.Transform.Scale(components[0], components[1], components[2]); } } }
private void ReadObject(ref XmlReadState state, System.Xml.XmlReader node) { node.Read(); var meshname = node.GetAttribute("mesh"); var me = meshes[meshname]; var ob = new ccl.Object(Client) { Transform = state.Transform, IsShadowCatcher = state.IsShadowCatcher }; ob.Mesh = me; }
public void ReadShader(ref XmlReadState state, System.Xml.XmlReader node) { node.Read(); var name = node.GetAttribute("name"); if (!state.Silent) { Console.WriteLine("Shader: {0}", node.GetAttribute("name")); } if (string.IsNullOrEmpty(name)) { return; } var shader = new Shader(Client, Shader.ShaderType.Material) { Name = name }; Utilities.Instance.ReadNodeGraph(ref shader, node.ReadSubtree()); state.Scene.AddShader(shader); }
public void ReadXml(System.Xml.XmlReader reader) { XmlSerializer keySerializer = new XmlSerializer(typeof(TKey)); XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue)); bool wasEmpty = reader.IsEmptyElement; reader.Read(); if (wasEmpty) { return; } //bool keyIsString = typeof(TKey) == typeof(string); bool keyIsString = typeof(TKey).FindInterfaces((n, k) => n.ToString() == k.ToString(), "System.IConvertible").Length > 0; while (reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (keyIsString) { /* * var ms = new MemoryStream(Encoding.Unicode.GetBytes(reader.GetAttribute("key"))); * TKey key = (TKey)keySerializer.Deserialize(ms); */ string at = reader.GetAttribute("key"); TKey key = (TKey)Convert.ChangeType(at, typeof(TKey)); reader.ReadStartElement("item"); TValue value = (TValue)valueSerializer.Deserialize(reader); this.Add(key, value); } else { reader.ReadStartElement("item"); reader.ReadStartElement("key"); TKey key = (TKey)keySerializer.Deserialize(reader); reader.ReadEndElement(); reader.ReadStartElement("value"); TValue value = (TValue)valueSerializer.Deserialize(reader); reader.ReadEndElement(); this.Add(key, value); } reader.ReadEndElement(); reader.MoveToContent(); } reader.ReadEndElement(); }