static FLMRequiredExtensionsType BuildFlmRequiredExtention(X509Certificate2 x509Certificate2) { FLMRequiredExtensionsType flmRequiredExtention = new FLMRequiredExtensionsType(); flmRequiredExtention.FacilityInfo = new FLMRequiredExtensionsTypeFacilityInfo(); flmRequiredExtention.FacilityInfo.AnnotationText = new UserTextType(); flmRequiredExtention.FacilityInfo.AnnotationText.language = "en-us"; flmRequiredExtention.FacilityInfo.AnnotationText.Value = "Example Facility List Message"; flmRequiredExtention.FacilityInfo.FacilityName = new UserTextType(); flmRequiredExtention.FacilityInfo.FacilityName.Value = "urn:x-facilityID:dcipllc.com:000000"; flmRequiredExtention.FacilityInfo.UTCOffset = new UTCOffsetType(); flmRequiredExtention.FacilityInfo.UTCOffset.Offset = "-05:00"; flmRequiredExtention.SecurityDeviceList = new SecurityDeviceListType(); CombinedType securityDevice = new CombinedType(); securityDevice.KeyInfo = new KeyInfoType(); securityDevice.KeyInfo.ItemsElementName = new ItemsChoiceType3[2]; securityDevice.KeyInfo.ItemsElementName[0] = ItemsChoiceType3.KeyName; securityDevice.KeyInfo.ItemsElementName[1] = ItemsChoiceType3.X509Data; securityDevice.KeyInfo.Items = new object[2]; securityDevice.KeyInfo.Items[0] = x509Certificate2.IssuerName.Name; X509DataType x509Data = new X509DataType(); x509Data.ItemsElementName = new ItemsChoiceType1[1]; x509Data.ItemsElementName[0] = ItemsChoiceType1.X509Certificate; x509Data.Items = new object[1]; x509Data.Items[0] = x509Certificate2.RawData; securityDevice.KeyInfo.Items[1] = x509Data; securityDevice.DeviceDescription = new deviceDescriptionType(); securityDevice.DeviceDescription.DeviceIdentifier = new deviceIdentifierPolyType(); securityDevice.DeviceDescription.DeviceIdentifier.idtype = new deviceIdentifierPolyTypeIdtype(); securityDevice.DeviceDescription.DeviceIdentifier.idtype = deviceIdentifierPolyTypeIdtype.DeviceUID; securityDevice.DeviceDescription.DeviceIdentifier.Value = "urn:uid:" + Guid.Empty; securityDevice.DeviceDescription.DeviceTypeID = new deviceTypeType(); securityDevice.DeviceDescription.DeviceTypeID.scope = "http://www.dcipllc.com/schemas/430-7/2009/FLM#deviceTypes"; securityDevice.DeviceDescription.DeviceTypeID.Value = "SMS"; securityDevice.DeviceDescription.DeviceSerial = "000000"; securityDevice.DeviceDescription.ManufacturerName = "Doremi"; securityDevice.DeviceDescription.ModelNumber = "DCP0000"; securityDevice.DeviceDescription.DeviceComment = new UserTextType(); securityDevice.DeviceDescription.DeviceComment.Value = "Not a Real Device"; flmRequiredExtention.SecurityDeviceList.Items = new CertOnlyType[1]; flmRequiredExtention.SecurityDeviceList.Items[0] = securityDevice; return(flmRequiredExtention); }
/// <summary> /// Create a wrapper observable that handles a list of observables. /// </summary> /// <param name="combinedNextType">Any: Emit when any observable emits. All: Emit when all observables have emitted once.</param> /// <param name="combinedCompleteType">Any: Complete when any observable completes. All: Complete when all observables are completed.</param> /// <param name="replay">Emit for every new subscriber if not completed and a value is present.</param> /// <param name="allowErrors">If false any error will immediately error and complete the observable.</param> /// <param name="oneValuePerObservale">If true after first emission of an observable, value subscription to that observable ends.</param> /// <param name="mapper">Mapping function to convert a list of inputs to the desired output.</param> /// <param name="observables">Input observables</param> public CombinedObservable(CombinedType combinedNextType, CombinedType combinedCompleteType, bool replay, bool allowErrors, bool oneValuePerObservale, Func <IEnumerable <T>, U> mapper, params Observable <T>[] observables) { if (observables.Length == 0) { _completed = true; return; } _mapper = mapper; _combinedNextType = combinedNextType; _combinedCompleteType = combinedCompleteType; _replay = replay; _allowErrors = allowErrors; _oneValuePerObservale = oneValuePerObservale; _observables = new Dictionary <Observable <T>, ObservableInfo>(observables.Length); foreach (var observable in observables) { var state = ObservableState.Empty; if (observable is IObservableStatusProvider observableWithStatus) { if (observableWithStatus.Errored) { if (allowErrors) { state = ObservableState.Error; } else { _completed = true; return; } } else if (observableWithStatus.HasValue) { state = observableWithStatus.Completed ? ObservableState.Completed : ObservableState.HasValue; } else if (observableWithStatus.Completed) { state = ObservableState.CompletedEmpty; } } _observables.Add(observable, new ObservableInfo() { State = state }); _subscriptions.Add(observable, observable.Subscribe( value => { var observableInfo = _observables[observable]; observableInfo.Value = value; if (oneValuePerObservale) { observableInfo.State = ObservableState.Completed; if (_subscriptions.ContainsKey(observable)) { _subscriptions[observable].Unsubscribe(); _subscriptions.Remove(observable); } } else if (observableInfo.State == ObservableState.Empty) { observableInfo.State = ObservableState.HasValue; } UpdateState(); }, error => { _mostRecentError = error; _observables[observable].State = ObservableState.Error; UpdateState(); }, () => { var observableInfo = _observables[observable]; if (observableInfo.State != ObservableState.Error) { observableInfo.State = observableInfo.State == ObservableState.HasValue ? ObservableState.Completed : ObservableState.CompletedEmpty; } UpdateState(); } )); if (_subscriptions.ContainsKey(observable) && _subscriptions[observable] == Subscription <T> .Empty) { _subscriptions.Remove(observable); } } }