Exemple #1
0
        internal IndexManager(IStorageEngine storageEngine, ClassInfo classInfo)
        {
            _storageEngine = storageEngine;
            _classInfo = classInfo;

            _reflectionService = DependencyContainer.Resolve<IReflectionService>();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="messageProcessor">Message Processor Object</param>
 public PluginService(IHostApplicationLifetime hostApplicationLifetime, IMessageProcessor messageProcessor, ISimConnectService simConnectService, IReflectionService reflectionService)
 {
     _hostApplicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime));
     _messageProcessor        = messageProcessor ?? throw new ArgumentNullException(nameof(messageProcessor));
     _simConnectService       = simConnectService ?? throw new ArgumentNullException(nameof(simConnectService));
     _reflectionService       = reflectionService ?? throw new ArgumentNullException(nameof(reflectionService));
 }
Exemple #3
0
        public static IEnumerable <Assembly> GetMatchingAssemblies(this IReflectionService service, string regex)
        {
            Guard.AgainstNull(service, nameof(service));
            Guard.AgainstNullOrEmptyString(regex, nameof(regex));

            return(service.GetMatchingAssemblies(new Regex(regex)));
        }
        public FilterBuilderViewModel(IUIVisualizerService uiVisualizerService, IFilterSchemeManager filterSchemeManager,
                                      IFilterService filterService, IMessageService messageService, IServiceLocator serviceLocator, IReflectionService reflectionService, ILanguageService languageService)
        {
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => filterSchemeManager);
            Argument.IsNotNull(() => filterService);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => serviceLocator);
            Argument.IsNotNull(() => reflectionService);
            Argument.IsNotNull(() => languageService);

            _uiVisualizerService = uiVisualizerService;
            _filterSchemeManager = filterSchemeManager;
            _filterService       = filterService;
            _messageService      = messageService;
            _serviceLocator      = serviceLocator;
            _reflectionService   = reflectionService;
            _languageService     = languageService;

            NewSchemeCommand    = new TaskCommand(OnNewSchemeExecuteAsync);
            EditSchemeCommand   = new TaskCommand <FilterScheme>(OnEditSchemeExecuteAsync, OnEditSchemeCanExecute);
            ApplySchemeCommand  = new TaskCommand(OnApplySchemeExecuteAsync, OnApplySchemeCanExecute);
            ResetSchemeCommand  = new Command(OnResetSchemeExecute, OnResetSchemeCanExecute);
            DeleteSchemeCommand = new Command <FilterScheme>(OnDeleteSchemeExecute, OnDeleteSchemeCanExecute);
        }
        public void SetUp()
        {
            _assemblyOutputDirectoy = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MixerTest");
            _modulePath             = Path.Combine(_assemblyOutputDirectoy, "Signed.dll");

            if (Directory.Exists(_assemblyOutputDirectoy))
            {
                Directory.Delete(_assemblyOutputDirectoy, true);
            }

            _mixedTypeFinderStub      = MockRepository.GenerateStub <IMixedTypeFinder> ();
            _mixerPipelineFactoryStub = MockRepository.GenerateStub <IMixerPipelineFactory> ();
            _pipelineStub             = MockRepository.GenerateStub <IPipeline> ();

            _mixer = new Mixer(_mixedTypeFinderStub, _mixerPipelineFactoryStub, _assemblyOutputDirectoy);

            _reflectionServiceDynamicMock = MockRepository.GenerateMock <IReflectionService>();
            _codeManagerDynamicMock       = MockRepository.GenerateMock <ICodeManager>();
            _pipelineStub.Stub(stub => stub.ReflectionService).Return(_reflectionServiceDynamicMock);
            _pipelineStub.Stub(stub => stub.CodeManager).Return(_codeManagerDynamicMock);

            _fakeMixedType = typeof(int);
            _configuration = new MixinConfiguration();

            _mixedTypeFinderStub.Stub(stub => stub.FindMixedTypes(_configuration)).Return(new[] { _fakeMixedType });

            _mixerPipelineFactoryStub.Stub(stub => stub.GetModulePaths(_assemblyOutputDirectoy)).Return(new[] { _modulePath });
            _mixerPipelineFactoryStub.Stub(stub => stub.CreatePipeline(_assemblyOutputDirectoy)).Return(_pipelineStub);
        }
