本文整理汇总了C#中SimpleClass类的典型用法代码示例。如果您正苦于以下问题:C# SimpleClass类的具体用法?C# SimpleClass怎么用?C# SimpleClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleClass类属于命名空间,在下文中一共展示了SimpleClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetClone_Class_Cloned
public void GetClone_Class_Cloned()
{
var source = new SimpleClass() { Property = 10, _field = 3 };
var target = CloneFactory.GetClone(source);
Assert.AreEqual(source.Property, target.Property);
Assert.AreEqual(source._field, target._field);
}
示例2: Main
public static void Main()
{
SimpleStruct ss = new SimpleStruct();
ss.X = 5;
ss.DisplayX();
SS si = (SS) ss;
si.X = 90;
si.DisplayX();
ss = (SimpleStruct) si ;
ss.X = 5;
ss.DisplayX();
SimpleClass ss1 = new SimpleClass();
ss1.X = 5;
ss1.DisplayX();
try {
ss1 = (SimpleClass) si ;
ss1.X = 5;
ss1.DisplayX();
}
catch(Exception)
{
Console.WriteLine("Failed to cast");
}
}
示例3: delegate_test_class
public static SimpleClass delegate_test_class(SimpleClass
ss)
{
if
(ss
==
null)
return
null;
if
(!
(!ss.a
&&
ss.b
&&
!ss.c
&&
ss.d
==
"TEST"))
return
null;
SimpleClass
res
=
ss;
return
res;
}
示例4: CrossoverTest
public void CrossoverTest()
{
var obj = new SimpleClass();
var generator = new Generator<SimpleClass>();
CodeExpression<SimpleClass> leftTree = generator.BuildRandomExpressionTree();
CodeExpression<SimpleClass> rightTree = generator.BuildRandomExpressionTree();
Trace.WriteLine("Vor dem Crossover");
Trace.WriteLine("-----------------");
Trace.WriteLine("");
Trace.WriteLine("Tree links:");
Trace.WriteLine(leftTree);
Trace.WriteLine("");
Trace.WriteLine("Tree rechts:");
Trace.WriteLine(rightTree);
generator.Crossover(ref leftTree, ref rightTree);
Trace.WriteLine("");
Trace.WriteLine("Nach dem Crossover");
Trace.WriteLine("------------------");
Trace.WriteLine("");
Trace.WriteLine("Tree links:");
Trace.WriteLine(leftTree);
Trace.WriteLine("");
Trace.WriteLine("Tree rechts:");
Trace.WriteLine(rightTree);
}
示例5: TestSimpleObject
public void TestSimpleObject()
{
var nodeContainer = new NodeContainer();
var instance = new SimpleClass { Member1 = 3, Member2 = new SimpleClass() };
var rootNode = nodeContainer.GetOrCreateNode(instance);
var visitor = new TestVisitor();
visitor.Visit(rootNode);
var expectedNodes = new[]
{
rootNode,
rootNode.TryGetChild(nameof(SimpleClass.Member1)),
rootNode.TryGetChild(nameof(SimpleClass.Member2)),
rootNode.TryGetChild(nameof(SimpleClass.Member2)).Target,
rootNode.TryGetChild(nameof(SimpleClass.Member2)).Target.TryGetChild(nameof(SimpleClass.Member1)),
rootNode.TryGetChild(nameof(SimpleClass.Member2)).Target.TryGetChild(nameof(SimpleClass.Member2)),
};
var expectedPaths = new[]
{
new GraphNodePath(rootNode),
new GraphNodePath(rootNode).PushMember(nameof(SimpleClass.Member1)),
new GraphNodePath(rootNode).PushMember(nameof(SimpleClass.Member2)),
new GraphNodePath(rootNode).PushMember(nameof(SimpleClass.Member2)).PushTarget(),
new GraphNodePath(rootNode).PushMember(nameof(SimpleClass.Member2)).PushTarget().PushMember(nameof(SimpleClass.Member1)),
new GraphNodePath(rootNode).PushMember(nameof(SimpleClass.Member2)).PushTarget().PushMember(nameof(SimpleClass.Member2)),
};
VerifyNodesAndPath(expectedNodes, expectedPaths, visitor);
}
示例6: CopyTo
public void CopyTo()
{
ViewFactory<SimpleClass> factory = ViewFactory<SimpleClass>.IList();
IList<SimpleClass> list = factory.List;
list.Add(new SimpleClass(100, "aaa", new DateTime(1970, 1, 1)));
list.Add(new SimpleClass(80, "bbb", new DateTime(1980, 12, 12)));
list.Add(new SimpleClass(60, "ccc", new DateTime(1975, 6, 6)));
SimpleClass[] array = new SimpleClass[3];
((ICollection)factory.View).CopyTo(array, 0);
SimpleClass item = array[0];
Assert.IsNotNull(item);
Assert.AreEqual(100, item.IntegerValue);
Assert.AreEqual("aaa", item.StringValue);
Assert.AreEqual(new DateTime(1970, 1, 1), item.DateTimeValue);
item = array[1];
Assert.AreEqual(80, item.IntegerValue);
Assert.AreEqual("bbb", item.StringValue);
Assert.AreEqual(new DateTime(1980, 12, 12), item.DateTimeValue);
item = array[2];
Assert.AreEqual(60, item.IntegerValue);
Assert.AreEqual("ccc", item.StringValue);
Assert.AreEqual(new DateTime(1975, 6, 6), item.DateTimeValue);
}
示例7: ToViewModel_Simple_Class
public void ToViewModel_Simple_Class()
{
var model = new SimpleClass { A = 5, B = "test" };
var json = Knockout.ToViewModel(model);
Assert.AreEqual("{\"A\":ko.observable(5),\"B\":ko.observable(\"test\")}", json.ToJson());
}
示例8: TestExecuteMethod
public void TestExecuteMethod()
{
SimpleClass simpleClass = new SimpleClass();
Assert.IsFalse(simpleClass.MethodCalled);
ReflectionUtilities.ExecuteMethod(simpleClass, "MyMethod");
Assert.IsTrue(simpleClass.MethodCalled);
}
示例9: Main
static void Main (string[] args)
{
var v = ObjCRuntime.Dlfcn.dlopen (GetCurrentExecutingDirectory () + "/SimpleClass.dylib", 0);
NSApplication.Init ();
SimpleClass c = new SimpleClass ();
Console.WriteLine (c.DoIt());
}
示例10: BuildNullObject6
public void BuildNullObject6()
{
UnityContainer uc = new UnityContainer();
SimpleClass myObject = new SimpleClass();
uc.BuildUp(myObject, String.Empty);
Assert.AreNotEqual(uc.Resolve<SimpleClass>(), myObject);
}
示例11: I_want_some_nifty_helpers_to_make_generics_useful
public void I_want_some_nifty_helpers_to_make_generics_useful()
{
SimpleClass testClass = new SimpleClass();
SingleGenericClass<Guid> single = new SingleGenericClass<Guid>(Guid.NewGuid());
DoubleGenericClass<SingleGenericClass<Guid>, Guid> argument = new DoubleGenericClass<SingleGenericClass<Guid>, Guid>(single, single.Key);
Generic.Call(testClass, x => x.DoubleGenericMethod<object, object>(null), argument);
}
示例12: GenerateExpressionTree
public void GenerateExpressionTree()
{
var obj = new SimpleClass();
var generator = new Generator<SimpleClass>();
var func = generator.BuildRandomExpressionTree();
Trace.WriteLine(func);
func.Execute(obj);
}
示例13: TestExecuteMethod_WithReturnValue
public void TestExecuteMethod_WithReturnValue()
{
SimpleClass simpleClass = new SimpleClass();
Assert.IsFalse(simpleClass.MethodCalled);
var returnValue = ReflectionUtilities.ExecuteMethod(simpleClass, "MyMethodWithReturn");
Assert.IsTrue(simpleClass.MethodCalled);
Assert.IsTrue(Convert.ToBoolean(returnValue));
}
示例14: GetBindingInstance_should_return_instance_specified_through_SetBindingInstance
public void GetBindingInstance_should_return_instance_specified_through_SetBindingInstance()
{
var scenarioContext = CreateScenarioContext();
var expectedInstance = new SimpleClass();
scenarioContext.SetBindingInstance(typeof(SimpleClass), expectedInstance);
var result = scenarioContext.GetBindingInstance(typeof(SimpleClass));
result.Should().Be(expectedInstance);
}
示例15: PacksDefinedClassCorrectly
public void PacksDefinedClassCorrectly()
{
var toPack = new SimpleClass {A = true};
var expected = new List<byte> {0xA1, 0x81, 0x41, (byte) Markers.True}; //1 fields
var actual = Packers.Map.Pack(toPack);
actual.Should().Equal(expected);
}