本文整理汇总了C#中System.Xaml.XamlSchemaContext类的典型用法代码示例。如果您正苦于以下问题:C# XamlSchemaContext类的具体用法?C# XamlSchemaContext怎么用?C# XamlSchemaContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XamlSchemaContext类属于System.Xaml命名空间,在下文中一共展示了XamlSchemaContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WpfKnownType
public WpfKnownType(XamlSchemaContext schema,
int bamlNumber,
string name,
Type underlyingType)
: this(schema, bamlNumber, name, underlyingType, true, true)
{
}
示例2: XamlObjectWriter
public XamlObjectWriter (XamlSchemaContext schemaContext, XamlObjectWriterSettings settings)
{
if (schemaContext == null)
throw new ArgumentNullException ("schemaContext");
this.sctx = schemaContext;
this.settings = settings ?? new XamlObjectWriterSettings ();
}
示例3: ReadWriteListShouldRoundtrip
public void ReadWriteListShouldRoundtrip()
{
var sc = new XamlSchemaContext();
var list = new XamlNodeList(sc);
var reader = new XamlObjectReader(new TestClass4 { Foo = "foo", Bar = "bar" }, sc);
XamlServices.Transform(reader, list.Writer);
var writer = new XamlObjectWriter(sc);
var listReader = list.GetReader();
XamlServices.Transform(listReader, writer);
Assert.IsNotNull(writer.Result, "#1");
Assert.IsInstanceOf<TestClass4>(writer.Result, "#2");
Assert.AreEqual("foo", ((TestClass4)writer.Result).Foo, "#3");
Assert.AreEqual("bar", ((TestClass4)writer.Result).Bar, "#4");
// try reading a 2nd time, we should not get the same reader
writer = new XamlObjectWriter(sc);
var listReader2 = list.GetReader();
Assert.AreNotSame(listReader, listReader2, "#5");
XamlServices.Transform(listReader2, writer);
Assert.IsNotNull(writer.Result, "#6");
Assert.IsInstanceOf<TestClass4>(writer.Result, "#7");
Assert.AreEqual("foo", ((TestClass4)writer.Result).Foo, "#8");
Assert.AreEqual("bar", ((TestClass4)writer.Result).Bar, "#9");
}
示例4: 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;
}
}
示例5: XamlWriterInternalBase
public XamlWriterInternalBase (XamlSchemaContext schemaContext, XamlWriterStateManager manager)
{
this.sctx = schemaContext;
this.manager = manager;
var p = new PrefixLookup (sctx) { IsCollectingNamespaces = true }; // it does not raise unknown namespace error.
service_provider = new ValueSerializerContext (p, schemaContext, AmbientProvider);
}
示例6: ReaderDelegate
public ReaderDelegate(XamlSchemaContext schemaContext, XamlNodeNextDelegate next, bool hasLineInfo) : base(schemaContext)
{
this._nextDelegate = next;
base._currentNode = new XamlNode(XamlNode.InternalNodeType.StartOfStream);
base._currentLineInfo = null;
base._hasLineInfo = hasLineInfo;
}
示例7: XamlNsReplacingType
public XamlNsReplacingType(Type underlyingType, XamlSchemaContext context, string localAssemblyName, string realAssemblyName)
: base(underlyingType, context)
{
this.localAssemblyName = localAssemblyName;
this.realAssemblyName = realAssemblyName;
namespaces = null;
}
示例8: XamlObjectReader
public XamlObjectReader (object instance, XamlSchemaContext schemaContext, XamlObjectReaderSettings settings)
{
if (schemaContext == null)
throw new ArgumentNullException ("schemaContext");
// FIXME: special case? or can it be generalized? In .NET, For Type instance Instance returns TypeExtension at root StartObject, while for Array it remains to return Array.
if (instance is Type)
instance = new TypeExtension ((Type) instance);
// See also Instance property for this weirdness.
this.root_raw = instance;
instance = TypeExtensionMethods.GetExtensionWrapped (instance);
this.root = instance;
sctx = schemaContext;
// this.settings = settings;
// check type validity. Note that some checks also needs done at Read() phase. (it is likely FIXME:)
if (instance != null) {
var type = new InstanceContext (instance).GetRawValue ().GetType ();
if (!type.IsPublic)
throw new XamlObjectReaderException (String.Format ("instance type '{0}' must be public and non-nested.", type));
var xt = SchemaContext.GetXamlType (type);
if (xt.ConstructionRequiresArguments && !xt.GetConstructorArguments ().Any () && xt.TypeConverter == null)
throw new XamlObjectReaderException (String.Format ("instance type '{0}' has no default constructor.", type));
}
value_serializer_context = new ValueSerializerContext (new PrefixLookup (sctx), sctx, null);
new XamlObjectNodeIterator (instance, sctx, value_serializer_context).PrepareReading ();
}
示例9: GetFirstAmbientValue
public AmbientPropertyValue GetFirstAmbientValue(IEnumerable<XamlType> ceilingTypes, params XamlMember[] properties)
{
var context = new XamlSchemaContext();
var type = context.GetXamlType(typeof (Setter));
var member = type.GetMember("TargetType");
return new AmbientPropertyValue(member, typeof (Button));
}
示例10: 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;
}
}
示例11: XamlObjectReader
public XamlObjectReader (object instance, XamlSchemaContext schemaContext, XamlObjectReaderSettings settings)
{
if (schemaContext == null)
throw new ArgumentNullException ("schemaContext");
// FIXME: special case? or can it be generalized? In .NET, For Type instance Instance returns TypeExtension at root StartObject, while for Array it remains to return Array.
if (instance is Type)
instance = new TypeExtension ((Type) instance);
this.root = instance;
sctx = schemaContext;
this.settings = settings;
prefix_lookup = new PrefixLookup (sctx);
// check type validity. Note that some checks also needs done at Read() phase. (it is likely FIXME:)
if (instance != null) {
var type = new InstanceContext (instance).GetWrappedValue ().GetType ();
if (!type.IsPublic)
throw new XamlObjectReaderException (String.Format ("instance type '{0}' must be public and non-nested.", type));
var xt = SchemaContext.GetXamlType (type);
if (xt.ConstructionRequiresArguments && !xt.GetConstructorArguments ().Any () && xt.TypeConverter == null)
throw new XamlObjectReaderException (String.Format ("instance type '{0}' has no default constructor.", type));
}
new XamlObjectNodeIterator (instance, sctx, prefix_lookup).CollectNamespaces ();
}
示例12: XamlNodeQueue
public XamlNodeQueue (XamlSchemaContext schemaContext)
{
if (schemaContext == null)
throw new ArgumentNullException ("schemaContext");
this.ctx = schemaContext;
reader = new XamlNodeQueueReader (this);
writer = new XamlNodeQueueWriter (this);
}
示例13: XamlObjectWriter
public XamlObjectWriter(XamlSchemaContext schemaContext, XamlObjectWriterSettings settings)
{
if (schemaContext == null)
{
throw new ArgumentNullException("schemaContext");
}
this.Initialize(schemaContext, null, settings);
}
示例14: WriterShouldThrowExceptionIfNotClosed
public void WriterShouldThrowExceptionIfNotClosed()
{
var sc = new XamlSchemaContext();
var list = new XamlNodeList(sc);
list.Writer.WriteStartObject(sc.GetXamlType(typeof(TestClass4)));
list.Writer.WriteEndObject();
Assert.Throws<XamlException> (() => list.GetReader());
}
示例15: ReaderBaseDelegate
protected ReaderBaseDelegate(XamlSchemaContext schemaContext)
{
if (schemaContext == null)
{
throw new ArgumentNullException("schemaContext");
}
this._schemaContext = schemaContext;
}