public static int Main() { Base <int> fInt = new FooInt(); Eval(fInt.Function <int>(1).Equals(1)); Eval(fInt.Function <string>("string").Equals("string")); Base <object> fObject = new FooObject(); Eval(fObject.Function <int>(1).Equals(1)); Eval(fObject.Function <string>("string").Equals("string")); Base <string> fString = new FooString(); Eval(fString.Function <int>(1).Equals(1)); Eval(fString.Function <string>("string").Equals("string")); if (result) { Console.WriteLine("Test Passed"); return(100); } else { Console.WriteLine("Test Failed"); return(1); } }
/// <summary> /// 更新 /// </summary> /// <param name="model">The model.</param> /// <returns> /// <c>true</c> if XXXX, <c>false</c> otherwise. /// </returns> /// <exception cref="System.ArgumentException">model</exception> public async Task <IResult> UpdateAsync(FooObject model) { var stepName = $"{nameof(FooService)}.UpdateAsync"; using (ProfilingSession.Current.Step(stepName)) { var startTime = SystemTime.UtcNow; if (model.EqualNull()) { throw new ArgumentNullException(nameof(model)); } IResult result = new Result(false); var exists = await this.IsExistsAsync(model.FooId); if (exists.Equals(false)) { result.Message = "無法找到 id 對應的資料"; return(result); } var fooModel = this.Mapper.Map <FooObject, FooModel>(model); result = await this.FooRepository.UpdateAsync(fooModel); return(result); } }
void Update() { TestSwig swig = new TestSwig(); FooObject obj = new FooObject(); obj.a = 1; //测试普通对象使用 int i = swig.UseFool(obj); number = TestSwig.Add(number, i); countNumberText.text = number.ToString(); }
protected override void Because_of() { var source = new FooDto { Values = new List <DestinationValuePair> { new DestinationValuePair { Key = "Key1", Value = "Value1" }, new DestinationValuePair { Key = "Key2", Value = "Value2" } }.ToArray() }; _result = Mapper.Map <FooDto, FooObject>(source); }
//----------------------------------------------------------------------------------------- /// <summary> /// 新增 /// </summary> /// <param name="model">The model.</param> /// <returns> /// <c>true</c> if XXXX, <c>false</c> otherwise. /// </returns> /// <exception cref="System.ArgumentNullException">model</exception> public async Task <IResult> InsertAsync(FooObject model) { var stepName = $"{nameof(FooService)}.InsertAsync"; using (ProfilingSession.Current.Step(stepName)) { var startTime = SystemTime.UtcNow; if (model.EqualNull()) { throw new ArgumentNullException(nameof(model)); } // 檢查名稱是否與現有資料衝突 var totalCount = await this.FooRepository.GetTotalCountAsync(true); if (totalCount > 0) { var collection = await this.FooRepository.GetCollectionAsync(1, totalCount, true); if (collection.Any(x => x.Name.Equals(model.Name, StringComparison.OrdinalIgnoreCase))) { return(new Result(false) { Message = "已有重複名稱的資料存在" }); } } if (model.FooId.Equals(Guid.Empty)) { model.FooId = Guid.NewGuid(); } // 新增資料 var fooModel = this.Mapper.Map <FooObject, FooModel>(model); var result = await this.FooRepository.InsertAsync(fooModel); return(result); } }
public async Task <IActionResult> Create(FooCreateViewModel model) { if (this.ModelState.IsValid.Equals(false)) { var viewModel = new FooCreateViewModel(); return(this.View(viewModel)); } var fooObject = new FooObject { FooId = Guid.NewGuid(), Name = model.Name, Description = model.Description, Enable = model.Enable, CreateTime = SystemTime.UtcNow, UpdateTime = SystemTime.UtcNow }; await this.FooService.InsertAsync(fooObject); return(this.RedirectToAction(nameof(Index))); }
public int UseFool(FooObject obj) { int ret = swiglibPINVOKE.TestSwig_UseFool(swigCPtr, FooObject.getCPtr(obj)); return(ret); }
public static float[] SuperFoo(this FooObject foo, float[] floats) { foo.FillFoos(floats); return(floats); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FooObject obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public async Task <FooObject?> GetFoo(IResolverContext context, CancellationToken ct) => await FooObject.Get(context, "hello", ct);