Exemple #1
0
        /// <summary>
        /// Loads XAML from the specified XamlXmlReader and returns the deserialized object.  Any event handlers
        /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
        /// object.
        /// </summary>
        public static object LoadComponent(dynamic scope, DynamicOperations operations, XamlXmlReader reader) {
            var settings = new XamlObjectWriterSettings();
            settings.RootObjectInstance = scope;

            var myWriter = new DynamicWriter((object)scope, operations, reader.SchemaContext, settings);
            while (reader.Read()) {
                myWriter.WriteNode(reader);
            }

            foreach (string name in myWriter.Names) {
                object value = myWriter.RootNameScope.FindName(name);
                if (value != null) {
                    operations.SetMember((object)scope, name, value);
                }
            }
            
            return myWriter.Result;
        }
Exemple #2
0
        /// <summary>
        /// Loads XAML from the specified XamlXmlReader and returns the deserialized object.  Any event handlers
        /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
        /// object.
        /// </summary>
        public static object LoadComponent(dynamic scope, DynamicOperations operations, XamlXmlReader reader)
        {
            var settings = new XamlObjectWriterSettings();

            settings.RootObjectInstance = scope;

            var myWriter = new DynamicWriter((object)scope, operations, reader.SchemaContext, settings);

            while (reader.Read())
            {
                myWriter.WriteNode(reader);
            }

            foreach (string name in myWriter.Names)
            {
                object value = myWriter.RootNameScope.FindName(name);
                if (value != null)
                {
                    operations.SetMember((object)scope, name, value);
                }
            }

            return(myWriter.Result);
        }
Exemple #3
0
 /// <summary>
 /// Returns a string representation of the object in a language specific object display format.
 /// </summary>
 /// <param name="operations">Dynamic sites container that could be used for any dynamic dispatches necessary for formatting.</param>
 /// <param name="obj">Object to format.</param>
 /// <returns>A string representation of object.</returns>
 public virtual string FormatObject(DynamicOperations operations, object obj)
 {
     return(obj == null ? "null" : obj.ToString());
 }
Exemple #4
0
 /// <summary>
 /// Loads XAML from the specified TextReader and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, TextReader reader, XamlSchemaContext schemaContext)
 {
     return(LoadComponent((object)scope, operations, new XamlXmlReader(reader, schemaContext ?? new XamlSchemaContext())));
 }
Exemple #5
0
 /// <summary>
 /// Loads XAML from the specified filename and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, string filename, XamlSchemaContext schemaContext)
 {
     using (var file = new StreamReader(filename)) {
         return(LoadComponent((object)scope, operations, new XamlXmlReader(file, schemaContext ?? new XamlSchemaContext())));
     }
 }
Exemple #6
0
 public DynamicWriter(object scope, DynamicOperations operations, XamlSchemaContext context, XamlObjectWriterSettings settings)
     : base(context, settings)
 {
     _scope      = scope;
     _operations = operations;
 }
Exemple #7
0
 public DynamicWriter(object scope, DynamicOperations operations, XamlSchemaContext context, XamlObjectWriterSettings settings)
     : base(context, settings) {
     _scope = scope;
     _operations = operations;
 }
Exemple #8
0
 /// <summary>
 /// Loads XAML from the specified TextReader and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, TextReader reader, XamlSchemaContext schemaContext) {
     return LoadComponent((object)scope, operations, new XamlXmlReader(reader, schemaContext ?? new XamlSchemaContext()));
 }
Exemple #9
0
 /// <summary>
 /// Loads XAML from the specified filename and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, string filename, XamlSchemaContext schemaContext) {
     using (var file = new StreamReader(filename)) {
         return LoadComponent((object)scope, operations, new XamlXmlReader(file, schemaContext ?? new XamlSchemaContext()));
     }
 }
 /// <summary>
 /// Loads XAML from the specified TextReader and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, TextReader reader) {
     return LoadComponent((object)scope, operations, new XamlXmlReader(reader));
 }
 /// <summary>
 /// Loads XAML from the specified filename and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, string filename) {
     using (var file = new StreamReader(filename)) {
         return LoadComponent((object)scope, operations, new XamlXmlReader(file));
     }
 }
 /// <summary>
 /// Loads XAML from the specified stream and returns the deserialized object.  Any event handlers
 /// are bound to methods defined in the provided Scope and converted using the provided DynamicOperations
 /// object.
 /// </summary>
 public static object LoadComponent(dynamic scope, DynamicOperations operations, Stream stream) {            
     return LoadComponent((object)scope, operations, new XamlXmlReader(stream));
 }