本文整理汇总了C#中MyObject类的典型用法代码示例。如果您正苦于以下问题:C# MyObject类的具体用法?C# MyObject怎么用?C# MyObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyObject类属于命名空间,在下文中一共展示了MyObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreatingAnEventFromASimpleMethodWithoutArgumentsShouldReturnMethodEventForThatMethod
public void CreatingAnEventFromASimpleMethodWithoutArgumentsShouldReturnMethodEventForThatMethod()
{
var obj = new MyObject();
var @event = MethodEventFactory.CreateMethodEventFromExpression(Guid.NewGuid(), () => obj.SimpleMethod());
Assert.That(@event, Is.Not.Null);
Assert.That(@event.Name,Is.EqualTo("SimpleMethod"));
}
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:7,代码来源:MethodEventFactorySpecs.cs
示例2: TestKeepAliveMax
public void TestKeepAliveMax()
{
WeakReference r;
ObjectKeepAlive keep = new ObjectKeepAlive(25, 50, TimeSpan.FromSeconds(1));
if(true)
{
object target = new MyObject();
r = new WeakReference(target);
keep.Add(target);
target = null;
}
_destroyed = false;
Assert.IsTrue(r.IsAlive);
for (int i = 0; i < 49; i++)
keep.Add(i);
Assert.IsTrue(r.IsAlive);
GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(r.IsAlive);
Assert.IsFalse(_destroyed);
keep.Add(new object());
keep.Add(new object());
GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsFalse(r.IsAlive);
Assert.IsTrue(_destroyed);
}
开发者ID:langimike,项目名称:CSharpTest.Net.Collections,代码行数:34,代码来源:TestObjectKeepAlive.cs
示例3: CustomBasedCache
static void CustomBasedCache()
{
MyObject obj1 = new MyObject();
obj1.var1 = 1;
obj1.var2 = 1;
MyObject obj3 = new MyObject();
obj3.var1 = 2;
obj3.var2 = 1;
MyObject obj2 = new MyObject();
obj2.var1 = 5;
obj2.var2 = 5;
LFUCache<MyKey, MyObject> customCache = new LFUCache<MyKey, MyObject>();
MyKey key = customCache.Add(obj1);
MyKey key2 = customCache.Add(obj2);
MyKey key3 = customCache.Add(obj3);
//........
//obj1.var1 + obj1.var2
//OUTPUT: 2
Console.WriteLine("" + (customCache[key].var1 + customCache[key].var2)); //The frequency count will go up 2, because we access it twice
MyObject obj = customCache[key3];
//obj3.var1 + obj3.var2
//OUTPUT: 3
Console.WriteLine("" + (obj.var1 + obj.var2)); //The frequency count will go up 1, because we only access it once
obj = customCache.LeastFrequentlyUsedObject; //The least frequently used object will be obj2 because we haven't requested it yet.
//obj2.var1 + obj2.var2
//OUTPUT: 10
Console.WriteLine("" + (obj.var1 + obj.var2)); //This will be obj2.var1 + obj2.var2
}
开发者ID:hypereddie,项目名称:LFUSharp,代码行数:32,代码来源:Program.cs
示例4: TestDestoryed
public void TestDestoryed()
{
Utils.WeakReference<MyObject> r;
if (true)
{
MyObject obj = new MyObject();
r = new Utils.WeakReference<MyObject>(obj);
Assert.IsTrue(r.IsAlive);
Assert.IsNotNull(r.Target);
MyObject test;
Assert.IsTrue(r.TryGetTarget(out test));
Assert.IsTrue(ReferenceEquals(obj, test));
test = null;
_destroyed = false;
GC.KeepAlive(obj);
obj = null;
}
GC.GetTotalMemory(true);
GC.WaitForPendingFinalizers();
Assert.IsTrue(_destroyed);
MyObject tmp;
Assert.IsFalse(r.IsAlive);
Assert.IsNull(r.Target);
Assert.IsFalse(r.TryGetTarget(out tmp));
}
开发者ID:langimike,项目名称:CSharpTest.Net.Collections,代码行数:30,代码来源:TestWeakReferenceT.cs
示例5: Init
public new void Init(object objParam)
{
// Get parameter info
_strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");
xsltArg1 = new XsltArgumentList();
MyObject obj1 = new MyObject(1, _output);
MyObject obj2 = new MyObject(2, _output);
MyObject obj3 = new MyObject(3, _output);
MyObject obj4 = new MyObject(4, _output);
MyObject obj5 = new MyObject(5, _output);
xsltArg1.AddExtensionObject("urn:my-obj1", obj1);
xsltArg1.AddExtensionObject("urn:my-obj2", obj2);
xsltArg1.AddExtensionObject("urn:my-obj3", obj3);
xsltArg1.AddExtensionObject("urn:my-obj4", obj4);
xsltArg1.AddExtensionObject("urn:my-obj5", obj5);
xsltArg1.AddParam("myArg1", szEmpty, "Test1");
xsltArg1.AddParam("myArg2", szEmpty, "Test2");
xsltArg1.AddParam("myArg3", szEmpty, "Test3");
xsltArg1.AddParam("myArg4", szEmpty, "Test4");
xsltArg1.AddParam("myArg5", szEmpty, "Test5");
return;
}
开发者ID:geoffkizer,项目名称:corefx,代码行数:27,代码来源:CXsltArgumentListMultith.cs
示例6: MyObject
public void CreatingAnEventFromASimpleMethodWithOneArgumentAndNotUsingConstantsShouldReturnMethodEventWithArgumentsForThatMethod(string expectedArgument)
{
var obj = new MyObject();
var @event = MethodEventFactory.CreateMethodEventFromExpression(Guid.NewGuid(), () => obj.SimpleMethodWithOneArgument(expectedArgument));
Assert.That(@event, Is.Not.Null);
dynamic arguments = @event.Arguments;
Assert.That(@event.Name, Is.EqualTo("SimpleMethodWithOneArgument"));
Assert.That(arguments.argument, Is.EqualTo(expectedArgument));
}
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:9,代码来源:MethodEventFactorySpecs.cs
示例7: Main
public static void Main(string[] args)
{
MyObject[] array = new MyObject[2];
array[0] = new MyObject (5, 8);
array[1] = new MyObject (12, 3);
using (FileStream fs = new FileStream("test.xml", FileMode.Create)) {
XmlSerializer serializer = new XmlSerializer(array.GetType());
serializer.Serialize(Console.Out, array);
}
}
开发者ID:BackupTheBerlios,项目名称:mspace-svn,代码行数:10,代码来源:testXML.cs
示例8: NewObject
public MyObject NewObject(int Width, int Height)
{
MyObject obj = new MyObject();
obj.Width = Width;
obj.Height = Height;
setСoordinates(obj);
return obj;
}
开发者ID:Shman4ik,项目名称:MPC1,代码行数:10,代码来源:Service1.cs
示例9: B002TestMethod1
public void B002TestMethod1()
{
var s = new XSerializer(typeof(MyObject));
var obj = new MyObject();
obj.List.AddRange(new[] { 10, 20, 30 });
var doc = s.GetSerializedDocument(obj);
Trace.WriteLine(doc);
var obj1 = (MyObject)s.Deserialize(doc, null);
Assert.AreEqual(obj1.List.Count, obj.List.Count);
}
开发者ID:CXuesong,项目名称:XSerializer,代码行数:10,代码来源:B002.cs
示例10: Method
public void Method()
{
using (MyObject my = new MyObject())
{
my.DoSomething();
string msg = "hello";
msg += " My name";
msg += " is Alex";
Console.WriteLine(msg);
}
}
开发者ID:kaplunov93,项目名称:EffectiveCsharp,代码行数:11,代码来源:ObjManagment.cs
示例11: ObjectSerializationTakesConvertersIntoAccount
public void ObjectSerializationTakesConvertersIntoAccount()
{
var o = new MyObject() { MyEnum = MyEnum.Foo, Nested = new NestedObject() };
var serializedObject = _serializationClient.Serializer.Serialize(o).Utf8String();
serializedObject.JsonEquals(@"
{
""myEnum"" : ""Foo"",
""nested"" : ""something""
}").Should().BeTrue();
}
开发者ID:radiosterne,项目名称:elasticsearch-net,代码行数:11,代码来源:CustomConvertersTests.cs
示例12: CreatingAnEventFromASimpleMethodWithTwoArgumentsShouldReturnMethodEventWithArgumentsForThatMethod
public void CreatingAnEventFromASimpleMethodWithTwoArgumentsShouldReturnMethodEventWithArgumentsForThatMethod()
{
var obj = new MyObject();
var expectedFirstArgument = "Something";
var expectedSecondArgument = 42;
var @event = MethodEventFactory.CreateMethodEventFromExpression(Guid.NewGuid(), () => obj.SimpleMethodWithTwoArguments(expectedFirstArgument, expectedSecondArgument));
Assert.That(@event, Is.Not.Null);
Assert.That(@event.Name, Is.EqualTo("SimpleMethodWithTwoArguments"));
dynamic arguments = @event.Arguments;
Assert.That(arguments.firstArgument, Is.EqualTo(expectedFirstArgument));
Assert.That(arguments.secondArgument, Is.EqualTo(expectedSecondArgument));
}
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:13,代码来源:MethodEventFactorySpecs.cs
示例13: CloneByJson_creates_new_object_with_same_values
public void CloneByJson_creates_new_object_with_same_values()
{
var nest = new MyNestedObject() { MyDateTimeProp = DateTime.Now, MyDoubleProp = 5.3 };
var obj = new MyObject() { MyIntProp = 5, MyStringProp = "Shnogerdob", MyNestedObjectProp = nest };
var objClone = obj.CloneByJson();
Assert.False(obj == objClone, "References should be different");
Assert.AreEqual(obj.MyIntProp, objClone.MyIntProp);
Assert.AreEqual(obj.MyStringProp, objClone.MyStringProp);
Assert.AreEqual(obj.MyNestedObjectProp.MyDateTimeProp, objClone.MyNestedObjectProp.MyDateTimeProp);
Assert.AreEqual(obj.MyNestedObjectProp.MyDoubleProp, obj.MyNestedObjectProp.MyDoubleProp);
}
开发者ID:DanStout,项目名称:ExtensionLib,代码行数:13,代码来源:GenericExtensionsTest.cs
示例14: Main
public static void Main()
{
MyObject obj1 = new MyObject(),obj2 = new MyObject(),obj3=obj1;
obj1.x =
obj2.x = 10;
ModifyByRef(ref obj1);
ModifyByVal(obj2);
if(obj1!=null) System.Console.WriteLine(obj1.x);
else System.Console.WriteLine("obj1 is null");
if(obj2!=null) System.Console.WriteLine(obj2.x);
else System.Console.WriteLine("obj2 is null");
if(obj3!=null) System.Console.WriteLine(obj3.x);
else System.Console.WriteLine("obj3 is null");
}
开发者ID:rags,项目名称:playground,代码行数:14,代码来源:objectref.cs
示例15: Test_Cache_Clear_All
public void Test_Cache_Clear_All()
{
var cache = Container.Resolve<IEntityCache>();
var msr = new ManualResetEvent(false);
Task.Run(async () =>
{
var item1 = new MyObject { ItemName = "Item1" };
var item2 = new MyObject { ItemName = "Item2" };
var item1a = new MyOtherObject { ItemName = "Item1" };
var item2a = new MyOtherObject { ItemName = "Item2" };
await cache.SetEntity(item1.ItemName, item1);
await cache.SetEntity(item2.ItemName, item2);
await cache.SetEntity(item1a.ItemName, item1a);
await cache.SetEntity(item2a.ItemName, item2a);
var result1 = await cache.GetEntity<MyObject>(item1.ItemName);
var result2 = await cache.GetEntity<MyObject>(item2.ItemName);
var result3 = await cache.GetEntity<MyOtherObject>(item1a.ItemName);
var result4 = await cache.GetEntity<MyOtherObject>(item2a.ItemName);
Assert.IsNotNull(result1);
Assert.IsNotNull(result2);
Assert.IsNotNull(result3);
Assert.IsNotNull(result4);
await cache.Clear();
var result1_e = await cache.GetEntity<MyObject>(item1.ItemName);
var result2_e = await cache.GetEntity<MyObject>(item2.ItemName);
var result3_e = await cache.GetEntity<MyOtherObject>(item1a.ItemName);
var result4_e = await cache.GetEntity<MyOtherObject>(item2a.ItemName);
Assert.IsNull(result1_e);
Assert.IsNull(result2_e);
Assert.IsNull(result3_e);
Assert.IsNull(result4_e);
msr.Set();
});
var msrResult = msr.WaitOne(20000);
Assert.IsTrue(msrResult, "MSR not set, means assertion failed in task");
}
开发者ID:jakkaj,项目名称:Xamling-Core,代码行数:50,代码来源:EntityCacheTEsts.cs
示例16: Map_MapsGenericProperties
public void Map_MapsGenericProperties()
{
int expectedInt = 42;
long expectedLong = 8675309;
string expectedString = "ExpectedString";
DateTime expectedDateTime = new DateTime(2015, 6, 12, 1, 2, 3);
MyObject myObject = new MyObject() { MyIntProperty = expectedInt, MyLongProperty = expectedLong, MyStringProperty = expectedString, MyDateTimeProperty = expectedDateTime };
var actual = AutoMapper.Map<MyObjectClone, MyObject>(myObject);
Assert.AreEqual(expectedInt, actual.MyIntProperty);
Assert.AreEqual(expectedLong, actual.MyLongProperty);
Assert.AreEqual(expectedString, actual.MyStringProperty);
Assert.AreEqual(expectedDateTime, actual.MyDateTimeProperty);
}
开发者ID:Flayed,项目名称:TrafficAvoider,代码行数:15,代码来源:AutoMapperTests.cs
示例17: Main
public static int Main ()
{
dynamic d = new MyObject ();
var g = d.GetMe;
if (MyObject.Get != 1 && MyObject.Invoke != 0)
return 1;
d.printf ("Hello, World!");
if (MyObject.Get != 1 && MyObject.Invoke != 1)
return 2;
Console.WriteLine ("ok");
return 0;
}
开发者ID:nobled,项目名称:mono,代码行数:15,代码来源:dtest-005.cs
示例18: TestReplaceBadTypeTarget
public void TestReplaceBadTypeTarget()
{
string value1 = "Testing Value - 1";
object value2 = new MyObject();
Utils.WeakReference<string> r = new Utils.WeakReference<string>(value1);
string tmp;
Assert.IsTrue(r.TryGetTarget(out tmp) && tmp == value1);
((WeakReference)r).Target = value2; //incorrect type...
Assert.IsFalse(r.IsAlive);
Assert.IsNull(r.Target);
Assert.IsFalse(r.TryGetTarget(out tmp));
Assert.IsTrue(ReferenceEquals(value2, ((WeakReference)r).Target));
}
开发者ID:langimike,项目名称:CSharpTest.Net.Collections,代码行数:16,代码来源:TestWeakReferenceT.cs
示例19: OnStart
protected override void OnStart()
{
var scene = new Scene();
var layer = new Layer2D();
var obj = new MyObject( 100, 128 );
var notDrawnObject = new MyObject( 300, 128 );
var notUpdatedObject = new MyObject( 500, 128 );
notDrawnObject.IsDrawn = false;
notUpdatedObject.IsUpdated = false;
layer.AddObject( obj );
layer.AddObject( notDrawnObject );
layer.AddObject( notUpdatedObject );
scene.AddLayer( layer );
Engine.ChangeScene( scene );
}
开发者ID:Pctg-x8,项目名称:Altseed,代码行数:17,代码来源:ObjectsFlag.cs
示例20: IsFree
bool IsFree(MyObject obj, int x, int y)
{
Rect myRectangleObj = new Rect();
myRectangleObj.Location = new Point(x, y);
myRectangleObj.Size = new Size(obj.Width, obj.Height);
foreach (var item in area.LMyObject)
{
Rect myRectangle = new Rect();
myRectangle.Location = new Point(item.X, item.Y);
myRectangle.Height = item.Height;
myRectangle.Width = item.Width;
if (myRectangle.IntersectsWith(myRectangleObj))
return false;
}
return true;
}
开发者ID:Shman4ik,项目名称:MPC1,代码行数:18,代码来源:Service1.cs
注:本文中的MyObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论