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


C# Foo类代码示例

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


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

示例1: Main

    public static int Main()
    {
        try
        {
            Foo testStruct = new Foo();

            int val = StructTaker_Inline(testStruct);
            if (val == 3)
            {
                return 100;
            }

            else
            {
                return 101;
            }


        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            return 666;
        }
    }
开发者ID:enavro,项目名称:coreclr,代码行数:25,代码来源:ArrayOfStructs.cs

示例2: TestSave

        public void TestSave()
        {
            _collection.RemoveAll();
            var foo1 = new Foo
            {
                Id = new Id { AccountId = 1, Index = 2 },
                Name = "foo1"
            };
            _collection.Save(foo1);

            var foo1Rehydrated = _collection.FindOne(Query.EQ("_id", BsonDocumentWrapper.Create(foo1.Id)));
            Assert.IsInstanceOf<Foo>(foo1Rehydrated);
            Assert.IsInstanceOf<Id>(foo1Rehydrated.Id);
            Assert.AreEqual(1, foo1Rehydrated.Id.AccountId);
            Assert.AreEqual(2, foo1Rehydrated.Id.Index);
            Assert.AreEqual("foo1", foo1Rehydrated.Name);

            var foo2 = new Foo
            {
                Id = new IdWithExtraField { AccountId = 3, Index = 4, Extra = 5 },
                Name = "foo2"
            };
            _collection.Save(foo2);

            var foo2Rehydrated = _collection.FindOne(Query.EQ("_id", BsonDocumentWrapper.Create(foo2.Id)));
            Assert.IsInstanceOf<Foo>(foo2Rehydrated);
            Assert.IsInstanceOf<IdWithExtraField>(foo2Rehydrated.Id);
            Assert.AreEqual(3, foo2Rehydrated.Id.AccountId);
            Assert.AreEqual(4, foo2Rehydrated.Id.Index);
            Assert.AreEqual(5, ((IdWithExtraField)foo2Rehydrated.Id).Extra);
            Assert.AreEqual("foo2", foo2Rehydrated.Name);
        }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:32,代码来源:CSharp198Tests.cs

示例3: Main

        static void Main(string[] args)
        {
            Foo foo = new Foo() {Bar = 4};
                MyBackgroundMethod(foo);

            Console.ReadLine();
        }
开发者ID:postsharp,项目名称:PostSharpTraining,代码行数:7,代码来源:Program.cs

示例4: Test

	public void Test (Foo foo)
	{
		Hello hello = delegate {
			Hello (3);
		};
		hello ();
	}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:cs1673-2.cs

示例5: RetrievingAnObjectFromANestedFile

        public static void RetrievingAnObjectFromANestedFile(Foo result)
        {
            "Given a config file containing a Foo with a Bar of 'baz'"
                .f(() =>
                {
                    using (var writer = new StreamWriter("foo.csx"))
                    {
                        writer.WriteLine(@"#r ""ConfigR.Features.dll""");
                        writer.WriteLine(@"using ConfigR.Features;");
                        writer.WriteLine(@"Add(""foo"", new Foo { Bar = ""baz"" });");
                        writer.Flush();
                    }
                })
                .Teardown(() => File.Delete("foo.csx"));

            "And another config file which loads the first config file"
                .f(() =>
                {
                    using (var writer = new StreamWriter("bar.csx"))
                    {
                        writer.WriteLine(@"LoadScriptFile(""foo.csx"");");
                        writer.Flush();
                    }
                })
                .Teardown(() => File.Delete("bar.csx"));

            "When I load the second config file"
                .f(() => Config.Global.LoadScriptFile("bar.csx"));

            "And I get the Foo"
                .f(() => result = Config.Global.Get<Foo>("foo"));

            "Then the Foo has a Bar of 'baz'"
                .f(() => result.Bar.Should().Be("baz"));
        }
开发者ID:catwarrior,项目名称:config-r,代码行数:35,代码来源:NestedConfigurationFeature.cs

示例6: DeserializeNakedArray

 public void DeserializeNakedArray()
 {
     var arr = new Foo[0];
     var model = TypeModel.Create();
     Foo[] foo = (Foo[])model.DeepClone(arr);
     Assert.AreEqual(0, foo.Length);
 }
