• EAS.Net 在程序里配置组件


    public class BeforStart
        {
            /// <summary>
            /// 程序配置初始化
            /// </summary>
            public static void EASConfig()
            {
                #region 系统日志
                ComponentInfo Log = new ComponentInfo();
                Log.Name = "Logger";
                Log.Type = "EAS.Services.TextLogger";
                Log.Assembly = "EAS.MicroKernel";
                Log.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Singleton;
                ComponentConfig.Components.Add(Log.Name, Log);
                #endregion
    
                #region 系统资源
                ComponentInfo Component = new ComponentInfo();
                Component.Name = "EAS.Explorer.Resource";
                Component.Type = "System.Res.Resources";
                Component.Assembly = "System.Res";
                Component.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Singleton;
                ComponentConfig.Components.Add(Component.Name, Component);
                #endregion
    
                #region 服务桥
                ComponentInfo ServiceBridger = new ComponentInfo();
                ServiceBridger.Name = "ServiceBridger";
                ServiceBridger.Type = "EAS.Distributed.ServiceBridger";
                ServiceBridger.Assembly = "EAS.Distributed.Client";
                ServiceBridger.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Thread;
                PropertyInfo BridgerProperty = new PropertyInfo();
                BridgerProperty.Name = "ServiceName";
                BridgerProperty.Type = "string";
                BridgerProperty.Expression = "EAS.RMIService.Service";
                ServiceBridger.Properties.Add(BridgerProperty.Name, BridgerProperty);
                ComponentConfig.Components.Add(ServiceBridger.Name, ServiceBridger);
                #endregion
    
                #region 通用数据访问
                ComponentInfo DataAccessor = new ComponentInfo();
                DataAccessor.Name = "DataAccessor";
                DataAccessor.Type = "EAS.Distributed.DataAccessor";
                DataAccessor.Assembly = "EAS.Distributed.Client";
                DataAccessor.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Thread;
                PropertyInfo DataAccessorProperty = new PropertyInfo();
                DataAccessorProperty.Name = "ServiceBridger";
                DataAccessorProperty.Type = "object";
                DataAccessorProperty.Expression = "ServiceBridger";
                DataAccessor.Properties.Add(DataAccessorProperty.Name, DataAccessorProperty);
                ComponentConfig.Components.Add(DataAccessor.Name, DataAccessor);
                #endregion
    
                #region ORM访问组件
                ComponentInfo OrmAccessor = new ComponentInfo();
                OrmAccessor.Name = "OrmAccessor";
                OrmAccessor.Type = "EAS.Distributed.OrmAccessor";
                OrmAccessor.Assembly = "EAS.Distributed.Client";
                OrmAccessor.Lifestyle = EAS.Objects.Lifecycle.LifestyleType.Thread;
    
                PropertyInfo OrmBridgerProperty = new PropertyInfo();
                OrmBridgerProperty.Name = "ServiceBridger";
                OrmBridgerProperty.Type = "object";
                OrmBridgerProperty.Expression = "ServiceBridger";
                OrmAccessor.Properties.Add(OrmBridgerProperty.Name, OrmBridgerProperty);
    
                PropertyInfo OrmDACProperty = new PropertyInfo();
                OrmDACProperty.Name = "DataAccessor";
                OrmDACProperty.Type = "object";
                OrmDACProperty.Expression = "DataAccessor";
                OrmAccessor.Properties.Add(OrmDACProperty.Name, OrmDACProperty);
                ComponentConfig.Components.Add(OrmAccessor.Name, OrmAccessor);
                #endregion
            }
        }
    


    再程序执行前 执行BeforStart.EASConfig();

    配置文件中只需要保留很少一部分信息

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
            <section name="eas" type="EAS.ConfigHandler,EAS.MicroKernel" />
        </configSections>
        <!--SQLite运行必需-->
        <startup useLegacyV2RuntimeActivationPolicy="true">
            <supportedRuntime version="v4.0" />
        </startup>
        <eas>
            <configurations>
                <item name="WorkstationUser" value="Administrator" />
                <item name="LastUser" value="Administrator" />
            </configurations>
            <services>
                <service name="EAS.RMIService.Service" service-type="WcfService" singleton="true" url="http://localhost:8888/eas/services/EAS.RMIService" />
            </services>
        </eas>
    </configuration>


     

  • 相关阅读:
    Q:简单实现URL只能页面跳转,禁止直接访问
    Q:elementUI中tree组件动态展开
    一个切图仔的 JS 笔记
    一个切图仔的HTML笔记
    一个切图仔的 CSS 笔记
    GnuPG使用笔记
    SQL Svr 2012 Enterprise/Always-on节点连接超时导致节点重启——case分享
    网卡配置文件备份在原目录下引起网络配置异常
    python培训
    service脚本的写法
  • 原文地址:https://www.cnblogs.com/docomo/p/3154813.html
Copyright © 2020-2023  润新知