本文整理汇总了C#中Xml类的典型用法代码示例。如果您正苦于以下问题:C# Xml类的具体用法?C# Xml怎么用?C# Xml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Xml类属于命名空间,在下文中一共展示了Xml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFromXml
static internal PipeLaunchOptions CreateFromXml(Xml.LaunchOptions.PipeLaunchOptions source)
{
var options = new PipeLaunchOptions(RequireAttribute(source.PipePath, "PipePath"), source.PipeArguments);
options.InitializeCommonOptions(source);
return options;
}
示例2: Util
public Util(Core RennderCore)
{
R = RennderCore;
Str = new Str(R);
Xml = new Xml();
Serializer = new Serializer(R);
}
示例3: Build
public static byte[] Build(Xml.FileGroupXml group, string spriteFile)
{
var bmps = group.Files.Select(x => new System.Drawing.Bitmap(x.Path));
var maxWidth = bmps.Max(x => x.Width);
var totalHeight = bmps.Sum(x => x.Height);
int top = 0;
using (var sprite = new System.Drawing.Bitmap(maxWidth, totalHeight))
using (var mem = new System.IO.MemoryStream())
using (var g = System.Drawing.Graphics.FromImage(sprite))
{
foreach (var bmp in bmps)
{
using (bmp)
{
g.DrawImage(bmp, new System.Drawing.Rectangle(0, top, bmp.Width, bmp.Height), new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.GraphicsUnit.Pixel);
top += bmp.Height;
}
}
sprite.Save(mem, GetFormat(spriteFile) ?? System.Drawing.Imaging.ImageFormat.Png);
return mem.ToArray();
}
}
示例4: createMessage
public static Xml createMessage(string type)
{
Xml ret = new Xml("msg");
ret.root.attribute("type").set(type);
return ret;
}
示例5: FollowingSiblings
public IEnumerable<Xml.IQueryableNode> FollowingSiblings(Xml.IQueryableNode node)
{
var result = node.FollowingSibling();
while (result != null)
{
yield return result;
result = result.FollowingSibling();
}
}
示例6: NuGetDependency
public NuGetDependency(Xml.NuGet.NuSpec.Dependency dependency)
: this()
{
Dependency = dependency;
_uiName.Text = Dependency.Id;
_uiVersion.Text = Dependency.Version;
_uiOriginalFramework.Text = Dependency.OriginalTargetFramework;
}
示例7: CreateCollectionFromXml
public static ReadOnlyCollection<LaunchCommand> CreateCollectionFromXml(Xml.LaunchOptions.Command[] source)
{
LaunchCommand[] commandArray = source?.Select(x => new LaunchCommand(x.Value, x.Description, x.IgnoreFailures)).ToArray();
if (commandArray == null)
{
commandArray = new LaunchCommand[0];
}
return new ReadOnlyCollection<LaunchCommand>(commandArray);
}
示例8: Xml_CData_AddsCDataNode
public void Xml_CData_AddsCDataNode()
{
var xml = new Xml();
xml.Tag("tag", Xml.Fragment(() =>
{
xml.CData("content");
xml.Tag("hello", "world");
}));
Assert.Equal("<tag><![CDATA[content]]><hello>world</hello></tag>", xml);
}
示例9: WriteSvg
internal void WriteSvg(Xml.SvgWriter w)
{
w.WriteStartElement("pressure");
w.WriteAttributeString("midiChannel", _midiChannel.ToString());
if(_inputControls != null)
{
_inputControls.WriteSvg(w);
}
w.WriteEndElement(); // trkOff
}
示例10: Xml
public Xml()
{
if (instance != null)
{
return;
}
else
{
instance = this;
}
}
示例11: Initialize
public void Initialize(Xml.XAccessor x)
{
string strHostType = x.GetStringValue(CLASS);
if (string.IsNullOrEmpty(strHostType))
ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), CLASS);
Type hostType = Reflector.LoadType(strHostType);
string memberName = x.GetStringValue(MEMBER);
if (string.IsNullOrEmpty(memberName))
ExceptionHelper.ThrowPolicyInitNullError(this.GetType(), MEMBER);
IReflector r = Reflector.Bind(hostType, ReflectorPolicy.TypePublic);
_instance = r.GetPropertyOrFieldValue(memberName, false);
}
示例12: WriteSvg
/// <summary>
/// This function only writes TrkRefs that refer to Trks stored in external VoiceDefs.
/// Note that successive Trks in the same VoiceDef may, in principle, contain common IUniqueDefs...
/// SVG files contain voice definitions that contain MidiChordDefs and restDefs, but no Trks.
/// </summary>
/// <param name="w"></param>
internal void WriteSvg(Xml.SvgWriter w)
{
w.WriteStartElement("seq");
if(TrkOptions != null)
{
TrkOptions.WriteSvg(w, false);
}
Debug.Assert(TrkRefs != null && TrkRefs.Count > 0);
foreach(TrkRef trkRef in TrkRefs)
{
trkRef.WriteSvg(w);
}
w.WriteEndElement(); // seq
}
示例13: WriteSvg
internal void WriteSvg(Xml.SvgWriter w)
{
w.WriteStartElement("pressures");
if(_inputControls != null)
{
_inputControls.WriteSvg(w);
}
Debug.Assert(_pressures != null && _pressures.Count > 0);
foreach(Pressure pressure in _pressures)
{
pressure.WriteSvg(w);
}
w.WriteEndElement(); // pressures
}
示例14: WriteSvg
internal void WriteSvg(Xml.SvgWriter w)
{
w.WriteStartElement("trkOffs");
if(_inputControls != null)
{
_inputControls.WriteSvg(w);
}
Debug.Assert(_trkOffs != null && _trkOffs.Count > 0);
foreach(TrkOff trkOff in _trkOffs)
{
trkOff.WriteSvg(w);
}
w.WriteEndElement(); // trkOffs
}
示例15: DiffReturnValues
/// <inheritdoc />
public IEnumerable<IAnalysisLogDiff> DiffReturnValues(Xml.Value oldValue, Xml.Value newValue)
{
// If both values are not null...
IEnumerable<IAnalysisLogDiff> list;
if (oldValue != null && newValue != null)
{
if (!newValue.IsComparableTo(oldValue))
{
var msg = string.Format(
"Items are incompatible for comparison! oldObject.Item.Type => {0}, newObject.Item.Type => {1}",
oldValue.UnderlyingType,
newValue.UnderlyingType);
throw new ArgumentException(msg);
}
if (newValue.IsPrimtive && oldValue.IsPrimtive && !newValue.AsPrimitive.Equals(oldValue.AsPrimitive))
{
list = new IAnalysisLogDiff[]
{
new ReturnValueAnalysisLogDiff(oldValue.AsPrimitive.Value, newValue.AsPrimitive.Value, newValue.AsPrimitive.FullName)
};
}
else if (newValue.IsObject && oldValue.IsObject)
{
list = this.DiffObjects(oldValue.AsObject, newValue.AsObject);
}
else
{
// No diff.
list = Enumerable.Empty<IAnalysisLogDiff>();
}
}
else if (oldValue == null && newValue == null)
{
// No diff.
list = Enumerable.Empty<IAnalysisLogDiff>();
}
else
{
// Either the old or new value is null. Not sure what happened here--should be impossible.
var msg = string.Format(
"The {0} return value was null! This indicates an analysis log file corruption. Terminating analysis!",
oldValue == null ? "old" : "current");
throw new ArgumentException(msg);
}
return list;
}