private void AdapterType(string data, int column) { try { TypeDecorator typeDecorator = TypeAdapter.Adapter(data); typeDecorator.index = column; datas.Add(typeDecorator); } catch (System.Exception e) { Common.Utility.Logger.Log("[{0}] AdapterType error, type is:{1}, column:{2}.", groupName, data, column); throw e; } }
public override object GetValue() { TypeDecoratorList itemsDecorator = TypeAdapter.Adapter("[float]") as TypeDecoratorList; itemsDecorator.runtimeType = typeof(List <float>); itemsDecorator.ResetFlag(1); object vs = ValueAdapter.Adapter(value, itemsDecorator); List <float> realvs = vs as List <float>; BindingFlags flags = BindingFlags.Public | BindingFlags.Instance; object v2 = Common.Utility.Reflection.CreateInstance(decorator.runtimeType); Common.Utility.Reflection.SetValue(decorator.runtimeType, "x", v2, realvs.Count > 0 ? realvs[0] : 0, flags); Common.Utility.Reflection.SetValue(decorator.runtimeType, "y", v2, realvs.Count > 1 ? realvs[1] : 0, flags); return(v2); }
public override object GetValue() { TypeDecoratorList itemsDecorator = TypeAdapter.Adapter("[int]") as TypeDecoratorList; itemsDecorator.runtimeType = typeof(List <int>); itemsDecorator.ResetFlag(1); object vs = ValueAdapter.Adapter(value, itemsDecorator); List <int> realvs = vs as List <int>; int r = realvs.Count > 0 ? realvs[0] : 0; int g = realvs.Count > 1 ? realvs[1] : 0; int b = realvs.Count > 2 ? realvs[2] : 0; int a = realvs.Count > 3 ? realvs[3] : 255; BindingFlags flags = BindingFlags.Public | BindingFlags.Instance; object Color = Common.Utility.Reflection.CreateInstance(decorator.runtimeType); Common.Utility.Reflection.SetValue(decorator.runtimeType, "r", Color, (float)r / 255f, flags); Common.Utility.Reflection.SetValue(decorator.runtimeType, "g", Color, (float)g / 255f, flags); Common.Utility.Reflection.SetValue(decorator.runtimeType, "b", Color, (float)b / 255f, flags); Common.Utility.Reflection.SetValue(decorator.runtimeType, "a", Color, (float)a / 255f, flags); return(Color); }