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


C# SomeClass类代码示例

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


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

示例1: ToBeSame_DifferentReferences_Fails

        public void ToBeSame_DifferentReferences_Fails()
        {
            var a = new SomeClass();
            var b = new SomeClass();

            Expect(b).ToBeSame(a);
        }
开发者ID:vinntreus,项目名称:NUnit.Expect,代码行数:7,代码来源:ExpectTests.cs

示例2: ToNotBeSame_SameReferences_IsSuccess

        public void ToNotBeSame_SameReferences_IsSuccess()
        {
            var a = new SomeClass();
            var b = a;

            Expect(b).ToNotBeSame(a);
        }
开发者ID:vinntreus,项目名称:NUnit.Expect,代码行数:7,代码来源:ExpectTests.cs

示例3: Interop_Event_TwoObjects

		public void Interop_Event_TwoObjects()
		{
			int invocationCount = 0;
			UserData.RegisterType<SomeClass>();
			UserData.RegisterType<EventArgs>();

			Script s = new Script(CoreModules.None);

			var obj = new SomeClass();
			var obj2 = new SomeClass();
			s.Globals["myobj"] = obj;
			s.Globals["myobj2"] = obj2;
			s.Globals["ext"] = DynValue.NewCallback((c, a) => { invocationCount += 1; return DynValue.Void; });

			s.DoString(@"
				function handler(o, a)
					ext();
				end

				myobj.MyEvent.add(handler);
				");

			obj.Trigger_MyEvent();
			obj2.Trigger_MyEvent();

			Assert.AreEqual(1, invocationCount);
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:27,代码来源:UserDataEventsTests.cs

示例4: ViaExpression

        public Action ViaExpression()
        {
            FieldInfo field = typeof (SomeClass).GetField("field", BindingFlags.NonPublic | BindingFlags.Instance);

            ParameterExpression xValue = Expression.Parameter(typeof (object));
            ParameterExpression xContainer = Expression.Parameter(typeof (object));
            ParameterExpression xTypedContainer = Expression.Parameter(typeof (SomeClass));
            Expression<Func<object, object, object>> xSetField = Expression
                .Lambda<Func<object, object, object>>(
                    Expression.Block(new[] { xTypedContainer },
                        Expression.Assign(
                            xTypedContainer,
                            Expression.Convert(xContainer, typeof (SomeClass))),
                        Expression.Assign(
                            Expression.Field(xTypedContainer, field),
                            Expression.Convert(xValue, typeof (int))),
                        Expression.Convert(xTypedContainer, typeof (object))),
                    xContainer, xValue);

            object someClass = new SomeClass();
            Func<object, object, object> setFieldDelegate = xSetField.Compile();

            return () => {
                       for (int i = 0; i < iterationCount; i++)
                           someClass = setFieldDelegate(someClass, i);
                   };
        }
开发者ID:MonDeveloper,项目名称:NClone,代码行数:27,代码来源:SetFieldCompetition.cs

示例5: ReplaceSomeClass

 public Entity ReplaceSomeClass(SomeClass newValue)
 {
     var component = CreateComponent<SomeClassComponent>(ComponentIds.SomeClass);
     component.value = newValue;
     ReplaceComponent(ComponentIds.SomeClass, component);
     return this;
 }
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:7,代码来源:SomeClassComponentGeneratedExtension.cs

示例6: When_getting_controller_attributes_then_builds_up_instance

        public void When_getting_controller_attributes_then_builds_up_instance()
        {
            using (var container = new UnityContainer())
            {
                // Arrange
                var someInstance = new SomeClass();
                container.RegisterInstance<ISomeInterface>(someInstance);
                container.RegisterType<TestFilterAttribute>(new InjectionProperty("Some"));

                var context = new ControllerContext { Controller = new ControllerWithTypeAttribute() };
                var controllerDescriptor = new ReflectedControllerDescriptor(context.Controller.GetType());
                var action = context.Controller.GetType().GetMethod("MyActionMethod");
                var actionDescriptor = new ReflectedActionDescriptor(action, "MyActionMethod", controllerDescriptor);
                var provider = new UnityFilterAttributeFilterProvider(container);

                // Act
                Filter filter = provider.GetFilters(context, actionDescriptor).Single();

                // Assert
                TestFilterAttribute attrib = filter.Instance as TestFilterAttribute;
                Assert.IsNotNull(attrib);
                Assert.AreEqual(FilterScope.Controller, filter.Scope);
                Assert.AreEqual(1234, filter.Order);
                Assert.AreSame(someInstance, attrib.Some);
            }
        }
开发者ID:kangkot,项目名称:unity,代码行数:26,代码来源:MvcUnityFilterAttributeFilterProviderFixture.cs

示例7: SetUp

        public void SetUp()
        {
            someClass = new SomeClass();
            var field = typeof (SomeClass).GetField("field", BindingFlags.NonPublic | BindingFlags.Instance);

            var xValue = Expression.Parameter(typeof (object));
            var xContainer = Expression.Parameter(typeof (object));
            var xTypedContainer = Expression.Parameter(typeof (SomeClass));
            var xSetField = Expression
                .Lambda<Func<object, object, object>>(
                    Expression.Block(new[] { xTypedContainer },
                        Expression.Assign(
                            xTypedContainer,
                            Expression.Convert(xContainer, typeof (SomeClass))),
                        Expression.Assign(
                            Expression.Field(xTypedContainer, field),
                            Expression.Convert(xValue, typeof (int))),
                        Expression.Convert(xTypedContainer, typeof (object))),
                    xContainer, xValue);
            setViaExpression = xSetField.Compile();

            var memberAccessor = FieldAccessorBuilder.BuildFor(typeof (SomeClass), field, true);
            setViaEmit = memberAccessor.SetMember;

            setViaReflection = (container, value) =>
            {
                field.SetValue(container, value);
                return container;
            };
        }
开发者ID:saeedallahyari,项目名称:NClone,代码行数:30,代码来源:SetFieldCompetition.cs

示例8: Test_NIntPropertyGetter

		public void Test_NIntPropertyGetter(InteropAccessMode opt)
		{
			string script = @"    
				x = myobj1.NIntProp;
				y = myobj2.NIntProp;
				return x,y;";

			Script S = new Script();

			SomeClass obj1 = new SomeClass() { NIntProp = 321 };
			SomeClass obj2 = new SomeClass() { NIntProp = null };

			UserData.UnregisterType<SomeClass>();
			UserData.RegisterType<SomeClass>(opt);

			S.Globals.Set("myobj1", UserData.Create(obj1));
			S.Globals.Set("myobj2", UserData.Create(obj2));

			DynValue res = S.DoString(script);

			Assert.AreEqual(DataType.Tuple, res.Type);
			Assert.AreEqual(321.0, res.Tuple[0].Number);
			Assert.AreEqual(DataType.Number, res.Tuple[0].Type);
			Assert.AreEqual(DataType.Nil, res.Tuple[1].Type);
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:25,代码来源:UserDataPropertiesTests.cs

示例9: Nuller_can_process_object_by_reference

 public void Nuller_can_process_object_by_reference()
 {
     var someClass = new SomeClass{FakeProp1="Test"};
     var processor = new TestProcessor();
     processor.Process(someClass);
     Assert.IsNull(someClass.FakeProp1);
 }
开发者ID:REAANDREW,项目名称:Nullifier,代码行数:7,代码来源:SanityCheck.cs

示例10: Test_ConstIntFieldSetter

		public void Test_ConstIntFieldSetter(InteropAccessMode opt)
		{
			try
			{
				string script = @"    
				myobj.ConstIntProp = 1;
				return myobj.ConstIntProp;";

				Script S = new Script();

				SomeClass obj = new SomeClass() { IntProp = 321 };

				UserData.UnregisterType<SomeClass>();
				UserData.RegisterType<SomeClass>(opt);

				S.Globals.Set("myobj", UserData.Create(obj));

				DynValue res = S.DoString(script);

				Assert.AreEqual(DataType.Number, res.Type);
				Assert.AreEqual(115, res.Number);
			}
			catch (ScriptRuntimeException)
			{
				return;
			}

			Assert.Fail();
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:29,代码来源:UserDataFieldsTests.cs

示例11: CreateData

 private static SomeClass CreateData()
 {
     var source = new SomeClass { Property = new SomeClass2[2000000] };
     for (int i = 0; i < source.Property.Length; i++)
         source.Property[i] = new SomeClass2 { field = i.ToString() };
     return source;
 }
开发者ID:saeedallahyari,项目名称:NClone,代码行数:7,代码来源:Program.cs

示例12: ThrowsExceptionWithNiceMessageWhenTrivialConversionCouldNotBeCompleted

        public void ThrowsExceptionWithNiceMessageWhenTrivialConversionCouldNotBeCompleted()
        {
            var instance = new SomeClass();

            var ex = Assert.Throws<FeatureExecutionException>(() => sut.SetValue(instance, typeof(SomeClass).GetProperty("AnotherProperty"), "yo!"));

            Assert.AreEqual("The value 'yo!' could not be automatically converted to target type Int32 (AnotherProperty property of SomeClass)", ex.Message);
        }
开发者ID:jlundstocholm,项目名称:DillPickle,代码行数:8,代码来源:TestTrivialPropertySetter.cs

示例13: Start

    void Start()
    {
        // our context can be any type at all
        var someClass = new SomeClass();

        // the initial state has to be passed to the constructor
        _machine = new SKStateMachine<SomeClass>( someClass, new PatrollingState() );
    }
开发者ID:kpro1999,项目名称:StateKit,代码行数:8,代码来源:StandardUITester.cs

示例14: Should_name_class_in_exception

 public void Should_name_class_in_exception()
 {
     var someObject = new SomeClass();
     const string str = default(string);
     Action act = () => str.DoIfNotNull(strange => someObject.SomeProperty = strange, false);
     act.ShouldThrow<NullReferenceException>()
         .Where(e => e.Message.Contains("System.String"));
 }
开发者ID:vidarkongsli,项目名称:flowcontrolextensions,代码行数:8,代码来源:FlowControlExtensions_DoIfNotNull.cs

示例15: PerformanceComparison

        public void PerformanceComparison()
        {
            // Demonstrating the performance difference of three approaches to getting the values of properties
            const int iterations = 10000000;

            var obj = new SomeClass();
            var s = new Stopwatch();

            // First just go through PropertyInfo.GetValue
            Console.Out.Write("PropertyInfo.GetValue: ");
            PropertyInfo prop = obj.GetType().GetProperty("Val");

            s.Reset();
            s.Start();
            for (int i = 0; i < iterations; i++)
            {
                prop.GetValue(obj, null);
            }
            s.Stop();
            Console.Out.WriteLine(s.ElapsedMilliseconds);

            // Second, create a delegate to get the property directly from the getter method
            Console.Out.Write("Delegate getter: ");
            var getMethod = prop.GetGetMethod();
            Func<SomeClass, string> typedGetter = (Func<SomeClass, string>)Delegate.CreateDelegate(typeof(Func<SomeClass, string>), null, getMethod);
            Func<object, object> delegateGetter = o => typedGetter((SomeClass)o);

            s.Reset();
            s.Start();
            for (int i = 0; i < iterations; i++)
            {
                delegateGetter(obj);
            }
            s.Stop();
            Console.Out.WriteLine(s.ElapsedMilliseconds);

            // Thirdly, create a dynamic method to get the property
            Console.Out.Write("IL getter: ");
            DynamicMethod dynamicMethod = new DynamicMethod("", typeof(object), new Type[] { typeof(object) }, typeof(SomeClass), true);
            ILGenerator ilGenerator = dynamicMethod.GetILGenerator();
            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Call, getMethod);
            if (prop.PropertyType.IsValueType)
            {
                ilGenerator.Emit(OpCodes.Box, prop.PropertyType);
            }
            ilGenerator.Emit(OpCodes.Ret);
            var ilGetter = (Func<object, object>)dynamicMethod.CreateDelegate(typeof(Func<object, object>));

            s.Reset();
            s.Start();
            for (int i = 0; i < iterations; i++)
            {
                ilGetter(obj);
            }
            s.Stop();
            Console.Out.WriteLine("IL getter: " + s.ElapsedMilliseconds);
        }
开发者ID:jmptrader,项目名称:Fudge-CSharp,代码行数:58,代码来源:TypeDataTest.cs


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