GVKun编程网logo

c# – 如何模拟IOptionsSnapshot实例进行测试(c# 模拟器)

13

想了解c#–如何模拟IOptionsSnapshot实例进行测试的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于c#模拟器的相关问题,此外,我们还将为您介绍关于.NetCore配置文件读取I

想了解c# – 如何模拟IOptionsSnapshot实例进行测试的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于c# 模拟器的相关问题,此外,我们还将为您介绍关于.Net Core 配置文件读取IOptions,IOptionsMonitor,IOptionsSnapshot、c# – 更改* .json文件后IOptionsSnapshot不刷新、EasyTransaction 发布 v1.0.0-SNAPSHOT 版本、ims.clinical.vo.lookups.MedicationSnapShot的实例源码的新知识。

本文目录一览:

c# – 如何模拟IOptionsSnapshot实例进行测试(c# 模拟器)

c# – 如何模拟IOptionsSnapshot实例进行测试(c# 模拟器)

我有类AbClass与asp.net核心内置DI实例的IOptionsSnapshot< AbOptions> (动态配置).
现在我想测试这个课程.

我试图在测试类中实例化AbClass类,但我不知道如何实例化IOptionsSnapshot< AbOptions>的实例.注入AbClass的构造函数.

我尝试使用Mock< IOptionsSnapshot< AbOptions>> .Object,但我需要为此实例设置一些值,因为在AbClass中代码使用此值(var x = _options.cc.D1).

所以我有一个代码

var builder = new ConfigurationBuilder();
builder.AddInMemoryCollection(new Dictionary<string,string>
{
    ["Ab:cc:D1"] = "https://",["Ab:cc:D2"] = "123145854170887"
});
var config = builder.Build();
var options = new AbOptions();
config.GetSection("Ab").Bind(options);

但我不知道如何链接此选项和IOptionsSnapshot模拟.

AbClass:

public class AbClass {
    private readonly AbOptions _options;

    public AbClass(IOptionsSnapshot<AbOptions> options) {
        _options = options.Value;    
    }
    private void x(){var t = _options.cc.D1}
}

我的测试实例化了这个类:

var service = new AbClass(new Mock???)

并且需要在AbClass中测试一个调用x()的方法,但它在_options.cc.D1上抛出ArgumentNullException

解决方法

您应该能够模拟界面并为测试创建选项类的实例.由于我不知道选项类的嵌套类,我正在做出一个广泛的假设.

Documentation: IOptionsSnapshot

//Arrange
//Instantiate options and nested classes
//making assumptions here about nested types
var options = new AbOptions(){
    cc = new cc {
        D1 = "https://",D2 = "123145854170887"
    }
};
var mock = new Mock<IOptionsSnapshot<AbOptions>>();
mock.Setup(m => m.Value).Returns(options);

var service = new AbClass(mock.Object);

现在,对嵌套值的访问应该返回正确的值而不是NRE

.Net Core 配置文件读取IOptions,IOptionsMonitor,IOptionsSnapshot

.Net Core 配置文件读取IOptions,IOptionsMonitor,IOptionsSnapshot

前言

众所周知,appsetting.json 配置文件是.Net 的重大革新之心,抛开了以前繁杂的xml文件,使用了更简洁易懂的json方式,简直不要太舒服了!东西虽然好,但怎么在程序中读取这个配置呢,是每个新手必须要跨过去的坑(当然也是包括我这个菜狗子)。

遇事不明上注入,只要是遇到不知道怎么办的事,首先要往注入方便想,框架有了这个配置文件,必然配备了简单直接的读取API,按照我的习惯,直接上代码:

首先,我们在配置文件中,增加 Demo 配置节点:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "Demo": {
    "Value1": "1",
    "Value2": "2",
    "Value3": "3",
    "Value4": "4"
  }
}

在需要用到配置文件的地方,注入 IConfiguration 服务接口

private readonly IConfiguration _configuration;

public ValuesController(IConfiguration configuration)
{
    _configuration = configuration;
}

通常,我们比较直接的方式是通过 GetSection 获取对应的配置节点,然后再获取对应的配置项

var section = _configuration.GetSection("Demo");
var value1 = section.GetValue("Value1", "1");

如果 Demo 节点内还有更深的节点,GetSection 可以通过 : 深入到对应的下一个节点

appsetting.json 

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "Demo": {
    "Value1": "1",
    "Value2": "2",
    "Value3": "3",
    "Value4": "4",
    "Model" {
      "Name": "小二",
      "Phone": "12345678911"
    }
  }
}
var model = _configuration.GetSection("Demo:Model");

有些小伙伴可能就会问了,那我每个需要用到的地方都需要直接以字符串作为参数去读取配置,以后要是突然改了配置项,岂不是非常麻烦;

这点小伙伴们大可放心,你可以定义一个实体类,然后绑定上去,以后有什么更改了,直接重命名对应的属性就行了,实例代码

方法一:

var options = new DemoOptions();
_configuration.GetSection("Demo").Bind(options);

方法二:

var options2 = _configuration.GetSection("Demo").Get<DemoOptions>();

方法三:在 Startup.cs、.Net 6 以上在 Program.cs- 中使用依赖注入方式,以下是 .Net 6 

builder.Services.Configure<DemoOptions>(builder.Configuration.GetSection("Demo"));