开发者ID:Erguotou,项目名称:protobuf-net,代码行数:7,代码来源:Arrays.cs

示例7: Main

    static void Main()
    {
        string p = constover.test("test");
        if ( p != "test" )
            throw new Exception( "test failed!" );

        p = constover.test_pconst("test");
        if ( p != "test_pconst" )
            throw new Exception( "test_pconst failed!" );

        Foo f = new Foo();
        p = f.test("test");
        if ( p != "test" )
            throw new Exception( "member-test failed!" );

        p = f.test_pconst("test");
        if ( p != "test_pconst" )
            throw new Exception( "member-test_pconst failed!" );

        p = f.test_constm("test");
        if ( p != "test_constmethod" )
            throw new Exception( "member-test_constm failed!" );

        p = f.test_pconstm("test");
        if ( p != "test_pconstmethod" )
            throw new Exception( "member-test_pconstm failed!" );
    }
开发者ID:janearc,项目名称:posixnap_old,代码行数:27,代码来源:constover_runme.cs

示例8: can_use_non_existing_function2

        public void can_use_non_existing_function2()
        {
            using (var store = NewDocumentStore())
            {
                var foo = new Foo
                {
                    Name = "test"
                };

                using (var session = store.OpenSession())
                {
                    session.Store(foo);
                    session.SaveChanges();
                }

                store.DatabaseCommands.Patch(foo.Id, new ScriptedPatchRequest
                {
                    Script = @"var test = ['My', 'Array'];
                               this.Name = function() {}"
                });

                using (var session = store.OpenSession())
                {
                    var loaded = session.Load<Foo>(foo.Id);
                    Assert.Null(loaded.Name);
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:28,代码来源:RavenDB-4144.cs

示例9: Main

    static void Main() 
    {
        // Print out the value of some enums
        Console.WriteLine("*** color ***");
        Console.WriteLine("    " + color.RED + " = " + (int)color.RED);
        Console.WriteLine("    " + color.BLUE + " = " + (int)color.BLUE);
        Console.WriteLine("    " + color.GREEN + " = " + (int)color.GREEN);

        Console.WriteLine("\n*** Foo::speed ***");
        Console.WriteLine("    Foo::" + Foo.speed.IMPULSE + " = " + (int)Foo.speed.IMPULSE);
        Console.WriteLine("    Foo::" + Foo.speed.WARP + " = " + (int)Foo.speed.WARP);
        Console.WriteLine("    Foo::" + Foo.speed.LUDICROUS + " = " + (int)Foo.speed.LUDICROUS);

        Console.WriteLine("\nTesting use of enums with functions\n");

        example.enum_test(color.RED, Foo.speed.IMPULSE);
        example.enum_test(color.BLUE, Foo.speed.WARP);
        example.enum_test(color.GREEN, Foo.speed.LUDICROUS);

        Console.WriteLine( "\nTesting use of enum with class method" );
        Foo f = new Foo();

        f.enum_test(Foo.speed.IMPULSE);
        f.enum_test(Foo.speed.WARP);
        f.enum_test(Foo.speed.LUDICROUS);
    }
开发者ID:FeepingCreature,项目名称:swig,代码行数:26,代码来源:runme.cs

示例10: TestSave

        public void TestSave()
        {
            var server = LegacyTestConfiguration.Server;
            var database = LegacyTestConfiguration.Database;
            var collection = LegacyTestConfiguration.GetCollection<Foo>();

            var conventions = new ConventionPack();
            conventions.Add(new NamedIdMemberConvention(new[] { "FooId" }));
            ConventionRegistry.Register("test", conventions, t => t == typeof(Foo));

            BsonClassMap.RegisterClassMap<Foo>();

            collection.RemoveAll();
            for (int i = 0; i < 10; i++)
            {
                var foo = new Foo
                {
                    FooId = ObjectId.Empty,
                    Name = string.Format("Foo-{0}", i),
                    Summary = string.Format("Summary for Foo-{0}", i)
                };
                collection.Save(foo);
                var count = collection.Count();
                Assert.AreEqual(i + 1, count);
            }
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:26,代码来源:CSharp77Tests.cs

示例11: can_save_javascript_array_values

        public void can_save_javascript_array_values()
        {
            using (var store = NewDocumentStore())
            {
                var foo = new Foo
                {
                    List = {"test"}
                };

                using (var session = store.OpenSession())
                {
                    session.Store(foo);
                    session.SaveChanges();
                }

                store.DatabaseCommands.Patch(foo.Id, new ScriptedPatchRequest
                {
                    Script = @"var list = ['my', 'list']; 
                                for(var x in list){
                                    this.List[x] = list[x];
                                }"
                });

                using (var session = store.OpenSession())
                {
                    var loaded = session.Load<Foo>(foo.Id);
                    Assert.Equal(new List<string> {"my", "list"}, loaded.List);
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:30,代码来源:RavenDB-4144.cs

示例12: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     configuration = new Configuration();
     configuration.SessionFactory()
                  .Integrate.Using<SQLiteDialect>()
                  .Connected.Using("Data source=testdb")
                  .AutoQuoteKeywords()
                  .LogSqlInConsole()
                  .EnableLogFormattedSql();
     var mapper = new ConventionModelMapper();
     mapper.Class<Foo>(cm => { });
     mapper.Class<Bar>(cm => { });
     CustomizeMapping(mapper);
     var mappingDocument = mapper.CompileMappingForAllExplicitlyAddedEntities();
     new XmlSerializer(typeof(HbmMapping)).Serialize(Console.Out, mappingDocument);
     configuration.AddDeserializedMapping(mappingDocument, "Mappings");
     new SchemaExport(configuration).Create(true, true);
     sessionFactory = configuration.BuildSessionFactory();
     using (var session = sessionFactory.OpenSession())
     using (var tx = session.BeginTransaction())
     {
         var foo = new Foo { Bars = CreateCollection() };
         foo.Bars.Add(new Bar { Data = 1 });
         foo.Bars.Add(new Bar { Data = 2 });
         id = session.Save(foo);
         tx.Commit();
     }
     sessionFactory.Statistics.IsStatisticsEnabled = true;
 }
开发者ID:polyzois,项目名称:NHibernate.Diegose,代码行数:29,代码来源:QueryableCollectionsFixture.cs

示例13: ReadOnly

        public void ReadOnly()
        {
            Foo foo = new Foo();

            //note an instance is need for a readonly
            foo.message.ShouldBe(_);
        }
开发者ID:seanbiefeld,项目名称:mentoring,代码行数:7,代码来源:AboutModifiers.cs

示例14: Main

	static int Main ()
	{
		Foo foo = new Foo ();
		foo.Test = "BAR";
		foo.NullableInt = 10;

		XmlSerializer serializer = new XmlSerializer (typeof (Foo));

		MemoryStream stream = new MemoryStream ();

		serializer.Serialize (stream, foo);
		stream.Position = 0;
		foo = (Foo) serializer.Deserialize (stream);

		if (foo.Test != "BAR")
			return 1;
		if (foo.NullableInt != 10)
			return 2;

		foo.NullableInt = null;
		stream = new MemoryStream ();
		serializer.Serialize (stream, foo);
		stream.Position = 0;
		foo = (Foo) serializer.Deserialize (stream);

		if (foo.Test != "BAR")
			return 3;
		if (foo.NullableInt != null)
			return 4;

		return 0;
	}
开发者ID:mono,项目名称:gert,代码行数:32,代码来源:test.cs

示例15: Blah2

        public void Blah2()
        {
            var foo = new Foo
            {
                Name = "Andrew",
                Friends = {
                    new Friend{Name =  "Matt"},
                    new SubFriend
                        {
                            Name =  "Nick",
                            Age = 28
                        },
                    }
            };
            var settings = new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Ignore };

            var serializeObject = JsonConvert.SerializeObject(foo, Formatting.Indented, settings);

            var bytes = Encoding.UTF8.GetBytes(serializeObject);

            var result = JsonConvert.DeserializeObject<Foo>(Encoding.UTF8.GetString(bytes), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects });

            Assert.That(result.Friends.Count, Is.EqualTo(2));

            var nick = result.Friends.Single(x => x.Name == "Nick");
            Assert.That(nick, Is.TypeOf<SubFriend>());

            var matt = result.Friends.Single(x => x.Name == "Matt");
            Assert.That(matt, Is.TypeOf<Friend>());
        }
开发者ID:adbrowne,项目名称:Samples,代码行数:30,代码来源:Class1.cs


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