コード例 #1
0
ファイル: CloneFactory.cs プロジェクト: whaycox/Creamery
 private void AddNewDefinition <TEntity>()
     where TEntity : class
 {
     lock (Locker)
     {
         if (!Definitions.ContainsKey(typeof(TEntity)))
         {
             Definitions.Add(typeof(TEntity), DefinitionFactory.Create <TEntity>(this));
         }
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #6
0
 public void Create_ShouldThrow_WhenDenyAll()
 {
     Assert.Throws <InvalidEnumArgumentException>(() => DefinitionFactory.Create(FilterDescriptor.DenyAll, Substitute.For <IElementConfiguration>()));
 }
コード例 #7
0
 public void Create_ShouldThrow_WhenUnknownDescriptor()
 {
     Assert.Throws <ArgumentException>(() => DefinitionFactory.Create(LayoutDescriptor.Simple, Substitute.For <IElementConfiguration>()));
 }
コード例 #8
0
 public void Create_ShouldReturnTheCorrectDefinition(DescriptorBase descriptorBase, Type expectedDefinitionType)
 {
     Assert.IsInstanceOf(expectedDefinitionType, DefinitionFactory.Create(descriptorBase, Substitute.For <IElementConfiguration>()));
 }