public Response <string> AddExpressAndUpdatePackageYD(YdResponseParam responseParam, Entity.PackageInfo package, PdfInfoObj obj) { Response <string> response = new Response <string>(); try { ExpressAccessor accessor = new ExpressAccessor(); response.Result = accessor.AddExpressAndUpdatePackageYD(responseParam, package, obj); if (response.Result == "") { response.IsSuccess = true; } else { response.IsSuccess = false; } } catch (Exception ex) { LogError(ex); response.Exception = ex; response.IsSuccess = false; response.Result = ex.Message; } return(response); }
public void ExpressAccessor_Setters() { //Arrange var dateTime = DateTime.Now; var childRef = new TestClass { TestString = "ChildRef" }; var testObject = new TestClass { TestString = "bbb", TestInt = 10, TestDate = dateTime, TestRef = null }; //Act var stringAcc = ExpressAccessor.Create(typeof(TestClass), typeof(string), "TestString"); var intAcc = ExpressAccessor.Create(typeof(TestClass), typeof(int), "TestInt"); var dateAcc = ExpressAccessor.Create(typeof(TestClass), typeof(DateTime), "TestDate"); var refAcc = ExpressAccessor.Create(typeof(TestClass), typeof(TestClass), "TestRef"); stringAcc.Set(testObject, "aaa"); intAcc.Set(testObject, 20); dateAcc.Set(testObject, DateTime.MaxValue); refAcc.Set(testObject, childRef); //Assert Assert.AreEqual("aaa", testObject.TestString); Assert.AreEqual(20, testObject.TestInt); Assert.AreEqual(DateTime.MaxValue, testObject.TestDate); Assert.AreEqual(childRef, testObject.TestRef); }
public void ExpressAccessor_Getters() { //Arrange var dateTime = DateTime.Now; var childRef = new TestClass { TestString = "ChildRef" }; var testObject = new TestClass { TestString = "bbb", TestInt = 10, TestDate = dateTime, TestRef = childRef }; //Act var stringAcc = ExpressAccessor.Create(typeof(TestClass), typeof(string), "TestString"); var intAcc = ExpressAccessor.Create(typeof(TestClass), typeof(int), "TestInt"); var dateAcc = ExpressAccessor.Create(typeof(TestClass), typeof(DateTime), "TestDate"); var refAcc = ExpressAccessor.Create(typeof(TestClass), typeof(TestClass), "TestRef"); var @string = stringAcc.Get(testObject); var @int = intAcc.Get(testObject); var date = dateAcc.Get(testObject); var @ref = refAcc.Get(testObject); //Assert Assert.AreEqual("bbb", @string); Assert.AreEqual(10, @int); Assert.AreEqual(dateTime, date); Assert.AreEqual(@ref, childRef); }
public void AddExpressAndUpdatePackage(DPCreateOrderResponse response, IEnumerable <Entity.PackageInfo> packages) { try { ExpressAccessor accessor = new ExpressAccessor(); packages.ForEach(item => accessor.AddExpressAndUpdatePackage(response, item)); } catch (Exception ex) { } }
public CollectionVisitor(Type ownerType, Type collectionType, string elementName = null, PropertyGuard guard = null, bool supportsCloning = true) : base(guard, supportsCloning) { ElementName = elementName; if (!string.IsNullOrWhiteSpace(elementName)) { _elementAccessor = ExpressAccessor.Create(ownerType, collectionType, elementName); } if (SupportsCloning) { _elementCloner = ClonerBase.Create(collectionType); } }
public InstanceCloner() : base() { //Creating constructor function (1st step: createing initial instance). _constructor = Constructor <TElement>(); //creating property getter/setter for each property that is of primitive (value) type (2nd step: cloning primitive values into new instance) _accessors = new List <ExpressAccessor>(); foreach (var property in typeof(TElement).GetProperties()) { if (Util.IsSimpleType(property.PropertyType)) { var accessor = ExpressAccessor.Create(typeof(TElement), property.PropertyType, property.Name); _accessors.Add(accessor); } } }
public Response <ExpressResponse> GetOrderByYD(string PackageNumber) { Response <ExpressResponse> response = new Response <ExpressResponse>() { Result = new ExpressResponse() }; try { ExpressAccessor accessor = new ExpressAccessor(); response.Result = accessor.GetOrderByYD(PackageNumber); response.IsSuccess = true; } catch (Exception ex) { LogError(ex); response.Exception = ex; response.IsSuccess = false; response.ErrorCode = ErrorCode.Technical; } return(response); }
public DictionaryVisitor(Type ownerType, Type dictionaryType, string elementName = null, PropertyGuard guard = null, bool supportsCloning = true) : base(guard, supportsCloning) { ElementName = elementName; if (!string.IsNullOrWhiteSpace(elementName)) { _elementAccessor = ExpressAccessor.Create(ownerType, dictionaryType, elementName); } if (SupportsCloning) { _elementCloner = ClonerBase.Create(dictionaryType); } var keyType = dictionaryType.GenericTypeArguments[0]; var valueType = dictionaryType.GenericTypeArguments[1]; var kvpType = typeof(KeyValuePair <,>).MakeGenericType(keyType, valueType); KeyValueAccessor = ExpressAccessor.Create(kvpType, valueType, "Value"); }