Exemple #6
0
        internal IndexManager(IStorageEngine storageEngine, ClassInfo classInfo)
        {
            _storageEngine = storageEngine;
            _classInfo     = classInfo;

            _reflectionService = DependencyContainer.Resolve <IReflectionService>();
        }
Exemple #7
0
        /// <summary>
        ///   The database file name
        /// </summary>
        public StorageEngine(IDbIdentification parameters)
        {
            _reflectionService = DependencyContainer.Resolve <IReflectionService>();

            try
            {
                var metaModelCompabilityChecker = DependencyContainer.Resolve <IMetaModelCompabilityChecker>();

                DbIdentification = parameters;
                IsDbClosed       = false;

                var isNewDatabase = DbIdentification.IsNew();

                _session = DependencyContainer.Resolve <ISession>(this);

                // Object Writer must be created before object Reader
                _objectWriter = DependencyContainer.Resolve <IObjectWriter>(this);
                ObjectReader  = DependencyContainer.Resolve <IObjectReader>(this);

                // Associate current session to the fsi -> all transaction writes
                // will be applied to this FileSystemInterface
                _session.SetFileSystemInterfaceToApplyTransaction(_objectWriter.FileSystemProcessor.FileSystemInterface);

                _objectIntrospectionDataProvider = new SessionDataProvider(_session);

                if (isNewDatabase)
                {
                    _objectWriter.CreateEmptyDatabaseHeader(OdbTime.GetCurrentTimeInTicks());
                }
                else
                {
                    GetObjectReader().ReadDatabaseHeader();
                }
                _objectWriter.AfterInit();
                _objectIntrospector = new ObjectIntrospector(GetClassInfoProvider());
                _triggerManager     = GetLocalTriggerManager();
                // This forces the initialization of the meta model
                var metaModel = GetMetaModel();

                var shouldUpdate = metaModelCompabilityChecker.Check(ClassIntrospector.Instrospect(metaModel.GetAllClasses()), GetMetaModel());

                if (shouldUpdate)
                {
                    UpdateMetaModel();
                }

                _objectWriter.SetTriggerManager(_triggerManager);
                _introspectionCallbackForInsert = new InstrumentationCallbackForStore(_triggerManager, false);
                _introspectionCallbackForUpdate = new InstrumentationCallbackForStore(_triggerManager, true);
            }
            catch
            {
                if (parameters is FileIdentification)
                {
                    Monitor.Exit(string.Intern(Path.GetFullPath(parameters.FileName)));
                }
                throw;
            }
        }
Exemple #8
0
        public QueueManager(IReflectionService reflectionService)
        {
            Guard.AgainstNull(reflectionService, "reflectionService");

            this.reflectionService = reflectionService;

            log = Log.For(this);
        }
 protected virtual IPipeline NewPipeline(
     PipelineSettings settings,
     ICodeManager codeManager,
     IReflectionService reflectionService,
     ITypeAssembler typeAssembler)
 {
     return(new Pipeline(settings, codeManager, reflectionService, typeAssembler));
 }
Exemple #10
0
        public QueueManager(IReflectionService reflectionService)
        {
            Guard.AgainstNull(reflectionService, "reflectionService");

            _reflectionService = reflectionService;

            _log = Log.For(this);
        }
        public override void SetUp()
        {
            base.SetUp();

            var pipeline = CreatePipelineWithAdditionalTypeParticipant();

            _codeManager       = pipeline.CodeManager;
            _reflectionService = pipeline.ReflectionService;
        }
