Here are the examples of the csharp api System.Xml.XmlReader.ReadSubtree() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
74 Examples
19
Source : GameSaveLoadInMem.cs
with Apache License 2.0
from AantCoder
with Apache License 2.0
from AantCoder
[HarmonyPrefix]
public static bool Prefix(ScribeLoader __instance, string filePath)
{
if (!ScribeLoader_InitLoading_Patch.Enable) return true;
Loger.Log("ScribeLoader_InitLoadingMetaHeaderOnly_Patch Start");
if (Scribe.mode != 0)
{
Log.Error("Called InitLoadingMetaHeaderOnly() but current mode is " + Scribe.mode);
Scribe.ForceStop();
}
try
{
using (var input = new MemoryStream(ScribeLoader_InitLoading_Patch.LoadData))
//using (StreamReader input = new StreamReader(filePath))
{
using (XmlTextReader xmlTextReader = new XmlTextReader(input))
{
if (!ScribeMetaHeaderUtility.ReadToMetaElement(xmlTextReader))
{
return false;
}
using (XmlReader reader = xmlTextReader.ReadSubtree())
{
XmlDoreplacedent xmlDoreplacedent = new XmlDoreplacedent();
xmlDoreplacedent.Load(reader);
XmlElement xmlElement = xmlDoreplacedent.CreateElement("root");
xmlElement.AppendChild(xmlDoreplacedent.DoreplacedentElement);
__instance.curXmlParent = xmlElement;
}
}
}
Scribe.mode = LoadSaveMode.LoadingVars;
}
catch (Exception ex)
{
Log.Error("Exception while init loading meta header: " + filePath + "\n" + ex);
__instance.ForceStop();
throw;
}
Loger.Log("ScribeLoader_InitLoadingMetaHeaderOnly_Patch End");
return false;
}
19
Source : DecisionTable.cs
with MIT License
from adamecr
with MIT License
from adamecr
public void ReadXml(XmlReader reader)
{
var r = reader.ReadSubtree();
var serializer = reader.NamespaceURI == DmnParser.XmlNamespaceDmn11
? DecisionTableSerializableSerializer
: DecisionTableSerializableSerializer13;
var proxy = (DecisionTableSerializable)serializer.Deserialize(r);
Inputs = proxy.Inputs;
AggregationSrc = proxy.Aggregation;
HitPolicySrc = proxy.HitPolicy;
Outputs = proxy.Outputs;
Rules = proxy.Rules;
reader.ReadEndElement();
}
19
Source : InformationRequirement.cs
with MIT License
from adamecr
with MIT License
from adamecr
public void ReadXml(XmlReader reader)
{
var r = reader.ReadSubtree();
var serializer = reader.NamespaceURI == DmnParser.XmlNamespaceDmn11
? InformationRequirementSerializableSerializer
: InformationRequirementSerializableSerializer13;
var proxy = (InformationRequirementSerializable)serializer.Deserialize(r);
RequiredDecision = proxy.RequiredDecision;
RequiredInput = proxy.RequiredInput;
reader.ReadEndElement();
}
19
Source : DrawingParser.cs
with MIT License
from ahopper
with MIT License
from ahopper
private static GeometryDrawing ParseGeometryDrawing(XmlReader reader)
{
GeometryDrawing drawing = new GeometryDrawing();
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case "Brush": drawing.Brush = Brush.Parse(reader.Value); break;
case "Geometry": drawing.Geometry = Geometry.Parse(reader.Value); break;
}
}
reader.MoveToElement();
reader = reader.ReadSubtree();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "GeometryDrawing.Geometry": drawing.Geometry = ParseGeometry(reader.ReadSubtree()); break;
case "GeometryDrawing.Brush": drawing.Brush = ParseBrush(reader.ReadSubtree()); break;
}
}
}
return drawing;
}
19
Source : DrawingParser.cs
with MIT License
from ahopper
with MIT License
from ahopper
private static LinearGradientBrush ParseLinearGradientBrush(XmlReader reader)
{
LinearGradientBrush brush = new LinearGradientBrush();
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case "StartPoint": brush.StartPoint = RelativePoint.Parse(reader.Value); break;
case "EndPoint": brush.EndPoint = RelativePoint.Parse(reader.Value); break;
}
}
reader.MoveToElement();
reader = reader.ReadSubtree();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "LinearGradientBrush.GradientStops": brush.GradientStops = ParseGradientStops(reader.ReadSubtree()); break;
}
}
}
return brush;
}
19
Source : DrawingParser.cs
with MIT License
from ahopper
with MIT License
from ahopper
private static DrawingGroup ParseDrawingGroup(XmlReader reader)
{
var drawingGroup = new DrawingGroup();
reader.MoveToElement();
reader = reader.ReadSubtree();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "GeometryDrawing")
{
drawingGroup.Children.Add(ParseGeometryDrawing(reader));
}
}
}
return drawingGroup;
}
19
Source : StreamParser.cs
with MIT License
from araditc
with MIT License
from araditc
public XmlElement NextElement(params string[] expected) {
// Advance reader to next node.
reader.Read();
if (reader.NodeType == XmlNodeType.EndElement && reader.Name ==
"stream:stream")
throw new IOException("The server has closed the XML stream.");
if (reader.NodeType != XmlNodeType.Element)
throw new XmlException("Unexpected node: '" + reader.Name +
"' of type " + reader.NodeType);
if (!reader.IsStartElement())
throw new XmlException("Not a start element: " + reader.Name);
// We can't use the ReadOuterXml method of reader directly as it places
// the cursor on the next element which may result in a blocking read
// on the underlying network stream.
using (XmlReader inner = reader.ReadSubtree()) {
inner.Read();
string xml = inner.ReadOuterXml();
XmlDoreplacedent doc = new XmlDoreplacedent();
using (var sr = new StringReader(xml))
using (var xtr = new XmlTextReader(sr))
doc.Load(xtr);
XmlElement elem = (XmlElement) doc.FirstChild;
// Handle unrecoverable stream errors.
if (elem.Name == "stream:error") {
string condition = elem.FirstChild != null ?
elem.FirstChild.Name : "undefined";
throw new IOException("Unrecoverable stream error: " + condition);
}
if (expected.Length > 0 && !expected.Contains(elem.Name))
throw new XmlException("Unexpected XML element: " + elem.Name);
return elem;
}
}
19
Source : SimplePropertyInfo.cs
with Apache License 2.0
from aws
with Apache License 2.0
from aws
private static bool HandleElement(StringBuilder sb, XmlTextReader reader, string name, bool forWebUse)
{
if (XMLNodesToCopyAsIs.Contains(name) || XMLNodesToRemove.Contains(name))
{
using (var subReader = reader.ReadSubtree())
{
var doc = new XmlDoreplacedent();
doc.Load(subReader);
var el = doc.DoreplacedentElement;
if (!XMLNodesToRemove.Contains(name))
{
sb.Append(el.OuterXml);
}
}
}
//else if (XMLNodesToIgnore.Contains(name))
//{
// sb.AppendFormat("<{0}>", name);
//}
else if (XMLNodesToNewline.Contains(name))
{
if (!forWebUse)
sb.AppendLine();
}
else
{
return false;
}
return true;
}
19
Source : DependencyInspector.cs
with MIT License
from bonsai-rx
with MIT License
from bonsai-rx
Configuration.PackageReference[] GetWorkflowPackageDependencies(string[] fileNames)
{
var replacedemblies = new HashSet<replacedembly>();
foreach (var path in fileNames)
{
var metadata = WorkflowBuilder.ReadMetadata(path);
using (var markupReader = new StringReader(metadata.WorkflowMarkup))
using (var reader = XmlReader.Create(markupReader))
{
reader.ReadToFollowing(WorkflowElementName);
using (var workflowReader = reader.ReadSubtree())
{
while (workflowReader.ReadToFollowing(ExpressionElementName))
{
if (!workflowReader.HasAttributes) continue;
if (workflowReader.GetAttribute(TypeAttributeName, XsiAttributeValue) == IncludeWorkflowTypeName)
{
var includePath = workflowReader.GetAttribute(PathAttributeName);
var separatorIndex = includePath != null ? includePath.IndexOf(replacedemblySeparator) : -1;
if (separatorIndex >= 0 && !Path.IsPathRooted(includePath))
{
var replacedemblyName = includePath.Split(new[] { replacedemblySeparator }, 2)[0];
if (!string.IsNullOrEmpty(replacedemblyName))
{
var replacedembly = replacedembly.Load(replacedemblyName);
replacedemblies.Add(replacedembly);
}
}
}
}
}
}
replacedemblies.Add(typeof(WorkflowBuilder).replacedembly);
replacedemblies.AddRange(metadata.GetExtensionTypes().Select(type => type.replacedembly));
var layoutPath = Path.ChangeExtension(path, Path.GetExtension(path) + Constants.LayoutExtension);
if (File.Exists(layoutPath))
{
var visualizerMap = new Lazy<IDictionary<string, Type>>(() =>
TypeVisualizerLoader.GetVisualizerTypes(packageConfiguration)
.Select(descriptor => descriptor.VisualizerTypeName).Distinct()
.Select(typeName => Type.GetType(typeName, false))
.Where(type => type != null)
.ToDictionary(type => type.FullName)
.Wait());
using (var reader = XmlReader.Create(layoutPath))
{
var layout = (VisualizerLayout)VisualizerLayout.Serializer.Deserialize(reader);
foreach (var settings in GetVisualizerSettings(layout))
{
var typeName = settings.VisualizerTypeName;
if (typeName == null) continue;
if (visualizerMap.Value.TryGetValue(typeName, out Type type))
{
replacedemblies.Add(type.replacedembly);
}
}
}
}
}
var packageMap = packageConfiguration.GetPackageReferenceMap();
var dependencies = packageConfiguration.GetreplacedemblyPackageReferences(
replacedemblies.Select(replacedembly => replacedembly.GetName().Name),
packageMap);
if (File.Exists(scriptEnvironment.ProjectFileName))
{
dependencies = dependencies.Concat(
from id in scriptEnvironment.GetPackageReferences()
where packageConfiguration.Packages.Contains(id)
select packageConfiguration.Packages[id]);
}
return dependencies.ToArray();
}
19
Source : EditorSettings.cs
with MIT License
from bonsai-rx
with MIT License
from bonsai-rx
static EditorSettings Load()
{
var settings = new EditorSettings();
if (File.Exists(SettingsPath))
{
try
{
using (var reader = XmlReader.Create(SettingsPath))
{
reader.MoveToContent();
while (reader.Read())
{
if (reader.NodeType != XmlNodeType.Element) continue;
if (reader.Name == WindowStateElement)
{
Enum.TryParse(reader.ReadElementContentreplacedtring(), out FormWindowState windowState);
settings.WindowState = windowState;
}
else if (reader.Name == EditorThemeElement)
{
Enum.TryParse(reader.ReadElementContentreplacedtring(), out ColorTheme editorTheme);
settings.EditorTheme = editorTheme;
}
else if (reader.Name == DesktopBoundsElement)
{
reader.ReadToFollowing(RectangleXElement);
int.TryParse(reader.ReadElementContentreplacedtring(), out int x);
reader.ReadToFollowing(RectangleYElement);
int.TryParse(reader.ReadElementContentreplacedtring(), out int y);
reader.ReadToFollowing(RectangleWidthElement);
int.TryParse(reader.ReadElementContentreplacedtring(), out int width);
reader.ReadToFollowing(RectangleHeightElement);
int.TryParse(reader.ReadElementContentreplacedtring(), out int height);
settings.DesktopBounds = new Rectangle(x, y, width, height);
}
else if (reader.Name == RecentlyUsedFilesElement)
{
var fileReader = reader.ReadSubtree();
while (fileReader.ReadToFollowing(RecentlyUsedFileElement))
{
if (fileReader.Name == RecentlyUsedFileElement)
{
string fileName;
fileReader.ReadToFollowing(FileTimestampElement);
DateTimeOffset.TryParse(fileReader.ReadElementContentreplacedtring(), out DateTimeOffset timestamp);
fileReader.ReadToFollowing(FileNameElement);
fileName = fileReader.ReadElementContentreplacedtring();
settings.recentlyUsedFiles.Add(timestamp, fileName);
}
}
}
}
}
}
catch (XmlException) { }
}
return settings;
}
19
Source : Read.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
public static HighlightingThemes ReadXML(String path = "",
String fileName = @"AvalonEdit\HighLighting_Themes\DeepBlack.xshd",
bool VerifySchema = true)
{
if (string.IsNullOrEmpty(path) == true && string.IsNullOrEmpty(fileName) == true)
return null;
HighlightingThemes HlThemeRoot = null;
try
{
string sPathfileName = fileName;
if (string.IsNullOrEmpty( path ) == false)
sPathfileName = System.IO.Path.Combine(path, fileName);
if (System.IO.File.Exists(sPathfileName) == false)
{
logger.Error(string.Format(CultureInfo.InvariantCulture,
"File '{0}' does not exist at '{1}' or cannot be accessed.", fileName, path));
return null;
}
if (VerifySchema == true) // Test whether XSD schema is valid or not
{
List<string> errorMsgs;
if ((errorMsgs = TestXML(sPathfileName)) != null)
{
// log error (if any) and return null
foreach(string s in errorMsgs)
logger.Error(s);
return null;
}
}
using (XmlReader reader = XmlReader.Create(sPathfileName))
{
string rootTagName = Read.XMLName;
string name = string.Empty;
reader.ReadToNextSibling(Read.XMLName);
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case Read.attr_name:
name = reader.Value;
break;
case XMLNameSpace:
string s = reader.Value;
break;
}
}
HlThemeRoot = new HighlightingThemes(name);
HlThemeRoot.FileNamePath = sPathfileName;
// Find all children that belong into the second level right below the XML root tag
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case ReadLexerStyles.XMLName:
ReadLexerStyles.ReadNode(reader.ReadSubtree(), HlThemeRoot);
break;
case ReadGlobalStyles.XMLName:
ReadGlobalStyles.ReadNode(reader.ReadSubtree(), HlThemeRoot);
break;
default:
if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + rootTagName + "' is not implemented.");
break;
}
}
}
}
}
catch (Exception e)
{
logger.Error(string.Format("An error occurred while reading a highlighting theme file at path '{0}', filename '{1}':\n\n",
(path == null ? "(null)" : path),
(fileName == null ? "(null)" : fileName)) + "Details:" + e.ToString());
return null;
}
return HlThemeRoot;
}
19
Source : Read.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
internal static HighlightingTheme ReadNode(XmlReader reader)
{
HighlightingTheme hlTheme = null;
string name = string.Empty;
string desc = string.Empty;
reader.ReadToNextSibling(ReadLexerType.XMLName);
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case ReadLexerType.attr_name:
name = reader.Value;
break;
case XMLNameSpace:
break;
case ReadLexerType.attr_desc:
desc = (reader.Value == null ? string.Empty : reader.Value);
break;
}
}
hlTheme = new HighlightingTheme(name);
hlTheme.HlDesc = desc;
while (reader.Read())
{
if (reader.IsStartElement() == true)
{
switch (reader.Name)
{
case ReadWordsStyle.XMLName:
WordsStyle t = ReadWordsStyle.ReadNode(reader.ReadSubtree());
hlTheme.AddWordStyle(t.Name, t);
break;
case XMLNameSpace:
break;
default:
if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerType.XMLName + "' is not implemented.");
break;
}
}
}
return hlTheme;
}
19
Source : Read.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
internal static void ReadNode(XmlReader reader, HighlightingThemes HlThemeRoot)
{
reader.ReadToNextSibling(ReadGlobalStyles.XMLName);
while (reader.Read())
{
if (reader.IsStartElement() == true)
{
switch (reader.Name)
{
case ReadWidgetStyle.XMLName_Hyperlink:
case ReadWidgetStyle.XMLName_DefaultStyle:
WidgetStyle t = ReadWidgetStyle.ReadForegroundBackgroundColorNode(reader.ReadSubtree(), reader.Name);
try
{
HlThemeRoot.AddWidgetStyle(t.Name, t);
}
catch (Exception e) // Reading one errornous style node should not crash the whole process
{
logger.Error("Error reading DefaultStyle node", e);
}
break;
case ReadWidgetStyle.XMLName_CurrentLineBackground:
t = ReadWidgetStyle.ReadCurrentLineBackgroundNode(reader.ReadSubtree());
try
{
HlThemeRoot.AddWidgetStyle(t.Name, t);
}
catch (Exception e) // Reading one errornous style node should not crash the whole process
{
logger.Error("Error reading CurrentLineBackground node", e);
}
break;
case ReadWidgetStyle.XMLName_LineNumbersForeground:
case ReadWidgetStyle.XMLName_NonPrintableCharacter:
t = ReadWidgetStyle.ReadForegroundColorNode(reader.ReadSubtree(), reader.Name);
try
{
HlThemeRoot.AddWidgetStyle(t.Name, t);
}
catch (Exception e) // Reading one errornous style node should not crash the whole process
{
logger.Error("Error reading LineNumbersForeground node", e);
}
break;
case ReadWidgetStyle.XMLName_Selection:
t = ReadWidgetStyle.ReadSelectionNode(reader.ReadSubtree());
try
{
HlThemeRoot.AddWidgetStyle(t.Name, t);
}
catch (Exception e) // Reading one errornous style node should not crash the whole process
{
logger.Error("Error reading Selection node", e);
}
break;
case XMLNameSpace:
break;
default:
if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadGlobalStyles.XMLName + "' is not implemented.");
break;
}
}
}
}
19
Source : Read.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
internal static void ReadNode(XmlReader reader, HighlightingThemes HlThemeRoot)
{
reader.ReadToNextSibling(ReadLexerStyles.XMLName);
while (reader.Read())
{
if (reader.IsStartElement() == true)
{
switch (reader.Name)
{
case ReadLexerType.XMLName:
HighlightingTheme t = ReadLexerType.ReadNode(reader.ReadSubtree());
try
{
HlThemeRoot.AddTheme(t.HlName, t);
}
catch (Exception e) // Reading one errornous style node should not crash the whole process
{
logger.Error("Error reading LexerType node", e);
}
break;
case XMLNameSpace:
break;
default:
if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerStyles.XMLName + "' is not implemented.");
break;
}
}
}
}
19
Source : UmlElementDataDef.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
public static ShapeViewModelBase ReadShape(XmlReader reader, UmlTypes umlType, IShapeParent parent)
{
switch (umlType)
{
case UmlTypes.Primitive:
case UmlTypes.DataType:
case UmlTypes.Signal:
case UmlTypes.Clreplaced:
case UmlTypes.Interface:
case UmlTypes.Table:
case UmlTypes.Enumeration:
case UmlTypes.Component:
return UmlSquareShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Decision:
return UmlDecisionShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Package:
return UmlPackageShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Boundary:
return UmlBoundaryShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Note:
return UmlNoteShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Node:
case UmlTypes.Device:
case UmlTypes.DeploymentSpec:
return UmlNodeShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Collaboration:
case UmlTypes.UseCase:
return UmlUseCaseShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Canvreplacedhape:
case UmlTypes.Actor:
case UmlTypes.Actor1:
case UmlTypes.ActivityInitial:
case UmlTypes.ActivityFinal:
case UmlTypes.ActivityFlowFinal:
case UmlTypes.ActivitySync:
case UmlTypes.Event1:
case UmlTypes.Event2:
case UmlTypes.Action1:
case UmlTypes.Action2:
case UmlTypes.ExecutionEnvironment:
return UmlCanvreplacedhapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.ConnectorAggregation:
case UmlTypes.Connectorreplacedociation:
case UmlTypes.ConnectorComposition:
case UmlTypes.ConnectorInheritance:
return UmlreplacedociationShapeViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, umlType);
case UmlTypes.Undefined:
default:
throw new NotImplementedException(string.Format("System error: '{0}' not supported in ReadShape.", umlType));
}
throw new NotImplementedException(umlType.ToString());
}
19
Source : UmlAssociationShapeViewModel.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
public static UmlreplacedociationShapeViewModel ReadDoreplacedent(XmlReader reader,
IShapeParent parent,
UmlTypes umlType)
{
UmlreplacedociationShapeViewModel ret = UmlElementDataDef.CreateShape(umlType,
new System.Windows.Point(UmlTypeToStringConverter.DefaultX,
UmlTypeToStringConverter.DefaultY), parent)
as UmlreplacedociationShapeViewModel;
reader.ReadToNextSibling(ret.UmlDataTypeString);
while (reader.MoveToNextAttribute())
{
if (ret.ReadAttributes(reader.Name, reader.Value) == false)
{
if (reader.Name.Trim().Length > 0 && reader.Name != XmlComment)
throw new ArgumentException("XML node:'" + reader.Name + "' as child of '" + ret.UmlDataTypeString + "' is not supported.");
}
}
// Read child elements of this XML node
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "Anchor":
AnchorViewModel p = new AnchorViewModel(parent)
{
Left = 0,
Top = 0
};
AnchorViewModel.ReadDoreplacedent(reader.ReadSubtree(), parent, p);
ret.Add(p);
break;
default:
throw new NotImplementedException(string.Format("'{0}' is not a valid sub-node of {1}", reader.Name, ret.XElementName));
}
}
}
return ret;
}
19
Source : UmlShapeBaseViewModel.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
protected string ReadXMLNode(string nodeName, XmlReader reader)
{
switch (nodeName)
{
case CommentViewModel.Comment_TAG:
CommentViewModel c = CommentViewModel.ReadDoreplacedent(reader.ReadSubtree());
if (c != null) // Add into list of comments
this.AddComment(c);
return string.Empty;
default:
return string.Format("'{0}' is not a valid sub-node of {1}", reader.Name, this.XElementName);
}
}
19
Source : UmlNoteShapeViewModel.cs
with MIT License
from Dirkster99
with MIT License
from Dirkster99
protected new string ReadXMLNode(string nodeName, XmlReader reader)
{
switch (nodeName)
{
case Text_TAG:
this.Text = ReadTextDoreplacedent(reader.ReadSubtree()); // Write text string as content of this tag
return string.Empty;
default:
if (base.ReadXMLNode(nodeName, reader) != string.Empty)
return string.Format("'{0}' is not a valid sub-node of {1}", reader.Name, this.XElementName);
break;
}
return string.Empty;
}
19
Source : DockForm.cs
with Apache License 2.0
from Epi-Info
with Apache License 2.0
from Epi-Info
internal void ReadXml(XmlReader reader)
{
try
{
string s;
int x = 0, y = 0;
s = reader.GetAttribute("width");
if (s != null)
this.Width = int.Parse(s);
s = reader.GetAttribute("height");
if (s != null)
this.Height = int.Parse(s);
s = reader.GetAttribute("x");
if (s != null)
x = int.Parse(s);
s = reader.GetAttribute("y");
if (s != null)
y = int.Parse(s);
this.Location = new Point(x, y);
reader.Read();
while (!reader.EOF)
{
if (reader.IsStartElement() & (reader.Name == "container"))
{
Console.WriteLine("container");
rootContainer.ReadXml(reader.ReadSubtree());
break;
}
else
reader.Read();
}
}
catch (Exception ex)
{
Console.WriteLine("DockContainer.ReadXml: " + ex.Message);
}
}
19
Source : DockManager.cs
with Apache License 2.0
from Epi-Info
with Apache License 2.0
from Epi-Info
public static void ReadXml(string file)
{
XmlTextReader reader = null;
try
{
// Load the reader with the data file and ignore all white space nodes.
reader = new XmlTextReader(file);
reader.WhitespaceHandling = WhitespaceHandling.None;
// Parse the file and display each of the nodes.
while (reader.Read())
{
if (!reader.IsStartElement())
continue;
switch (reader.Name)
{
case "form":
Console.WriteLine("form");
DockForm form = new DockForm();
form.Opacity = 0;
form.Show();
form.ReadXml(reader.ReadSubtree());
//if (!form.RootContainer.IsEmpty)
form.Opacity = 1;
//else
// form.Close();
break;
case "manager":
Console.WriteLine("manager");
string hostType = reader.GetAttribute("parent");
if (hostType != null)
{
foreach (DockManager m in managerList)
if (m.Parent.GetType().FullName == hostType)
m.ReadXml(reader.ReadSubtree());
}
break;
}
}
}
finally
{
if (reader != null)
reader.Close();
}
}
19
Source : XmlDocumentParser.cs
with MIT License
from erdomke
with MIT License
from erdomke
private void ProcessElement()
{
bool emptyElement = this.reader.IsEmptyElement;
string elementNamespace = this.reader.NamespaceURI;
string elementName = this.reader.LocalName;
if (elementNamespace == this.DoreplacedentNamespace)
{
XmlElementParser newParser;
if (!this.currentScope.Parser.TryGetChildElementParser(elementName, out newParser))
{
this.ReportUnexpectedElement(this.Location, this.reader.Name);
if (!emptyElement)
{
int depth = reader.Depth;
do
{
reader.Read();
}
while (reader.Depth > depth);
}
return;
}
XmlElementInfo newElement = this.ReadElement(elementName, this.Location);
this.BeginElement(newParser, newElement);
if (emptyElement)
{
this.EndElement();
}
}
else
{
// This element is not in the expected XML namespace for this artifact.
// we need to report an error if the namespace for this element is a target namespace for the xml schemas we are parsing against.
// otherwise we replacedume that this is either a valid 'any' element or that the xsd validator has generated an error
if (string.IsNullOrEmpty(elementNamespace) || this.IsOwnedNamespace(elementNamespace))
{
this.ReportUnexpectedElement(this.Location, this.reader.Name);
this.reader.Skip();
}
else
{
XmlReader elementReader = this.reader.ReadSubtree();
elementReader.MoveToContent();
string annotationValue = elementReader.ReadOuterXml();
this.currentScope.Element.AddAnnotation(new XmlAnnotationInfo(this.Location, elementNamespace, elementName, annotationValue, false));
}
}
}
19
Source : DocumentationCache.cs
with MIT License
from fuse-open
with MIT License
from fuse-open
static async Task<Dictionary<string, Entry>> LoadCache()
{
var doreplacedentation = new Dictionary<string, Entry>();
using(var fileStream = new FileStream(CacheFilePath, FileMode.Open, FileAccess.Read))
using (var reader = XmlReader.Create(fileStream, new XmlReaderSettings { Async = true }))
while (await reader.ReadAsync())
{
if (reader.NodeType != XmlNodeType.Element || reader.Name != "Element") continue;
string key = null;
string value = null;
string url = null;
var hasMoreContent = false;
using (var subReader = reader.ReadSubtree())
while (await subReader.ReadAsync())
{
if (subReader.Name == "Key")
key = await subReader.ReadElementContentreplacedtringAsync();
if (subReader.Name == "Value")
value = await subReader.ReadElementContentreplacedtringAsync();
if (subReader.Name == "Url")
url = await subReader.ReadElementContentreplacedtringAsync();
if (subReader.Name == "HasMoreContent")
hasMoreContent = subReader.ReadElementContentAsBoolean();
}
if (key != null) doreplacedentation.Add(key, new Entry(value, url, hasMoreContent));
}
return doreplacedentation;
}
19
Source : XMLProcessor.cs
with Apache License 2.0
from Ginger-Automation
with Apache License 2.0
from Ginger-Automation
private void SetOutput(XmlDoreplacedent xmlDoc, Act act)
{
XmlReader xmlReader = XmlReader.Create(new System.IO.StringReader(xmlDoc.InnerXml));
XmlReader subXmlReader = null;
string xmlElement = "";
ArrayList elementArrayList = new ArrayList();
List<string> DeParams = new List<string>();
foreach (ActReturnValue actReturnValue in act.ReturnValues)
{
//TODO: How the user will know? add check box?
if (actReturnValue.Param.IndexOf("AllDescOf") == 0)
{
DeParams.Add(actReturnValue.Param.Trim().Substring(9).Trim());
}
}
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
xmlElement = xmlReader.Name;
if (elementArrayList.Count <= xmlReader.Depth)
{
elementArrayList.Add(xmlElement);
}
else
{
elementArrayList[xmlReader.Depth] = xmlElement;
}
foreach (var p in DeParams)
{
if (p == xmlReader.Name)
{
subXmlReader = xmlReader.ReadSubtree();
subXmlReader.ReadToFollowing(p);
act.AddOrUpdateReturnParamActualWithPath("AllDescOf" + p, subXmlReader.ReadInnerXml(), "/" + string.Join("/", elementArrayList.ToArray().Take(xmlReader.Depth)));
}
}
}
if (xmlReader.NodeType == XmlNodeType.Text)
{
// soup req contains sub xml, so parse them
if (xmlReader.Value.StartsWith("<?xml"))
{
XmlDoreplacedent xmlnDoc = new XmlDoreplacedent();
xmlnDoc.LoadXml(xmlReader.Value);
SetOutput(xmlnDoc, act);
}
else
{
act.AddOrUpdateReturnParamActualWithPath(xmlElement, xmlReader.Value, "/" + string.Join("/", elementArrayList.ToArray().Take(xmlReader.Depth)));
}
}
}
}
19
Source : General.cs
with Apache License 2.0
from Ginger-Automation
with Apache License 2.0
from Ginger-Automation
public static List<XmlNodeItem> GetXMLNodesItems(XmlDoreplacedent xmlDoc, bool DisableProhibitDtd = false)
{
List<XmlNodeItem> returnDict = new List<XmlNodeItem>();
XmlReader rdr1 = XmlReader.Create(new System.IO.StringReader(xmlDoc.InnerXml));
XmlReader rdr = null;
if (DisableProhibitDtd)
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
rdr = XmlReader.Create(new System.IO.StringReader(xmlDoc.InnerXml), settings);
}
else
{
rdr = XmlReader.Create(new System.IO.StringReader(xmlDoc.InnerXml));
}
XmlReader subrdr = null;
string Elm = "";
ArrayList ls = new ArrayList();
Dictionary<string, int> lspath = new Dictionary<string, int>();
List<string> DeParams = new List<string>();
while (rdr.Read())
{
if (rdr.NodeType == XmlNodeType.Element)
{
Elm = rdr.Name;
if (ls.Count <= rdr.Depth)
ls.Add(Elm);
else
ls[rdr.Depth] = Elm;
foreach (var p in DeParams)
{
if (p == rdr.Name)
{
subrdr = rdr.ReadSubtree();
subrdr.ReadToFollowing(p);
returnDict.Add(new XmlNodeItem("AllDescOf" + p, subrdr.ReadInnerXml(), "/" + string.Join("/", ls.ToArray().Take(rdr.Depth))));
subrdr = null;
}
}
}
if (rdr.NodeType == XmlNodeType.Text)
{
// soup req contains sub xml, so parse them
if (rdr.Value.StartsWith("<?xml"))
{
XmlDoreplacedent xmlnDoc = new XmlDoreplacedent();
xmlnDoc.LoadXml(rdr.Value);
GetXMLNodesItems(xmlnDoc);
}
else
{
if (!lspath.Keys.Contains("/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm))
{
returnDict.Add(new XmlNodeItem(Elm, rdr.Value, "/" + string.Join("/", ls.ToArray().Take(rdr.Depth))));
lspath.Add("/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm, 0);
}
else if (lspath.Keys.Contains("/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm))
{
returnDict.Add(new XmlNodeItem(Elm + "_" + lspath["/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm], rdr.Value, "/" + string.Join("/", ls.ToArray().Take(rdr.Depth))));
lspath["/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm]++;
}
}
}
}
return returnDict;
}
19
Source : General.cs
with Apache License 2.0
from Ginger-Automation
with Apache License 2.0
from Ginger-Automation
public static List<XmlNodeItem> GetXMLNodesItems(XmlDoreplacedent xmlDoc)
{
List<XmlNodeItem> returnDict = new List<XmlNodeItem>();
XmlReader rdr1 = XmlReader.Create(new System.IO.StringReader(xmlDoc.InnerXml));
XmlReader rdr = XmlReader.Create(new System.IO.StringReader(xmlDoc.InnerXml));
XmlReader subrdr = null;
string Elm = "";
ArrayList ls = new ArrayList();
Dictionary<string, int> lspath = new Dictionary<string, int>();
List<string> DeParams = new List<string>();
while (rdr.Read())
{
if (rdr.NodeType == XmlNodeType.Element)
{
Elm = rdr.Name;
if (ls.Count <= rdr.Depth)
ls.Add(Elm);
else
ls[rdr.Depth] = Elm;
foreach (var p in DeParams)
{
if (p == rdr.Name)
{
subrdr = rdr.ReadSubtree();
subrdr.ReadToFollowing(p);
returnDict.Add(new XmlNodeItem("AllDescOf" + p, subrdr.ReadInnerXml(), "/" + string.Join("/", ls.ToArray().Take(rdr.Depth))));
subrdr = null;
}
}
}
if (rdr.NodeType == XmlNodeType.Text)
{
// soup req contains sub xml, so parse them
if (rdr.Value.StartsWith("<?xml"))
{
XmlDoreplacedent xmlnDoc = new XmlDoreplacedent();
xmlnDoc.LoadXml(rdr.Value);
GetXMLNodesItems(xmlnDoc);
}
else
{
if (!lspath.Keys.Contains("/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm))
{
returnDict.Add(new XmlNodeItem(Elm, rdr.Value, "/" + string.Join("/", ls.ToArray().Take(rdr.Depth))));
lspath.Add("/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm, 0);
}
else if (lspath.Keys.Contains("/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm))
{
returnDict.Add(new XmlNodeItem(Elm + "_" + lspath["/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm], rdr.Value, "/" + string.Join("/", ls.ToArray().Take(rdr.Depth))));
lspath["/" + string.Join("/", ls.ToArray().Take(rdr.Depth)) + "/" + Elm]++;
}
}
}
}
return returnDict;
}
19
Source : LevelImporterV1.cs
with GNU General Public License v3.0
from Gota7
with GNU General Public License v3.0
from Gota7
protected virtual void ReadLevelSettingsFromXML(XmlReader reader, Level level)
{
LevelSettings levelSettings = new LevelSettings();
while (reader.Read())
{
reader.MoveToContent();
if (reader.NodeType.Equals(XmlNodeType.Element))
{
if (reader.LocalName.Equals("ObjectBankSettings"))
{
ReadObjectBankSettings(reader.ReadSubtree(), levelSettings);
}
else if (reader.LocalName.Equals("LevelModel"))
{
ReadFileFromXML(reader, "LevelModel", level.m_LevelSettings.BMDFileID);
levelSettings.BMDFileID = level.m_LevelSettings.BMDFileID;
}
else if (reader.LocalName.Equals("CollisionMap"))
{
ReadFileFromXML(reader, "CollisionMap", level.m_LevelSettings.KCLFileID);
levelSettings.KCLFileID = level.m_LevelSettings.KCLFileID;
}
else if (reader.LocalName.Equals("MinimapSettings"))
{
ReadMinimapSettings(reader.ReadSubtree(), level, levelSettings);
}
else if (reader.LocalName.Equals("NumberOfAreas"))
{
level.m_NumAreas = byte.Parse(reader.ReadElementContentreplacedtring());
}
else if (reader.LocalName.Equals("CameraStartZoomedOut"))
{
levelSettings.CameraStartZoomedOut = byte.Parse(reader.ReadElementContentreplacedtring());
}
else if (reader.LocalName.Equals("Background"))
{
levelSettings.Background = byte.Parse(reader.ReadElementContentreplacedtring());
levelSettings.QuestionMarks = 0xF;
}
else if (reader.LocalName.Equals("Music"))
{
ReadMusicBytes(reader.ReadSubtree(), levelSettings);
}
else if (reader.LocalName.Equals("ActSelectorID"))
{
levelSettings.ActSelectorID = byte.Parse(reader.ReadElementContentreplacedtring());
}
}
else if (reader.NodeType.Equals(XmlNodeType.EndElement))
{
if (reader.LocalName.Equals("LevelSettings"))
{
level.m_LevelSettings = levelSettings;
break;
}
}
}
}
19
Source : AniDbSeriesProvider.cs
with GNU General Public License v2.0
from jellyfin-archive
with GNU General Public License v2.0
from jellyfin-archive
private async Task FetchSeriesInfo(MetadataResult<Series> result, string seriesDataPath, string preferredMetadataLangauge)
{
var series = result.Item;
var settings = new XmlReaderSettings
{
Async = true,
CheckCharacters = false,
IgnoreProcessingInstructions = true,
IgnoreComments = true,
ValidationType = ValidationType.None
};
using (var streamReader = File.Open(seriesDataPath, FileMode.Open, FileAccess.Read))
using (var reader = XmlReader.Create(streamReader, settings))
{
await reader.MoveToContentAsync().ConfigureAwait(false);
while (await reader.ReadAsync().ConfigureAwait(false))
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "startdate":
var val = await reader.ReadElementContentreplacedtringAsync().ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(val))
{
if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out DateTime date))
{
date = date.ToUniversalTime();
series.PremiereDate = date;
}
}
break;
case "enddate":
var endDate = await reader.ReadElementContentreplacedtringAsync().ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(endDate))
{
if (DateTime.TryParse(endDate, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out DateTime date))
{
date = date.ToUniversalTime();
series.EndDate = date;
}
}
break;
case "replacedles":
using (var subtree = reader.ReadSubtree())
{
var replacedle = await Parsereplacedle(subtree, preferredMetadataLangauge).ConfigureAwait(false);
if (!string.IsNullOrEmpty(replacedle))
{
series.Name = Plugin.Instance.Configuration.AniDbReplaceGraves
? replacedle.Replace('`', '\'')
: replacedle;
}
}
break;
case "creators":
using (var subtree = reader.ReadSubtree())
{
await ParseCreators(result, subtree).ConfigureAwait(false);
}
break;
case "description":
series.Overview = ReplaceLineFeedWithNewLine(
StripAniDbLinks(
await reader.ReadElementContentreplacedtringAsync().ConfigureAwait(false)));
break;
case "ratings":
using (var subtree = reader.ReadSubtree())
{
ParseRatings(series, subtree);
}
break;
case "resources":
using (var subtree = reader.ReadSubtree())
{
await ParseResources(series, subtree).ConfigureAwait(false);
}
break;
case "characters":
using (var subtree = reader.ReadSubtree())
{
await ParseActors(result, subtree).ConfigureAwait(false);
}
break;
case "tags":
using (var subtree = reader.ReadSubtree())
{
await ParseTags(series, subtree).ConfigureAwait(false);
}
break;
case "episodes":
using (var subtree = reader.ReadSubtree())
{
await ParseEpisodes(series, subtree).ConfigureAwait(false);
}
break;
}
}
}
}
GenreHelper.CleanupGenres(series);
}
19
Source : AniDbSeriesProvider.cs
with GNU General Public License v2.0
from jellyfin-archive
with GNU General Public License v2.0
from jellyfin-archive
private async Task ParseEpisodes(Series series, XmlReader reader)
{
while (await reader.ReadAsync().ConfigureAwait(false))
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "episode")
{
if (int.TryParse(reader.GetAttribute("id"), out int id) && IgnoredTagIds.Contains(id))
{
continue;
}
using (var episodeSubtree = reader.ReadSubtree())
{
while (await episodeSubtree.ReadAsync().ConfigureAwait(false))
{
if (episodeSubtree.NodeType == XmlNodeType.Element)
{
switch (episodeSubtree.Name)
{
case "epno":
//var epno = episodeSubtree.ReadElementContentreplacedtring();
//EpisodeInfo info = new EpisodeInfo();
//info.AnimeSeriesIndex = series.AnimeSeriesIndex;
//info.IndexNumberEnd = string(epno);
//info.SeriesProviderIds.GetOrDefault(ProviderNames.AniDb);
//episodes.Add(info);
break;
}
}
}
}
}
}
}
19
Source : AniDbSeriesProvider.cs
with GNU General Public License v2.0
from jellyfin-archive
with GNU General Public License v2.0
from jellyfin-archive
private async Task ParseTags(Series series, XmlReader reader)
{
var genres = new List<GenreInfo>();
while (await reader.ReadAsync().ConfigureAwait(false))
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "tag")
{
if (!int.TryParse(reader.GetAttribute("weight"), out int weight) || weight < 400)
{
continue;
}
if (int.TryParse(reader.GetAttribute("id"), out int id) && IgnoredTagIds.Contains(id))
{
continue;
}
if (int.TryParse(reader.GetAttribute("parentid"), out int parentId)
&& IgnoredTagIds.Contains(parentId))
{
continue;
}
using (var tagSubtree = reader.ReadSubtree())
{
while (await tagSubtree.ReadAsync().ConfigureAwait(false))
{
if (tagSubtree.NodeType == XmlNodeType.Element && tagSubtree.Name == "name")
{
var name = await tagSubtree.ReadElementContentreplacedtringAsync().ConfigureAwait(false);
genres.Add(new GenreInfo { Name = name, Weight = weight });
}
}
}
}
}
series.Genres = genres.OrderBy(g => g.Weight).Select(g => g.Name).ToArray();
}
19
Source : AniDbSeriesProvider.cs
with GNU General Public License v2.0
from jellyfin-archive
with GNU General Public License v2.0
from jellyfin-archive
private async Task ParseActors(MetadataResult<Series> series, XmlReader reader)
{
while (await reader.ReadAsync().ConfigureAwait(false))
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "character")
{
using (var subtree = reader.ReadSubtree())
{
await ParseActor(series, subtree).ConfigureAwait(false);
}
}
}
}
}
19
Source : SSRSEnumerator.cs
with Microsoft Public License
from keif888
with Microsoft Public License
from keif888
private void Enumerate2005Server(SSRS2005.ReportingService2005 reportingServer2005, String path, bool recursive)
{
byte[] reportDefinition = null;
String commandText = string.Empty;
String dsName = string.Empty;
String sdsName = string.Empty;
int reportID = -1;
int dsID = -1;
SSRS2005.DataSourceDefinition dsDef;
SSRS2005.DataSource[] dsArray;
Dictionary<String, int> dsNameToRepository = new Dictionary<string, int>();
// Get the array of items that are in the location that has been requested.
SSRS2005.CatalogItem[] items = reportingServer2005.ListChildren(path, recursive);
// Step through the items.
foreach (SSRS2005.CatalogItem item in items)
{
dsNameToRepository.Clear();
#region item.TypeName = Report
if (item.Type == SSRS2005.ItemTypeEnum.Report)
{
Console.WriteLine(string.Format("replacedysing Report {0}", item.Name));
reportID = repository.AddObject(item.Path, item.Name, ReportEnumerator.ObjectTypes.Report, reportServerID);
reportDefinition = reportingServer2005.GetReportDefinition(item.Path);
dsArray = reportingServer2005.GereplacedemDataSources(item.Path);
foreach (SSRS2005.DataSource ds in dsArray)
{
if (ds.Item is SSRS2005.DataSourceReference)
{
dsNameToRepository.Add(ds.Name, HandleDataSource(reportingServer2005, ((SSRS2005.DataSourceReference)ds.Item).Reference));
}
else if (ds.Item is SSRS2005.DataSourceDefinition)
{
dsNameToRepository.Add(ds.Name, HandleDataSource(((SSRS2005.DataSourceDefinition)ds.Item).ConnectString, ds.Name));
}
}
using (var stream = new MemoryStream(reportDefinition))
{
using (var xmlreader = new XmlTextReader(stream))
{
xmlreader.MoveToContent();
if (xmlreader.ReadToDescendant("DataSet"))
{
do
{
XmlReader dsReader = xmlreader.ReadSubtree();
dsReader.MoveToContent();
if (dsReader.IsStartElement("DataSet"))
{
dsReader.ReadStartElement();
dsReader.MoveToContent();
}
if (dsReader.IsStartElement("Query"))
{
while (dsReader.ReadToDescendant("DataSourceName"))
{
dsName = dsReader.ReadString();
dsID = -1;
if (!dsNameToRepository.TryGetValue(dsName, out dsID))
{
Console.WriteLine(string.Format("Unable to locate DataSourceName {0} Using First Value", dsName));
dsID = dsNameToRepository.ElementAt(0).Value;
}
}
while (dsReader.ReadToNextSibling("CommandText"))
{
commandText = dsReader.ReadString();
}
if (dsID != -1)
{
ParseTSqlStatement(commandText, dsID, reportID);
}
}
else if (dsReader.IsStartElement("Fields"))
{
dsReader.ReadInnerXml();
if (dsReader.IsStartElement("Query"))
{
while (dsReader.ReadToDescendant("DataSourceName"))
{
dsName = dsReader.ReadString();
dsID = -1;
if (!dsNameToRepository.TryGetValue(dsName, out dsID))
{
Console.WriteLine(string.Format("Unable to locate DataSourceName {0} Using First Value", dsName));
dsID = dsNameToRepository.ElementAt(0).Value;
}
}
while (dsReader.ReadToNextSibling("CommandText"))
{
commandText = dsReader.ReadString();
}
if (dsID != -1)
{
ParseTSqlStatement(commandText, dsID, reportID);
}
}
}
else
{
while (dsReader.ReadToDescendant("SharedDataSetReference"))
{
sdsName = dsReader.ReadString();
dsID = repository.GetDataSet(sdsName, reportServerID);
if (!repository.DoesMappingExist(dsID, reportID))
repository.AddMapping(dsID, reportID);
dsID = -1;
}
}
}
while (xmlreader.ReadToFollowing("DataSet"));
}
}
}
}
#endregion
else if (item.Type == SSRS2005.ItemTypeEnum.DataSource)
{
HandleDataSource(reportingServer2005, item.Path);
}
}
}
19
Source : SSRSEnumerator.cs
with Microsoft Public License
from keif888
with Microsoft Public License
from keif888
private void Enumerate2010Server(SSRS2010.ReportingService2010 reportingServer2010, String path, bool recursive)
{
byte[] reportDefinition = null;
String commandText = string.Empty;
String dsName = string.Empty;
String sdsName = string.Empty;
int reportID = -1;
int dsID = -1;
SSRS2010.DataSourceDefinition dsDef;
SSRS2010.DataSource[] dsArray;
Dictionary<String, int> dsNameToRepository = new Dictionary<string, int>();
// Get the array of items that are in the location that has been requested.
SSRS2010.CatalogItem[] items = reportingServer2010.ListChildren(path, recursive);
// Step through the items.
foreach (SSRS2010.CatalogItem item in items)
{
dsNameToRepository.Clear();
#region item.TypeName = Report
if (item.TypeName == "Report")
{
Console.WriteLine(string.Format("replacedysing Report {0}", item.Name));
reportID = repository.AddObject(item.Path, item.Name, ReportEnumerator.ObjectTypes.Report, reportServerID);
reportDefinition = reportingServer2010.GereplacedemDefinition(item.Path);
dsArray = reportingServer2010.GereplacedemDataSources(item.Path);
foreach (SSRS2010.DataSource ds in dsArray)
{
if (ds.Item is SSRS2010.DataSourceReference)
{
dsNameToRepository.Add(ds.Name, HandleDataSource(reportingServer2010, ((SSRS2010.DataSourceReference)ds.Item).Reference));
}
else if (ds.Item is SSRS2010.DataSourceDefinition)
{
if (!String.IsNullOrEmpty(((SSRS2010.DataSourceDefinition)ds.Item).ConnectString)) // Don't create if there is an empty Connection String.
dsNameToRepository.Add(ds.Name, HandleDataSource(((SSRS2010.DataSourceDefinition)ds.Item).ConnectString, ds.Name));
}
else if (ds.Item is SSRS2010.InvalidDataSourceReference)
{
dsNameToRepository.Add(ds.Name, HandleDataSource(String.Empty, ds.Name));
}
}
using (var stream = new MemoryStream(reportDefinition))
{
using (var xmlreader = new XmlTextReader(stream))
{
xmlreader.MoveToContent();
// Find any DataSources
if (xmlreader.ReadToDescendant("DataSource"))
{
do
{
XmlReader dsReader = xmlreader.ReadSubtree();
dsReader.MoveToContent();
if (dsReader.IsStartElement("DataSource"))
{
dsName = dsReader.GetAttribute("Name");
while (dsReader.ReadToDescendant("ConnectString"))
{
String connectionString = dsReader.ReadString();
if (String.IsNullOrEmpty(connectionString))
connectionString = String.Empty;
if (!dsNameToRepository.TryGetValue(dsName, out dsID))
{
Console.WriteLine(string.Format("Unable to locate DataSourceName {0} Using First Value", dsName));
dsNameToRepository.Add(dsName, HandleDataSource(connectionString, dsName));
}
}
}
}
while (xmlreader.ReadToFollowing("DataSource"));
}
}
}
using (var stream = new MemoryStream(reportDefinition))
{
using (var xmlreader = new XmlTextReader(stream))
{
xmlreader.MoveToContent();
// Now find any DataSet.
if (xmlreader.ReadToDescendant("DataSet"))
{
do
{
XmlReader dsReader = xmlreader.ReadSubtree();
dsReader.MoveToContent();
if (dsReader.IsStartElement("DataSet"))
{
dsReader.ReadStartElement();
dsReader.MoveToContent();
}
if (dsReader.IsStartElement("Query"))
{
while (dsReader.ReadToDescendant("DataSourceName"))
{
dsName = dsReader.ReadString();
dsID = -1;
if (!dsNameToRepository.TryGetValue(dsName, out dsID))
{
Console.WriteLine(string.Format("Unable to locate DataSourceName {0} Creating with Empty Connection String", dsName));
dsNameToRepository.Add(dsName, HandleDataSource(String.Empty, dsName));
dsNameToRepository.TryGetValue(dsName, out dsID);
}
}
while (dsReader.ReadToNextSibling("CommandText"))
{
commandText = dsReader.ReadString();
}
if (dsID != -1)
{
ParseTSqlStatement(commandText, dsID, reportID);
}
}
else if (dsReader.IsStartElement("Fields"))
{
dsReader.ReadInnerXml();
if (dsReader.IsStartElement("Query"))
{
while (dsReader.ReadToDescendant("DataSourceName"))
{
dsName = dsReader.ReadString();
dsID = -1;
if (!dsNameToRepository.TryGetValue(dsName, out dsID))
{
Console.WriteLine(string.Format("Unable to locate DataSourceName {0} Using First Value", dsName));
dsID = dsNameToRepository.ElementAt(0).Value;
}
}
while (dsReader.ReadToNextSibling("CommandText"))
{
commandText = dsReader.ReadString();
}
if (dsID != -1)
{
ParseTSqlStatement(commandText, dsID, reportID);
}
}
}
else
{
while (dsReader.ReadToDescendant("SharedDataSetReference"))
{
sdsName = dsReader.ReadString();
dsID = repository.GetDataSet(sdsName, reportServerID);
if (!repository.DoesMappingExist(dsID, reportID))
repository.AddMapping(dsID, reportID);
dsID = -1;
}
}
}
while (xmlreader.ReadToFollowing("DataSet"));
}
}
}
}
#endregion
else if (item.TypeName == "DataSource")
{
HandleDataSource(reportingServer2010, item.Path);
}
else if (item.TypeName == "DataSet")
{
reportDefinition = reportingServer2010.GereplacedemDefinition(item.Path);
reportID = repository.GetDataSet(item.Path, reportServerID);
dsArray = reportingServer2010.GereplacedemDataSources(item.Path);
foreach (SSRS2010.DataSource ds in dsArray)
{
if (ds.Item is SSRS2010.DataSourceReference)
{
dsNameToRepository.Add(((SSRS2010.DataSourceReference)ds.Item).Reference, HandleDataSource(reportingServer2010, ((SSRS2010.DataSourceReference)ds.Item).Reference));
}
else if (ds.Item is SSRS2010.DataSourceDefinition)
{
dsNameToRepository.Add(ds.Name, HandleDataSource(((SSRS2010.DataSourceDefinition)ds.Item).ConnectString, ds.Name));
}
}
using (var stream = new MemoryStream(reportDefinition))
{
using (var xmlreader = new XmlTextReader(stream))
{
xmlreader.MoveToContent();
while (xmlreader.ReadToDescendant("DataSourceReference"))
{
dsName = xmlreader.ReadString();
dsID = -1;
if (!dsNameToRepository.TryGetValue(dsName, out dsID))
{
Console.WriteLine(string.Format("Unable to locate DataSourceName {0} Using First Entry", dsName));
dsID = dsNameToRepository.ElementAt(0).Value;
}
}
while (xmlreader.ReadToNextSibling("CommandText"))
{
commandText = xmlreader.ReadString();
}
if (dsID != -1)
{
ParseTSqlStatement(commandText, dsID, reportID);
}
}
}
}
}
}
19
Source : EffectLoader.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private static EffectManager ReadXMLEffects(XmlReader reader, ReadResourceCallBack callback, StreamCallBack streamCallBack, string dir)
{
var list = new List<BaseEffect>();
var manager = new EffectManager();
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "Effects":
float val = 0;
if (float.TryParse(reader.GetAttribute("FPS"), NumberStyles.Float, CultureInfo.InvariantCulture, out val))
{
manager.FPS = val;
}
else
{
manager.FPS = 60;
}
break;
case "Effect":
manager.Effects.Add(ReadXMLEffect(reader.ReadSubtree(), callback, dir));
break;
case "EffectReference":
var filepath = reader.GetAttribute("FilePath");
var parentdir = Path.GetDirectoryName(dir);
var be = ReadXMLEffect(reader.ReadSubtree(), callback, dir);
be.Filename = Path.Combine(parentdir, filepath);
list.Add(be);
manager.Effects.Add(be);
break;
}
}
}
reader.Close();
foreach (BaseEffect baseEffect in list)
{
using (Stream stream = streamCallBack(baseEffect.Filename))
{
var em = Load(stream, baseEffect.Filename, callback, streamCallBack);
if (em != null)
{
baseEffect.Effects = em.Effects;
baseEffect.FPS = em.FPS;
}
}
}
return manager;
}
19
Source : EffectLoader.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private static BaseEffect ReadXMLEffect(XmlReader reader, ReadResourceCallBack callback, string dir)
{
var effect = new BaseEffect();
EffectStateStructure lastess = null;
var set = new EffectStateRatioSet();
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "Effect":
effect.Filename = Path.Combine(dir, reader.GetAttribute("FilePath"));
callback(effect.Filename);
break;
case "State":
var ess = new EffectStateStructure();
BlendMode blendMode;
if (!Enum.TryParse<BlendMode>(reader.GetAttribute("Blend"), out blendMode))
{
blendMode = BlendMode.None;
}
ess.BlendMode = blendMode;
ess.X = float.Parse(reader.GetAttribute("X"), CultureInfo.InvariantCulture);
ess.Y = float.Parse(reader.GetAttribute("Y"), CultureInfo.InvariantCulture);
ess.Alpha = float.Parse(reader.GetAttribute("Alpha"), CultureInfo.InvariantCulture);
ess.Rotation = float.Parse(reader.GetAttribute("Rotation"), CultureInfo.InvariantCulture);
ess.ScaleX = float.Parse(reader.GetAttribute("ScaleX"), CultureInfo.InvariantCulture);
ess.ScaleY = float.Parse(reader.GetAttribute("ScaleY"), CultureInfo.InvariantCulture);
if (lastess != null)
{
set.StartState = lastess;
set.EndState = ess;
effect.Sets.Add(set.StartFrame, set);
set = new EffectStateRatioSet();
}
lastess = ess;
break;
case "RatioMakers":
set.StartFrame = int.Parse(reader.GetAttribute("StartFrame"), CultureInfo.InvariantCulture);
set.EndFrame = int.Parse(reader.GetAttribute("EndFrame"), CultureInfo.InvariantCulture);
ReadXMLRatioMakers(reader.ReadSubtree(), set);
break;
case "BezierPositions":
ReadXMLBezierPositions(reader.ReadSubtree(), set);
break;
}
}
}
effect.CheckFrameLength();
reader.Close();
return effect;
}
19
Source : EffectLoader.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private static EffectManager LoadEffect(Stream stream, ReadResourceCallBack callback, StreamCallBack streamCallBack, string dir)
{
var reader = XmlReader.Create(stream);
while (reader.Read())
{
if (reader.IsStartElement())
{
if (reader.Name == "Effects")
{
return ReadXMLEffects(reader.ReadSubtree(), callback, streamCallBack, dir);
}
}
}
reader.Close();
return null;
}
19
Source : Engine.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private KeyValuePair<FlowSourceObjectBase, KeyValuePair<string, string>[]>[] LoadSync(Stream stream, FlowSourceManager manager)
{
var reader = XmlReader.Create(stream);
KeyValuePair<FlowSourceObjectBase, KeyValuePair<string, string>[]>[] defaultValues = null;
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "Sources":
defaultValues = ReadSources(reader.ReadSubtree(), manager);
break;
case "Flows":
ReadFlows(reader.ReadSubtree(), manager);
break;
case "Scope":
ReadScopes(reader.ReadSubtree(), manager);
break;
}
}
}
reader.Close();
return defaultValues;
}
19
Source : Form1.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private void ReadKeySettingFromXml()
{
var reader = XmlReader.Create(keyConfigFileName, new XmlReaderSettings());
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.LocalName)
{
case "KeyConfigs":
keyConfigs.Clear();
break;
case "KeyConfig":
var keyConfig = new KeyConfig
{
Name = reader.GetAttribute("Name")
};
AddKeyConfig(keyConfig);
ReadKeySetting(reader.ReadSubtree(), keyConfig);
break;
}
}
}
reader.Close();
if (keyConfigs.Count == 0)
{
AddKeyConfig(new KeyConfig());
}
}
19
Source : Engine.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private KeyValuePair<FlowSourceObjectBase, KeyValuePair<string, string>[]>[] ReadSources(XmlReader reader, FlowSourceManager manager)
{
var ret = new List<KeyValuePair<FlowSourceObjectBase, KeyValuePair<string, string>[]>>();
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "Source":
var fullName = reader.GetAttribute("FullName");
var ID = int.Parse(reader.GetAttribute("ID"), CultureInfo.InvariantCulture);
var scopeId = ParseId(reader.GetAttribute("ScopeID"));
var source = FlowSourceObjectManager.CreateSource(fullName);
if (source == null)
{
throw new ArgumentException(String.Format("{0} not found", fullName));
}
source.Id = ID;
source.ScopeId = scopeId;
var defaultValues = ReadValues(reader.ReadSubtree(), source);
ret.Add(new KeyValuePair<FlowSourceObjectBase, KeyValuePair<string, string>[]>(source, defaultValues));
manager.AddFlowSourceObject(source);
break;
}
}
}
reader.Close();
return ret.ToArray();
}
19
Source : FeedPanel.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private void InnerGetList()
{
try
{
var webReq = (HttpWebRequest)HttpWebRequest.Create(@"http://projectdxxx.me/feed/FeedList.xml");
var res = (HttpWebResponse)webReq.GetResponse();
using (XmlReader reader = XmlReader.Create(res.GetResponseStream(), new XmlReaderSettings()))
{
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.LocalName)
{
case "FeedList":
ReadFeed(reader.ReadSubtree());
break;
}
}
}
}
res.Close();
feedList.Sort(Compare);
while (feedList.Count > 10)
{
feedList.RemoveAt(feedList.Count - 1);
}
}
catch
{
Error = true;
}
Loading = false;
Finished = true;
}
19
Source : KeyConfig.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private void ReadKeySettingFromXml(string fileName)
{
var reader = XmlReader.Create(fileName, new XmlReaderSettings());
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.LocalName)
{
case "KeyConfigs":
keyConfigs.Clear();
break;
case "KeyConfig":
var keyConfig = new KeyConfig
{
Name = reader.GetAttribute("Name")
};
keyConfigs.Add(keyConfig);
ReadKeySetting(reader.ReadSubtree(), keyConfig);
break;
}
}
}
reader.Close();
if (keyConfigs.Count == 0)
{
keyConfigs.Add(new KeyConfig());
}
}
19
Source : BackGroundDisplay.cs
with Apache License 2.0
from KHCmaster
with Apache License 2.0
from KHCmaster
private void Read()
{
if (File.Exists(filePath))
{
var reader = XmlReader.Create(filePath);
try
{
while (reader.Read())
{
if (reader.IsStartElement(contentElementName))
{
ReadData(reader.ReadSubtree());
}
}
}
catch
{
}
finally
{
reader.Close();
}
}
}
19
Source : Configuration.cs
with MIT License
from microsoft
with MIT License
from microsoft
public static Manifest Create(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
var configurationNode = new Manifest();
// no attributes on the root node; just process child elements
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case ArgumentsElementName:
ReadArgumentsElement(reader.ReadSubtree(), configurationNode.DefaultArguments);
break;
case OutputElementName:
configurationNode.Outputs.Add(ReadOutputElement(reader.ReadSubtree()));
break;
case RenameElementName:
ReadRenameElement(reader.ReadSubtree(), configurationNode.RenameIdentifiers);
break;
case NoRenameElementName:
ReadNoRenameElement(reader.ReadSubtree(), configurationNode.NoRenameIdentifiers);
break;
}
}
}
reader.Close();
return configurationNode;
}
19
Source : Configuration.cs
with MIT License
from microsoft
with MIT License
from microsoft
[System.Diagnostics.Codereplacedysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
private static OutputGroup ReadOutputElement(XmlReader reader)
{
var outputNode = new OutputGroup();
while (reader.Read())
{
// get the attributes
if (reader.Name == OutputElementName && reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
switch (reader.Name)
{
case PathAttributeName:
outputNode.Path = reader.Value;
break;
case EncodingAttributeName:
case EncodingAttributeShortName:
outputNode.EncodingName = reader.Value;
break;
case TypeAttributeName:
switch (reader.Value.ToUpperInvariant())
{
case "JS":
case "JAVASCRIPT":
case "JSCRIPT":
outputNode.CodeType = CodeType.JavaScript;
break;
case "CSS":
case "STYLESHEET":
case "STYLESHEETS":
outputNode.CodeType = CodeType.StyleSheet;
break;
}
break;
case MapPathAttributeName:
outputNode.SymbolMap = new SymbolMap()
{
Path = reader.Value
};
break;
}
}
// back to element
reader.MoveToElement();
}
// process child elements
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case ArgumentsElementName:
ReadArgumentsElement(reader.ReadSubtree(), outputNode.Arguments);
break;
case RenameElementName:
ReadRenameElement(reader.ReadSubtree(), outputNode.RenameIdentifiers);
break;
case NoRenameElementName:
ReadNoRenameElement(reader.ReadSubtree(), outputNode.NoRenameIdentifiers);
break;
case SymbolMapElementName:
outputNode.SymbolMap = ReadSymbolMapElement(reader.ReadSubtree());
break;
case ResourceElementName:
outputNode.Resources.Add(ReadResourceElement(reader.ReadSubtree()));
break;
case InputElementName:
outputNode.Inputs.Add(ReadInputElement(reader.ReadSubtree()));
break;
}
}
}
reader.Close();
return outputNode;
}
19
Source : XmlReader.cs
with MIT License
from mystborn
with MIT License
from mystborn
public TsObject read_subtree(ITsInstance inst, TsObject[] args)
{
return new XmlReader(Source.ReadSubtree());
}
19
Source : ServiceMetadataEndpointBehavior.cs
with Apache License 2.0
from OpenRIAServices
with Apache License 2.0
from OpenRIAServices
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
XmlDictionaryReader reader = this.originalMessage.GetReaderAtBodyContents();
// Write root StartElement
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
reader.ReadStartElement();
// Write QueryResult StartElement
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
// Write QueryResult content
string nodeName = reader.LocalName;
reader.Read();
while (reader.NodeType != XmlNodeType.EndElement || reader.Name != nodeName)
{
XmlReader subtree = reader.ReadSubtree();
writer.WriteNode(subtree, false);
reader.ReadEndElement();
}
// Insert metadata start
writer.WriteStartElement("Metadata");
writer.WriteAttributeString("type", "array");
// This two foreach loops are to ensure we write the return enreplacedy of the query first, then all the rest.
// This is a requirement of the RIA/JS client side implementation. If modifying this, client side needs update too.
foreach (ServiceMetadataGenerator.TypeMetadata map in ServiceMetadataGenerator.EnreplacediesMetadata)
{
if (map.Name == this.enreplacedyTypeName)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("type", "object");
map.WriteJson(writer);
writer.WriteEndElement();
break;
}
}
foreach (ServiceMetadataGenerator.TypeMetadata map in ServiceMetadataGenerator.EnreplacediesMetadata)
{
if (map.Name != this.enreplacedyTypeName)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("type", "object");
map.WriteJson(writer);
writer.WriteEndElement();
}
}
writer.WriteEndElement();
// Insert metadata end
// Close QueryResult
writer.WriteEndElement();
// Close root
writer.WriteEndElement();
}
19
Source : GraphMLSerializer.cs
with MIT License
from pelikhan
with MIT License
from pelikhan
private void ReadElements()
{
this.Reader.ReadStartElement("graph");
Dictionary<string, TVertex> vertices = new Dictionary<string, TVertex>();
// read vertices or edges
while (this.Reader.Read())
{
if (this.Reader.NodeType == XmlNodeType.Element)
{
if (this.Reader.Name == "node")
{
// get subtree
XmlReader subReader = this.Reader.ReadSubtree();
// read id
string id = this.ReadAttributeValue("id");
// create new vertex
TVertex vertex = vertexFactory.CreateVertex(id);
// read data
GraphMLSerializer<TVertex, TEdge>.DelegateCompiler.VertexAttributesReader(subReader, vertex);
// add to graph
this.VisitedGraph.AddVertex(vertex);
vertices.Add(vertex.ID, vertex);
}
else if (this.Reader.Name == "edge")
{
// get subtree
XmlReader subReader = reader.ReadSubtree();
// read id
string id = this.ReadAttributeValue("id");
string sourceid = this.ReadAttributeValue("source");
TVertex source;
if (!vertices.TryGetValue(sourceid, out source))
throw new ArgumentException("Could not find vertex " + sourceid);
string targetid = this.ReadAttributeValue("target");
TVertex target;
if (!vertices.TryGetValue(targetid, out target))
throw new ArgumentException("Could not find vertex " + targetid);
TEdge edge = this.edgeFactory.CreateEdge(id, source, target);
// read data
GraphMLSerializer<TVertex, TEdge>.DelegateCompiler.EdgeAttributesReader(subReader, edge);
this.VisitedGraph.AddEdge(edge);
}
}
}
}
19
Source : GraphMLDeserializer.cs
with MIT License
from pelikhan
with MIT License
from pelikhan
private void ReadEdge(Dictionary<string, TVertex> vertices)
{
Contract.Requires(vertices != null);
Contract.replacedert(
this.Reader.NodeType == XmlNodeType.Element &&
this.Reader.Name == "edge" &&
this.Reader.NamespaceURI == this.graphMLNamespace);
// get subtree
using (var subReader = this.Reader.ReadSubtree())
{
// read id
string id = ReadAttributeValue(this.Reader, "id");
string sourceid = ReadAttributeValue(this.Reader, "source");
TVertex source;
if (!vertices.TryGetValue(sourceid, out source))
throw new ArgumentException("Could not find vertex " + sourceid);
string targetid = ReadAttributeValue(this.Reader, "target");
TVertex target;
if (!vertices.TryGetValue(targetid, out target))
throw new ArgumentException("Could not find vertex " + targetid);
var edge = this.edgeFactory(source, target, id);
ReadDelegateCompiler.SetEdgeDefault(edge);
// read data
while (subReader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
reader.Name == "data" &&
reader.NamespaceURI == this.graphMLNamespace)
ReadDelegateCompiler.EdgeAttributesReader(subReader, this.graphMLNamespace, edge);
}
this.VisitedGraph.AddEdge(edge);
}
}
19
Source : GraphMLDeserializer.cs
with MIT License
from pelikhan
with MIT License
from pelikhan
private void ReadVertex(Dictionary<string, TVertex> vertices)
{
Contract.Requires(vertices != null);
Contract.replacedert(
this.Reader.NodeType == XmlNodeType.Element &&
this.Reader.Name == "node" &&
this.Reader.NamespaceURI == this.graphMLNamespace);
// get subtree
using (var subReader = this.Reader.ReadSubtree())
{
// read id
string id = ReadAttributeValue(this.Reader, "id");
// create new vertex
TVertex vertex = vertexFactory(id);
// apply defaults
ReadDelegateCompiler.SetVertexDefault(vertex);
// read data
while (subReader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
reader.Name == "data" &&
reader.NamespaceURI == this.graphMLNamespace)
ReadDelegateCompiler.VertexAttributesReader(subReader, this.graphMLNamespace, vertex);
}
// add to graph
this.VisitedGraph.AddVertex(vertex);
vertices.Add(id, vertex);
}
}
19
Source : SerializationExtensions.cs
with MIT License
from pelikhan
with MIT License
from pelikhan
public static TGraph DeserializeFromXml<TVertex, TEdge, TGraph>(
#if !NET20
this
#endif
XmlReader reader,
Predicate<XmlReader> graphPredicate,
Predicate<XmlReader> vertexPredicate,
Predicate<XmlReader> edgePredicate,
Func<XmlReader, TGraph> graphFactory,
Func<XmlReader, TVertex> vertexFactory,
Func<XmlReader, TEdge> edgeFactory
)
where TGraph : clreplaced, IMutableVertexAndEdgeSet<TVertex, TEdge>
where TEdge : IEdge<TVertex>
{
Contract.Requires(reader != null);
Contract.Requires(graphPredicate != null);
Contract.Requires(vertexPredicate != null);
Contract.Requires(edgePredicate != null);
Contract.Requires(graphFactory != null);
Contract.Requires(vertexFactory != null);
Contract.Requires(edgeFactory != null);
// find the graph node
TGraph g = null;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
graphPredicate(reader))
{
g = graphFactory(reader);
break;
}
}
if (g == null)
throw new ArgumentException("could not find graph node");
using (var graphReader = reader.ReadSubtree())
{
while (graphReader.Read())
{
if (graphReader.NodeType == XmlNodeType.Element)
{
if (vertexPredicate(graphReader))
{
var vertex = vertexFactory(graphReader);
g.AddVertex(vertex);
}
else if (edgePredicate(reader))
{
var edge = edgeFactory(graphReader);
g.AddEdge(edge);
}
}
}
}
return g;
}
19
Source : MainSettings.cs
with Apache License 2.0
from ProteoWizard
with Apache License 2.0
from ProteoWizard
public static MainSettings ReadXmlVersion_20_2(XmlReader reader)
{
var mainSettingsReader = reader.ReadSubtree();
mainSettingsReader.Read();
var templateFilePath = mainSettingsReader.GetAttribute(OLD_XML_TAGS.TemplateFilePath);
string zippedFilePath = null;
var dependentConfigName = mainSettingsReader.GetAttribute(OLD_XML_TAGS.DependentConfigName);
PanoramaFile templatePanoramaFile = null;
var replacedysisFolderPath = mainSettingsReader.GetAttribute(OLD_XML_TAGS.replacedysisFolderPath);
var dataFolderPath = mainSettingsReader.GetAttribute(OLD_XML_TAGS.DataFolderPath);
var annotationsFilePath = mainSettingsReader.GetAttribute(OLD_XML_TAGS.AnnotationsFilePath);
var replicateNamingPattern = mainSettingsReader.GetAttribute(OLD_XML_TAGS.ReplicateNamingPattern);
var server = DataServerInfo.ReadXmlVersion_20_2(mainSettingsReader, dataFolderPath);
//ReadDataServerXmlFields(mainSettingsReader, out Server dataServer, out string dataNamingPattern);
if (templateFilePath == null)
{
XmlUtil.ReadNextElement(mainSettingsReader, "template_file");
templateFilePath = mainSettingsReader.GetAttribute(OLD_XML_TAGS.FilePath);
zippedFilePath = mainSettingsReader.GetAttribute(OLD_XML_TAGS.ZipFilePath);
dependentConfigName = mainSettingsReader.GetAttribute(OLD_XML_TAGS.DependentConfigName);
templatePanoramaFile = PanoramaFile.ReadXmlVersion_20_2(mainSettingsReader); //ReadOldPanoramaFile(mainSettingsReader);
}
if (XmlUtil.ReadNextElement(mainSettingsReader, "data_server"))
{
server = DataServerInfo.ReadXmlVersion_20_2(mainSettingsReader, dataFolderPath);
//ReadDataServerXmlFields(mainSettingsReader, out dataServer, out dataNamingPattern);
}
var template = new SkylineTemplate(templateFilePath, zippedFilePath, dependentConfigName, templatePanoramaFile);
return new MainSettings(template, replacedysisFolderPath, false, dataFolderPath, server,
annotationsFilePath, null, replicateNamingPattern);
}
See More Examples