Ejemplo n.º 1
0
 private void AddNewDefinition <TEntity>()
     where TEntity : class
 {
     lock (Locker)
     {
         if (!Definitions.ContainsKey(typeof(TEntity)))
         {
             Definitions.Add(typeof(TEntity), DefinitionFactory.Create <TEntity>(this));
         }
     }
 }
Ejemplo n.º 2
0
        private void ShowMappingWindow(MappingModel mappingModel)
        {
            XmlElement newMapping = mConfiguration.ConfigXml.CreateElement(MappingName);

            IElementConfiguration elementConfiguration = new ElementConfiguration(mConfiguration, mappingModel.Node, newMapping);

            ElementWindow elementWindow = new ElementWindow(elementConfiguration,
                                                            DefinitionFactory.Create(MappingDescriptor.Mapping, elementConfiguration),
                                                            WindowSizeLocationFactory.Create(MappingDescriptor.Mapping),
                                                            new AddSaveStrategy <MappingModel>(mappingModel, model => Mappings.Add(model), newMapping));

            mMessageBoxService.ShowWindow(elementWindow);
        }
Ejemplo n.º 3
0
        public IDefinition GetDefinition(string id)
        {
            IDefinition definition;

            if (_definitions.TryGetValue(id, out definition))
            {
                return(definition);
            }

            definition = _factory.Create(id);
            _definitions.Add(id, definition);
            return(definition);
        }
Ejemplo n.º 4
0
        private void ShowFilterWindow(FilterModel filterModel)
        {
            XmlElement newFilter = mConfiguration.ConfigXml.CreateElementWithAttribute("filter", "type", filterModel.Descriptor.TypeNamespace);

            IElementConfiguration configuration = new ElementConfiguration(mConfiguration, filterModel.Node, newFilter);

            ISaveStrategy saveStrategy = new AddSaveStrategy <FilterModel>(filterModel, Add, newFilter);

            Window filterWindow = new ElementWindow(configuration,
                                                    DefinitionFactory.Create(filterModel.Descriptor, configuration),
                                                    WindowSizeLocationFactory.Create(filterModel.Descriptor),
                                                    saveStrategy);

            mMessageBoxService.ShowWindow(filterWindow);
        }
Ejemplo n.º 5
0
        private void ShowParamWindow(ParamModel paramModel)
        {
            XmlElement newParam = mConfiguration.ConfigXml.CreateElement(ParamDescriptor.Param.ElementName);

            IElementConfiguration configuration = new ElementConfiguration(mConfiguration, paramModel.Node, newParam);

            ISaveStrategy saveStrategy = new AddSaveStrategy <ParamModel>(paramModel, AddModel, newParam);

            Window paramWindow = new ElementWindow(configuration,
                                                   DefinitionFactory.Create(ParamDescriptor.Param, configuration),
                                                   WindowSizeLocationFactory.Create(ParamDescriptor.Param),
                                                   saveStrategy);

            mMessageBoxService.ShowWindow(paramWindow);
        }
 public void Create_ShouldThrow_WhenDenyAll()
 {
     Assert.Throws <InvalidEnumArgumentException>(() => DefinitionFactory.Create(FilterDescriptor.DenyAll, Substitute.For <IElementConfiguration>()));
 }
 public void Create_ShouldThrow_WhenUnknownDescriptor()
 {
     Assert.Throws <ArgumentException>(() => DefinitionFactory.Create(LayoutDescriptor.Simple, Substitute.For <IElementConfiguration>()));
 }
 public void Create_ShouldReturnTheCorrectDefinition(DescriptorBase descriptorBase, Type expectedDefinitionType)
 {
     Assert.IsInstanceOf(expectedDefinitionType, DefinitionFactory.Create(descriptorBase, Substitute.For <IElementConfiguration>()));
 }