public object LoadValue(XmlReaderContext context) { var type = DecodeTypeName(context.LoadFromAttribute("Type")); var etype = type.GetElementType(); var sranks = context.LoadFromAttribute("Array").Split(';'); var lengths = new int[sranks.Length]; bool empty = true; for (int i = 0; i < lengths.Length; ++i) { lengths[i] = int.Parse(sranks[i], System.Globalization.NumberStyles.None); if (lengths[i] > 0) { empty = false; } } Array res; if (lengths.Length == 1) { res = Array.CreateInstance(etype, lengths[0]); } else { res = Array.CreateInstance(etype, lengths); } if (empty) { return(res); } var values = new int[lengths.Length]; bool inc = true; context.Push(); try { if (!empty) { while (inc) { var p = ParameterPersister.Load(context); res.SetValue(p.Value, values); inc = Increment(values, lengths); if (inc) { context.Next(); } } } } finally { context.Pop(); } return(res); }
public static Section Load(XmlReaderContext context) { var name = context.CurrentName; var res = new Section(name); bool empty = context.Node.ChildNodes.Count == 0; if (empty) { return(res); } var style = context.LoadFromAttribute("Style"); bool noSections = style == "NoSections"; bool noParameters = !noSections && style == "NoParameters"; if (noParameters || context.TryPush("Sections")) { try { foreach (XmlNode subsectionNode in context.Node.ChildNodes) { context.Push(subsectionNode.Name); try { res.AddSection(SectionPersister.Load(context)); } finally { context.Pop(); } } } finally { if (!noParameters) { context.Pop(); } } } if (noSections || context.TryPush("Parameters")) { try { foreach (XmlNode parameterNode in context.Node.ChildNodes) { context.Push(parameterNode.Name); try { res.AddParameter(ParameterPersister.Load(context)); } catch (Exception exc) { if (exc.IsCritical()) { throw; } } finally { context.Pop(); } } } finally { if (!noSections) { context.Pop(); } } } return(res); }