Exemple #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="loggingService"> </param>
 /// <param name="localizationService"> </param>
 /// <param name="membershipUserPointsService"></param>
 /// <param name="reflectionService"></param>
 /// <param name="context"></param>
 public BadgeService(ILoggingService loggingService, ILocalizationService localizationService,
                     IMembershipUserPointsService membershipUserPointsService, IReflectionService reflectionService, IMVCForumContext context)
 {
     _loggingService              = loggingService;
     _localizationService         = localizationService;
     _membershipUserPointsService = membershipUserPointsService;
     _reflectionService           = reflectionService;
     _context = context as MVCForumContext;
 }
        public FilterService(IFilterSchemeManager filterSchemeManager)
        {
            Argument.IsNotNull(() => filterSchemeManager);

            var scope = filterSchemeManager.Scope;
            _reflectionService = this.GetServiceLocator().ResolveType<IReflectionService>(scope);
            
            filterSchemeManager.Updated += OnFilterSchemeManagerUpdated;
        }
Exemple #14
0
        private static void ProcessForClass(IReflectionService reflectionService, ComponentModel model)
        {
            var classAttribute = reflectionService.GetCustomAttribute <NamedAttribute>(model.Implementation);

            if (classAttribute != null)
            {
                model.Name = classAttribute.Name;
            }
        }
        public static void EnsureIntegrity(this FilterScheme filterScheme, IReflectionService reflectionService)
        {
            Argument.IsNotNull(() => filterScheme);
            Argument.IsNotNull(() => reflectionService);

            foreach (var item in filterScheme.ConditionItems)
            {
                item.EnsureIntegrity(reflectionService);
            }
        }
Exemple #16
0
        public FilterService(IFilterSchemeManager filterSchemeManager)
        {
            Argument.IsNotNull(() => filterSchemeManager);

            var scope = filterSchemeManager.Scope;

            _reflectionService = this.GetServiceLocator().ResolveType <IReflectionService>(scope);

            filterSchemeManager.Updated += OnFilterSchemeManagerUpdated;
        }
Exemple #17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="badgeRepository"> </param>
 /// <param name="api"></param>
 /// <param name="loggingService"> </param>
 /// <param name="localizationService"> </param>
 /// <param name="activityService"> </param>
 public BadgeService(IBadgeRepository badgeRepository,
                     ILoggingService loggingService, ILocalizationService localizationService, IActivityService activityService, IMembershipUserPointsService membershipUserPointsService, IReflectionService reflectionService)
 {
     _badgeRepository             = badgeRepository;
     _loggingService              = loggingService;
     _localizationService         = localizationService;
     _activityService             = activityService;
     _membershipUserPointsService = membershipUserPointsService;
     _reflectionService           = reflectionService;
 }
Exemple #18
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="messageProcessor">Message Processor Object</param>
        public PluginService(IHostApplicationLifetime hostApplicationLifetime, ILogger <PluginService> logger,
                             ITouchPortalClientFactory clientFactory, ISimConnectService simConnectService, IReflectionService reflectionService)
        {
            _hostApplicationLifetime = hostApplicationLifetime ?? throw new ArgumentNullException(nameof(hostApplicationLifetime));
            _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
            _simConnectService = simConnectService ?? throw new ArgumentNullException(nameof(simConnectService));
            _reflectionService = reflectionService ?? throw new ArgumentNullException(nameof(reflectionService));

            _client = clientFactory?.Create(this) ?? throw new ArgumentNullException(nameof(clientFactory));
        }
