Inheritance: VMISelectableElement, ILogConfig
Exemplo n.º 1
0
        public static VMLogServiceConfig CreateFrom( VMLogConfig holder, ILogServiceConfig s )
        {
            VMLogServiceConfig result = new VMLogServiceConfig( s.Name, false );

            result._holder = holder;
            result.Config = holder.Config;
            result._doLog = s.DoLog;

            foreach( ILogEventConfig e in s.Events )
            {
                VMLogEventConfig evVM = VMLogEventConfig.CreateFrom( result, e );
                evVM.LogConfigChanged += new EventHandler<PropertyChangedEventArgs>(
                    ( sndr, args ) =>
                    { result.IsDirty = true; }
                    );
                result.Events.Add( evVM );
            }

            foreach( ILogPropertyConfig p in s.Properties )
            {
                VMLogPropertyConfig propVM = VMLogPropertyConfig.CreateFrom( p );
                propVM.LogConfigChanged += new EventHandler<PropertyChangedEventArgs>(
                    ( sndr, args ) =>
                    { result.IsDirty = true; }
                    );
                result.Properties.Add( propVM );
            }

            foreach( ILogMethodConfig m in s.Methods )
            {
                VMLogMethodConfig mthdVM = VMLogMethodConfig.CreateFrom( result, m );
                mthdVM.LogConfigChanged += new EventHandler<PropertyChangedEventArgs>(
                ( sndr, args ) =>
                { result.IsDirty = true; }
                );
                result.Methods.Add( mthdVM );
            }

            return result;
        }
Exemplo n.º 2
0
        public VMIContextViewModel( IContext context, IPluginConfigAccessor config, ILogService logService, IHelpService helpService )
        {
            DisplayName = "Object explorer";

            Context = context;
            Config = config;
            HelpService = helpService;

            InitializeCommands();

            _plugins = new Dictionary<IPluginInfo, VMIPlugin>();
            _allServices = new Dictionary<IServiceInfo, VMIService>();
            _dynamicServices = new Dictionary<IServiceInfo, VMIService>();
            _serviceRefs = new Dictionary<IServiceReferenceInfo, VMIService>();
            _assemblies = new Dictionary<IAssemblyInfo, VMIAssembly>();

            _pluginRunner = Context.GetService<PluginRunner>( true );
            _pluginRunner.ApplyDone += new EventHandler<ApplyDoneEventArgs>( OnApplyDone );

            NotificationService = context.GetService<INotificationService>();

            Assemblies = new VMCollection<VMIAssembly, IAssemblyInfo>( PluginRunner.Discoverer.AllAssemblies, FindOrCreate );
            Plugins = new VMCollection<VMIPlugin, IPluginInfo>( PluginRunner.Discoverer.AllPlugins.OrderBy( p => p.PublicName ), FindOrCreate );
            AllServices = new VMCollection<VMIService, IServiceInfo>( PluginRunner.Discoverer.AllServices, FindOrCreate );
            DynamicServices = new VMCollection<VMIService, IServiceInfo>( PluginRunner.Discoverer.AllServices.Where( p => p.IsDynamicService ), FindOrCreateDynamic );
            Categories = new ObservableCollection<VMIFolder>();

            _vmLogConfig = new VMLogConfig( this, logService );
            _vmLogConfig.Initialize();

            OsInfo = new VMOSInfo( this );

            VMApplicationInfo = new VMApplicationInfo( this );

            Dictionary<string, List<IPluginInfo>> categoryFolders = new Dictionary<string, List<IPluginInfo>>();
            foreach( IPluginInfo plugin in PluginRunner.Discoverer.AllPlugins )
            {
                foreach( string categ in plugin.Categories )
                {
                    List<IPluginInfo> col;
                    if( !categoryFolders.TryGetValue( categ, out col ) )
                    {
                        col = new List<IPluginInfo>();
                        col.Add( plugin );
                        categoryFolders.Add( categ, col );
                    }
                    else
                    {
                        col.Add( plugin );
                    }
                }
            }
            foreach( KeyValuePair<string, List<IPluginInfo>> item in categoryFolders )
            {
                VMCollection<VMAlias<VMIPlugin>, IPluginInfo> collection = new VMCollection<VMAlias<VMIPlugin>, IPluginInfo>( item.Value, ( info ) => { return new VMAlias<VMIPlugin>( FindOrCreate( info ), null ); } );
                VMIFolder folder = new VMIFolder( collection, item.Key );
                Categories.Add( folder );
            }
        }
Exemplo n.º 3
0
        public static VMLogServiceConfig CreateFrom( VMLogConfig holder, IServiceInfo s )
        {
            VMLogServiceConfig result = new VMLogServiceConfig( s.ServiceFullName, true );
            result._holder = holder;
            result.Config = result._holder.Config;

            result.DoLog = result.Config.User.GetOrSet( result._doLogDataPath, true );

            foreach( ISimpleEventInfo e in s.EventsInfoCollection )
            {
                VMLogEventConfig evVM = VMLogEventConfig.CreateFrom( result, e );
                evVM.LogConfigChanged += new EventHandler<PropertyChangedEventArgs>(
                    ( sndr, args ) =>
                    { result.IsDirty = true; } //When an event's conf is modified, the service conf is set to dirty
                );
                result.Events.Add( evVM );
            }

            foreach( ISimplePropertyInfo p in s.PropertiesInfoCollection )
            {
                VMLogPropertyConfig propVM = VMLogPropertyConfig.CreateFrom( p );
                propVM.LogConfigChanged += new EventHandler<PropertyChangedEventArgs>(
                    ( sndr, args ) =>
                    { result.IsDirty = true; }//When a property's conf is modified, the service conf is set to dirty
                    );
                result.Properties.Add( propVM );
            }

            foreach( ISimpleMethodInfo m in s.MethodsInfoCollection )
            {
                VMLogMethodConfig mthdVM = VMLogMethodConfig.CreateFrom( result, m );
                mthdVM.LogConfigChanged += new EventHandler<PropertyChangedEventArgs>(
                ( sndr, args ) =>
                { result.IsDirty = true; } //When a method's conf is modified, the service conf is set to dirty
                );
                result.Methods.Add( mthdVM );
            }

            return result;
        }