在需要使用的地方注入  IOptions<TOptions> 即可获取到配置值,需要注意的是,IOptions 是单例(Singleton)服务,即在应用启动时进行注册,后续更改配置文件,该 IOptions 将不会同步更新,依然还是旧值 

private readonly DemoOptions _demoOptions;
public ValuesController(IOptions<DemoOptions> options)
{
    _demoOptions = options.Value;
}

如需要配置进行热更新,只需要改成注入 IOptionsMonitor<TOptions> 或者 IOptionsSnapshot<TOptions>;IOptionsSnapshot<TOptions>的生命周期是作用域(Scoped),每次请求都会重新获取一次配置;IOptionsSnapshot<TOptions> 的生命周期是单例(Singleton),与 IOptions<TOptions> 不一样的是当配置文件发生改变时,将会自动同步响应。

到此这篇关于.Net Core 配置文件读取IOptions,IOptionsMonitor,IOptionsSnapshot的文章就介绍到这了,更多相关.Net Core 文件读取内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

您可能感兴趣的文章:
  • .NetCore获取Json和Xml格式的配置信息
  • .NET Core控制台应用ConsoleApp读取appsettings.json配置文件
  • .net6 使用Senparc开发小程序配置过程
  • .NET Core自定义配置文件
  • .NET Core读取配置文件
  • .NET 中配置从xml转向json方法示例详解

c# – 更改* .json文件后IOptionsSnapshot不刷新

c# – 更改* .json文件后IOptionsSnapshot不刷新

我按照hello world示例表单 IOptionsSnapshot进行了操作,但在更改和保存文件config.json后,内容未刷新.

我的开发环境:

1.VS 2017

2 .csproj文件如下

<PropertyGroup>
        <TargetFramework>netcoreapp1.1</TargetFramework>
        <PreserveCompilationContext>true</PreserveCompilationContext>
        <AssemblyName>UsingOptions</AssemblyName>
        <OutputType>Exe</OutputType>
        <PackageId>UsingOptions</PackageId>
        <RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
        <PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
      </PropertyGroup>

  <ItemGroup>
    <packagereference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <packagereference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
    <packagereference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
    <packagereference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Configuration" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Options" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
    <packagereference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
    <packagereference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
  </ItemGroup>

以下是IOptionsSnapshot的代码

config.json:
{
  "Time": {
    "Message": "Hello "
  }
}


public class TimeOptions
{
    // Records the time when the options are created.
    public DateTime CreationTime { get; set; } = DateTime.Now;

    // Bound to config. Changes to the value of "Message"
    // in config.json will be reflected in this property.
    public string Message { get; set; }
}

public class Controller
{
    public readonly TimeOptions _options;

    public Controller(IOptionsSnapshot<TimeOptions> options)
    {
        _options = options.Value;
    }

    public Task displayTimeAsync(HttpContext context)
    {
        return context.Response.WriteAsync(_options.Message + _options.CreationTime);
    }
}

public class Startup
{
    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(Directory.GetCurrentDirectory())
            // reloadOnChange: true is required for config changes to be detected.
            .AddJsonFile("config.json",optional: false,reloadOnChange: true)
            .AddEnvironmentvariables();
        Configuration = builder.Build();
    }

    public IConfigurationRoot Configuration { get; set; }

    public void Configure(IApplicationBuilder app)
    {
        // Simple mockup of a simple per request controller that writes
        // the creation time and message of TimeOptions.
        app.Run(displayTimeAsync);
    }

    public void ConfigureServices(IServiceCollection services)
    {
        // Simple mockup of a simple per request controller.
        services.AddScoped<Controller>();

        // Binds config.json to the options and setups the change tracking.
        services.Configure<TimeOptions>(Configuration.GetSection("Time"));
    }

    public Task displayTimeAsync(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        return context.RequestServices.GetrequiredService<Controller>().displayTimeAsync(context);
    }

    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();
        host.Run();
    }
}

解决方法

IOptions和IOptionsSnapshot的源代码看起来是一样的.该接口在 OptionsManager中具有通用实现.因此OptionsSnapshot不会重新加载选项.而不是IOptionsSnapshot,使用IOptionsMonitor.您无需订阅OnChange事件,只需访问CurrentValue属性即可.

UPD自Microsoft.Extensions.Options 2.x发布IOptionsSnapshot已被删除.

EasyTransaction 发布 v1.0.0-SNAPSHOT 版本

EasyTransaction 发布 v1.0.0-SNAPSHOT 版本

EasyTransaction 1.0.0-SNAPSHOT 发布了。Easytransaction 是一个 SOA (微服务) 跨服务柔性事务 (分布式事务) 解决方案,其为常用的分布式事务场景提供统一的调用入口,数行代码就能高效明了的完成分布式事务。

这次版本更新包括以下内容:

  • kafka 消息队列实现

  • 允许同一事务多次调用同一方法

  • 解耦调用框架存储用的元数据与业务请求参数

  • 使用 spring 自身的配置功能代替原来自定义的配置读取功能

  • 使用 spring boot 风格改造代码,配置及使用更加方便

  • 事务级联功能(已完成,在事务模式里,除了传统补偿模式 CompensableMethod 不能进行事务级联,其他都可以进行事务级联)

  • restful rpc(Spring MVC/RestTemplate/Ribbon/Eureka)实现

