private BoolToAddressDependencyViewModel CreateBoolToAddressDependencyViewModel(
            IBoolToAddressDependency boolToAddressDependency)
        {
            var formatterParametersIfTrueViewModel = StaticContainer.Container.Resolve <IFormatterViewModelFactory>()
                                                     .CreateFormatterViewModel(boolToAddressDependency.FormatterIfTrue);

            var formatterParametersIfFalseViewModel = StaticContainer.Container.Resolve <IFormatterViewModelFactory>()
                                                      .CreateFormatterViewModel(boolToAddressDependency.FormatterIfFalse);

            return(new BoolToAddressDependencyViewModel(_formatterEditorFactory, _sharedResourcesGlobalViewModel)
            {
                RelatedResourceName = boolToAddressDependency.RelatedResourceName,
                ResultingAddressIfTrue = boolToAddressDependency.ResultingAddressIfTrue,
                ResultingAddressIfFalse = boolToAddressDependency.ResultingAddressIfFalse,
                FormatterParametersIfTrueViewModel = formatterParametersIfTrueViewModel,
                FormatterParametersIfFalseViewModel = formatterParametersIfFalseViewModel
            });
        }
Example #2
0
        private static async Task <Result <bool> > IsDependencyTrue(IBoolToAddressDependency boolToAddressDependency,
                                                                    DeviceContext deviceContext)
        {
            if (!deviceContext.DataProviderContainer.DataProvider.IsSuccess)
            {
                return(Result <bool> .Create(false));
            }
            if (string.IsNullOrWhiteSpace(boolToAddressDependency.RelatedResourceName))
            {
                return(Result <bool> .Create(false));
            }
            var res = deviceContext.DeviceSharedResources.SharedResourcesInContainers.FirstOrDefault(container =>
                                                                                                     container.ResourceName == boolToAddressDependency.RelatedResourceName);

            if (res == null)
            {
            }
            if (res.Resource is IDiscretMeasuringElement discretMeasuringElement)
            {
                return(await discretMeasuringElement.GetDiscretElementValue(deviceContext));
            }
            return(Result <bool> .Create(false));
        }