public void NullSimpleGenericType() { var tc = new TestClass(); var obj = PropertyAdapter.Create <TestClass>(tc, null); Assert.Equal(AsyncNull.Instance, obj.TryGetValue("GenericType")); }
static T1ProtocolParameterAdapter() { IPropertyAdapterFactory <T1ProtocolParameterAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <T1ProtocolParameterAdapter>(); T1ProtocolParameterAdapter.informationFieldSizeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.InformationFieldSize), instance => instance.protocolParameters.IfscValue, (instance, value) => instance.protocolParameters.Ifsc = value ); T1ProtocolParameterAdapter.informationFieldSizeIsDefaultAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.InformationFieldSizeIsDefault), instance => instance.protocolParameters.Ifsc.HasValue == false ); T1ProtocolParameterAdapter.characterWaitingTimeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.CharacterWaitingTime), instance => instance.protocolParameters.CwiValue ); T1ProtocolParameterAdapter.blockWaitingTimeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.BlockWaitingTime), instance => instance.protocolParameters.BwiValue ); T1ProtocolParameterAdapter.blockAndCharacterWaitingTimeIsDefaultAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.BlockAndCharacterWaitingTimeIsDefault), instance => instance.protocolParameters.Bwi.HasValue == false && instance.protocolParameters.Cwi.HasValue == false ); T1ProtocolParameterAdapter.redundancyCodeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.RedundancyCode), instance => EnumerationAdapter <RedundancyCodeType> .GetInstanceFor(instance.protocolParameters.RedundancyCodeValue), (instance, value) => instance.protocolParameters.RedundancyCode = value ); T1ProtocolParameterAdapter.redundancyCodeIsDefaultAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.RedundancyCodeIsDefault), instance => instance.protocolParameters.RedundancyCode.HasValue == false ); }
public void NullTaskObject() { var tc = new TestClass(); var obj = PropertyAdapter.Create <TestClass>(tc, null); Assert.Equal(new AsyncError("task is null"), obj.TryGetValue("TaskObject")); }
static DataObjectCardServiceDataAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectCardServiceDataAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectCardServiceDataAdapter>(); DataObjectCardServiceDataAdapter.dataObjectsAvailableInAtrFileAdapter = PropertyFactory.Create( nameof(DataObjectCardServiceDataAdapter.DataObjectsAvailableInAtrFile), instance => instance.value.DataObjectsAvailableInAtrFile, (instance, value) => instance.value.DataObjectsAvailableInAtrFile = value ); DataObjectCardServiceDataAdapter.dataObjectsAvailableInDirFileAdapter = PropertyFactory.Create( nameof(DataObjectCardServiceDataAdapter.DataObjectsAvailableInDirFile), instance => instance.value.DataObjectsAvailableInDirFile, (instance, value) => instance.value.DataObjectsAvailableInDirFile = value ); DataObjectCardServiceDataAdapter.supportsApplicationSelectionByFullDfNameAdapter = PropertyFactory.Create( nameof(DataObjectCardServiceDataAdapter.SupportsApplicationSelectionByFullDfName), instance => instance.value.SupportsApplicationSelectionByFullDfName, (instance, value) => instance.value.SupportsApplicationSelectionByFullDfName = value ); DataObjectCardServiceDataAdapter.supportsApplicationSelectionByPartialDfNameAdapter = PropertyFactory.Create( nameof(DataObjectCardServiceDataAdapter.SupportsApplicationSelectionByPartialDfName), instance => instance.value.SupportsApplicationSelectionByPartialDfName, (instance, value) => instance.value.SupportsApplicationSelectionByPartialDfName = value ); DataObjectCardServiceDataAdapter.fileIoServicesMethodAdapter = PropertyFactory.Create( nameof(DataObjectCardServiceDataAdapter.FileIoServicesMethod), instance => EnumerationAdapter <FileIoServices> .GetInstanceFor(instance.value.FileIoServicesMethod), (instance, value) => instance.value.FileIoServicesMethod = value ); }
public async Task <IEnumerable <Property> > GetAsync() { var response = await this.proxy.GetAsync(); var properties = response.Properties.Select(p => PropertyAdapter.CreateProperty(p)); return(properties.ToList()); }
public ModelAdapter(IModel model) { this.propertyAdapter = this.CreatePropertyAdapter( () => this.Property, () => model.SourceProperty.ToHexString(" "), value => model.SourceProperty = value.ToByteArray() ); }
public void SimpleInteger() { var tc = new TestClass { Integer = 456 }; var obj = PropertyAdapter.Create <TestClass>(tc, null) as IBifoqlLookupInternal; Assert.Equal(456, (int)obj.TryGetValueAsNumber("Integer")); }
public void SimpleProperty() { var tc = new TestClass { String = "Hello" }; var obj = PropertyAdapter.Create <TestClass>(tc, null) as IBifoqlLookupInternal; Assert.Equal("Hello", obj.TryGetValueAsString("String")); }
public void AsyncStringProperty() { var tc = new TestClass { AsyncString = (IBifoqlString)"Hello".ToBifoqlObject() }; var obj = PropertyAdapter.Create <TestClass>(tc, null) as IBifoqlLookupInternal; Assert.Equal("Hello", obj.TryGetValueAsString("AsyncString")); }
public void AsyncTaskObject() { var tc = new TestClass { AsyncTaskObject = Task.FromResult <IBifoqlObject>("HI".ToBifoqlObject()) }; var obj = PropertyAdapter.Create <TestClass>(tc, null); Assert.Equal("HI", obj.TryGetValueAsString("AsyncTaskObject")); }
public void TaskObject() { var tc = new TestClass { TaskObject = Task.FromResult <object>(12345) }; var obj = PropertyAdapter.Create <TestClass>(tc, null); Assert.Equal(12345d, obj.TryGetValueAsNumber("TaskObject")); }
public void SimpleObject() { var tc = new TestClass { SimpleObject = new { Name = "Fred" } }; var obj = PropertyAdapter.Create <TestClass>(tc, null); Assert.Equal("Fred", obj.TryGetValue("SimpleObject").TryGetValueAsString("Name")); }
static DataObjectStatusIndicatorAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectStatusIndicatorAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectStatusIndicatorAdapter>(); DataObjectStatusIndicatorAdapter.includedInTlvAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.IncludedInTlv), instance => instance.value.IncludedInTlv ); DataObjectStatusIndicatorAdapter.lifeCycleAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.LifeCycle), instance => instance.value.LifeCycle != null ? instance.value.LifeCycle.Value.ToString("X2") : null, (instance, value) => Helper.SetAsHexByteValue(value, _ => instance.value.LifeCycle = _) ); DataObjectStatusIndicatorAdapter.isLifeCycleDefinedAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.IsLifeCycleDefined), instance => instance.value.LifeCycle != null ); DataObjectStatusIndicatorAdapter.canUndefineLifeCycleAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.CanUndefineLifeCycle), instance => instance.value.CanUndefineLifeCycle ); DataObjectStatusIndicatorAdapter.lifeCycleInformationAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.LifeCycleInformation), instance => EnumerationAdapter <KnownLifeCycle> .GetInstanceFor(instance.value.LifeCycleInformation), (instance, value) => instance.value.LifeCycleInformation = value ); DataObjectStatusIndicatorAdapter.statusWordIndicationAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.StatusWordIndication), instance => EnumerationAdapter <StatusWordIndication> .GetInstanceFor(instance.value.StatusWordIndication), (instance, value) => instance.value.StatusWordIndication = value ); DataObjectStatusIndicatorAdapter.statusWordAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.StatusWord), instance => instance.value.StatusWord != null ? instance.value.StatusWord.Value.ToString("X4") : null, (instance, value) => Helper.SetAsHexUShortValue(value, _ => instance.value.StatusWord = _) ); DataObjectStatusIndicatorAdapter.statusWordCodingAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.StatusWordCoding), instance => EnumerationAdapter <StatusWordCoding> .GetInstanceFor(instance.value.IncludedInTlv?Classes.ATR.StatusWordCoding.WithinTlvData : Classes.ATR.StatusWordCoding.FollowingTlvData) ); DataObjectStatusIndicatorAdapter.isStatusWordDefinedAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.IsStatusWordDefined), instance => instance.value.StatusWordIndication != null ); DataObjectStatusIndicatorAdapter.canUndefineStatusWordAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.CanUndefineStatusWord), instance => instance.value.CanUndefineStatusWordIndication ); }
public void SimpleNumber() { var tc = new TestClass { Number = 123.0 }; var obj = PropertyAdapter.Create <TestClass>(tc, null) as IBifoqlLookupInternal; Assert.Equal(123.0, obj.TryGetValueAsNumber("Number")); }
static AtrInterfaceByteGroupTokenAdapter() { ObservableObject.IPropertyAdapterFactory <AtrInterfaceByteGroupTokenAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrInterfaceByteGroupTokenAdapter>(); AtrInterfaceByteGroupTokenAdapter.groupNumberAdatper = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.GroupNumber), instance => instance.atrInterfaceByteGroupToken.Number ); AtrInterfaceByteGroupTokenAdapter.typeAdatper = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Type), instance => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(instance.atrInterfaceByteGroupToken.Type) ); AtrInterfaceByteGroupTokenAdapter.taAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Ta), instance => instance.atrInterfaceByteGroupToken.Ta.HasValue ? instance.atrInterfaceByteGroupToken.Ta.Value.ToHexString() : null, (instance, value) => instance.atrInterfaceByteGroupToken.Ta = !string.IsNullOrEmpty(value)?byte.Parse(value.Substring(0, Math.Min(value.Length, 2)), NumberStyles.HexNumber):(byte?)null ); AtrInterfaceByteGroupTokenAdapter.tbAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Tb), instance => instance.atrInterfaceByteGroupToken.Tb.HasValue ? instance.atrInterfaceByteGroupToken.Tb.Value.ToHexString() : null, (instance, value) => instance.atrInterfaceByteGroupToken.Tb = !string.IsNullOrEmpty(value) ? byte.Parse(value.Substring(0, Math.Min(value.Length, 2)), NumberStyles.HexNumber) : (byte?)null ); AtrInterfaceByteGroupTokenAdapter.tcAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Tc), instance => instance.atrInterfaceByteGroupToken.Tc.HasValue ? instance.atrInterfaceByteGroupToken.Tc.Value.ToHexString() : null, (instance, value) => instance.atrInterfaceByteGroupToken.Tc = !string.IsNullOrEmpty(value) ? byte.Parse(value.Substring(0, Math.Min(value.Length, 2)), NumberStyles.HexNumber) : (byte?)null ); AtrInterfaceByteGroupTokenAdapter.nextGroupTypeAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.NextGroupType), instance => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator != null?instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.GroupType:(InterfaceByteGroupType?)null) ); AtrInterfaceByteGroupTokenAdapter.nextBytesTypeAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.NextBytes), instance => instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator != null?AtrTokenAdapterBase.ToString(instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TaExists, instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TbExists, instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TcExists, instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TdExists):"not set" ); AtrInterfaceByteGroupTokenAdapter.possibleTypesToChangeToAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.PossibleTypesToChangeTo), instance => ((InterfaceByteGroupType[])Enum.GetValues(typeof(InterfaceByteGroupType))) .Where(_ => _ != InterfaceByteGroupType.Global) //gloabl cannot be set; the first group automatically is global .Where(_ => instance.atrInterfaceByteGroupToken.NextGroup != null) //nothing cannot be set if no next group .Where(_ => _ != instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.GroupType) //we can skip what is already set .OrderBy(_ => (int)_) //Sort by id .SkipWhile(value => value < instance.atrInterfaceByteGroupToken.Type) //Next Group cannot be less than this group. Same is OK .TakeWhile(value => instance.atrInterfaceByteGroupToken.NextGroup.NextInterfaceBytesIndicator == null || value <= instance.atrInterfaceByteGroupToken.NextGroup.NextInterfaceBytesIndicator.GroupType), //next group cannot be higher than next to next group. Same is OK (instance, item) => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(item) ); AtrInterfaceByteGroupTokenAdapter.possibleTypesToAddNextGroupAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.PossibleTypesToAddNextGroup), instance => ((InterfaceByteGroupType[])Enum.GetValues(typeof(InterfaceByteGroupType))) .Where(_ => _ != InterfaceByteGroupType.Global) //gloabl cannot be set; the first group automatically is global .OrderBy(_ => (int)_) //Sort by id .SkipWhile(value => value < instance.atrInterfaceByteGroupToken.Type) //Next Group cannot be less than this group. Same is OK .TakeWhile(value => instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator == null || value <= instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.GroupType), //next group cannot be higher than next to next group. Same is OK (instance, item) => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(item) ); }
static DataObjectIssuerIdentificationNumberAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectIssuerIdentificationNumberAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectIssuerIdentificationNumberAdapter>(); DataObjectIssuerIdentificationNumberAdapter.issuerIdentificationNumberAdapter = PropertyFactory.Create( nameof(DataObjectIssuerIdentificationNumberAdapter.IssuerIdentificationNumber), instance => instance.value.IssuerIdentificationNumber, (instance, value) => instance.value.IssuerIdentificationNumber = value ); }
static AtrDirDataReferenceHistoricalBytesAdapter() { ObservableObject.IPropertyAdapterFactory <AtrDirDataReferenceHistoricalBytesAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrDirDataReferenceHistoricalBytesAdapter>(); AtrDirDataReferenceHistoricalBytesAdapter.dirDataReferenceAdapter = PropertyFactory.Create( nameof(AtrDirDataReferenceHistoricalBytesAdapter.DirDataReference), instance => instance.historicalCharacters.DirDataReference.ToHexString(), (instance, value) => Helper.SetAsHexByteValue(value, _ => instance.historicalCharacters.DirDataReference = _) ); }
public void SimpleObjectTask() { var tc = new TestClass { TaskObject = Task.FromResult <object>(new Person { Name = "Bill" }) }; var obj = PropertyAdapter.Create <TestClass>(tc, null) as IBifoqlLookupInternal; Assert.Equal("Bill", obj.TryGetValue("TaskObject").TryGetValueAsString("Name")); }
public void SimpleNamedType() { var tc = new TestClass { NamedType = new Person { Name = "Bill" } }; var obj = PropertyAdapter.Create <TestClass>(tc, null) as IBifoqlLookupInternal; Assert.Equal("Bill", obj.TryGetValue("NamedType").TryGetValueAsString("Name")); }
static T0ProtocolParameterAdapter() { IPropertyAdapterFactory <T0ProtocolParameterAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <T0ProtocolParameterAdapter>(); T0ProtocolParameterAdapter.waitingTimeIntegerAdapter = PropertyFactory.Create( nameof(T0ProtocolParameterAdapter.WaitingTimeInteger), instance => instance.protocolParameters.WaitingTimeIntegerValue, // read value or default (instance, value) => instance.protocolParameters.WaitingTimeInteger = value // set fix value ); T0ProtocolParameterAdapter.waitingTimeIntegerIsDefaultAdapter = PropertyFactory.Create( nameof(T0ProtocolParameterAdapter.WaitingTimeIntegerIsDefault), instance => instance.protocolParameters.WaitingTimeInteger.HasValue == false ); }
static ModelGroupAdapter() { IPropertyAdapterFactory <ModelGroupAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelGroupAdapter>(); ModelGroupAdapter.modelsAdapter = Factory.Create( nameof(ModelGroupAdapter.Models), instance => instance.Group.Models, (instance, model) => new ModelInfoAdapter(instance, model) ); ModelGroupAdapter.nameAdapter = Factory.Create( nameof(ModelGroupAdapter.Name), instance => instance.Group.Name, (instance, value) => instance.Group.Name = value ); }
static AtrProprietaryHistoricalBytesAdapter() { IPropertyAdapterFactory <AtrProprietaryHistoricalBytesAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrProprietaryHistoricalBytesAdapter>(); AtrProprietaryHistoricalBytesAdapter.structureIndicatorAdapter = PropertyFactory.Create( nameof(AtrProprietaryHistoricalBytesAdapter.CategoryIndicator), instance => instance.historicalCharacters.CategoryIndicator.ToHexString(), (instance, value) => Helper.SetAsHexByteValue(value, _ => instance.historicalCharacters.CategoryIndicator = _) ); AtrProprietaryHistoricalBytesAdapter.dataAdapter = PropertyFactory.Create( nameof(AtrProprietaryHistoricalBytesAdapter.Bytes), instance => instance.historicalCharacters.Bytes.ToHexString(" "), (instance, value) => Helper.SetAsHexValue(value, 0, 15, _ => instance.historicalCharacters.Bytes = _) ); }
public void SimpleAsyncGenericType() { var list = new List <IBifoqlObject> { "Hi".ToBifoqlObject() }; var tc = new TestClass { AsyncGenericType = list }; var obj = PropertyAdapter.Create <TestClass>(tc, null); var listObj = (IBifoqlArrayInternal)obj.TryGetValue("AsyncGenericType"); var hi = listObj[0]().Result.TryGetString(); Assert.Equal("Hi", hi); }
public void DictOfAsyncObjectTasks() { var dict = new Dictionary <string, Task <IBifoqlObject> > { ["a"] = Task.FromResult("ABC".ToBifoqlObject()) }; var tc = new TestClass() { DictOfAsyncObjectTasks = dict }; var obj = PropertyAdapter.Create <TestClass>(tc, null); IBifoqlLookupInternal lookup = (IBifoqlLookupInternal)obj.TryGetValue("DictOfAsyncObjectTasks"); Assert.Equal("ABC", lookup.TryGetValueAsString("a")); }
static ModelInfoAdapter() { IPropertyAdapterFactory <ModelInfoAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelInfoAdapter>(); ModelInfoAdapter.typeNameAdapter = Factory.Create( nameof(ModelInfoAdapter.TypeName), instance => instance.Model.Root.Type != null ? instance.Model.Root.Type.Name : "null" ); ModelInfoAdapter.rootAdapter = Factory.Create( nameof(ModelInfoAdapter.Root), instance => ModelNodeBaseAdapter.GetAdapter(instance, instance.Model.Root) ); ModelInfoAdapter.nameAdapter = Factory.Create( nameof(ModelInfoAdapter.Name), instance => instance.Model.Name, (instance, value) => instance.Model.Name = value ); }
static DataObjectCountryCodeAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectCountryCodeAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectCountryCodeAdapter>(); DataObjectCountryCodeAdapter.countryAdapter = PropertyFactory.Create( nameof(DataObjectCountryCodeAdapter.Country), instance => instance.value.Country, (instance, value) => instance.value.Country = value ); DataObjectCountryCodeAdapter.countryTextAdapter = PropertyFactory.Create( nameof(DataObjectCountryCodeAdapter.CountryText), instance => instance.value.Country.ToString() ); DataObjectCountryCodeAdapter.nationalDateAdapter = PropertyFactory.Create( nameof(DataObjectCountryCodeAdapter.NationalDate), instance => instance.value.NationalDate, (instance, value) => instance.value.NationalDate = value ); }
public async Task SimpleNestedAsyncGenericType() { var list = new List <IBifoqlObject> { "Hey".ToBifoqlObject() }; var listOfList = new List <IList <IBifoqlObject> > { list }; var tc = new TestClass { NestedAsyncGenericType = listOfList }; var obj = PropertyAdapter.Create <TestClass>(tc, null); var listObj = (IBifoqlArrayInternal)obj.TryGetValue("NestedAsyncGenericType"); var innerListObj = (IBifoqlArrayInternal)await listObj[0](); var hi = innerListObj[0]().Result.TryGetString(); Assert.Equal("Hey", hi); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value.GetType() == typeof(string)) { PropertyAdapter adapter = (PropertyAdapter)context.Instance; string name = context.PropertyDescriptor.Name; GeneralPropertyDescriptor gpd = (GeneralPropertyDescriptor)context.PropertyDescriptor; WhiskeyProperty whiskeyProp = adapter.WhiskeyPropertys.Where((w) => { return(w.Name.Equals(name)); }).ToList()[0]; Type toType = whiskeyProp.TypeVal.Value.GetType(); TypeConverter converter = WhiskeyTypeConverters.lookUp(toType.Name); if (converter != null && value != null && converter.CanConvertFrom(value.GetType())) { object converted = converter.ConvertFrom(context, culture, value); whiskeyProp.TypeVal.Value = converted; } if (ConverterManager.Instance.hasConverter(toType)) { whiskeyProp.TypeVal.Value = ConverterManager.Instance.convertFromString(toType, (string)value); } else { try { whiskeyProp.TypeVal.Value = Convert.ChangeType(value, toType); } catch (Exception e) { //??? } } return(gpd.PropValue); } return(base.ConvertFrom(context, culture, value)); }
public void Add(string propertyName, IMessagePropertyInitializer <TMessage> initializer) { _initializers[propertyName] = new PropertyAdapter(initializer); }
internal static IBifoqlObject ToBifoqlObject(this object o) { if (o is IBifoqlObject) { return((IBifoqlObject)o); } if (o == null) { return(AsyncNull.Instance); } var defaultValue = GetDefaultValueFunc(o); if (o is IBifoqlArray) { return(ConvertAsyncArray((IBifoqlArray)o)); } if (o is IBifoqlArraySync) { return(ConvertSyncArray((IBifoqlArraySync)o)); } if (o is IBifoqlMap) { return(ConvertAsyncMap((IBifoqlMap)o, defaultValue)); } if (o is IBifoqlMapSync) { return(ConvertSyncMap((IBifoqlMapSync)o, defaultValue)); } if (o is IBifoqlLookup) { return(new AsyncPureLookup(((IBifoqlLookup)o), defaultValue)); } if (o is IBifoqlLookupSync) { return(new SyncPureLookup((IBifoqlLookupSync)o, defaultValue)); } if (o is IBifoqlIndex) { return(ConvertAsyncIndex((IBifoqlIndex)o, defaultValue)); } if (o is IBifoqlIndexSync) { return(ConvertSyncIndex((IBifoqlIndexSync)o, defaultValue)); } if (o is DynamicDict) { return(ConvertDynamicDict((DynamicDict)o)); } if (o is IDictionary) { return(ConvertDictionary(o, toLookup: false)); } if (o is bool) { return(new AsyncBoolean(Convert.ToBoolean(o))); } if (o is int || o is uint || o is byte || o is sbyte || o is short || o is ushort || o is long || o is ulong || o is double || o is float) { return(new AsyncNumber(Convert.ToDouble(o))); } if (o is string || o.GetType().IsValueType) { return(new AsyncString(o.ToString())); } if (o is IEnumerable) { return(ConvertList(o)); } return(PropertyAdapter.Create(o, o.GetType(), defaultValue)); }