ims.clinical.vo.lookups.MedicationSnapShot的实例源码

ims.clinical.vo.lookups.MedicationSnapShot的实例源码

项目:openMAXims    文件:Logic.java   
private void initialize() 
{
    form.setMode(FormMode.VIEW);

    MedicationDosesDynamicGridPopulation gridPopulation = getHelper();
    gridPopulation.initializeGrid();

    formatMedicationAndDosesGrids();

    if (isMedicationMultipleDosesPatientLevel())
        form.getLocalContext().setScreenType(MedicationSnapShot.PATIENT);

    if ( (form.getGlobalContext().Clinical.getReturnToFormNameIsNotNull())
        && (form.getGlobalContext().Clinical.getReturnToFormName().equals(engine.getPrevIoUsNonDialogFormName())) )
    {
        isBtnCloseVisible(true);
        form.lnkReturn().setVisible(true);
    }
    else
    {
        isBtnCloseVisible(false);
        form.lnkReturn().setVisible(false);
    }

    displayOrHideEnabledisableScreenSpecificControls();
}
项目:openMAXims    文件:Logic.java   
private void displayOrHideEnabledisableScreenSpecificControls() 
{
    form.ctnDetails().lblIncludeinTTO().setVisible(false);
    form.ctnDetails().chkTTO().setVisible(false);
    form.ctnDetails().lblNumDays().setVisible(false);
    form.ctnDetails().intNumDays().setVisible(false);
    form.recbroverviews().setVisible(false);

    MedicationSnapShot screenType = form.getLocalContext().getScreenType();
    if (screenType != null)
    {
        if (form.getMode().equals(FormMode.VIEW) )
        {
            form.chkFilter().setVisible(false);
            form.setcustomControlAuthoringInfoEnabled(false);
            if (form.getLocalContext().getCurrentOverViewIsNotNull()) 
                form.chkFilter().setVisible(true);
        }
        else
        {
            form.setcustomControlAuthoringInfoEnabled(true);
            if (isDialog())
                isBtnCloseVisible(true);
        }
    }
}
项目:AvoinApotti    文件:Logic.java   
private void initialize() 
{
    form.setMode(FormMode.VIEW);

    MedicationDosesDynamicGridPopulation gridPopulation = getHelper();
    gridPopulation.initializeGrid();

    formatMedicationAndDosesGrids();

    if (isDialog())
        form.getLocalContext().setScreenType(MedicationSnapShot.ADMISSION);
    if (isMedicationMultipleDosesOnAdmission() || isDialog())
        form.getLocalContext().setScreenType(MedicationSnapShot.ADMISSION);
    else if (isMedicationMultipleDosesOndischarge())
        form.getLocalContext().setScreenType(MedicationSnapShot.disCHARGE);
    else if (isMedicationMultipleDosesOPD())
        form.getLocalContext().setScreenType(MedicationSnapShot.OPD);
    else if (isMedicationMultipleDosesPatientLevel())
        form.getLocalContext().setScreenType(MedicationSnapShot.PATIENT);

    if ( (form.getGlobalContext().Clinical.getReturnToFormNameIsNotNull())
        && (form.getGlobalContext().Clinical.getReturnToFormName().equals(engine.getPrevIoUsNonDialogFormName())) )
    {
        isBtnCloseVisible(true);
        form.lnkReturn().setVisible(true);
    }
    else
    {
        isBtnCloseVisible(false);
        form.lnkReturn().setVisible(false);
    }

    displayOrHideEnabledisableScreenSpecificControls();
}
项目:openMAXims    文件:Logic.java   
private void initialize() 
{
    form.setMode(FormMode.VIEW);

    MedicationDosesDynamicGridPopulation gridPopulation = getHelper();
    gridPopulation.initializeGrid();

    formatMedicationAndDosesGrids();

    if (isDialog())
        form.getLocalContext().setScreenType(MedicationSnapShot.ADMISSION);
    if (isMedicationMultipleDosesOnAdmission() || isDialog())
        form.getLocalContext().setScreenType(MedicationSnapShot.ADMISSION);
    else if (isMedicationMultipleDosesOndischarge())
        form.getLocalContext().setScreenType(MedicationSnapShot.disCHARGE);
    else if (isMedicationMultipleDosesOPD())
        form.getLocalContext().setScreenType(MedicationSnapShot.OPD);
    else if (isMedicationMultipleDosesPatientLevel())
        form.getLocalContext().setScreenType(MedicationSnapShot.PATIENT);

    if ( (form.getGlobalContext().Clinical.getReturnToFormNameIsNotNull())
        && (form.getGlobalContext().Clinical.getReturnToFormName().equals(engine.getPrevIoUsNonDialogFormName())) )
    {
        isBtnCloseVisible(true);
        form.lnkReturn().setVisible(true);
    }
    else
    {
        isBtnCloseVisible(false);
        form.lnkReturn().setVisible(false);
    }

    displayOrHideEnabledisableScreenSpecificControls();
}
项目:openmaxims-linux    文件:Logic.java   
private void initialize() 
{
    form.setMode(FormMode.VIEW);

    MedicationDosesDynamicGridPopulation gridPopulation = getHelper();
    gridPopulation.initializeGrid();

    formatMedicationAndDosesGrids();

    if (isDialog())
        form.getLocalContext().setScreenType(MedicationSnapShot.ADMISSION);
    if (isMedicationMultipleDosesOnAdmission() || isDialog())
        form.getLocalContext().setScreenType(MedicationSnapShot.ADMISSION);
    else if (isMedicationMultipleDosesOndischarge())
        form.getLocalContext().setScreenType(MedicationSnapShot.disCHARGE);
    else if (isMedicationMultipleDosesOPD())
        form.getLocalContext().setScreenType(MedicationSnapShot.OPD);
    else if (isMedicationMultipleDosesPatientLevel())
        form.getLocalContext().setScreenType(MedicationSnapShot.PATIENT);

    if ( (form.getGlobalContext().Clinical.getReturnToFormNameIsNotNull())
        && (form.getGlobalContext().Clinical.getReturnToFormName().equals(engine.getPrevIoUsNonDialogFormName())) )
    {
        isBtnCloseVisible(true);
        form.lnkReturn().setVisible(true);
    }
    else
    {
        isBtnCloseVisible(false);
        form.lnkReturn().setVisible(false);
    }

    displayOrHideEnabledisableScreenSpecificControls();
}
项目:AvoinApotti    文件:Logic.java   
protected void onlyrDetailsTabChanged(LayerBridge tab)
{
    if(tab.equals(form.lyrDetails().tabPreview()) && form.getLocalContext().getSelectedItem() != null && form.getLocalContext().getReportChangedisNotNull() && form.getLocalContext().getReportChanged().booleanValue())
    {
        form.lyrDetails().tabPreview().htmReport().setHTML("");

        if(form.getLocalContext().getSelectedItem() != null && form.getLocalContext().getReportChangedisNotNull() && form.getLocalContext().getReportChanged().booleanValue() && form.getLocalContext().getSelectedItem().getID_ClinicalCorrespondence() != null)
        {
            buildreport();
            form.getLocalContext().setReportChanged(Boolean.FALSE);
        }
    }  //WDEV-1039 - 3) We need to display the Medication Overview record for this context,if the ClinicalCorrespondenceBo has not been saved for the context we are in we need to retrieve the Overview and display it. 
    else if(tab.equals(form.lyrDetails().tabServices()) && !isMedicationDataLoaded())
    {
        form.lyrDetails().tabServices().dynGrdMedication().clear();

        MedicationOverViewFilterVo voFilter = new MedicationOverViewFilterVo();

        voFilter.setType(MedicationSnapShot.disCHARGE);
        voFilter.setCareContext(form.getGlobalContext().Core.getCurrentCareContext());
        voFilter.setPatientRef(form.getGlobalContext().Core.getPatientShort());

        MedicationOverViewVo voOverView = domain.getLatestMedicationOverViewVo(voFilter);

        if (voOverView != null && voOverView.getMedicationIsNotNull())
        {
            //WDEV-1039 - 2)We need to change the icons used in the medication preview to those used in the medication page 
            MedicationDosesDynamicGridPopulation gridPopulation = new MedicationDosesDynamicGridPopulation(form.lyrDetails().tabServices().dynGrdMedication(),form.getimages().Admin.Activity,form.getimages().ICP.Child);            
            gridPopulation.initializeGrid();
            gridPopulation.populate(voOverView);

            form.getLocalContext().setIsMedicationDataLoaded(Boolean.TRUE);
        }
    }
    else if(tab.equals(form.lyrDetails().tabCommentsOPD()) && form.getLocalContext().getoutpatientSummaryChanged().booleanValue() && form.getMode().equals(FormMode.EDIT))
    {
        if(form.getLocalContext().getSelectedItem() == null)
        {
            OutpatientNotesOutcomeVo voOPDSummary = domain.getoPDSummary(form.getGlobalContext().Core.getCurrentClinicalContact());

            if(voOPDSummary != null && form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().size() == 3)
            {
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(0).setColText(voOPDSummary.getClinicalNote().getobjectiveNote());
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(1).setColText(voOPDSummary.getClinicalNote().getPlanNote());
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(2).setColText(voOPDSummary.getInstructionNextClinic());

                form.lyrDetails().tabCommentsOPD().cmbOPFollowUp().setValue(voOPDSummary.getoutcome());
                form.lyrDetails().tabCommentsOPD().intOPReviewIn().setValue(voOPDSummary.getReviewIn());
                form.lyrDetails().tabCommentsOPD().cmbOPReviewIn().setValue(voOPDSummary.getReviewinUnits());

                form.getLocalContext().setoutpatientSummaryChanged(Boolean.FALSE);
            }
        }
    }
}
项目:AvoinApotti    文件:Logic.java   
private void displayOrHideEnabledisableScreenSpecificControls() 
{
    form.ctnDetails().lblIncludeinTTO().setVisible(false);
    form.ctnDetails().chkTTO().setVisible(false);
    form.ctnDetails().lblNumDays().setVisible(false);
    form.ctnDetails().intNumDays().setVisible(false);
    form.recbroverviews().setVisible(false);

    MedicationSnapShot screenType = form.getLocalContext().getScreenType();
    if (screenType != null)
    {
        if (screenType.equals(MedicationSnapShot.disCHARGE) || screenType.equals(MedicationSnapShot.OPD))
        {
            form.ctnDetails().lblIncludeinTTO().setVisible(true);
            form.ctnDetails().chkTTO().setVisible(true);
            form.ctnDetails().lblNumDays().setVisible(true);
            form.ctnDetails().intNumDays().setVisible(true);

            form.ctnDetails().chkTTO().setEnabled(form.getMode().equals(FormMode.EDIT));
            form.ctnDetails().intNumDays().setEnabled(form.getMode().equals(FormMode.EDIT));
        }
        else if(screenType.equals(MedicationSnapShot.PATIENT))
        {
            form.recbroverviews().setEnabled(true);
            form.recbroverviews().setVisible(true);
            form.setcustomControlAuthoringInfoEnabled(false);
            form.setMode(FormMode.VIEW);
        }
    }
    if (form.getMode().equals(FormMode.VIEW) )
    {
        form.chkFilter().setVisible(false);
        form.setcustomControlAuthoringInfoEnabled(false);
        if (form.getLocalContext().getCurrentOverViewIsNotNull()) 
            form.chkFilter().setVisible(true);
    }
    else
    {
        form.setcustomControlAuthoringInfoEnabled(true);
        if (isDialog())
            isBtnCloseVisible(true);
    }
}
项目:AvoinApotti    文件:Logic.java   
public void updateControlsstate()
{
    form.getContextMenus().hideAllMedicationMultipleMenuItems();
    form.getContextMenus().hideAllMedicationMultipleDosesMenuItems();
    boolean isRieMode = engine.isRIEMode();

    form.getContextMenus().getMedicationMultipleNEW_MEDICATIONItem().setVisible(form.getMode().equals(FormMode.VIEW) && !isRieMode);
    form.getContextMenus().getMedicationMultipleNEW_MEDICATIONItem().setEnabled(form.getMode().equals(FormMode.VIEW));

    form.getContextMenus().getMedicationMultipleUPDATE_MEDICATIONItem().setVisible( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) && !isRieMode);
    form.getContextMenus().getMedicationMultipleUPDATE_MEDICATIONItem().setEnabled( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) );

    form.getContextMenus().getMedicationMultipledisCONTINUE_MEDICATIONItem().setVisible( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) && !isRieMode );
    form.getContextMenus().getMedicationMultipledisCONTINUE_MEDICATIONItem().setEnabled( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) );


    form.getContextMenus().getMedicationMultipleDosesNEW_DOSEItem().setVisible(form.getMode().equals(FormMode.EDIT));
    form.getContextMenus().getMedicationMultipleDosesNEW_DOSEItem().setEnabled(form.getMode().equals(FormMode.EDIT));

    form.getContextMenus().getMedicationMultipleDosesdisCONTINUE_DOSEItem().setVisible( (form.getMode().equals(FormMode.EDIT)) 
            && (form.ctnDetails().dynGrdDoses().getSelectedRow() != null) );
    form.getContextMenus().getMedicationMultipleDosesdisCONTINUE_DOSEItem().setEnabled( (form.getMode().equals(FormMode.EDIT)) 
            && (form.ctnDetails().dynGrdDoses().getSelectedRow() != null) );


    if (form.getMode().equals(FormMode.EDIT))
    {
        form.ctnDetails().setcustomControlCodingItemEnabled(true);
        form.customControlAuthoringInfo().setIsrequiredPropertyToControls(true); //wdev-15369
        form.customControlAuthoringInfo().setEnabledAuthoringHCP(true);
    }
    else
    {
        form.customControlAuthoringInfo().setIsrequiredPropertyToControls(false);   //wdev-15369
        form.customControlAuthoringInfo().setEnabledAuthoringHCP(false);
    }

    form.ctnDetails().customControlCodingItem().setParentEditing(new Boolean(form.getMode().equals(FormMode.EDIT)));        


    if (form.getLocalContext().getScreenTypeIsNotNull() 
            && form.getLocalContext().getScreenType().equals(MedicationSnapShot.PATIENT) )
    {
        form.getContextMenus().hideAllMedicationMultipleMenuItems();
        form.getContextMenus().hideAllMedicationMultipleDosesMenuItems();
    }
}
项目:openMAXims    文件:Logic.java   
protected void onlyrDetailsTabChanged(LayerBridge tab)
{
    if(tab.equals(form.lyrDetails().tabPreview()) && form.getLocalContext().getSelectedItem() != null && form.getLocalContext().getReportChangedisNotNull() && form.getLocalContext().getReportChanged().booleanValue())
    {
        form.lyrDetails().tabPreview().htmReport().setHTML("");

        if(form.getLocalContext().getSelectedItem() != null && form.getLocalContext().getReportChangedisNotNull() && form.getLocalContext().getReportChanged().booleanValue() && form.getLocalContext().getSelectedItem().getID_ClinicalCorrespondence() != null)
        {
            buildreport();
            form.getLocalContext().setReportChanged(Boolean.FALSE);
        }
    }  //WDEV-1039 - 3) We need to display the Medication Overview record for this context,form.getimages().ICP.Child);            
            gridPopulation.initializeGrid();
            gridPopulation.populate(voOverView);

            form.getLocalContext().setIsMedicationDataLoaded(Boolean.TRUE);
        }
    }
    else if(tab.equals(form.lyrDetails().tabCommentsOPD()) && form.getLocalContext().getoutpatientSummaryChanged().booleanValue() && form.getMode().equals(FormMode.EDIT))
    {
        if(form.getLocalContext().getSelectedItem() == null)
        {
            OutpatientNotesOutcomeVo voOPDSummary = domain.getoPDSummary(form.getGlobalContext().Core.getCurrentClinicalContact());

            if(voOPDSummary != null && form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().size() == 3)
            {
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(0).setColText(voOPDSummary.getClinicalNote().getobjectiveNote());
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(1).setColText(voOPDSummary.getClinicalNote().getPlanNote());
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(2).setColText(voOPDSummary.getInstructionNextClinic());

                form.lyrDetails().tabCommentsOPD().cmbOPFollowUp().setValue(voOPDSummary.getoutcome());
                form.lyrDetails().tabCommentsOPD().intOPReviewIn().setValue(voOPDSummary.getReviewIn());
                form.lyrDetails().tabCommentsOPD().cmbOPReviewIn().setValue(voOPDSummary.getReviewinUnits());

                form.getLocalContext().setoutpatientSummaryChanged(Boolean.FALSE);
            }
        }
    }
}
项目:openMAXims    文件:Logic.java   
private void displayOrHideEnabledisableScreenSpecificControls() 
    {
        form.ctnDetails().lblIncludeinTTO().setVisible(false);
        form.ctnDetails().chkTTO().setVisible(false);
        form.ctnDetails().lblNumDays().setVisible(false);
        form.ctnDetails().intNumDays().setVisible(false);
        form.recbroverviews().setVisible(false);

        MedicationSnapShot screenType = form.getLocalContext().getScreenType();
        if (screenType != null)
        {
            //WDEV-20591
//          if (screenType.equals(MedicationSnapShot.disCHARGE) || screenType.equals(MedicationSnapShot.OPD))
            if (screenType.equals(MedicationSnapShot.disCHARGE))
            {
                form.ctnDetails().lblIncludeinTTO().setVisible(true);
                form.ctnDetails().chkTTO().setVisible(true);
                form.ctnDetails().lblNumDays().setVisible(true);
                form.ctnDetails().intNumDays().setVisible(true);

                form.ctnDetails().chkTTO().setEnabled(form.getMode().equals(FormMode.EDIT));
                form.ctnDetails().intNumDays().setEnabled(form.getMode().equals(FormMode.EDIT));
            }
            else if(screenType.equals(MedicationSnapShot.PATIENT))
            {
                form.recbroverviews().setEnabled(true);
                form.recbroverviews().setVisible(true);
                form.setcustomControlAuthoringInfoEnabled(false);
                form.setMode(FormMode.VIEW);
            }
        }
        if (form.getMode().equals(FormMode.VIEW) )
        {
            form.chkFilter().setVisible(false);
            form.setcustomControlAuthoringInfoEnabled(false);
            if (form.getLocalContext().getCurrentOverViewIsNotNull()) 
                form.chkFilter().setVisible(true);
        }
        else
        {
            form.setcustomControlAuthoringInfoEnabled(true);
            if (isDialog())
                isBtnCloseVisible(true);
        }
    }
