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); }
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 }
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")); }
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)); }
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; }
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)); }
public MyObject NewObject(int Width, int Height) { MyObject obj = new MyObject(); obj.Width = Width; obj.Height = Height; setСoordinates(obj); return obj; }
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); }
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); } }
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(); }
public void Method() { using (MyObject my = new MyObject()) { my.DoSomething(); string msg = "hello"; msg += " My name"; msg += " is Alex"; Console.WriteLine(msg); } }
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)); }
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); }
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"); }
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"); }
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; }
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); }
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)); }
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 ); }
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; }
public void TestKeepAliveMin() { WeakReference r; ObjectKeepAlive keep = new ObjectKeepAlive(1, 10, TimeSpan.FromTicks(1), true); for (int i = 0; i < 35; i++) keep.Add(i); 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 < 100; i++) keep.Tick(); Assert.IsTrue(r.IsAlive); GC.GetTotalMemory(true); GC.WaitForPendingFinalizers(); Assert.IsTrue(r.IsAlive); Assert.IsFalse(_destroyed); System.Threading.Thread.Sleep(1); GC.GetTotalMemory(true); GC.WaitForPendingFinalizers(); Assert.IsTrue(r.IsAlive); Assert.IsFalse(_destroyed); keep.Clear(); GC.GetTotalMemory(true); GC.WaitForPendingFinalizers(); Assert.IsFalse(r.IsAlive); Assert.IsTrue(_destroyed); }
MyObject setСoordinates(MyObject obj) { if (obj.Width >= obj.Height) { foreach (var item in area.LMyObject) { if (IsFree(obj, item.X + item.Width, item.Y + item.Height)) { obj.X = item.X + item.Width; obj.Y = item.Y + item.Height; return obj; } } } return null; // area. }
public EditCollectionsView() { InitializeComponent(); DataContext = this; Mapper.CreateMap<MyObject, MyObject>(); MyObjects = new ObservableCollection<MyObject>() { new MyObject() { Name = "Первый"}, new MyObject() { Name = "Второй"}, new MyObject() { Name = "Третий"} }; CurrentObject = new MyObject() { Name = "test" }; MyObjects.Insert(0, CurrentObject); SelectedItem = MyObjects.FirstOrDefault(); }
protected override void OnStart() { scene = new Scene(); layer = new Layer2D(); var notDrawnLayer = new Layer2D(); var notUpdatedLayer = new Layer2D(); var object1 = new MyObject( 100, 128 ); var object2 = new MyObject( 300, 128 ); var object3 = new MyObject( 500, 128 ); notDrawnLayer.IsDrawn = false; notUpdatedLayer.IsUpdated = false; layer.AddObject( object1 ); notDrawnLayer.AddObject( object2 ); notUpdatedLayer.AddObject( object3 ); scene.AddLayer( layer ); scene.AddLayer( notDrawnLayer ); scene.AddLayer( notUpdatedLayer ); Engine.ChangeScene( scene ); }
private void RemoveItemButtonClick(object sender, RoutedEventArgs e) { MyObjects.Remove(SelectedItem); SelectedItem = _observableCollection.FirstOrDefault(); }
public void Typeof_gets_reported_correctly() { var foo = new MyObject(); GetFailureMessage(() => foo.GetType() == typeof(string)); Verify.That(() => this.message == "Expected foo.GetType() to be typeof(string) but was typeof(MyObject)"); }
private void AddItemButtonClick(object sender, RoutedEventArgs e) { var newObject = new MyObject() {Name = "New object"}; MyObjects.Add(newObject); SelectedItem = newObject; }
private async Task TestOrderyByQueryAsync() { var jsonSerializerSettings = new JsonSerializerSettings { ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, Converters = { new ObjectStringJsonConverter <SerializedObject>(_ => _.Name, _ => SerializedObject.Parse(_)) } }; CosmosClient cosmosClient = TestCommon.CreateCosmosClient((cosmosClientBuilder) => cosmosClientBuilder.WithCustomSerializer(new CustomJsonSerializer(jsonSerializerSettings))); Container container = cosmosClient.GetContainer(databaseName, partitionedCollectionName); // Create a few test documents int documentCount = 3; var numberFieldName = "NumberField"; for (int i = 0; i < documentCount; ++i) { var newDocument = new MyObject(i); var createdDocument = await container.CreateItemAsync <MyObject>(newDocument); } QueryDefinition cosmosSqlQueryDefinition1 = new QueryDefinition("SELECT * FROM root"); FeedIterator <MyObject> setIterator1 = container.GetItemQueryIterator <MyObject>(cosmosSqlQueryDefinition1, requestOptions: new QueryRequestOptions { MaxConcurrency = -1, MaxItemCount = -1 }); QueryDefinition cosmosSqlQueryDefinition2 = new QueryDefinition("SELECT * FROM root ORDER BY root[\"" + numberFieldName + "\"] DESC"); FeedIterator <MyObject> setIterator2 = container.GetItemQueryIterator <MyObject>(cosmosSqlQueryDefinition2, requestOptions: new QueryRequestOptions { MaxConcurrency = -1, MaxItemCount = -1 }); List <MyObject> list1 = new List <MyObject>(); List <MyObject> list2 = new List <MyObject>(); while (setIterator1.HasMoreResults) { foreach (MyObject obj in await setIterator1.ReadNextAsync()) { list1.Add(obj); } } while (setIterator2.HasMoreResults) { foreach (MyObject obj in await setIterator2.ReadNextAsync()) { list2.Add(obj); } } Assert.AreEqual(documentCount, list1.Count); Assert.AreEqual(documentCount, list2.Count); for (int i = 0; i < documentCount; ++i) { Assert.AreEqual("Name: " + (documentCount - i - 1), list2[i].SerializedObject.Name); } }
public override void Initialize() { if (type != WeaponType.FISTS) { myPoint = new LightPoint(110, "LightPoint1", Color.Orange.ToVector3(), Color.Orange.ToVector3(), 6.0f, false); MyObject.AddChild(myPoint); myPoint.MyTransform = new Transform(myPoint, new Vector3(0.0f, 0.25f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), 1.0f); myPoint.MyCollider = new SphereCollider(myPoint, true); myPoint.MyCollider.CustomScale = new Vector3(5.0f, 0.0f, 0.0f); myPoint.MyPhysicalObject = new PhysicalObject(myPoint, 0.0f, 0.0f, false); ResourceManager.Instance.CurrentScene.PointLights.Add(myPoint); foreach (GameObject obj in ResourceManager.Instance.CurrentScene.ObjectsDictionary.Values) { if (obj.Name.Contains("Street") && !obj.LightsAffecting.Contains(myPoint) && Vector3.Distance(MyObject.MyTransform.PositionGlobal, obj.MyTransform.PositionGlobal) <= 20.0f) { myPoint.AffectedObjects.Add(obj); obj.LightsAffecting.Add(myPoint); } } } this.player = ResourceManager.Instance.CurrentScene.GetObject(1); if (this.player != null) { this.pc = (PlayerController)this.player.GetComponent <PlayerController>(); } if (ParticleTexturePaths != null && ParticleTexturePaths.Count() != 0) { int pCount = ParticleTexturePaths.Count(); GameObject dupa = new GameObject(132453245, "asfoieasjhgeowisughasaedokfgheasiourfdseyhaeyogfiuhsweoiughdseifoluh"); ps = new ParticleSystem(this.MyObject); for (int i = 0; i < pCount; ++i) { ps.Textures.Add(ResourceManager.Instance.LoadTexture(ParticleTexturePaths[i])); } ps.ParticleCount = 20; ps.ParticleSize = new Vector2(0.3f, 0.3f); ps.ParticleSizeVariation = new Vector2(0.2f, 0.2f); ps.LifespanSec = 0.8f; ps.Wind = new Vector3(0.0f, 0.0f, 0.0f); ps.Offset = new Vector3(MathHelper.Pi); ps.Speed = 2.0f; ps.RotationMode = ParticleSystem.ParticleRotationMode.DIRECTION_Z; ps.ParticleRotation = new Vector3(0.0f, 0.0f, MathHelper.PiOver4); ps.FadeInTime = 0.0f; ps.FadeOutTime = 0.05f; //ps.PositionOffset = new Vector3(0.0f, -1.0f, 0.0f) * MyObject.MyTransform.Scale; ps.BlendMode = BlendState.AlphaBlend; ps.UseGravity = true; ps.Mass = 0.00000005f; ps.Initialize(); ps.Stop(); dupa.Components.Add(ps); dupa.MyTransform = new Transform(dupa); MyObject.AddChild(dupa); } cModel = (CustomModel)MyObject.GetComponent <CustomModel>(); if (DestroyCueName != null && !TrashSoupGame.Instance.EditorMode) { jeb = Engine.AudioManager.Instance.SoundBank.GetCue(DestroyCueName); } base.Initialize(); }
public VeryBaseClass(string className, MyObject myObject) { this.ClassName = className; }
public MySecondObject(MyObject myObject) { myObject = myObject.PropertyOne;
public bool Equals(MyObject other) { return(other != null && other.attrb1 == attrb1 && other.attrb2 == attrb2); }
public void Method1() { myObject = new MyObject(); }
public SubEventArgs(MyObject obj) { MyObject = obj; }
private void Awake() { MainCamera = MyObject.Find("Camera"); }
public void CreateNewObject() { _obj = new MyObject(); }
private int numberOfRooms; //количество комнат public House() { MyObject.inputValue(ref numberOfRooms, "Введите количество комнат: "); }
protected void CalculatePosition(Vector3 value) { if (MyObject.GetType() == typeof(LightPoint)) { value.Z = -value.Z; } Vector3 tmp = this.prevPosition; this.positionChangeNormal = value - this.position; this.prevPosition = this.position; position.X = value.X; CalculateWorldMatrix(); if (!TrashSoupGame.Instance.EditorMode) { if (this.MyObject.MyCollider != null) { this.MyObject.MyCollider.UpdateCollider(); } if (!PhysicsManager.Instance.CanMove(this.MyObject)) { this.position = this.prevPosition; this.prevPosition = tmp; this.positionChangeNormal = Vector3.Zero; if (this.MyObject.MyCollider != null) { this.MyObject.MyCollider.UpdateCollider(); } CalculateWorldMatrix(); } } this.prevPosition = this.position; position.Y = value.Y; CalculateWorldMatrix(); if (!TrashSoupGame.Instance.EditorMode) { if (this.MyObject.MyCollider != null) { this.MyObject.MyCollider.UpdateCollider(); } if (!PhysicsManager.Instance.CanMove(this.MyObject)) { this.position = this.prevPosition; this.prevPosition = tmp; this.positionChangeNormal = Vector3.Zero; if (this.MyObject.MyCollider != null) { this.MyObject.MyCollider.UpdateCollider(); } CalculateWorldMatrix(); } } this.prevPosition = this.position; position.Z = value.Z; CalculateWorldMatrix(); if (!TrashSoupGame.Instance.EditorMode) { if (this.MyObject.MyCollider != null) { this.MyObject.MyCollider.UpdateCollider(); } if (!PhysicsManager.Instance.CanMove(this.MyObject)) { this.position = this.prevPosition; this.prevPosition = tmp; this.positionChangeNormal = Vector3.Zero; if (this.MyObject.MyCollider != null) { this.MyObject.MyCollider.UpdateCollider(); } CalculateWorldMatrix(); } } if (PositionChanged != null) { PositionChanged(this, null); } }
/// <summary> /// 读取地图中的配置 /// </summary> /// <param name="mapID">地图ID</param> /// <param name="path">配置文件路径</param> /// <param name="mapHeight">地图高度</param> /// <param name="MapWidth">地图宽度</param> /// <param name="readEquType">该设备类型是否进行读取</param> /// <returns>读取是否成功</returns> public bool Read(string mapID, string path, int mapHeight, int MapWidth, ReadEquType readEquType) { XmlDocument doc = new XmlDocument(); // 缓存设备 List <MyObject> equList = new List <MyObject>(); try { doc.Load(path); // 设备加载 List <Equ> equs = ds.ReadEqu(Convert.ToInt32(mapID)); List <yx> yxs = ds.GetYXs(); List <Yx_cfg> yxcfgs = ds.GetYXcfgs(); List <yk> yks = ds.GetYks(); List <Yk_cfg> ykcfgs = ds.GetYKcfgs(); List <yc> ycs = ds.GetYcs(); List <Yc_cfg> yccfgs = ds.GetYccfgs(); List <p_area_cfg> areas = ds.GetAllArea(); gMain.log.WriteLog("start readxml:" + DateTime.Now.ToString("HH:mm:ss.fff")); List <Yx_cfg> yxcfgdb = new List <Yx_cfg>(); List <Yk_cfg> ykcfgdb = new List <Yk_cfg>(); //交大地图的宽度和高度 int width = Convert.ToInt32(doc.GetElementsByTagName("PicInfo")[0].Attributes["width"].InnerText); int hight = Convert.ToInt32(doc.GetElementsByTagName("PicInfo")[0].Attributes["hight"].InnerText); XmlNodeList xnl = doc.GetElementsByTagName("ob"); if (xnl != null) { //读取父设备信息 string tvFarther = ds.GetFartherID("TV"); string epFarther = ds.GetFartherID("EP"); string firFarther = ds.GetFartherID("F"); for (int i = 0; i < xnl.Count; i++) { MyObject m_object = null; //m_object = new MyObject(); string type = xnl[i].Attributes["Type"].Value; XmlNode ConXml = xnl[i].SelectSingleNode("ControlObject"); XmlNode drawob = xnl[i].SelectSingleNode("DrawOb"); XmlNode name = drawob.SelectSingleNode("ObjectName"); XmlNode xy = drawob.SelectSingleNode("EndPoint"); if (Convert.ToInt32(xy.Attributes["X"].Value) < 0) { continue; } if (Convert.ToInt32(xy.Attributes["Y"].Value) < 0) { continue; } switch (type) { case "12836": //情报板 #region 情报板 if (!readEquType.CMS) { continue; } m_object = new CMObject(); string strName = ConXml.Attributes["StrName"].Value; if (strName.IndexOf("1") > 0) //门架 { m_object.equtype = MyObject.ObjectType.CM; } //else //if (strName.IndexOf("2") > 0)//限速标志 //{ // m_object.equtype = "S"; //} else //F板 { m_object.equtype = MyObject.ObjectType.CF; } if (strName.IndexOf("r") > 0) { m_object.equ.DirectionID = 1; } if (strName.IndexOf("l") > 0) { m_object.equ.DirectionID = 2; } #region 情报板配置信息读取 XmlDocument xd = new XmlDocument(); var cmsNode = ConXml.SelectSingleNode("ExtAttribute"); if (cmsNode == null) { continue; } string cmsInfo = cmsNode.InnerText; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); xd.LoadXml(cmsInfo); ((CMSEqu)m_object).cms_pro.CMSWidth = Convert.ToInt32(xd.GetElementsByTagName("CMS")[0].Attributes["Width"].InnerText); ((CMSEqu)m_object).cms_pro.CMSHeight = Convert.ToInt32(xd.GetElementsByTagName("CMS")[0].Attributes["Height"].InnerText); ((CMSEqu)m_object).cms_pro.EquID = m_object.equ.EquID; ((CMSEqu)m_object).cms_pro.FontType = "楷体"; ((CMSEqu)m_object).cms_pro.FontColor = "黄"; ((CMSEqu)m_object).cms_pro.BackColor = "黑"; ((CMSEqu)m_object).cms_pro.FontSize = 24; ((CMSEqu)m_object).cms_pro.ContentType = 1; ((CMSEqu)m_object).cms_pro.CharBetween = 5; ((CMSEqu)m_object).cms_pro.OutType = 1; ((CMSEqu)m_object).cms_pro.OutSpeed = 20; ((CMSEqu)m_object).cms_pro.StayTime = 200; ((CMSEqu)m_object).cms_pro.BlankCount = 0; ((CMSEqu)m_object).cms_pro.MinFontSize = 16; ((CMSEqu)m_object).cms_pro.SupportPic = 1; ((CMSEqu)m_object).cms_pro.PicLocation = "CmsListBitmap1"; #endregion m_object.equ.TaskWV = 1; #endregion break; case "12839": //限速标志 m_object = new MyObject(); if (!readEquType.S) { continue; } m_object.equtype = MyObject.ObjectType.S; m_object.equ.TaskWV = 1; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); break; case "12838": //车检器 if (!readEquType.VC) { continue; } m_object = new MyObject(); m_object.equtype = MyObject.ObjectType.VC; m_object.equ.AlarmMethod = "NORMAL"; m_object.equ.TaskWV = 1; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); break; case "12862": //气象仪 if (!readEquType.VI) { continue; } m_object = new MyObject(); m_object.equtype = MyObject.ObjectType.VI; m_object.equ.AlarmMethod = "YW"; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.TaskWV = 1; break; case "12834": //广播 continue; case "12832": //紧急电话 if (!readEquType.EP) { continue; } m_object = new EPEqu(); m_object.equtype = MyObject.ObjectType.EP_T; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); AddEPConfig((EPEqu)m_object, ConXml); break; case "12833": //摄像机 if (!readEquType.TV) { continue; } m_object = new TVEqu(); switch (ConXml.Attributes["StrName"].Value) { case "lcctv1_mov.bmp": case "rcctv1_mov.bmp": m_object.equtype = MyObject.ObjectType.TV_CCTV_Gun; break; case "rcctv2_mov.bmp": case "lcctv2_mov.bmp": m_object.equtype = MyObject.ObjectType.TV_CCTV_E; break; default: m_object.equtype = MyObject.ObjectType.TV_CCTV_Ball; break; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); if (!ConXml.Attributes["Region"].Value.Equals("0")) { AddCCTVConfig((TVEqu)m_object, ConXml.Attributes["Region"].Value); } break; case "12835": //火灾 if (!readEquType.FIRE) { continue; } //m_object = new MyObject(); XmlNode addressxy = drawob.SelectSingleNode("EndPoint"); int x = Convert.ToInt32(addressxy.Attributes["X"].Value) * MapWidth / width; AddFireConfig(equList, ConXml, name.InnerText, x, ref firFarther, mapID); continue; #region plc case "12837": //车道指示器 if (!readEquType.P_TL) { continue; } m_object = new PLCEqu(); switch (ConXml.Attributes["StrName"].Value) { case "lindicator_mov.bmp": //左 case "uindicator_mov.bmp": m_object.equtype = MyObject.ObjectType.P_TL5_Left; break; case "rindicator_mov.bmp": //右 case "dindicator_mov.bmp": m_object.equtype = MyObject.ObjectType.P_TL5_Right; break; case "sindicator_mov.bmp": m_object.equtype = MyObject.ObjectType.P_TL2_Close; break; default: continue; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12831": //交通灯 if (!readEquType.P_HL) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_HL2; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12830": //照明 if (!readEquType.LIGHT) { continue; } m_object = new PLCEqu(); if (name.InnerText.IndexOf("应") > 0 || name.InnerText.IndexOf("引") > 0) //基本 { m_object.equtype = MyObject.ObjectType.P_LYJ; } else if (name.InnerText.IndexOf("JQ") > 0 || name.InnerText.IndexOf("加") > 0) //加强 { m_object.equtype = MyObject.ObjectType.P_LJQ; } else //基本 { m_object.equtype = MyObject.ObjectType.P_L; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12829": //风机 if (!readEquType.P_JF) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_JF; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12846": //GJ if (!readEquType.GJ) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_GJ; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12843": //CO if (!readEquType.CO) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_CO; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12844": //VI if (!readEquType.VI) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_VI; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12848": //TW if (!readEquType.TW) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_TW; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12842": //横通门 if (!readEquType.TD) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_TD; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; case "12845": //高位水池 if (!readEquType.LLID) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_LLDI; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12855": //水泵 if (!readEquType.P_P) { continue; } m_object = new PLCEqu(); m_object.equtype = MyObject.ObjectType.P_P; m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddYCConfig(m_object as PLCEqu, ConXml, ycs, yccfgs, ref areas, equList, mapID); break; case "12840": //车行横通标志\转弯灯 if (!readEquType.P_TL2) { continue; } m_object = new PLCEqu(); switch (ConXml.Attributes["StrName"].Value) { case "uvehicleflag_mov.bmp": //向上 m_object.equtype = MyObject.ObjectType.P_TL2_UP; break; case "dvehicleflag_mov.bmp": //向下 m_object.equtype = MyObject.ObjectType.P_TL2_Down; break; default: continue; } m_object.equ.EquID = NameTool.CreateEquId(m_object.equtype); m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; AddConfig((PLCEqu)m_object, ConXml, yxcfgs, ykcfgs, equList, ref areas, mapID, yxcfgdb, ykcfgdb); break; #endregion default: continue; } m_object.equ.EquName = name.InnerText; m_object.equ.PileNo = ConXml.Attributes["Badge"].Value; m_object.equ.PointX = (Convert.ToInt32(xy.Attributes["X"].Value) * MapWidth / width).ToString(); m_object.equ.PointY = "-" + Convert.ToInt32(xy.Attributes["Y"].Value) * mapHeight / hight; m_object.equ.MapID = mapID; m_object.equ.plcStationAddress = ConXml.Attributes["Station"].Value; m_object.equ.AddressDiscribe = xnl[i].Attributes["ID"].Value; #region 子系统 if ("-1".Equals(ConXml.Attributes["Station"].Value) && m_object.equtype != MyObject.ObjectType.TV_CCTV_Gun) { if (m_object.equtype == MyObject.ObjectType.TV_CCTV_Gun || m_object.equtype == MyObject.ObjectType.TV_CCTV_E || m_object.equtype == MyObject.ObjectType.TV_CCTV_Ball || m_object.equtype == MyObject.ObjectType.EP_T) { } else { continue; } } if (m_object.equ.EquTypeID.StartsWith("TV_CCTV")) { if (tvFarther == null) { TVEqu tvInfo = new TVEqu(); tvInfo.equtype = MyObject.ObjectType.TV; tvInfo.equ.EquID = NameTool.CreateEquId(tvInfo.equtype); tvInfo.equ.EquName = "摄像机流媒体服务器"; tvInfo.equ.PointX = "0"; tvInfo.equ.PointY = "0"; tvInfo.equ.TaskWV = 1; tvInfo.equ.MapID = mapID; equList.Add(tvInfo); tvFarther = tvInfo.equ.EquID; } m_object.equ.FatherEquID = tvFarther; } if (m_object.equ.EquTypeID.StartsWith("EP_")) { if (epFarther == null) { EPEqu epInfo = new EPEqu(); epInfo.equtype = MyObject.ObjectType.EP; epInfo.equ.EquID = NameTool.CreateEquId(epInfo.equtype); epInfo.equ.EquName = "紧急电话主机"; epInfo.equ.PointX = "50"; epInfo.equ.PointY = "0"; epInfo.equ.TaskWV = 1; epInfo.equ.MapID = mapID; equList.Add(epInfo); epFarther = epInfo.equ.EquID; } m_object.equ.FatherEquID = epFarther; } if (m_object.equ.EquTypeID.StartsWith("F_")) { } #endregion equList.Add(m_object); } int InsertCount = 0; if (equList.Count > 0) { InsertCount = dbop.InsertEqu(equList); List <Tv_cctv_cfg> tvinfos = new List <Tv_cctv_cfg>(); List <f_c_cfg> fireinfos = new List <f_c_cfg>(); List <ep_c_cfg> epinfos = new List <ep_c_cfg>(); List <c_cfg> cms = new List <c_cfg>(); gMain.log.WriteLog("yxcfgdb:" + DateTime.Now); if (yxcfgdb.Count > 0) { dbop.InsertYXConfig(yxcfgdb); } gMain.log.WriteLog("ykcfgdb:" + DateTime.Now); if (ykcfgdb.Count > 0) { dbop.InsertYKConfig(ykcfgdb); } gMain.log.WriteLog("子系统:" + DateTime.Now); for (int i = 0; i < equList.Count; i++) { if (equList[i] is FireEqu)//插入火灾配置信息 { fireinfos.Add((equList[i] as FireEqu).fire_pro); } else if (equList[i] is TVEqu)//插入摄像机配置信息 { if ((equList[i] as TVEqu).tv_pro.CCTVID != null) { tvinfos.Add((equList[i] as TVEqu).tv_pro); } } else if (equList[i] is EPEqu)//插入紧急电话配置 { epinfos.Add((equList[i] as EPEqu).ep_pro); } else if (equList[i] is CMSEqu)//插入plc配置信息 { cms.Add((equList[i] as CMSEqu).cms_pro); } } gMain.log.WriteLog("火灾配置条数:" + dbop.InsertFire(fireinfos)); gMain.log.WriteLog("摄像机配置条数:" + dbop.InsertCCTV(tvinfos)); gMain.log.WriteLog("紧急电话配置条数:" + dbop.InsertEpList(epinfos)); gMain.log.WriteLog("情报板配置条数:" + dbop.InsertC_cfgList(cms)); } //gMain.log.WriteLog("InsertCount:" + InsertCount); } } catch (Exception e) { gMain.log.WriteLog(e); return(false); } return(true); }
public void AddAvatarPedestals() { GameObject MyObject, MyParentObject = null; VRC_AvatarPedestal MyAvatarScript; Vector3 V = new Vector3(); int i, l, m, n, k, CurrentRow = 0, CurrentReset = 0, CurrentReset2 = 0; MeshRenderer[] MyMeshRenderers; Material[] MyMaterials; if (SelectedObject == null) { CustomMessage = "You've To Select Avatar Pedestal"; return; } MyAvatarScript = SelectedObject.GetComponent <VRC_AvatarPedestal>(); if (MyAvatarScript == null) { CustomMessage = "VRC_AvatarPedestal Script Not Found. Select Correct Avatar Pedestal"; return; } if (UsedName == "" || UsedTag == "") { CustomMessage = "You've To Set Used Name And Used Tag"; return; } CustomMessage = ""; PendingAvatarPedestals.Clear(); for (i = 0; i < ListOfAvatarIDs.Count; i++) { if (i > 0 && i % LengthOfRow == 0) { CurrentRow++; if (CurrentRow == MaxRows) { CurrentRow = 0; CurrentReset++; if (CurrentReset == MaxResets) { CurrentReset = 0; CurrentReset2++; } } } V = StartPosition + (i % LengthOfRow) * OffsetByIndex + OffsetByRow * CurrentRow + OffsetByReset * CurrentReset + OffsetByReset2 * CurrentReset2; MyObject = Instantiate(SelectedObject, V, SelectedObject.transform.rotation); MyObject.name = Repl(UsedName, "%Index%", i.ToString()); MyObject.tag = UsedTag; MyObject.SetActive(!bDefaultHide); if (bKeepParentObject) { if (SelectedObject.transform.parent != null) { MyParentObject = SelectedObject.transform.parent.gameObject; } } else { MyParentObject = ParentObject; } if (MyParentObject != null && MyParentObject.transform != null) { MyObject.transform.SetParent(MyParentObject.transform, bWorldPositionStays); } if (CustomMeterialsByID.List.Count > 0) { for (m = 0; m < CustomMeterialsByID.List.Count; m++) { for (n = 0; n < CustomMeterialsByID.List[m].ListOfIDs.Count; n++) { if (CustomMeterialsByID.List[m].ListOfIDs[n] == ListOfAvatarIDs[i]) { MyMeshRenderers = MyObject.GetComponentsInChildren <MeshRenderer>(true); for (k = 0; k < MyMeshRenderers.Length; k++) { MyMaterials = MyMeshRenderers[k].materials; for (l = 0; l < MyMaterials.Length; l++) { MyMaterials[l] = CustomMeterialsByID.List[m].M; } MyMeshRenderers[k].materials = MyMaterials; } } } } } MyAvatarScript = MyObject.GetComponent <VRC_AvatarPedestal>(); MyAvatarScript.blueprintId = ListOfAvatarIDs[i]; if (bActivateByTrigger) { PendingAvatarPedestals.Add(MyObject); } } if (bActivateByTrigger) { AddAvatarPedestalsToTrigger(); } }
public InheritedClass(MyObject myObject) : base(myObject) { }
public void TestStoredProcedure() { // Create a document client with a customer json serializer settings JsonSerializerSettings serializerSettings = new JsonSerializerSettings(); serializerSettings.Converters.Add(new ObjectStringJsonConverter <SerializedObject>(_ => _.Name, _ => SerializedObject.Parse(_))); ConnectionPolicy connectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway }; ConsistencyLevel defaultConsistencyLevel = ConsistencyLevel.Session; DocumentClient client = CreateDocumentClient( this.hostUri, this.masterKey, serializerSettings, connectionPolicy, defaultConsistencyLevel); // Create a simple stored procedure var scriptId = "bulkImportScript"; var sproc = new StoredProcedure { Id = scriptId, Body = @" function bulkImport(docs) { var collection = getContext().getCollection(); var collectionLink = collection.getSelfLink(); // The count of imported docs, also used as current doc index. var count = 0; // Validate input. if (!docs) throw new Error(""The array is undefined or null.""); var docsLength = docs.length; if (docsLength == 0) { getContext().getResponse().setBody(0); } // Call the CRUD API to create a document. tryCreate(docs[count], callback); // Note that there are 2 exit conditions: // 1) The createDocument request was not accepted. // In this case the callback will not be called, we just call setBody and we are done. // 2) The callback was called docs.length times. // In this case all documents were created and we don't need to call tryCreate anymore. Just call setBody and we are done. function tryCreate(doc, callback) { // If you are sure that every document will contain its own (unique) id field then // disable the option to auto generate ids. // by leaving this on, the entire document is parsed to check if there is an id field or not // by disabling this, parsing of the document is skipped because you're telling DocumentDB // that you are providing your own ids. // depending on the size of your documents making this change can have a significant // improvement on document creation. var options = { disableAutomaticIdGeneration: true }; var isAccepted = collection.createDocument(collectionLink, doc, options, callback); // If the request was accepted, callback will be called. // Otherwise report current count back to the client, // which will call the script again with remaining set of docs. // This condition will happen when this stored procedure has been running too long // and is about to get cancelled by the server. This will allow the calling client // to resume this batch from the point we got to before isAccepted was set to false if (!isAccepted) getContext().getResponse().setBody(count); } // This is called when collection.createDocument is done and the document has been persisted. function callback(err, doc, options) { if (err) throw err; // One more document has been inserted, increment the count. count++; if (count >= docsLength) { // If we have created all documents, we are done. Just set the response. getContext().getResponse().setBody(count); } else { // Create next document. tryCreate(docs[count], callback); } } } " }; sproc = client.CreateStoredProcedureAsync(collectionUri, sproc).Result.Resource; var doc = new MyObject(1); var args = new dynamic[] { new dynamic[] { doc } }; RequestOptions requestOptions = ApplyRequestOptions(new RequestOptions { PartitionKey = new PartitionKey("value") }, serializerSettings); StoredProcedureResponse <int> scriptResult = client.ExecuteStoredProcedureAsync <int>( sproc.SelfLink, requestOptions, args).Result; var docUri = UriFactory.CreateDocumentUri(databaseName, collectionName, doc.id); var readDoc = client.ReadDocumentAsync <MyObject>(docUri, requestOptions).Result.Document; Assert.IsNotNull(readDoc.SerializedObject); Assert.AreEqual(doc.SerializedObject.Name, readDoc.SerializedObject.Name); }
public BaseClass(MyObject myObject) : base(typeof(T).Name, myObject) { }
public MyClass(MyObject Test) { this.Test = Test; }
static void Main(string[] args) { var o = new MyObject { MyNumber = 8 }; }
void UpdatePlayer(MyObject obj, Player player) { }
public static Type GetMyObjectInstanceType(MyObject someObject) { return(someObject.GetType()); }
public static void Main() { MyObject my = new MyObject(10, 20); Console.WriteLine("x = {0}, y = {1}", my.X, my.Y); }
public static int Main() { var context = new MyObject(); return(0); }
public void Test_Clear_And_Read_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 item3 = new MyObject { ItemName = "Item3" }; var item4 = new MyObject { ItemName = "Item4" }; await cache.SetEntity(item1.ItemName, item1); var result = await cache.GetEntity<MyObject>(item1.ItemName); Assert.IsNotNull(result); await cache.DeleteAll<MyObject>(); var result2 = await cache.GetEntity<MyObject>(item1.ItemName); Assert.IsNull(result2); await cache.SetEntity(item1.ItemName, item1); await cache.SetEntity(item2.ItemName, item2); await cache.SetEntity(item3.ItemName, item3); await cache.SetEntity(item4.ItemName, item4); var result3 = await cache.GetEntity<MyObject>(item1.ItemName); var result4 = await cache.GetEntity<MyObject>(item2.ItemName); var result5 = await cache.GetEntity<MyObject>(item3.ItemName); var result6 = await cache.GetEntity<MyObject>(item4.ItemName); Assert.IsNotNull(result3); Assert.IsNotNull(result4); Assert.IsNotNull(result5); Assert.IsNotNull(result6); var all = await cache.GetAll<MyObject>(); Assert.IsFalse(all.Count == 0); await cache.Delete<MyObject>(item2.ItemName); var result7 = await cache.GetEntity<MyObject>(item1.ItemName); var result8 = await cache.GetEntity<MyObject>(item2.ItemName); var result9 = await cache.GetEntity<MyObject>(item3.ItemName); var result10 = await cache.GetEntity<MyObject>(item4.ItemName); var result10a = await cache.GetEntity<MyObject>("Some other thing"); Assert.IsNotNull(result7); Assert.IsNull(result8); Assert.IsNull(result10a); Assert.IsNotNull(result9); Assert.IsNotNull(result10); await cache.DeleteAll<MyObject>(); var result11 = await cache.GetEntity<MyObject>(item1.ItemName); var result12 = await cache.GetEntity<MyObject>(item2.ItemName); var result13 = await cache.GetEntity<MyObject>(item3.ItemName); var result14 = await cache.GetEntity<MyObject>(item4.ItemName); Assert.IsNull(result11); Assert.IsNull(result12); Assert.IsNull(result13); Assert.IsNull(result14); msr.Set(); }); var msrResult = msr.WaitOne(20000); Assert.IsTrue(msrResult, "MSR not set, means assertion failed in task"); }
static void Main(string[] args) { var myValue = new MyObject() { attr1 = "ABC", attr2 = new MySubObject() { attr1 = "XYZ", attr2 = "ABC", attr3 = 567 }, attr3 = 123, attr4 = new List<String>(new String[] { "abc", "def" }) }; var outputBuffer = new MemoryStream(); var serializerSettings = new DataContractJsonSerializerSettings() { UseSimpleDictionaryFormat = false }; var serializer = new DataContractJsonSerializer(typeof(MyObject), serializerSettings); serializer.WriteObject(outputBuffer, myValue); System.Console.Out.WriteLine(Encoding.UTF8.GetString(outputBuffer.ToArray())); }
public MyObjectSearch(MyObject obj) : base(obj) { this.Distance = 0; }
private void EditItemButtonClick(object sender, RoutedEventArgs e) { var objectCopy = Mapper.Map<MyObject>(SelectedItem); objectCopy.Name = "Edited object " + _counter++; var index = MyObjects.IndexOf(SelectedItem); MyObjects[index].InjectFrom(objectCopy); SelectedItem = MyObjects[index]; }
public void CSharpEngineTestTex() { string result; var o = new MyObject(); var engine = new CSharpEngine(); result = engine.Generate(@"{## print o.x; ##}", o); Trace.WriteLine(result); Assert.AreEqual(o.x.ToString(), result); engine.AddEscapeSequenze("%##", "##%"); result = engine.Generate(@"%####% %## ##% %####% \documentclass{article} \usepackage{bchart} \begin{document} \begin{bchart}[step=2,max=10] {####} {## ##} {## print o.Value; ##} {## print o.Value2; ##} {## if (o.x) { ##} \bcbar{3.4} \smallskip {## } else if (o.y) { ##} \bcbar{5.6} \medskip {## } else if (o.z) { ##} \bcbar{7.2} \bigskip {## } else { ##} \bcbar{9.9} {## } ##} \end{bchart} \end{document}", o); Trace.WriteLine(result); Assert.AreEqual(@" " + @" " + @" \documentclass{article} " + @" \usepackage{bchart} " + @" \begin{document} \begin{bchart}[step=2,max=10] " + @" " + @" " + o.Value.ToString() + @" " + o.Value2.ToString() + @" " + @" \bcbar{9.9} " + @" \end{bchart} \end{document}", result); }
private void Event() { target = MyPlayer.GetPlayer(); switch (triggerPointName) { case "ComeDown": { if (MySpace.IsInArea2D(gameObject, target, 0.15f)) { MyObject.SetObjectActive("Canvas/ComeDown"); } else { MyObject.SetObjectActive("Canvas/ComeDown", false); } break; } case "ComeUp": { if (MySpace.IsInArea2D(gameObject, target, 0.15f)) { MyObject.SetObjectActive("Canvas/ComeUp"); } else { MyObject.SetObjectActive("Canvas/ComeUp", false); } break; } case "ExitHome": { if (Dialogue.nowIndex >= 15) { if (MySpace.IsInArea2D(gameObject, target, 0.4f)) { MyObject.SetObjectActive("Canvas/ExitHome"); } else { MyObject.SetObjectActive("Canvas/ExitHome", false); } } break; } case "GoHome": { if (target.name == "YangYi" && Dialogue.nowIndex >= 5 && !target.GetComponent <PlayerStatus>().isInCarrier) { if (MySpace.IsInArea2D(gameObject, target, 0.4f)) { MyObject.SetObjectActive("Canvas/GoHome"); } else { MyObject.SetObjectActive("Canvas/GoHome", false); } } break; } case "UpDown_01": { float deltaX = target.transform.position.x - transform.position.x; if (deltaX > 0 && deltaX < 1.0f) { if (nowTime == 0.0f) { target.GetComponent <SpriteRenderer>().enabled = false; target.GetComponent <PlayerController>().enabled = false; } nowTime += Time.deltaTime; if (nowTime >= 3.0f) { target.GetComponent <SpriteRenderer>().enabled = true; nowTime = 0.0f; nowFloorNum = (nowFloorNum + 1) % 2; if (nowFloorNum == 0) { target.transform.position = new Vector3(transform.position.x, -0.3f, -0.2f); } else if (nowFloorNum == 1) { target.transform.position = new Vector3(transform.position.x, 2.1f, -0.2f); } target.GetComponent <PlayerController>().SetDirection(-1); target.GetComponent <PlayerController>().enabled = true; } } break; } } }
/// <summary> /// 设置plc父设备信息配置 /// </summary> /// <param name="mapID">地图ID</param> /// <param name="equList">设备列表</param> /// <param name="m_object">实体对象</param> /// <param name="note">YK,YX,YC 设置需要的分区类型</param> /// <returns>分区编号,-1表示失败</returns> private int SetPLCFartherInfo(string mapID, List <MyObject> equList, MyObject m_object, string note, ref List <p_area_cfg> areaList) { int areaID = -1; try { string farterEquid = string.Empty; farterEquid = (from a in equList where a.equtype == MyObject.ObjectType.P && a.equ.plcStationAddress == m_object.equ.plcStationAddress select a.equ.EquID).FirstOrDefault(); if (string.IsNullOrEmpty(farterEquid)) { PLCEqu plcInfo = new PLCEqu(); plcInfo.equtype = MyObject.ObjectType.P; plcInfo.equ.EquID = NameTool.CreateEquId(plcInfo.equtype); plcInfo.equ.EquName = plcInfo.equ.EquID; plcInfo.equ.plcStationAddress = m_object.equ.plcStationAddress; plcInfo.equ.AddressDiscribe = m_object.equ.plcStationAddress; plcInfo.equ.PointX = (Convert.ToInt32(m_object.equ.PointX) + 20).ToString(); plcInfo.equ.PointY = m_object.equ.PointY; plcInfo.equ.TaskWV = 1; plcInfo.equ.MapID = mapID; equList.Add(plcInfo); farterEquid = plcInfo.equ.EquID; } m_object.equ.FatherEquID = farterEquid; var temp = (from a in areaList where a.equid == farterEquid && a.note == note select a).FirstOrDefault(); if (temp == null) { p_area_cfg areainfo = new p_area_cfg(); areainfo = (from a in PlcString.p_config.areas where a.note == note select a).FirstOrDefault(); areainfo.equid = m_object.equ.FatherEquID; if (areainfo != null) { areaID = dbop.InsertArea(areainfo); areaList.Add(new p_area_cfg { equid = areainfo.equid, id = areaID, note = areainfo.note, point = areainfo.point, yclength = areainfo.yclength, ycstartAddress = areainfo.ycstartAddress, yxcommlength = areainfo.yxcommlength, yxlength = areainfo.yxlength, yxstartAddress = areainfo.yxstartAddress }); //areaList.Clear(); //areaList = ds.GetAllArea(); } } else { areaID = temp.id; } } catch (Exception e) { gMain.log.WriteLog("SetPLCFartherInfo:" + e); return(-1); } return(areaID); }
public UndoRedoAction(MyObject obj) { myobj = obj; }
public A([param: Obsolete] int foo) : base(1) { L: { int i = sizeof(int); ++i; var s1 = $"x {1 , -2 :d}"; var s2 = $@"x {1 , -2 :d}"; } Console.WriteLine(export.iefSupplied.command); const int? local = int.MaxValue; const Guid?local0 = new Guid(r.ToString()); var привет = local; var мир = local; var local3 = 0, local4 = 1; local3 = local4 = 1; var local5 = null as Action ?? null; var local6 = local5 is Action; var u = 1u; var U = 1U; long hex = 0xBADC0DE, Hex = 0XDEADBEEF, l = -1L, L = 1L, l2 = 2l; ulong ul = 1ul, Ul = 1Ul, uL = 1uL, UL = 1UL, lu = 1lu, Lu = 1Lu, lU = 1lU, LU = 1LU; int minInt32Value = -2147483648; int minInt64Value = -9223372036854775808L; bool @bool; byte @byte; char @char = 'c', \u0066 = '\u0066', hexchar = '\x0130', hexchar2 = (char)0xBAD; string \U00000065 = "\U00000065"; decimal @decimal = 1.44M; @decimal = 1.2m; dynamic @dynamic; double @double = M.PI; @double = 1d; @double = 1D; @double = -1.2e3; float @float = 1.2f; @float = 1.44F; int @int = local ?? -1; long @long; object @object; sbyte @sbyte; short @short; string @string = @"""/*"; uint @uint; ulong @ulong; ushort @ushort; dynamic dynamic = local5; var add = 0; var alias = 0; var arglist = 0; var ascending = 0; var async = 0; var await = 0; var by = 0; var descending = 0; var dynamic = 0; var equals = 0; var from = 0; var get = 0; var group = 0; var into = 0; var join = 0; var let = 0; var nameof = 0; var on = 0; var orderby = 0; var partial = 0; var remove = 0; var select = 0; var set = 0; var var = 0; var when = 0; var where = 0; var yield = 0; var __ = 0; where = yield = 0; if (i > 0) { return; } else if (i == 0) { throw new Exception(); } var o1 = new MyObject(); var o2 = new MyObject(var); var o3 = new MyObject { A = i }; var o4 = new MyObject(@dynamic) { A = 0, B = 0, C = 0 }; var o5 = new { A = 0 }; var dictionaryInitializer = new Dictionary <int, string> { { 1, "" }, { 2, "a" } }; float[] a = new float[] { 0f, 1.1f }; int[, ,] cube = { { { 111, 112, }, { 121, 122 } }, { { 211, 212 }, { 221, 222 } } }; int[][] jagged = { { 111 }, { 121, 122 } }; int[][,] arr = new int[5][, ]; // as opposed to new int[][5,5] arr[0] = new int[5, 5]; // as opposed to arr[0,0] = new int[5]; arr[0][0, 0] = 47; int[] arrayTypeInference = new[] { 0, 1, }; switch (3) { } switch (i) { case 0: case 1: { goto case 2; } case 2 + 3: { goto default; break; } default: { return; } } while (i < 10) { ++i; if (true) { continue; } break; } do { ++i; if (true) { continue; } break; }while (i < 10); for (int j = 0; j < 100; ++j) { for (;;) { for (int i = 0, j = 0; i < length; i++, j++) { } if (true) { continue; } break; } } label: goto label; label2 :; foreach (var i in Items()) { if (i == 7) { return; } else { continue; } } checked { checked (++i); } unchecked { unchecked (++i); } lock (sync) process(); using (var v = BeginScope()) using (A a = new A()) using (A a = new A(), b = new A()) using (BeginScope()) return; yield return(this.items[3]); yield break; fixed(int *p = stackalloc int[100], q = &y) { *intref = 1; } fixed(int *p = stackalloc int[100]) { *intref = 1; } unsafe { int *p = null; } try { throw null; } catch (System.AccessViolationException av) { throw av; } catch (Exception) { throw; } finally { try { } catch { } } var anonymous = { A = 1, B = 2, C = 3, }; var query = from c in customers let d = c where d != null join c1 in customers on c1.GetHashCode() equals c.GetHashCode() join c1 in customers on c1.GetHashCode() equals c.GetHashCode() into e group c by c.Country into g orderby g.Count() ascending orderby g.Key descending select new { Country = g.Key, CustCount = g.Count() }; query = from c in customers select c into d select d; }
public void DelayActionObject(string objectName, float seconds) { nowTime = -seconds; MyObject.SetObjectActive(objectName); }
protected MyObject(MyObject other) { this.Prop1 = other.Prop1; this.Prop2 = other.Prop2; }