Exemple #19
0
        public PipelineService()
        {
            var factory = ServiceLocator.ServiceProvider.GetRequiredService <IReflectionServiceFactory>();

            ReflectionService = factory.GetVersionSpecificService();
            SettingsService   = ServiceLocator.ServiceProvider.GetRequiredService <ISettingsService>();
            BaseFactory       = ServiceLocator.ServiceProvider.GetRequiredService <BaseFactory>();

            InitializePipelines();
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="loggingService"> </param>
 /// <param name="localizationService"> </param>
 /// <param name="membershipUserPointsService"></param>
 /// <param name="reflectionService"></param>
 /// <param name="context"></param>
 /// <param name="cacheService"></param>
 public BadgeService(ILoggingService loggingService, ILocalizationService localizationService,
                     IMembershipUserPointsService membershipUserPointsService, IReflectionService reflectionService,
                     IMvcForumContext context, ICacheService cacheService)
 {
     _loggingService              = loggingService;
     _localizationService         = localizationService;
     _membershipUserPointsService = membershipUserPointsService;
     _reflectionService           = reflectionService;
     _cacheService = cacheService;
     _context      = context;
 }
Exemple #21
0
        private static void ProcessForProperties(IReflectionService reflectionService, ComponentModel model)
        {
            var properties = model.Properties
                             .Select(property => (property: property, attribute: reflectionService.GetCustomAttribute <NamedAttribute>(property.Property)))
                             .Where(x => x.attribute != null);

            foreach (var property in properties)
            {
                property.property.Dependency.DependencyKey = property.attribute.Name;
            }
        }
Exemple #22
0
        private IEnumerable <SQLiteConnection.ColumnInfo> GetExpectedColumnInfos(IReflectionService reflectionService, Type type)
        {
            var expectedValues = from prop in reflectionService.GetPublicInstanceProperties(type)
                                 select new SQLiteConnection.ColumnInfo
            {
                Name    = prop.Name,
                notnull = ((!prop.GetCustomAttributes <NotNullAttribute>(true).Any()) && (!prop.GetCustomAttributes <PrimaryKeyAttribute>(true).Any())) ? 0 : 1
            };

            return(expectedValues);
        }
        private IEnumerable<SQLiteConnection.ColumnInfo> GetExpectedColumnInfos(IReflectionService reflectionService, Type type)
        {
            var expectedValues = from prop in reflectionService.GetPublicInstanceProperties(type)
                                 select new SQLiteConnection.ColumnInfo
                                 {
                                     Name = prop.Name,
                                     notnull = ((!prop.GetCustomAttributes<NotNullAttribute>(true).Any()) && (!prop.GetCustomAttributes<PrimaryKeyAttribute>(true).Any())) ? 0 : 1
                                 };

            return expectedValues;
        }
Exemple #24
0
 public ArgsMapper()
 {
     Introduction                   = new GeneralPageBuilder <T>(Commands, Options);
     Usage                          = new GeneralPageBuilder <T>(Commands, Options);
     ValueConverterFactory          = new ValueConverterFactory();
     OptionValidationService        = new OptionValidationService(ValueConverterFactory);
     CommandValidationService       = new CommandValidationService(Settings);
     SubcommandValidationService    = new SubcommandValidationService(Settings);
     ReflectionService              = new ReflectionService(ValueConverterFactory);
     CommandOptionValidationService = new CommandOptionValidationService(ValueConverterFactory, Settings);
 }
 public ReflectionServiceFactory()
 {
     if (!SitecoreVersion.LesserThan(SitecoreVersion.Versions.Sitecore9_0_2))
     {
         _implementation = new Sitecore_9_0_2();
     }
     else
     {
         _implementation = new Base();
     }
 }
Exemple #26
0
        public void SetUp()
        {
            _settings              = PipelineSettings.New().Build();
            _codeManagerMock       = MockRepository.GenerateStrictMock <ICodeManager>();
            _reflectionServiceMock = MockRepository.GenerateStrictMock <IReflectionService>();
            _typeAssemblerMock     = MockRepository.GenerateStrictMock <ITypeAssembler>();

            _pipeline = new Pipeline(_settings, _codeManagerMock, _reflectionServiceMock, _typeAssemblerMock);

            _requestedType = ReflectionObjectMother.GetSomeType();
            _typeID        = AssembledTypeIDObjectMother.Create();
        }
        public void AutoWireConverters()
        {
            IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain();

            using (ITypeExecutorService executors = reflectionService.PrepareTypeExecutors())
            {
                executors.AddConverters();
            }

            string value;

            Assert.AreEqual(true, Converts.Repository.TryConvert <int, string>(5, out value));
            Assert.AreEqual("5", value);
        }
Exemple #28
0
            public void Base()
            {
                IDependencyContainer root = new SimpleDependencyContainer();

                IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain();

                using (ITypeExecutorService executorService = reflectionService.PrepareTypeExecutors())
                {
                    executorService.AddQueryHandlers(root);
                }

                IQueryHandler <Q1, R1> handler1 = root.Resolve <IQueryHandler <Q1, R1> >();
                IQueryHandler <Q2, R2> handler2 = root.Resolve <IQueryHandler <Q2, R2> >();
            }
        public static async Task EnsureIntegrityAsync(this ConditionTreeItem conditionTreeItem, IReflectionService reflectionService = null)
        {
            Argument.IsNotNull(() => conditionTreeItem);

            var propertyExpression = conditionTreeItem as PropertyExpression;
            if (propertyExpression != null)
            {
                await propertyExpression.EnsureIntegrityAsync(reflectionService);
            }

            foreach (var item in conditionTreeItem.Items)
            {
                await item.EnsureIntegrityAsync(reflectionService);
            }
        }
Exemple #30
0
        public Pipeline(
            PipelineSettings settings,
            ICodeManager codeManager,
            IReflectionService reflectionService,
            ITypeAssembler typeAssembler)
        {
            ArgumentUtility.CheckNotNull("settings", settings);
            ArgumentUtility.CheckNotNull("codeManager", codeManager);
            ArgumentUtility.CheckNotNull("reflectionService", reflectionService);
            ArgumentUtility.CheckNotNull("typeAssembler", typeAssembler);

            _settings          = settings;
            _codeManager       = codeManager;
            _reflectionService = reflectionService;
            _typeAssembler     = typeAssembler;
        }
        public void BaseComposition()
        {
            StringBuilder result = new StringBuilder();

            IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain();

            using (ITypeExecutorService executors = reflectionService.PrepareTypeExecutors())
            {
                executors.AddFiltered(true)
                .AddFilterNotInterface()
                .AddFilterNotAbstract()
                .AddHandler(t => result.AppendLine(t.FullName));
            }

            File.WriteAllText("C:/Temp/Files.txt", result.ToString());
        }
        public override void SetUp()
        {
            base.SetUp();

            var participant = CreateParticipant(
                ctx =>
            {
                if (ctx.RequestedType == typeof(RequestedType1))
                {
                    ctx.CreateAdditionalType(new object(), "AdditionalType", "MyNs", TypeAttributes.Class, typeof(object));
                }
            });

            _pipeline          = CreatePipeline(participant);
            _reflectionService = _pipeline.ReflectionService;
        }
        public static void EnsureIntegrity(this ConditionTreeItem conditionTreeItem, IReflectionService reflectionService)
        {
            Argument.IsNotNull(() => conditionTreeItem);
            Argument.IsNotNull(() => reflectionService);

            var propertyExpression = conditionTreeItem as PropertyExpression;

            if (propertyExpression != null)
            {
                propertyExpression.EnsureIntegrity(reflectionService);
            }

            foreach (var item in conditionTreeItem.Items)
            {
                item.EnsureIntegrity(reflectionService);
            }
        }
		/// <summary>
		/// Constructs the EmbeddedApplicationResourceService.
		/// </summary>
		/// <param name="resourceSubFolder">The subfolder in which the resources live.</param>
		/// <param name="pathInterpreters">The <see cref="IEnumerable{T}"/>s.</param>
		/// <param name="reflectionService">The <see cref="IReflectionService"/> holding the assemblies used to load the resources from.</param>
		/// <exception cref="ArgumentNullException">Thrown if <paramref name="resourceSubFolder"/>, <paramref name="pathInterpreters"/> or <paramref name="reflectionService"/> is null.</exception>
		public EmbeddedApplicationResourceService(string resourceSubFolder, IEnumerable<ResourcePathInterpreter> pathInterpreters, IReflectionService reflectionService)
		{
			// validate arguments
			if (string.IsNullOrEmpty(resourceSubFolder))
				throw new ArgumentNullException("resourceSubFolder");
			if (pathInterpreters == null)
				throw new ArgumentNullException("pathInterpreters");
			if (reflectionService == null)
				throw new ArgumentNullException("reflectionService");

			// set values
			this.pathInterpreters = pathInterpreters.ToArray();

			// translate the resource sub folder
			this.resourceSubFolder = TranslatePath(resourceSubFolder);

			// first select all the resource names from all assemblies
			var allResourceNames = reflectionService.Assemblies.SelectMany(assembly => {
				// get all the resources in this assembly
				var resourceNames = assembly.GetManifestResourceNames();

				// remove the assembly name from each resource.
				var assemblyName = assembly.GetName();
				var assemblyNameLength = assemblyName.Name.Length + 1 + this.resourceSubFolder.Length + 1;
				var normalizedResourceNames = resourceNames.Where(resourceName => resourceName.Length > assemblyNameLength).Select(resourceName => resourceName.Substring(assemblyNameLength));

				// return the assembly and the normalized resource name
				return normalizedResourceNames.Select(resourceName => new {
					AssemblyName = assemblyName,
					ResourceName = resourceName
				});
			}
				);

			// group all the assemblies by the common resource names
			var groupedResourceNames = allResourceNames.GroupBy(resourceName => resourceName.ResourceName, StringComparer.OrdinalIgnoreCase);

			// turn the grouped resource name into a lookup table
			lookupTable = groupedResourceNames.ToDictionary(key => key.Key, group => {
				var assemblyNames = group.Select(resource => resource.AssemblyName).Where(name => name != null).ToArray();
				if (assemblyNames.Length == 0)
					throw new InvalidOperationException(string.Format("No assemblies registered for resource '{0}'", group.First().ResourceName));
				return assemblyNames;
			}, StringComparer.OrdinalIgnoreCase);
		}
Exemple #35
0
            public void ConcreteType()
            {
                IQueryHandlerCollection collection = new DefaultQueryDispatcher();

                IReflectionService reflectionService = ReflectionFactory.FromCurrentAppDomain();

                using (ITypeExecutorService executorService = reflectionService.PrepareTypeExecutors())
                {
                    executorService.AddQueryHandlers(collection);
                }

                IQueryHandler <Q3, R3> handler3;

                Assert.AreEqual(true, collection.TryGet(out handler3));
                IQueryHandler <Q4, R4> handler4;

                Assert.AreEqual(false, collection.TryGet(out handler4));
            }
Exemple #36
0
        private static void ProcessForParameters(IReflectionService reflectionService, ComponentModel model)
        {
            var parameters = model.Dependencies
                             .OfType <ConstructorDependencyModel>()
                             .Where(x => !x.IsPrimitiveTypeDependency)
                             .ToList();

            foreach (var parameter in parameters)
            {
                var parameterName = parameter.DependencyKey;
                var parameterInfo = parameter.Constructor.Constructor.GetParameters().First(x => x.Name == parameterName);
                var attribute     = reflectionService.GetCustomAttribute <NamedAttribute>(parameterInfo);
                if (attribute != null)
                {
                    parameter.DependencyKey = attribute.Name;
                }
            }
        }
        public EditFilterViewModel(FilterSchemeEditInfo filterSchemeEditInfo, IReflectionService reflectionService, 
            IXmlSerializer xmlSerializer, IMessageService messageService)
        {
            Argument.IsNotNull(() => filterSchemeEditInfo);
            Argument.IsNotNull(() => reflectionService);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => messageService);

            PreviewItems = new FastObservableCollection<object>();
            RawCollection = filterSchemeEditInfo.RawCollection;
            EnableAutoCompletion = filterSchemeEditInfo.EnableAutoCompletion;
            AllowLivePreview = filterSchemeEditInfo.AllowLivePreview;
            EnableLivePreview = filterSchemeEditInfo.AllowLivePreview;
            
            var filterScheme = filterSchemeEditInfo.FilterScheme;

            _originalFilterScheme = filterScheme;
            _reflectionService = reflectionService;
            _xmlSerializer = xmlSerializer;
            _messageService = messageService;

            DeferValidationUntilFirstSaveCall = true;

            InstanceProperties = _reflectionService.GetInstanceProperties(filterScheme.TargetType).Properties;

            // Serializing gives us a *real* deep clone, there was a bug in Copy()
            //FilterScheme = _originalFilterScheme.Copy();

            using (var memoryStream = new MemoryStream())
            {
                xmlSerializer.Serialize(_originalFilterScheme, memoryStream);
                memoryStream.Position = 0L;
                FilterScheme = (FilterScheme) xmlSerializer.Deserialize(typeof (FilterScheme), memoryStream);
            }

            FilterSchemeTitle = FilterScheme.Title;

            AddGroupCommand = new Command<ConditionGroup>(OnAddGroup);
            AddExpressionCommand = new Command<ConditionGroup>(OnAddExpression);
            DeleteConditionItem = new Command<ConditionTreeItem>(OnDeleteCondition);
        }
        public TypesViewModel(IOpenFileService openFileService, IPleaseWaitService pleaseWaitService,
            IUIServiceHost uiServiceHost, IReflectionService reflectionService, ICommandManager commandManager)
        {
            Argument.IsNotNull(() => openFileService);
            Argument.IsNotNull(() => pleaseWaitService);
            Argument.IsNotNull(() => uiServiceHost);
            Argument.IsNotNull(() => reflectionService);
            Argument.IsNotNull(() => commandManager);

            _openFileService = openFileService;
            _pleaseWaitService = pleaseWaitService;
            _uiServiceHost = uiServiceHost;
            _reflectionService = reflectionService;

            Assemblies = new List<AssemblyEntry>();

            FileOpen = new Command(OnFileOpenExecute);
            ClearFilter = new Command(OnClearFilterExecute);

            commandManager.RegisterCommand("File.Open", FileOpen, this);
        }
        public EditFilterViewModel(FilterSchemeEditInfo filterSchemeEditInfo, IXmlSerializer xmlSerializer, 
            IMessageService messageService, IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => filterSchemeEditInfo);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => serviceLocator);

            PreviewItems = new FastObservableCollection<object>();
            RawCollection = filterSchemeEditInfo.RawCollection;
            EnableAutoCompletion = filterSchemeEditInfo.EnableAutoCompletion;
            AllowLivePreview = filterSchemeEditInfo.AllowLivePreview;
            EnableLivePreview = filterSchemeEditInfo.AllowLivePreview;

            var filterScheme = filterSchemeEditInfo.FilterScheme;

            _originalFilterScheme = filterScheme;
            _xmlSerializer = xmlSerializer;
            _messageService = messageService;
            _serviceLocator = serviceLocator;

            _reflectionService = _serviceLocator.ResolveType<IReflectionService>(filterScheme.Tag);

            DeferValidationUntilFirstSaveCall = true;

            using (var memoryStream = new MemoryStream())
            {
                xmlSerializer.Serialize(_originalFilterScheme, memoryStream);
                memoryStream.Position = 0L;
                FilterScheme = (FilterScheme)xmlSerializer.Deserialize(typeof(FilterScheme), memoryStream);
                FilterScheme.Tag = filterScheme.Tag;
            }

            FilterSchemeTitle = FilterScheme.Title;

            AddGroupCommand = new Command<ConditionGroup>(OnAddGroup);
            AddExpressionCommand = new Command<ConditionGroup>(OnAddExpression);
            DeleteConditionItem = new Command<ConditionTreeItem>(OnDeleteCondition, OnDeleteConditionCanExecute);
        }
        public FilterBuilderViewModel(IUIVisualizerService uiVisualizerService, IFilterSchemeManager filterSchemeManager,
            IFilterService filterService, IMessageService messageService, IServiceLocator serviceLocator, IReflectionService reflectionService)
        {
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => filterSchemeManager);
            Argument.IsNotNull(() => filterService);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => serviceLocator);
            Argument.IsNotNull(() => reflectionService);

            _uiVisualizerService = uiVisualizerService;
            _filterSchemeManager = filterSchemeManager;
            _filterService = filterService;
            _messageService = messageService;
            _serviceLocator = serviceLocator;
            _reflectionService = reflectionService;

            NewSchemeCommand = new Command(OnNewSchemeExecute);
            EditSchemeCommand = new Command<FilterScheme>(OnEditSchemeExecute, OnEditSchemeCanExecute);
            ApplySchemeCommand = new TaskCommand(OnApplySchemeExecuteAsync, OnApplySchemeCanExecute);
            ResetSchemeCommand = new Command(OnResetSchemeExecute, OnResetSchemeCanExecute);
            DeleteSchemeCommand = new Command<FilterScheme>(OnDeleteSchemeExecute, OnDeleteSchemeCanExecute);
        }
        public EditFilterViewModel(FilterSchemeEditInfo filterSchemeEditInfo, IXmlSerializer xmlSerializer,
            IMessageService messageService, IServiceLocator serviceLocator, ILanguageService languageService)
        {
            Argument.IsNotNull(() => filterSchemeEditInfo);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => serviceLocator);
            Argument.IsNotNull(() => languageService);

            _xmlSerializer = xmlSerializer;
            _messageService = messageService;
            _serviceLocator = serviceLocator;
            _languageService = languageService;

            PreviewItems = new FastObservableCollection<object>();
            RawCollection = filterSchemeEditInfo.RawCollection;
            EnableAutoCompletion = filterSchemeEditInfo.EnableAutoCompletion;
            AllowLivePreview = filterSchemeEditInfo.AllowLivePreview;
            EnableLivePreview = filterSchemeEditInfo.AllowLivePreview;

            var filterScheme = filterSchemeEditInfo.FilterScheme;
            _originalFilterScheme = filterScheme;

            _reflectionService = _serviceLocator.ResolveType<IReflectionService>(filterScheme.Scope);

            DeferValidationUntilFirstSaveCall = true;

            FilterScheme = new FilterScheme
            {
                Scope = _originalFilterScheme.Scope
            };

            AddGroupCommand = new Command<ConditionGroup>(OnAddGroup);
            AddExpressionCommand = new Command<ConditionGroup>(OnAddExpression);
            DeleteConditionItem = new Command<ConditionTreeItem>(OnDeleteCondition, OnDeleteConditionCanExecute);
        }
        public static async Task EnsureIntegrityAsync(this PropertyExpression propertyExpression, IReflectionService reflectionService = null)
        {
            Argument.IsNotNull(() => propertyExpression);

            if (reflectionService == null)
            {
                reflectionService = _reflectionService;
            }

            if (propertyExpression.Property == null)
            {
                using (await LockPropertyExpression.LockAsync())
                {
                    var serializationValue = propertyExpression.PropertySerializationValue;
                    if (!string.IsNullOrWhiteSpace(serializationValue))
                    {
                        var splittedString = serializationValue.Split(new[] {Separator}, StringSplitOptions.RemoveEmptyEntries);
                        if (splittedString.Length == 2)
                        {
                            var type = TypeCache.GetType(splittedString[0]);
                            if (type != null)
                            {
                                var typeProperties = await reflectionService.GetInstancePropertiesAsync(type);
                                propertyExpression.Property = typeProperties.GetProperty(splittedString[1]);
                            }
                        }
                    }
                }
            }
        }
Exemple #43
0
 /// <summary>
 /// Constructor - hidden
 /// </summary>
 private EventManager()
 {
     _reflectionService = DependencyResolver.Current.GetService<IReflectionService>();
 }
 public EnrichWithOidTrigger()
 {
     _reflectionService = DependencyContainer.Resolve<IReflectionService>();
 }
        private void OnScopeChanged()
        {
            if (_filterSchemeManager != null)
            {
                _filterSchemeManager.Loaded -= OnFilterSchemeManagerLoaded;
                _filterService.SelectedFilterChanged -= OnFilterServiceSelectedFilterChanged;
            }

            var scope = Scope;
            _filterSchemeManager = _serviceLocator.ResolveType<IFilterSchemeManager>(scope);
            _filterSchemeManager.Loaded += OnFilterSchemeManagerLoaded;

            _filterService = _serviceLocator.ResolveType<IFilterService>(scope);
            _filterService.SelectedFilterChanged += OnFilterServiceSelectedFilterChanged;

            _reflectionService = _serviceLocator.ResolveType<IReflectionService>(scope);

            UpdateFilters();
        }