项目:openMAXims    文件:Logic.java   
public void updateControlsstate()
{
    form.getContextMenus().hideAllMedicationMultipleMenuItems();
    form.getContextMenus().hideAllMedicationMultipleDosesMenuItems();
    boolean isRieMode = engine.isRIEMode();

    form.getContextMenus().getMedicationMultipleNEW_MEDICATIONItem().setVisible(form.getMode().equals(FormMode.VIEW) && !isRieMode);
    form.getContextMenus().getMedicationMultipleNEW_MEDICATIONItem().setEnabled(form.getMode().equals(FormMode.VIEW));

    form.getContextMenus().getMedicationMultipleUPDATE_MEDICATIONItem().setVisible( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) && !isRieMode);
    form.getContextMenus().getMedicationMultipleUPDATE_MEDICATIONItem().setEnabled( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) );

    form.getContextMenus().getMedicationMultipledisCONTINUE_MEDICATIONItem().setVisible( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) && !isRieMode );
    form.getContextMenus().getMedicationMultipledisCONTINUE_MEDICATIONItem().setEnabled( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) );


    form.getContextMenus().getMedicationMultipleDosesNEW_DOSEItem().setVisible(form.getMode().equals(FormMode.EDIT));
    form.getContextMenus().getMedicationMultipleDosesNEW_DOSEItem().setEnabled(form.getMode().equals(FormMode.EDIT));

    form.getContextMenus().getMedicationMultipleDosesdisCONTINUE_DOSEItem().setVisible( (form.getMode().equals(FormMode.EDIT)) 
            && (form.ctnDetails().dynGrdDoses().getSelectedRow() != null) );
    form.getContextMenus().getMedicationMultipleDosesdisCONTINUE_DOSEItem().setEnabled( (form.getMode().equals(FormMode.EDIT)) 
            && (form.ctnDetails().dynGrdDoses().getSelectedRow() != null) );


    if (form.getMode().equals(FormMode.EDIT))
    {
        form.ctnDetails().setcustomControlCodingItemEnabled(true);
        form.customControlAuthoringInfo().setIsrequiredPropertyToControls(true); //wdev-15369
        form.customControlAuthoringInfo().setEnabledAuthoringHCP(true);
    }
    else
    {
        form.customControlAuthoringInfo().setIsrequiredPropertyToControls(false);   //wdev-15369
        form.customControlAuthoringInfo().setEnabledAuthoringHCP(false);
    }

    form.ctnDetails().customControlCodingItem().setParentEditing(new Boolean(form.getMode().equals(FormMode.EDIT)));        


    if (form.getLocalContext().getScreenTypeIsNotNull() 
            && form.getLocalContext().getScreenType().equals(MedicationSnapShot.PATIENT) )
    {
        form.getContextMenus().hideAllMedicationMultipleMenuItems();
        form.getContextMenus().hideAllMedicationMultipleDosesMenuItems();
    }
}
项目:openMAXims    文件:Logic.java   
private void displayOrHideEnabledisableScreenSpecificControls() 
{
    form.ctnDetails().lblIncludeinTTO().setVisible(false);
    form.ctnDetails().chkTTO().setVisible(false);
    form.ctnDetails().lblNumDays().setVisible(false);
    form.ctnDetails().intNumDays().setVisible(false);
    form.recbroverviews().setVisible(false);

    MedicationSnapShot screenType = form.getLocalContext().getScreenType();
    if (screenType != null)
    {
        if (screenType.equals(MedicationSnapShot.disCHARGE) || screenType.equals(MedicationSnapShot.OPD))
        {
            form.ctnDetails().lblIncludeinTTO().setVisible(true);
            form.ctnDetails().chkTTO().setVisible(true);
            form.ctnDetails().lblNumDays().setVisible(true);
            form.ctnDetails().intNumDays().setVisible(true);

            form.ctnDetails().chkTTO().setEnabled(form.getMode().equals(FormMode.EDIT));
            form.ctnDetails().intNumDays().setEnabled(form.getMode().equals(FormMode.EDIT));
        }
        else if(screenType.equals(MedicationSnapShot.PATIENT))
        {
            form.recbroverviews().setEnabled(true);
            form.recbroverviews().setVisible(true);
            form.setcustomControlAuthoringInfoEnabled(false);
            form.setMode(FormMode.VIEW);
        }
    }
    if (form.getMode().equals(FormMode.VIEW) )
    {
        form.chkFilter().setVisible(false);
        form.setcustomControlAuthoringInfoEnabled(false);
        if (form.getLocalContext().getCurrentOverViewIsNotNull()) 
            form.chkFilter().setVisible(true);
    }
    else
    {
        form.setcustomControlAuthoringInfoEnabled(true);
        if (isDialog())
            isBtnCloseVisible(true);
    }
}
项目:openmaxims-linux    文件:Logic.java   
protected void onlyrDetailsTabChanged(LayerBridge tab)
{
    if(tab.equals(form.lyrDetails().tabPreview()) && form.getLocalContext().getSelectedItem() != null && form.getLocalContext().getReportChangedisNotNull() && form.getLocalContext().getReportChanged().booleanValue())
    {
        form.lyrDetails().tabPreview().htmReport().setHTML("");

        if(form.getLocalContext().getSelectedItem() != null && form.getLocalContext().getReportChangedisNotNull() && form.getLocalContext().getReportChanged().booleanValue() && form.getLocalContext().getSelectedItem().getID_ClinicalCorrespondence() != null)
        {
            buildreport();
            form.getLocalContext().setReportChanged(Boolean.FALSE);
        }
    }  //WDEV-1039 - 3) We need to display the Medication Overview record for this context,form.getimages().ICP.Child);            
            gridPopulation.initializeGrid();
            gridPopulation.populate(voOverView);

            form.getLocalContext().setIsMedicationDataLoaded(Boolean.TRUE);
        }
    }
    else if(tab.equals(form.lyrDetails().tabCommentsOPD()) && form.getLocalContext().getoutpatientSummaryChanged().booleanValue() && form.getMode().equals(FormMode.EDIT))
    {
        if(form.getLocalContext().getSelectedItem() == null)
        {
            OutpatientNotesOutcomeVo voOPDSummary = domain.getoPDSummary(form.getGlobalContext().Core.getCurrentClinicalContact());

            if(voOPDSummary != null && form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().size() == 3)
            {
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(0).setColText(voOPDSummary.getClinicalNote().getobjectiveNote());
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(1).setColText(voOPDSummary.getClinicalNote().getPlanNote());
                form.lyrDetails().tabCommentsOPD().GrdClinicalNotes().getRows().get(2).setColText(voOPDSummary.getInstructionNextClinic());

                form.lyrDetails().tabCommentsOPD().cmbOPFollowUp().setValue(voOPDSummary.getoutcome());
                form.lyrDetails().tabCommentsOPD().intOPReviewIn().setValue(voOPDSummary.getReviewIn());
                form.lyrDetails().tabCommentsOPD().cmbOPReviewIn().setValue(voOPDSummary.getReviewinUnits());

                form.getLocalContext().setoutpatientSummaryChanged(Boolean.FALSE);
            }
        }
    }
}
项目:openmaxims-linux    文件:Logic.java   
private void displayOrHideEnabledisableScreenSpecificControls() 
{
    form.ctnDetails().lblIncludeinTTO().setVisible(false);
    form.ctnDetails().chkTTO().setVisible(false);
    form.ctnDetails().lblNumDays().setVisible(false);
    form.ctnDetails().intNumDays().setVisible(false);
    form.recbroverviews().setVisible(false);

    MedicationSnapShot screenType = form.getLocalContext().getScreenType();
    if (screenType != null)
    {
        if (screenType.equals(MedicationSnapShot.disCHARGE) || screenType.equals(MedicationSnapShot.OPD))
        {
            form.ctnDetails().lblIncludeinTTO().setVisible(true);
            form.ctnDetails().chkTTO().setVisible(true);
            form.ctnDetails().lblNumDays().setVisible(true);
            form.ctnDetails().intNumDays().setVisible(true);

            form.ctnDetails().chkTTO().setEnabled(form.getMode().equals(FormMode.EDIT));
            form.ctnDetails().intNumDays().setEnabled(form.getMode().equals(FormMode.EDIT));
        }
        else if(screenType.equals(MedicationSnapShot.PATIENT))
        {
            form.recbroverviews().setEnabled(true);
            form.recbroverviews().setVisible(true);
            form.setcustomControlAuthoringInfoEnabled(false);
            form.setMode(FormMode.VIEW);
        }
    }
    if (form.getMode().equals(FormMode.VIEW) )
    {
        form.chkFilter().setVisible(false);
        form.setcustomControlAuthoringInfoEnabled(false);
        if (form.getLocalContext().getCurrentOverViewIsNotNull()) 
            form.chkFilter().setVisible(true);
    }
    else
    {
        form.setcustomControlAuthoringInfoEnabled(true);
        if (isDialog())
            isBtnCloseVisible(true);
    }
}
项目:openmaxims-linux    文件:Logic.java   
public void updateControlsstate()
{
    form.getContextMenus().hideAllMedicationMultipleMenuItems();
    form.getContextMenus().hideAllMedicationMultipleDosesMenuItems();
    boolean isRieMode = engine.isRIEMode();

    form.getContextMenus().getMedicationMultipleNEW_MEDICATIONItem().setVisible(form.getMode().equals(FormMode.VIEW) && !isRieMode);
    form.getContextMenus().getMedicationMultipleNEW_MEDICATIONItem().setEnabled(form.getMode().equals(FormMode.VIEW));

    form.getContextMenus().getMedicationMultipleUPDATE_MEDICATIONItem().setVisible( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) && !isRieMode);
    form.getContextMenus().getMedicationMultipleUPDATE_MEDICATIONItem().setEnabled( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) );

    form.getContextMenus().getMedicationMultipledisCONTINUE_MEDICATIONItem().setVisible( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) && !isRieMode );
    form.getContextMenus().getMedicationMultipledisCONTINUE_MEDICATIONItem().setEnabled( (form.getMode().equals(FormMode.VIEW)) 
            && (form.dynGrdMedication().getSelectedRow() != null) );


    form.getContextMenus().getMedicationMultipleDosesNEW_DOSEItem().setVisible(form.getMode().equals(FormMode.EDIT));
    form.getContextMenus().getMedicationMultipleDosesNEW_DOSEItem().setEnabled(form.getMode().equals(FormMode.EDIT));

    form.getContextMenus().getMedicationMultipleDosesdisCONTINUE_DOSEItem().setVisible( (form.getMode().equals(FormMode.EDIT)) 
            && (form.ctnDetails().dynGrdDoses().getSelectedRow() != null) );
    form.getContextMenus().getMedicationMultipleDosesdisCONTINUE_DOSEItem().setEnabled( (form.getMode().equals(FormMode.EDIT)) 
            && (form.ctnDetails().dynGrdDoses().getSelectedRow() != null) );


    if (form.getMode().equals(FormMode.EDIT))
    {
        form.ctnDetails().setcustomControlCodingItemEnabled(true);
        form.customControlAuthoringInfo().setIsrequiredPropertyToControls(true); //wdev-15369
        form.customControlAuthoringInfo().setEnabledAuthoringHCP(true);
    }
    else
    {
        form.customControlAuthoringInfo().setIsrequiredPropertyToControls(false);   //wdev-15369
        form.customControlAuthoringInfo().setEnabledAuthoringHCP(false);
    }

    form.ctnDetails().customControlCodingItem().setParentEditing(new Boolean(form.getMode().equals(FormMode.EDIT)));        


    if (form.getLocalContext().getScreenTypeIsNotNull() 
            && form.getLocalContext().getScreenType().equals(MedicationSnapShot.PATIENT) )
    {
        form.getContextMenus().hideAllMedicationMultipleMenuItems();
        form.getContextMenus().hideAllMedicationMultipleDosesMenuItems();
    }
}

关于c# – 如何模拟IOptionsSnapshot实例进行测试c# 模拟器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于.Net Core 配置文件读取IOptions,IOptionsMonitor,IOptionsSnapshot、c# – 更改* .json文件后IOptionsSnapshot不刷新、EasyTransaction 发布 v1.0.0-SNAPSHOT 版本、ims.clinical.vo.lookups.MedicationSnapShot的实例源码等相关知识的信息别忘了在本站进行查找喔。

本文标签: