// friend class: DynamicOperations internal ObjectOperations(DynamicOperations ops, ScriptEngine engine) { Assert.NotNull(ops); Assert.NotNull(engine); _ops = ops; _engine = engine; }
public object __exit__(CodeContext context, object exc_type, object exc_value, object exc_tb) { DynamicOperations ops = context.LanguageContext.Operations; if (exc_type == null && exc_value == null && exc_tb == null) { object commitfn; if (ops.TryGetMember(this, "commit", out commitfn)) { ops.Invoke(commitfn); } else { commit(); } } else { object rollbackfn; if (ops.TryGetMember(this, "rollback", out rollbackfn)) { ops.Invoke(rollbackfn); } else { rollback(); } } return(false); }
private void ReadOrdersButton2_Click(object sender, EventArgs e) { var ordersList = DynamicOperations.ReadOrdersStrongTyped("orders.json"); for (int index = 0; index < ordersList.Count; index++) { Console.WriteLine(ordersList[index].id); } Console.WriteLine(); var id = 234; var specificOrder = ordersList.Where(order => order.customerId == id).ToList(); for (int index = 0; index < specificOrder.Count(); index++) { Console.WriteLine(specificOrder[index].id); } }
/// <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); }
public DynamicWriter(object scope, DynamicOperations operations, XamlSchemaContext context, XamlObjectWriterSettings settings) : base(context, settings) { _scope = scope; _operations = operations; }
/// <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()))); }
/// <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()))); } }
public override string FormatObject(DynamicOperations operations, object obj) { return(base.FormatObject(operations, obj)); }
private void ReadOrdersButton1_Click(object sender, EventArgs e) { DynamicOperations.ReadOrders1A("orders.json"); }