void IGXDLMSBase.Load(GXXmlReader reader) { MBusPortReference = reader.ReadElementContentAsString("MBusPortReference"); CaptureDefinition.Clear(); if (reader.IsStartElement("CaptureDefinition", true)) { while (reader.IsStartElement("Item", true)) { string d = reader.ReadElementContentAsString("Data"); string v = reader.ReadElementContentAsString("Value"); CaptureDefinition.Add(new KeyValuePair <string, string>(d, v)); } reader.ReadEndElement("CaptureDefinition"); } CapturePeriod = (UInt16)reader.ReadElementContentAsInt("CapturePeriod"); PrimaryAddress = reader.ReadElementContentAsInt("PrimaryAddress"); IdentificationNumber = (UInt16)reader.ReadElementContentAsInt("IdentificationNumber"); ManufacturerID = (UInt16)reader.ReadElementContentAsInt("ManufacturerID"); DataHeaderVersion = reader.ReadElementContentAsInt("DataHeaderVersion"); DeviceType = reader.ReadElementContentAsInt("DeviceType"); AccessNumber = reader.ReadElementContentAsInt("AccessNumber"); Status = reader.ReadElementContentAsInt("Status"); Alarm = reader.ReadElementContentAsInt("Alarm"); if (Version > 0) { Configuration = (UInt16)reader.ReadElementContentAsInt("Configuration"); EncryptionKeyStatus = (MBusEncryptionKeyStatus)reader.ReadElementContentAsInt("EncryptionKeyStatus"); } }
public void 解決メソッドよりもキャプチャした解決メソッドのほうが優先() { var resolver = ResolverDefinition(ServiceBInfo); var capture = new CaptureDefinition(FactoryInterfaceInfo2, "Captured", new [] { resolver }, new CollectionResolverDefinition[0]); var factory = FactoryDefinition("Subject", FactoryInterfaceInfo, resolvers: new[] { resolver }, captures: new[] { capture }); var pivot = ResolverDefinition(ServiceCInfo); var generated = pivot.GetPriorInjectionExpression(ServiceBInfo, factory); Assert.Equal("Captured.ResolveServiceB()", generated); }
public void 解決メソッドよりもキャプチャしたファクトリープロパティのほうが優先() { var capture = new CaptureDefinition(FactoryInterfaceInfo2, "Captured", new ResolverDefinition[0], new CollectionResolverDefinition[0]); var resolver = ResolverDefinition(FactoryInterfaceInfo2); var factory = FactoryDefinition("Subject", FactoryInterfaceInfo, new[] { resolver }, captures: new[] { capture }); var generated = resolver.GetPriorInjectionExpression(FactoryInterfaceInfo2, factory); Assert.Equal("Captured", generated); }
public void キャプチャしたファクトリーよりthisのほうが優先() { var capturedResolver = ResolverDefinition(FactoryInterfaceInfo); var capture = new CaptureDefinition(FactoryInterfaceInfo2, "Capture", new [] { capturedResolver }, new CollectionResolverDefinition[0]); var resolver = ResolverDefinition(FactoryInterfaceInfo); var factory = FactoryDefinition("Subject", FactoryInterfaceInfo, captures: new [] { capture }); var generated = resolver.GetPriorInjectionExpression(FactoryInterfaceInfo, factory); Assert.Equal("this", generated); }
public void コレクション解決メソッドよりもキャプチャしたコレクション解決メソッドのほうが優先() { var resolver = GetCollectionResolverDefinition(ServiceAInfo); var capture = new CaptureDefinition(FactoryInterfaceInfo2, "Captured", new ResolverDefinition[0], new CollectionResolverDefinition[] { resolver }); var factory = FactoryDefinition("Subject", FactoryInterfaceInfo, new ResolverDefinition[0], new CollectionResolverDefinition[] { resolver }, captures: new[] { capture }); var pivot = ResolverDefinition(ServiceBInfo); // 基準としてのResolverを置かずに呼び出したい(パラメータの都合で難しそう) var generated = pivot.GetPriorInjectionExpression(ToEnumerableType(ServiceAInfo), factory); Assert.Equal("Captured.ResolveServiceAs()", generated); }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { if (e.Value is string) { LogicalName = e.Value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString(); } } else if (e.Index == 2) { if (e.Value is string) { MBusPortReference = e.Value.ToString(); } else { MBusPortReference = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString(); } } else if (e.Index == 3) { CaptureDefinition.Clear(); if (e.Value != null) { foreach (object[] it in (object[])e.Value) { CaptureDefinition.Add(new KeyValuePair <string, string>(GXDLMSClient.ChangeType((byte[])it[0], DataType.OctetString).ToString(), GXDLMSClient.ChangeType((byte[])it[1], DataType.OctetString).ToString())); } } } else if (e.Index == 4) { CapturePeriod = Convert.ToUInt32(e.Value); } else if (e.Index == 5) { PrimaryAddress = Convert.ToByte(e.Value); } else if (e.Index == 6) { IdentificationNumber = Convert.ToUInt32(e.Value); } else if (e.Index == 7) { ManufacturerID = Convert.ToUInt16(e.Value); } else if (e.Index == 8) { DataHeaderVersion = Convert.ToByte(e.Value); } else if (e.Index == 9) { DeviceType = Convert.ToByte(e.Value); } else if (e.Index == 10) { AccessNumber = Convert.ToByte(e.Value); } else if (e.Index == 11) { Status = Convert.ToByte(e.Value); } else if (e.Index == 12) { Alarm = Convert.ToByte(e.Value); } else if (Version > 0) { if (e.Index == 13) { Configuration = Convert.ToUInt16(e.Value); } else if (e.Index == 14) { EncryptionKeyStatus = (MBusEncryptionKeyStatus)Convert.ToInt32(e.Value); } else { e.Error = ErrorCode.ReadWriteDenied; } } else { e.Error = ErrorCode.ReadWriteDenied; } }
void IGXDLMSBase.SetValue(int index, object value) { if (index == 1) { if (value is string) { LogicalName = value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString(); } } else if (index == 2) { if (value is string) { MBusPortReference = value.ToString(); } else { MBusPortReference = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString(); } } else if (index == 3) { CaptureDefinition.Clear(); foreach (object[] it in (object[])value) { CaptureDefinition.Add(new KeyValuePair <string, string>(GXDLMSClient.ChangeType((byte[])it[0], DataType.OctetString).ToString(), GXDLMSClient.ChangeType((byte[])it[1], DataType.OctetString).ToString())); } } else if (index == 4) { CapturePeriod = Convert.ToUInt32(value); } else if (index == 5) { PrimaryAddress = Convert.ToByte(value); } else if (index == 6) { IdentificationNumber = Convert.ToUInt32(value); } else if (index == 7) { ManufacturerID = Convert.ToUInt16(value); } else if (index == 8) { DataHeaderVersion = Convert.ToByte(value); } else if (index == 9) { DeviceType = Convert.ToByte(value); } else if (index == 10) { AccessNumber = Convert.ToByte(value); } else if (index == 11) { Status = Convert.ToByte(value); } else if (index == 12) { Alarm = Convert.ToByte(value); } else if (Version > 0) { if (index == 13) { Configuration = Convert.ToUInt16(value); } else if (index == 14) { EncryptionKeyStatus = Convert.ToInt32(value); } else { throw new ArgumentException("SetValue failed. Invalid attribute index."); } } else { throw new ArgumentException("SetValue failed. Invalid attribute index."); } }
private IEnumerable <InjectionExpression> DelegationsFromCapture(TypeName typeName, CaptureDefinition capture) { if (typeName == capture.InterfaceNameInfo) { yield return(new InjectionExpression(typeName, InjectionMethod.CapturedFactory, capture.PropertyName)); } var capabilities1 = capture.Resolvers.Select(x => DelegationFromResolver(typeName, x)); var capabilities2 = capture.CollectionResolvers.Select(x => DelegationFromResolver(typeName, x)); foreach (var expression in capabilities1.Concat(capabilities2).FilterNull()) { yield return(new InjectionExpression( typeName, InjectionMethod.CapturedResolver, $"{capture.PropertyName}.{expression.Code}")); } }