示例#1
0
 public ColumnMulti <T> get <T> (TypedMultiCH <T> CH)
 {
     if (!D.ContainsKey(CH))
     {
         D[CH] = CH.SpawnColumn();
     }
     return((ColumnMulti <T>)D[CH]);
 }
示例#2
0
 public OP_SG_all_GO(TypedCH <GameObject> CH_in, TypedMultiCH <GameObject> CH_out)
 {
     this.CH_in = CH_in; this.CH_out = CH_out;
 }
示例#3
0
 public OP_SG_all_Comp(TypedCH <Component> CH_in, TypedMultiCH <GameObject> CH_out)
 {
     this.CH_in = CH_in; this.CH_out = CH_out;
 }
示例#4
0
文件: Scopes.cs 项目: elkawee/UShell
        public static void Test2_basic_scoping()
        {
            var closA = new TypedSingleCH <int>();
            var closB = new TypedMultiCH <string>();  // types and kinds don't matter

            var closedSC = new CH_closedScope()
                           .decl("cA", closA)
                           .decl("cB", closB);

            var D1 = new TypedSingleCH <int>();
            var D2 = new TypedMultiCH <string>();  // types and kinds don't matter

            TypedCH dummy1;
            TypedCH dummy2;

            var deltaCH = new CH_deltaScope(closedSC)
                          .decl("new name", D1)
                          .addRef("cA", out dummy1)
                          .addRef("new name", out dummy2);

            D.Assert(object.ReferenceEquals(dummy1, closA));
            D.Assert(object.ReferenceEquals(dummy2, D1));

            D.Assert(
                deltaCH.external_refs().Select(_ref => _ref.name).
                SequenceEqual(new [] { "cA" })                        // ref for "new name" is not external
                );

            // ----------------------------

            var deltaCH2 = new CH_deltaScope(closedSC)
                           .decl("cA", D1)
                           .decl("cA", D1)
                           .decl("cA", D1)
                           .decl("cB", D1) // shadow both, multiple "cA"s are compressed to one in LIFO_shadowed
                           .decl("cA", D2) // shadow cA again with a different target
                           .addRef("cA", out dummy1);

            var expected_names = new []        { "cA", "cB" };   // in reverse of insertion order
            var expected_chs   = new TypedCH[] { D2, D1 };       // for cA , cB resp.

            D.Assert(deltaCH2.refs().Select(r => r.name).SequenceEqual(expected_names));
            D.Assert(deltaCH2.refs().Select(r => r.CH).SequenceEqual(expected_chs));

            // -------------------------------------


            var closFunky = new TypedSingleCH <object>();


            var origSC = new CH_closedScope()
                         .decl("cA", closFunky) // never see this guy
                         .decl("cA", closA)
                         .decl("cB", closB);

            var     sh1       = new TypedMultiCH <float>();
            TypedCH sh_dummy1 = null;
            TypedCH sh_dummy2 = null;

            var shadowDelta1 = new CH_deltaScope(origSC)
                               .decl("sh1", sh1)
                               .addRef("cA", out sh_dummy1) // external ref
                               .decl("cA", sh1)
                               .addRef("cA", out sh_dummy2) // now cA is both an external and internal ref
            ;

            // cB is not touched , thus :
            // refs in order : [  "cA" -> sh_dummy2 == sh1 | "sh1" -> sh1 | "cB" -> closB ]
            //                 ["cA" -> closA == sh_dummy1] is preserved in external_refs

            D.Assert(ReferenceEquals(sh_dummy1, closA));
            D.Assert(ReferenceEquals(sh_dummy2, sh1));

            expected_names = new []        { "cA", "sh1", "cB" };
            expected_chs   = new TypedCH[] { sh1, sh1, closB };

            D.Assert(shadowDelta1.refs().Select(r => r.name).SequenceEqual(expected_names));
            D.Assert(shadowDelta1.refs().Select(r => r.CH).SequenceEqual(expected_chs));

            D.Assert(shadowDelta1.external_refs().Select(r => r.name).SequenceEqual(new        [] { "cA" }));
            D.Assert(shadowDelta1.external_refs().Select(r => r.CH).SequenceEqual(new TypedCH[] { closA }));

            // heheh :) two chaining deltaScopes need no extra testing   new DeltaScope ( fromDeltaScope ) is identical to its original in all fields - there is no point to this

            Console.WriteLine("================= basicScoping ok ============= ");
        }