本文整理汇总了C#中System.Xaml.XamlReader类的典型用法代码示例。如果您正苦于以下问题:C# XamlReader类的具体用法?C# XamlReader怎么用?C# XamlReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XamlReader类属于System.Xaml命名空间,在下文中一共展示了XamlReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: XamlBackgroundReader
public XamlBackgroundReader (XamlReader wrappedReader)
{
if (wrappedReader == null)
throw new ArgumentNullException ("wrappedReader");
r = wrappedReader;
q = new XamlNodeQueue (r.SchemaContext) { LineInfoProvider = r as IXamlLineInfo };
}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:XamlBackgroundReader.cs
示例2: DynamicActivityXamlReader
public DynamicActivityXamlReader(bool isBuilder, XamlReader innerReader, XamlSchemaContext schemaContext)
: base()
{
this.isBuilder = isBuilder;
this.innerReader = innerReader;
this.schemaContext = schemaContext ?? innerReader.SchemaContext;
this.xamlTypeXamlType = this.schemaContext.GetXamlType(typeof(XamlType));
this.typeXamlType = this.schemaContext.GetXamlType(typeof(Type));
this.baseActivityXamlType = this.schemaContext.GetXamlType(typeof(Activity));
this.activityPropertyXamlType = this.schemaContext.GetXamlType(typeof(DynamicActivityProperty));
this.activityPropertyType = this.activityPropertyXamlType.GetMember("Type");
this.activityPropertyName = this.activityPropertyXamlType.GetMember("Name");
this.activityPropertyValue = this.activityPropertyXamlType.GetMember("Value");
this.activityPropertyAttributes = this.activityPropertyXamlType.GetMember("Attributes");
this.namespaceTable = new NamespaceTable();
this.frontLoadedDirectives = true;
// we pump items through this node-list when rewriting
this.nodeQueue = new XamlNodeQueue(this.schemaContext);
this.nodeReader = this.nodeQueue.Reader;
IXamlLineInfo lineInfo = innerReader as IXamlLineInfo;
if (lineInfo != null && lineInfo.HasLineInfo)
{
this.innerReaderLineInfo = lineInfo;
this.nodeReaderLineInfo = (IXamlLineInfo)nodeQueue.Reader;
this.hasLineInfo = true;
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:31,代码来源:DynamicActivityXamlReader.cs
示例3: LoadAttributeData
// We get here when we are inside x:ClassAttributes or x:Property.Attributes. We expect the first element to be the Attribute SO.
internal static AttributeData LoadAttributeData(XamlReader reader, NamespaceTable namespaceTable, string rootNamespace)
{
AttributeData attributeData = null;
reader.Read();
if (reader.NodeType == XamlNodeType.StartObject)
{
attributeData = new AttributeData { Type = reader.Type };
bool readNext = false;
while (readNext || reader.Read())
{
namespaceTable.ManageNamespace(reader);
readNext = false;
if (reader.NodeType == XamlNodeType.StartMember)
{
if (reader.Member == XamlLanguage.Arguments)
{
foreach (AttributeParameterData parameterData in ReadParameters(reader.ReadSubtree(), namespaceTable, rootNamespace))
{
attributeData.Parameters.Add(parameterData);
}
readNext = true;
}
else if (!reader.Member.IsDirective)
{
KeyValuePair<string, AttributeParameterData> propertyInfo = ReadAttributeProperty(reader.ReadSubtree(), namespaceTable, rootNamespace);
attributeData.Properties.Add(propertyInfo.Key, propertyInfo.Value);
readNext = true;
}
}
}
}
return attributeData;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:35,代码来源:AttributeData.cs
示例4: ManageNamespace
public void ManageNamespace(XamlReader reader)
{
switch (reader.NodeType)
{
case XamlNodeType.NamespaceDeclaration:
tempNamespaceList.Add(reader.Namespace.Prefix,
new NamespaceDeclaration(
XamlBuildTaskServices.UpdateClrNamespaceUriWithLocalAssembly(reader.Namespace.Namespace, this.localAssemblyName),
reader.Namespace.Prefix));
break;
case XamlNodeType.StartObject:
case XamlNodeType.StartMember:
case XamlNodeType.GetObject:
if (tempNamespaceList != null)
{
namespaceStack.Push(tempNamespaceList);
tempNamespaceList = new Dictionary<string, NamespaceDeclaration>();
}
break;
case XamlNodeType.EndMember:
case XamlNodeType.EndObject:
namespaceStack.Pop();
break;
default:
break;
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:NamespaceTable.cs
示例5: WriteNode
public void WriteNode (XamlReader reader)
{
if (reader == null)
throw new ArgumentNullException ("reader");
switch (reader.NodeType) {
case XamlNodeType.StartObject:
WriteStartObject (reader.Type);
break;
case XamlNodeType.GetObject:
WriteGetObject ();
break;
case XamlNodeType.EndObject:
WriteEndObject ();
break;
case XamlNodeType.StartMember:
WriteStartMember (reader.Member);
break;
case XamlNodeType.EndMember:
WriteEndMember ();
break;
case XamlNodeType.Value:
WriteValue (reader.Value);
break;
case XamlNodeType.NamespaceDeclaration:
WriteNamespace (reader.Namespace);
break;
default:
throw NotImplemented (); // documented behavior
}
}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:31,代码来源:XamlWriter.cs
示例6: Main
static void Main(string[] args)
{
Xaml.XamlReader reader = new Xaml.XamlReader();
Page page = (Page)reader.Load("Test.xaml");
Console.WriteLine(page.Title);
var stream = File.Open("Test.html", FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
StreamWriter writer = new StreamWriter(stream);
page.Render(writer);
//writer.Flush();
//writer.Close();
Console.ReadLine();
//XmlWriterSettings setting = new XmlWriterSettings();
//setting.Encoding = new UTF8Encoding(false);
//XmlWriter xmlWriter = XmlWriter.Create(writer, setting);
//xmlWriter.WriteStartDocument();
//xmlWriter.WriteStartElement("html");
//xmlWriter.WriteStartElement("span");
//xmlWriter.WriteString("test");
//xmlWriter.WriteEndElement();
//xmlWriter.WriteEndElement();
//xmlWriter.WriteEndDocument();
//xmlWriter.Flush();
//xmlWriter.Close();
//Console.ReadLine();
}
开发者ID:Kation,项目名称:WebPresentation,代码行数:26,代码来源:Program.cs
示例7: DynamicActivityXamlReader
public DynamicActivityXamlReader(bool isBuilder, XamlReader innerReader, XamlSchemaContext schemaContext)
{
this.isBuilder = isBuilder;
this.innerReader = innerReader;
this.schemaContext = schemaContext ?? innerReader.SchemaContext;
this.xamlTypeXamlType = this.schemaContext.GetXamlType(typeof(XamlType));
this.typeXamlType = this.schemaContext.GetXamlType(typeof(System.Type));
this.baseActivityXamlType = this.schemaContext.GetXamlType(typeof(Activity));
this.activityPropertyXamlType = this.schemaContext.GetXamlType(typeof(DynamicActivityProperty));
this.activityPropertyType = this.activityPropertyXamlType.GetMember("Type");
this.activityPropertyName = this.activityPropertyXamlType.GetMember("Name");
this.activityPropertyValue = this.activityPropertyXamlType.GetMember("Value");
this.activityPropertyAttributes = this.activityPropertyXamlType.GetMember("Attributes");
this.namespaceTable = new NamespaceTable();
this.frontLoadedDirectives = true;
this.nodeQueue = new XamlNodeQueue(this.schemaContext);
this.nodeReader = this.nodeQueue.Reader;
IXamlLineInfo info = innerReader as IXamlLineInfo;
if ((info != null) && info.HasLineInfo)
{
this.innerReaderLineInfo = info;
this.nodeReaderLineInfo = (IXamlLineInfo) this.nodeQueue.Reader;
this.hasLineInfo = true;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:DynamicActivityXamlReader.cs
示例8: ManageNamespace
public void ManageNamespace(XamlReader reader)
{
switch (reader.NodeType)
{
case XamlNodeType.StartObject:
case XamlNodeType.GetObject:
case XamlNodeType.StartMember:
this.EnterScope();
return;
case XamlNodeType.EndObject:
case XamlNodeType.EndMember:
this.ExitScope();
break;
case XamlNodeType.Value:
break;
case XamlNodeType.NamespaceDeclaration:
this.AddNamespace(reader.Namespace);
return;
default:
return;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:NamespaceTable.cs
示例9: Load
public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider)
{
IXamlObjectWriterFactory settings = serviceProvider.GetService(typeof(IXamlObjectWriterFactory)) as IXamlObjectWriterFactory;
System.Windows.Markup.IProvideValueTarget provideValueService = serviceProvider.GetService(typeof(System.Windows.Markup.IProvideValueTarget)) as System.Windows.Markup.IProvideValueTarget;
Type propertyType = null;
// IProvideValueTarget.TargetProperty can return DP, Attached Property or MemberInfo for clr property
// In this case it should always be a regular clr property here.
PropertyInfo propertyInfo = provideValueService.TargetProperty as PropertyInfo;
if (propertyInfo != null)
{
propertyType = propertyInfo.PropertyType;
}
else
{
return null;
}
object instance = Activator.CreateInstance(
typeof(FuncFactory<>).MakeGenericType(propertyType.GetGenericArguments()),
settings,
xamlReader);
return Delegate.CreateDelegate(propertyType, instance, instance.GetType().GetMethod("Evaluate"));
}
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:28,代码来源:FuncFactoryDeferringLoader.cs
示例10: ValidateXaml
public bool ValidateXaml(XamlReader xamlReader, bool failOnFirstError, string assemblyName, out IList<LogData> validationErrors)
{
if (xamlReader == null)
{
throw FxTrace.Exception.ArgumentNull("xamlReader");
}
validationErrors = null;
// We loop through the provided XAML using a XamlValidatingReader to ensure that:
// 1. XAML is valid.
// 2. All types referenced in XAML are validate-able. At this point, any types defined in the local
// assembly should be referenced, so this should be possible.
XamlValidatingReader reader = new XamlValidatingReader(xamlReader, this.localAssembly, rootNamespace, assemblyName);
reader.OnValidationError += new EventHandler<ValidationEventArgs>(reader_OnValidationError);
while (reader.Read())
{
if (this.eventArgs != null && failOnFirstError)
{
validationErrors = this.eventArgs;
return false;
}
}
validationErrors = this.eventArgs;
if (validationErrors != null && validationErrors.Count > 0)
{
return false;
}
return true;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:30,代码来源:ClassValidator.cs
示例11: Transform
// This method is a workaround for TFS bug #788190, since XamlReader.ReadSubtree() should (but doesn't) preserve IXamlLineInfo on the subreader
public static void Transform(XamlReader reader, XamlWriter writer, IXamlLineInfo readerLineInfo, bool closeWriter)
{
IXamlLineInfoConsumer consumer = writer as IXamlLineInfoConsumer;
SharedFx.Assert(consumer != null && consumer.ShouldProvideLineInfo, "Should only call this function to write into a XamlNodeQueue.Writer, which is always IXamlLineInfoConsumer");
bool shouldPassLineNumberInfo = false;
if (readerLineInfo != null)
{
shouldPassLineNumberInfo = true;
}
while (reader.Read())
{
if (shouldPassLineNumberInfo)
{
consumer.SetLineInfo(readerLineInfo.LineNumber, readerLineInfo.LinePosition);
}
writer.WriteNode(reader);
}
if (closeWriter)
{
writer.Close();
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:XamlWriterExtensions.cs
示例12: Initialize
private void Initialize(XamlReader wrappedReader, int bufferSize)
{
XamlNodeNextDelegate delegate4;
this._providerFullEvent = new EventWaitHandle(false, EventResetMode.AutoReset);
this._dataReceivedEvent = new EventWaitHandle(false, EventResetMode.AutoReset);
this._incoming = new XamlNode[bufferSize];
this._outgoing = new XamlNode[bufferSize];
this._wrappedReader = wrappedReader;
this._wrappedReaderHasLineInfo = ((IXamlLineInfo) this._wrappedReader).HasLineInfo;
XamlNodeAddDelegate add = new XamlNodeAddDelegate(this.Add);
XamlLineInfoAddDelegate addlineInfoDelegate = null;
if (this._wrappedReaderHasLineInfo)
{
addlineInfoDelegate = new XamlLineInfoAddDelegate(this.AddLineInfo);
}
this._writer = new WriterDelegate(add, addlineInfoDelegate, this._wrappedReader.SchemaContext);
if (this._wrappedReaderHasLineInfo)
{
delegate4 = new XamlNodeNextDelegate(this.Next_ProcessLineInfo);
}
else
{
delegate4 = new XamlNodeNextDelegate(this.Next);
}
this._internalReader = new ReaderDelegate(this._wrappedReader.SchemaContext, delegate4, this._wrappedReaderHasLineInfo);
this._currentNode = new XamlNode(XamlNode.InternalNodeType.StartOfStream);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:XamlBackgroundReader.cs
示例13: XamlWrappingReader
internal XamlWrappingReader(XamlReader underlyingReader)
{
if (underlyingReader == null)
{
throw FxTrace.Exception.AsError(new ArgumentNullException("underlyingReader"));
}
_underlyingReader = underlyingReader;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:8,代码来源:XamlWrappingReader.cs
示例14: Load
public static XamlDomNode Load(XamlReader xxr)
{
var ixli = xxr as IXamlLineInfo;
var dw = new XamlDomWriter(xxr.SchemaContext);
XamlServices.Transform(xxr, dw);
return dw.RootNode;
}
开发者ID:siwuxian,项目名称:WinObjC,代码行数:8,代码来源:XamlDomServices.cs
示例15: CreateReader
public static XamlReader CreateReader(XamlReader innerReader)
{
if (innerReader == null)
{
throw FxTrace.Exception.ArgumentNull("innerReader");
}
return new DynamicActivityXamlReader(innerReader);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ActivityXamlServices.cs
示例16: Load
public static Object Load (XamlReader xamlReader)
{
if (xamlReader == null)
throw new ArgumentNullException ("xamlReader");
var w = new XamlObjectWriter (xamlReader.SchemaContext);
Transform (xamlReader, w);
return w.Result;
}
开发者ID:stabbylambda,项目名称:mono,代码行数:8,代码来源:XamlServices.cs
示例17: XamlBackgroundReader
public XamlBackgroundReader(XamlReader wrappedReader)
{
if (wrappedReader == null)
{
throw new ArgumentNullException("wrappedReader");
}
this.Initialize(wrappedReader, 0x40);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:XamlBackgroundReader.cs
示例18: Load
public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider)
{
// Expects a nodestream produced by WriteNodesList
xamlReader.Read();
xamlReader.Read();
xamlReader.Read();
Fx.Assert(xamlReader.NodeType == XamlNodeType.Value, "Expected Value node");
return (XamlNodeList)xamlReader.Value;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:9,代码来源:ErrorActivity.cs
示例19: XamlSubreader
public XamlSubreader(XamlReader reader)
{
this._reader = reader;
this._lineInfoReader = reader as IXamlLineInfo;
this._done = false;
this._depth = 0;
this._firstRead = true;
this._rootIsStartMember = reader.NodeType == XamlNodeType.StartMember;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:XamlSubreader.cs
示例20: Load
public static object Load(XamlReader xamlReader)
{
if (xamlReader == null)
{
throw new ArgumentNullException("xamlReader");
}
XamlObjectWriter xamlWriter = new XamlObjectWriter(xamlReader.SchemaContext);
Transform(xamlReader, xamlWriter);
return xamlWriter.Result;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XamlServices.cs
注:本文中的System.Xaml.XamlReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论