当前位置: 首页>>代码示例>>C#>>正文


C# MacroExpansion类代码示例

本文整理汇总了C#中MacroExpansion的典型用法代码示例。如果您正苦于以下问题:C# MacroExpansion类的具体用法?C# MacroExpansion怎么用?C# MacroExpansion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MacroExpansion类属于命名空间,在下文中一共展示了MacroExpansion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExpectSpecToExist

        public void ExpectSpecToExist()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId)
            };
            var specs = new List<OracularSpec>();
            var config = new OracularConfig (tables, specs);
            var checker = new RefChecker (config);

            var reference = new Reference (new [] { "Foobar" });
            var fn = new Reference (new [] { "isBaz" });
            var call = new MacroExpansion (fn, new [] { reference });

            var initial = new []{ "Foobar" };

            var ex = Assert.Throws<RefCheckException>(() => call.Walk (checker, initial));

            Assert.That (REFERENCE_RE.IsMatch (ex.Message));
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:24,代码来源:RefCheckerTests.cs

示例2: CheckJoinTables

        public void CheckJoinTables()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var potatoFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("FoobarId", null),
                new FieldConfig("Type", null)
            };
            var foobarRelationship = new ParentConfig ("Foobar", null, null);
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId),
                new OracularTable("Potato", null, new List<ParentConfig>{foobarRelationship}, potatoFields)
            };
            var specs = new List<OracularSpec>();
            var config = new OracularConfig (tables, specs);
            var checker = new RefChecker (config);

            var fingerlingPotatoes = new BinaryOperation("=",
                new Reference(new [] { "Potato", "Type" }),
                new StringLiteral("Fingerling")
            );

            var call = new MacroExpansion(
                new Reference(new [] { "ANY" }),
                new AstNode[] {
                    new Reference(new [] { "Potato" }),
                    fingerlingPotatoes
                }
            );

            var initial = new []{ "Foobar" };

            var result = call.Walk (checker, initial);

            Assert.AreEqual (2, result.Length);
            Assert.Contains ("Foobar", result);
            Assert.Contains ("Potato", result);
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:43,代码来源:RefCheckerTests.cs

示例3: ExpectSpecTableToMatchInput

        public void ExpectSpecTableToMatchInput()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId),
                new OracularTable("SomethingElse", null, null, justAnId)
            };
            var specs = new List<OracularSpec>
            {
                new OracularSpec("isBaz", "SomethingElse", "SomethingElse.Id = null")
            };
            var config = new OracularConfig (tables, specs);

            var fnRef = new Reference (new string[]{ "isBaz" });
            var foobarRef = new Reference (new string[]{ "Foobar" });
            var isFoobarBaz = new MacroExpansion (fnRef, new AstNode[]{ foobarRef });

            var ex = Assert.Throws<TypeCheckException> (() => isFoobarBaz.Walk (new TypeChecker (config)));

            Assert.That (ex.Message, Is.StringContaining ("mismatch"));
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:25,代码来源:TypeCheckerTests.cs

示例4: ExpectNestedSpecToRefcheck

        public void ExpectNestedSpecToRefcheck()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var potatoFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("FoobarId", null)
            };
            var foobarRelationship = new ParentConfig ("Foobar", null, null);
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId),
                new OracularTable("Potato", null, new List<ParentConfig>{foobarRelationship}, potatoFields)
            };
            var specs = new List<OracularSpec>();
            var config = new OracularConfig (tables, specs);
            var checker = new RefChecker (config);

            var fingerlingPotatoes = new MacroExpansion(
                new Reference(new [] { "isFingerling" }),
                new [] { new Reference(new [] { "Potato" }) }
            );

            var call = new MacroExpansion(
                new Reference(new [] { "ANY" }),
                new AstNode[] {
                    new Reference(new [] { "Potato" }),
                    fingerlingPotatoes
                }
            );

            var initial = new []{ "Foobar" };

            var ex = Assert.Throws<RefCheckException> (() => call.Walk (checker, initial));

            Assert.That (REFERENCE_RE.IsMatch (ex.Message));
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:40,代码来源:RefCheckerTests.cs

示例5: __CreateInstance

 public static MacroExpansion __CreateInstance(MacroExpansion.Internal native)
 {
     return new MacroExpansion(native);
 }
开发者ID:RainsSoft,项目名称:CppSharp,代码行数:4,代码来源:AST.cs

示例6: MacroExpansion

 private MacroExpansion(MacroExpansion.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
开发者ID:RainsSoft,项目名称:CppSharp,代码行数:6,代码来源:AST.cs

示例7: MacroExpansion

 private MacroExpansion(MacroExpansion.Internal native)
     : this(__CopyValue(native))
 {
     __ownsNativeInstance = true;
 }
开发者ID:KonajuGames,项目名称:CppSharp,代码行数:5,代码来源:AST.cs

示例8: MacroExpansion

 private MacroExpansion(MacroExpansion.Internal native, bool skipVTables = false)
     : this(__CopyValue(native), skipVTables)
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[__Instance] = this;
 }
开发者ID:CSRedRat,项目名称:CppSharp,代码行数:6,代码来源:AST.cs

示例9: SerializeSpecReferences

        public void SerializeSpecReferences()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var idAndBarId = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("BarId", null)
            };
            var barRelationship = new List<ParentConfig>
            {
                new ParentConfig("Bar", null, null)
            };
            var foo = new OracularTable ("Foo", null, barRelationship, idAndBarId);
            var tables = new List<OracularTable>
            {
                foo,
                new OracularTable("Bar", null, null, justAnId)
            };
            var specs = new List<OracularSpec>
            {
                new OracularSpec("barHasId", "Bar", "Bar.Id != null")
            };
            var config = new OracularConfig (tables, specs);

            var foobarReference = new Reference (new [] { "Foo", "Bar" });
            var specReference = new Reference (new [] { "barHasId" });
            var macroExpansion = new MacroExpansion (specReference, new [] { foobarReference });

            var builder = new Sqlizer (foo, config);
            var sql = macroExpansion.Walk (builder);

            Assert.AreEqual ("([Foo.Bar].[Id] != NULL)", sql);

            Assert.AreEqual (1, builder.JoinTables.Count ());
            var joinClause = builder.JoinTables.First();

            Assert.AreEqual ("INNER JOIN [Bar] [Foo.Bar] ON [Foo.Bar].[Id] = [Foo].[BarId]", joinClause);
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:41,代码来源:SqlizerTests.cs

示例10: MacroExpansion

 internal MacroExpansion(MacroExpansion.Internal native)
     : this(__CopyValue(native))
 {
 }
开发者ID:vovkasm,项目名称:CppSharp,代码行数:4,代码来源:AST.cs

示例11: SerializeReducer

        public void SerializeReducer(string macro, string prefix, string suffix, string value, string equality)
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var idAndBarId = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("BarId", null)
            };
            var barRelationship = new List<ParentConfig>
            {
                new ParentConfig("Bar", null, null)
            };
            var foo = new OracularTable ("Foo", null, barRelationship, idAndBarId);
            var bar = new OracularTable("Bar", null, null, justAnId);
            var tables = new List<OracularTable>{ foo, bar };
            var specs = new List<OracularSpec> ();
            var config = new OracularConfig (tables, specs);

            var macroReference = new Reference (new[]{ macro });
            var fooReference = new Reference (new[]{ "Foo" });
            var idNotNull = new BinaryOperation ("!=",
                new Reference (new[]{ "Foo", "Id" }),
                new NullLiteral ()
            );

            var macroExpansion = new MacroExpansion (macroReference, new AstNode[] { fooReference, idNotNull });

            var builder = new Sqlizer (bar, config);
            var sql = macroExpansion.Walk (builder);

            var expected = String.Format ("[AnnotatedBar{0}].[{1}Foo{0}]{2}", idNotNull.Id, prefix, suffix);
            Assert.AreEqual (expected, sql);

            Assert.AreEqual (1, builder.JoinTables.Count ());
            var join = builder.JoinTables.First ();

            expected = String.Format ("LEFT JOIN [AnnotatedBar{0}] ON [AnnotatedBar{0}].[Id] = [Bar].[Id]", idNotNull.Id);
            Assert.AreEqual (expected, join);

            Assert.AreEqual (1, builder.CommonTableExpressions.Count ());
            var annotated = builder.CommonTableExpressions.First ();

            expected = String.Format (@"[AnnotatedBar{0}] AS (
            SELECT DISTINCT [Bar].[Id], {2} [{1}Foo{0}]
            FROM [Bar]
            LEFT JOIN [Foo] ON [Foo].[BarId] = [Bar].[Id]
            WHERE ([Foo].[Id] {3} NULL)
            )", idNotNull.Id, prefix, value, equality);
            Assert.AreEqual (expected, annotated);
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:53,代码来源:SqlizerTests.cs

