示例#1
0
    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();
    }
示例#2
0
 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;
     }
 }
示例#3
0
        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);
        }
示例#4
0
文件: Not.cs 项目: QuickOrBeDead/Flee
 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);
     }
 }
示例#5
0
 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);
     }
 }
示例#6
0
        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);
            }
        }
示例#7
0
        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");
        }
示例#9
0
文件: Not.cs 项目: QuickOrBeDead/Flee
 private void EmitLogical(FleeILGenerator ilg, IServiceProvider services)
 {
     MyChild.Emit(ilg, services);
     ilg.Emit(OpCodes.Ldc_I4_0);
     ilg.Emit(OpCodes.Ceq);
 }
示例#10
0
        public static void TestMain()
        {
            MyChild c = new MyChild("child", 1);

            System.Console.WriteLine("child value:" + c);
        }
示例#11
0
 public MyApplication()
 {
     IpAdress = "ip adress test";
     Child    = new MyChild(this, "");
 }
示例#12
0
 static void Main(string[] args)
 {
     var c = new MyChild();
 }
示例#13
0
 private void EmitLogical(YaleIlGenerator ilg, ExpressionContext context)
 {
     MyChild.Emit(ilg, context);
     ilg.Emit(OpCodes.Ldc_I4_0);
     ilg.Emit(OpCodes.Ceq);
 }
示例#14
0
 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();
 }