public static void RunTest() { var child = new Child(); var otherChild = new OtherChild(); MyObj <Child> myObj = child.GetMyObj(); MyObj <OtherChild> myOtherObj = otherChild.GetMyObj(); }
void OnEnable() { if (_myobj == null) { _myobj = target as MyObj; } }
public void ConstructorValidationWorks() { MyObj objectInstance1 = new MyObj(); MyObj objectInstance2 = SingletonFactory.Get<MyObj>(); MyObj objectInstance3 = Activator.CreateInstance<MyObj>(); IOnce anotherObject = IoC.Resolve<IOnce>(); IoC.Resolve<IOnce>(1, objectInstance1, objectInstance2, objectInstance3, anotherObject); }
async Task RunIEnumeratorStringTestAsync() { Debug.Log("Waiting for ienumerator..."); //Debug.Log("Done! Result: " + await WaitForString()); MyObj obj = await WaitForStruct(); Debug.Log(obj.f1); }
public void Request() { if (mo == null) { mo = new MyObj(); } mo.Request(); }
void ToEmptyScene() { // 清理MyObj.saveAsset MyObj myObj = GameObject.FindObjectOfType <MyObj>(); GameObject.DestroyImmediate(myObj.saveAsset, true); UnityEngine.SceneManagement.SceneManager.LoadScene("empty"); }
static void Main(string[] args) { var json_serializer = new JavaScriptSerializer(); MyObj routes_list = json_serializer.Deserialize <MyObj>("{ \"test\":\"some data\" }"); Console.WriteLine(routes_list.test); Console.WriteLine("Done..."); Console.ReadKey(true); }
static void Main(string[] args) { MyDict <string, MyObj> dict; dict = new MyDict <string, MyObj>(); MyObj sampleObj = new MyObj(); dict.Add("aaa", sampleObj); MyObj xxx = dict["aaa"]; }
public static bool SaveData(string item, int qty, DateTime date, string phone) { var select = MyObj.InsertData(item, qty, date, phone); /* return new JavaScriptSerializer().Serialize( * "Hello, " + item + ", " + qty + " " + date+ " "+ phone+"!");*/ return(select); //return "Hello i am parth"; }
public bool override Equals(Object obj) { MyObj mobj = obj as MyObj; if (mobj == null) { return(false); } return(this.mID == mobj.mID); }
public void SetEquals(MyObj other) { if (object.ReferenceEquals(this, other)) { return; // We are equal by reference, so do nothing. } this.Property1 = other.Property1; this.Property2 = other.Property2; this.Property3 = other.Property3; // ... }
IEnumerator <string> WaitForString() { MyObj obj = new MyObj("f1", "f2"); var startTime = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup - startTime < 2) { yield return(null); } yield return(obj.f2); }
IEnumerator <MyObj> WaitForStruct() { MyObj obj = new MyObj("f1", "f2"); int count = 0; while (count < 100) { count += 1; yield return(null); } yield return(obj); }
public void TestInstanceFunc() { object result; MyObj obj = new MyObj(1); ExpressionContext ctx = new ExpressionContext(); ctx.AddVariable <Func <long, long> >("add"); ctx.SetVariable("add", new Func <long, long>(obj.Add)); CompileContext comple = new CompileContext(ctx); var expr = ScriptExpressionReader.Instance.Parse("add(2)", comple); result = comple.Compile(expr)(ctx); Assert.AreEqual(result, 3L); }
public void implicit_null_comparison_demo() { MyObj mo = null; // ... if (mo) // <-- like so (can also use !mo) { // it's not null... } else { // it's null... } }
private static void AssertRoundtrips(DataSerializer ser) { var o = new MyObj { X = 42 }; var ms = new MemoryStream(); ser.Serialize(o, ms); ms.Position = 0; var res = ser.Deserialize <MyObj>(ms); Assert.AreEqual(42, res.X); }
public void SetEquals(MyObj other) { if (object.ReferenceEquals(this, other)) { return; // We are equal by reference, so do nothing. } if (other == null) { return; // Throw ArgumentException? Up to you. } this.Property1 = other.Property1; this.Property2 = other.Property2; this.Property3 = other.Property3; // ... }
public void Main() { try { using (var obj = MyObj.Create()) { var message = obj.ReadMessage(); Console.WriteLine(message); } } catch (Exception ex) { // Everything is already cleaned up by the using statement. Console.WriteLine(ex.Message); } }
public async Task dtStringJson(string input) { var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringjson"; _ = await _redisCacheSvc.db.KeyDeleteAsync(key); var objOut = new MyObj($"{input} {DateTime.UtcNow}"); var jsonOut = objOut.ToJSON(); _ = await _redisCacheSvc.db.StringSetAsync(key, jsonOut); var result = await _redisCacheSvc.db.StringGetAsync(key); Assert.Equal(jsonOut, result); Assert.Equal(objOut, result.FromJSON <MyObj>()); }
protected void Page_Load(object sender) { if (a == true) { CallFunc(123, 456); } const int AAA = 0xF5; Label1.Text = "Hello World!"; var a = 1234; string s = "asd\nf;oaweif" + 'a'; MyObj o = new MyObj <T> { A = 1 }; var s = $"asdfasdf{123}"; var r = new Regex("\<[a-zA-Z]+\>");
public async Task dtStringMsgPack(string input) { var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringmessagepack"; _ = await _redisCacheSvc.db.KeyDeleteAsync(key); var objOut = new MyObj($"{input} {DateTime.UtcNow}"); var jsonOut = objOut.ToMessagePack(); _ = await _redisCacheSvc.db.StringSetAsync(key, jsonOut); var result = await _redisCacheSvc.db.StringGetAsync(key); Assert.Equal(jsonOut.Length, result.Length()); Assert.Equal(objOut, result.FromMessagePack <MyObj>()); }
public async Task DataTypeMessagePack() { var _redisCacheSvc = _serviceProvider.GetRequiredService <RedisCacheService>(); var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringmessagepack"; var obj = new MyObj($"hello world! {DateTime.UtcNow}"); for (var i = 0; i < 10_000; i++) { _ = await _redisCacheSvc.db.KeyDeleteAsync(key); _ = await _redisCacheSvc.db.StringSetAsync(key, obj.ToMessagePack()); var result = await _redisCacheSvc.db.StringGetAsync(key); _ = result.FromMessagePack <MyObj>(); } }
public async Task DataTypeJson() { var _redisCacheSvc = _serviceProvider.GetRequiredService <RedisCacheService>(); var key = $"datatypes:{DateTime.UtcNow:yyyy-MM-dd}:stringjson"; var obj = new MyObj($"hello world! {DateTime.UtcNow}"); for (var i = 0; i < maxIterations; i++) { _ = await _redisCacheSvc.db.KeyDeleteAsync(key); _ = await _redisCacheSvc.db.StringSetAsync(key, obj.ToJSON()); var result = await _redisCacheSvc.db.StringGetAsync(key); _ = result.FromJSON <MyObj>(); } }
/// <summary> /// Overrides drawing. /// </summary> /// <param name="sB"></param> public override void Draw(SpriteBatch sB) { // If it has a texture: if (MyObj.GetModule <TextureModule>().Texture != null) { // Draw hitbox: Texture2D tex = MyObj.GetModule <TextureModule>().Texture; // Line across: sB.DrawLine( MyObj.WorldPosition, new Vector2(MyObj.WorldPosition.X + tex.Width, MyObj.WorldPosition.Y), Color.LightGreen, 1 ); sB.DrawLine( new Vector2(MyObj.WorldPosition.X + tex.Width, MyObj.WorldPosition.Y), new Vector2(MyObj.WorldPosition.X + tex.Width, MyObj.WorldPosition.Y + tex.Height), Color.LightGreen, 1 ); sB.DrawLine( new Vector2(MyObj.WorldPosition.X + tex.Width, MyObj.WorldPosition.Y + tex.Height), new Vector2(MyObj.WorldPosition.X, MyObj.WorldPosition.Y + tex.Height), Color.LightGreen, 1 ); sB.DrawLine( new Vector2(MyObj.WorldPosition.X, MyObj.WorldPosition.Y + tex.Height), MyObj.WorldPosition, Color.LightGreen, 1 ); sB.DrawLine( new Vector2(MyObj.WorldPosition.X + tex.Width, MyObj.WorldPosition.Y), new Vector2(MyObj.WorldPosition.X, MyObj.WorldPosition.Y + tex.Height), Color.LightGreen, 1 ); } // Else hitArea is 0 else { } }
public void Main() { try { using (var obj = MyObj.Create()) { // everything is already in a valid state. var message = obj.ReadMessage(); Console.WriteLine(message); } } catch (Exception ex) { // If the factory succeeded, the using statement did the cleanup. // if the factory failed, the factory took care of the cleanup. Console.WriteLine(ex.Message); } }
public static ItemMasterList GetData() { /*Dictionary<string, string> name = new Dictionary<string, string>(); * name.Add("1", "Sourav Kayal"); * name.Add("2", "Ram mishra"); * // my complicated logic goes here * // json dataArray = obj.ComplicatedMethod(params); * // return jsonStr; * string myJsonString = (new JavaScriptSerializer()).Serialize(name); * return myJsonString;*/ string myJsonString; var select = MyObj.GetData(); var serializer = new JavaScriptSerializer(); myJsonString = serializer.Serialize(select); return(select); }
public override void Update(GameTime gT) { TextureModule texModule = MyObj.GetModule <TextureModule>(); if (texModule == null) { _bounds = new Rectangle(); return; } if (texModule.Texture == null) { _bounds = new Rectangle(); return; } _bounds = new Rectangle((int)MyObj.WorldPosition.X, (int)MyObj.WorldPosition.Y, texModule.Texture.Width, texModule.Texture.Height); base.Update(gT); }
public void Add(MyObj obj) { List.Add(obj); }
static void Main(string[] args) { A aaa = new A(); MyObj ooo = new MyObj(aaa); A bbb = ooo.MyValue; }
public MyWrapper(MyObj paramObj) { wrappedObj = paramObj; }
static printString makeDelegate1(MyObj x) { printString ps = new printString(x.writeStr); return(ps); }
public Once1(int a, ObjBase b, IObj c, MyObj d, object e) { }