static void Main(string[] args) { var childBuilder = new DataBuilderChild().WithId(1).WithDescription("Child"); MyParent parent = childBuilder; MyChild child = childBuilder; Console.WriteLine(@"Parent With Id {0}", parent.Id); Console.WriteLine(@"Child With Id {0} and Desciprtion - {1}", child.Id, child.Description); Console.ReadKey(); }
private void _control_OnExit(UserControl sender) { if (sender == _control) { // Or if you have a collection remove the sender like // _controls.Remove(sender); _control = null; _content.Content = null; } }
internal override Item GetItem(IServiceProvider services) { var item = MyChild.GetItem(services); var group = item as Group; if (group != null) { group.operation = Group.NOT_PREFIX + group.operation; } return(item); }
public override void Emit(FleeILGenerator ilg, IServiceProvider services) { if (object.ReferenceEquals(MyChild.ResultType, typeof(bool))) { this.EmitLogical(ilg, services); } else { MyChild.Emit(ilg, services); ilg.Emit(OpCodes.Not); } }
public override void Emit(YaleIlGenerator ilGenerator, ExpressionContext context) { if (ReferenceEquals(MyChild.ResultType, typeof(bool))) { EmitLogical(ilGenerator, context); } else { MyChild.Emit(ilGenerator, context); ilGenerator.Emit(OpCodes.Not); } }
public override void Emit(YaleIlGenerator ilGenerator, ExpressionContext context) { var resultType = ResultType; MyChild.Emit(ilGenerator, context); ImplicitConverter.EmitImplicitConvert(MyChild.ResultType, resultType, ilGenerator); var methodInfo = Utility.GetSimpleOverloadedOperator(UnaryNegation, resultType, resultType); if (methodInfo == null) { ilGenerator.Emit(OpCodes.Neg); } else { ilGenerator.Emit(OpCodes.Call, methodInfo); } }
public override void Emit(FleeILGenerator ilg, IServiceProvider services) { Type resultType = this.ResultType; MyChild.Emit(ilg, services); ImplicitConverter.EmitImplicitConvert(MyChild.ResultType, resultType, ilg); MethodInfo mi = Utility.GetSimpleOverloadedOperator("UnaryNegation", resultType, resultType); if (mi == null) { ilg.Emit(OpCodes.Neg); } else { ilg.Emit(OpCodes.Call, mi); } }
public void Inferrence() { // hide var client = TestClient.GetInMemoryClient(c => c.DisableDirectStreaming().PrettyJson()); var infer = client.Infer; var parent = new MyParent { Id = 1337, MyJoinField = JoinField.Root <MyParent>() }; infer.Routing(parent).Should().Be("1337"); var child = new MyChild { Id = 1338, MyJoinField = JoinField.Link <MyChild>(parentId: "1337") }; infer.Routing(child).Should().Be("1337"); child = new MyChild { Id = 1339, MyJoinField = JoinField.Link <MyChild, MyParent>(parent) }; infer.Routing(child).Should().Be("1337"); /** * here we index `parent` and rather than fishing out the parent id by inspecting `parent` we just pass the instance * to `Routing` which can infer the correct routing key based on the JoinField property on the instance */ var indexResponse = client.Index(parent, i => i.Routing(Routing.From(parent))); indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337"); /** * The same goes for when we index a child, we can pass the instance directly to `Routing` and NEST will use the parent id * already specified on `child`. Here we use the static import `using static Nest.Infer` and it's `Route()` static method to * create an instance of `Routing` */ indexResponse = client.Index(child, i => i.Routing(Route(child))); indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337"); /** Wouldn't be handy if NEST does this automatically? It does! */ indexResponse = client.IndexDocument(child); indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337"); /** You can always override the default inferred routing though */ indexResponse = client.Index(child, i => i.Routing("explicit")); indexResponse.ApiCall.Uri.Query.Should().Contain("routing=explicit"); indexResponse = client.Index(child, i => i.Routing(null)); indexResponse.ApiCall.Uri.Query.Should().NotContain("routing"); /** * This works for both the fluent and object initializer syntax */ var indexRequest = new IndexRequest <MyChild>(child); indexResponse = client.Index(indexRequest); indexResponse.ApiCall.Uri.Query.Should().Contain("routing=1337"); /** * Its important to note that the routing is resolved at request time, not instantation time * here we update the `child`'s `JoinField` after already creating the index request for `child` */ child.MyJoinField = JoinField.Link <MyChild>(parentId: "something-else"); indexResponse = client.Index(indexRequest); indexResponse.ApiCall.Uri.Query.Should().Contain("routing=something-else"); }
private void EmitLogical(FleeILGenerator ilg, IServiceProvider services) { MyChild.Emit(ilg, services); ilg.Emit(OpCodes.Ldc_I4_0); ilg.Emit(OpCodes.Ceq); }
public static void TestMain() { MyChild c = new MyChild("child", 1); System.Console.WriteLine("child value:" + c); }
public MyApplication() { IpAdress = "ip adress test"; Child = new MyChild(this, ""); }
static void Main(string[] args) { var c = new MyChild(); }
private void EmitLogical(YaleIlGenerator ilg, ExpressionContext context) { MyChild.Emit(ilg, context); ilg.Emit(OpCodes.Ldc_I4_0); ilg.Emit(OpCodes.Ceq); }
private void Button_Click(object sender, RoutedEventArgs e) { _control = new MyChild(); _control.OnExit += _control_OnExit; // Subscribe to event so you can remove the child when it exits _content.Content = _control; // _content is a ContentControl defined in Window.xaml }
public MyObject() { Child = new MyChild(); }