示例12: SerializeNestedReducers

        public void SerializeNestedReducers()
        {
            var bazFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var barFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("BazId", null)
            };
            var barbazRelationship = new List<ParentConfig>
            {
                new ParentConfig("Baz", null, null)
            };
            var fooFields = new List<FieldConfig>
            {
                new FieldConfig("Id", null),
                new FieldConfig("BarId", null),
                new FieldConfig("IsQux", FieldType.Boolean)
            };
            var foobarRelationship = new List<ParentConfig>
            {
                new ParentConfig("Bar", null, null)
            };
            var baz = new OracularTable ("Baz", null, null, bazFields);
            var tables = new List<OracularTable>
            {
                new OracularTable ("Foo", null, foobarRelationship, fooFields),
                new OracularTable("Bar", null, barbazRelationship, barFields),
                baz
            };
            var specs = new List<OracularSpec> ();
            var config = new OracularConfig (tables, specs);

            var fooIsQuxNode = new Reference (new [] { "Foo", "IsQux" });
            var anyFooNode = new MacroExpansion (
                new Reference (new [] { "ANY" }),
                new [] {
                    new Reference(new [] { "Foo" }),
                    fooIsQuxNode
                }
            );

            var anyBarNode = new MacroExpansion (
                new Reference(new [] { "ANY" }),
                new AstNode[] {
                    new Reference(new [] { "Bar" }),
                    anyFooNode
                }
            );

            var builder = new Sqlizer (baz, config);
            var whereClause = anyBarNode.Walk (builder);

            var expected = String.Format ("[AnnotatedBaz{0}].[AnyBar{0}] = 1", anyFooNode.Id);
            Assert.AreEqual (expected, whereClause);

            Assert.AreEqual (1, builder.JoinTables.Count ());
            var join = builder.JoinTables.First ();

            expected = String.Format ("LEFT JOIN [AnnotatedBaz{0}] ON [AnnotatedBaz{0}].[Id] = [Baz].[Id]", anyFooNode.Id);
            Assert.AreEqual (expected, join);

            Assert.AreEqual (2, builder.CommonTableExpressions.Count ());

            var annotatedBar = builder.CommonTableExpressions.First ();
            expected = String.Format (@"[AnnotatedBar{0}] AS (
            SELECT DISTINCT [Bar].[Id], 1 [AnyFoo{0}]
            FROM [Bar]
            LEFT JOIN [Foo] ON [Foo].[BarId] = [Bar].[Id]
            WHERE [Foo].[IsQux] = 1
            )", fooIsQuxNode.Id);
            Assert.AreEqual (expected, annotatedBar);

            var annotatedBaz = builder.CommonTableExpressions.Last ();
            expected = String.Format(@"[AnnotatedBaz{0}] AS (
            SELECT DISTINCT [Baz].[Id], 1 [AnyBar{0}]
            FROM [Baz]
            LEFT JOIN [Bar] ON [Bar].[BazId] = [Baz].[Id]
            LEFT JOIN [AnnotatedBar{1}] ON [AnnotatedBar{1}].[Id] = [Bar].[Id]
            WHERE [AnnotatedBar{1}].[AnyFoo{1}] = 1
            )", anyFooNode.Id, fooIsQuxNode.Id);
            Assert.AreEqual (expected, annotatedBaz);
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:85,代码来源:SqlizerTests.cs

示例13: ExpectSpecToExist

        public void ExpectSpecToExist()
        {
            var justAnId = new List<FieldConfig>
            {
                new FieldConfig("Id", null)
            };
            var tables = new List<OracularTable>
            {
                new OracularTable("Foobar", null, null, justAnId)
            };
            var config = new OracularConfig (tables, new List<OracularSpec> ());

            var fnRef = new Reference (new string[]{ "isBaz" });
            var foobarRef = new Reference (new string[]{ "Foobar" });
            var isFoobarBaz = new MacroExpansion (fnRef, new AstNode[]{ foobarRef });

            var ex = Assert.Throws<TypeCheckException> (() => isFoobarBaz.Walk (new TypeChecker (config)));

            Assert.That (ex.Message, Is.StringContaining ("name"));
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:20,代码来源:TypeCheckerTests.cs

示例14: __CopyValue

 private static void* __CopyValue(MacroExpansion.__Internal native)
 {
     var ret = Marshal.AllocHGlobal(64);
     global::CppSharp.Parser.AST.MacroExpansion.__Internal.cctor_1(ret, new global::System.IntPtr(&native));
     return ret.ToPointer();
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:6,代码来源:CppSharp.CppParser.cs

示例15: MacroExpansion

 internal MacroExpansion(MacroExpansion.Internal* native)
     : this(new global::System.IntPtr(native))
 {
 }
开发者ID:kidleon,项目名称:CppSharp,代码行数:4,代码来源:AST.cs


注:本文中的MacroExpansion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。