Esempio n. 1
0
        /// <summary>
        /// Creates a new strategy for saving the specified type.
        /// </summary>
        /// <param name="typeName">The short name of the type involved in the strategy.</param>
        /// <param name="requiresAuthorisation">A value indicating whether the strategy requires authorisation.</param>
        static public ISaveStrategy New(string typeName, bool requiresAuthorisation)
        {
            ISaveStrategy strategy = StrategyState.Strategies.Creator.NewSaver(typeName);

            strategy.RequireAuthorisation = requiresAuthorisation;
            return(strategy);
        }
Esempio n. 2
0
        protected override void OnPreLoad(EventArgs e)
        {
            Response.CacheControl = "no-cache";
            if (IdTipoDocumento < 0)
            {
                throw new ArgumentException(@"No se encontro el parametro", "Id Tipo Documento");
            }

            var tipoDoc = DAOFactory.TipoDocumentoDAO.FindById(IdTipoDocumento);

            IdTipoDocumento = tipoDoc.Id;

            presenter = new PartePresentStrategy(tipoDoc, this, DAOFactory);
            saver     = new ParteSaveStrategy(tipoDoc, this);

            presenter.CrearForm();

            if (EditMode)
            {
                presenter.SetValores(EditObject);
                if (Usuario.AccessLevel < Logictracker.Types.BusinessObjects.Usuario.NivelAcceso.SysAdmin && EditObject.Valores[ParteCampos.EstadoControl].ToString() != "0")
                {
                    PanelForm.Enabled = false;
                }
            }

            base.OnPreLoad(e);
        }
 public StorageBox(Bucket bucket, ISaveStrategy saveStrategy, SaveRequestHandler saver)
 {
     this.Name             = bucket.Name;
     this.UnderlyingBucket = bucket;
     this.SaveStrategy     = saveStrategy;
     this.SaveHandler      = saver;
     this.InnerBoxes       = new Dictionary <string, StorageBox>();
 }
Esempio n. 4
0
 public PoolObject(string route, string directory, string description, IInfoAccessor infoAccessor, ISaveStrategy saveStrategy)
 {
     Route         = route;
     _directory    = directory;
     Description   = description;
     _infoAccessor = infoAccessor;
     _saveStrategy = saveStrategy;
 }
        public RequestCreater(ISaveStrategy aRequestSaver, DataRepository SRepository, DataRepository LRepository, DataRepository JRepository)
        {
            _RequestSaver = aRequestSaver;

            _JRepository = JRepository;
            _LRepository = LRepository;
            _SRepository = SRepository;
        }
Esempio n. 6
0
 public PersistentList(IDataStore dataStore, ISerializer serializer, ISaveStrategy saveStrategy)
 {
     _dataStore    = dataStore;
     _serializer   = serializer;
     _items        = new List <T>();
     _serializer   = serializer ?? new JsonSerializer();
     _saveStrategy = saveStrategy ?? new SaveOnlyWhenRequested();
     _saveStrategy.NotifyUnsolicitedSave += (sender, args) => Save();
     Load();
 }
Esempio n. 7
0
 private PersistentList <T> Create()
 {
     if (_serializer == null)
     {
         _serializer = new JsonSerializer();
     }
     if (_saveStrategy == null)
     {
         _saveStrategy = new SaveOnlyWhenRequested();
     }
     return(new PersistentList <T>(_dataStore, _serializer, _saveStrategy));
 }
Esempio n. 8
0
        /// <summary>
        /// Creates a new strategy for saving the provided type.
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="requireAuthorisation"></param>
        /// <returns>A save strategy for the provided type.</returns>
        static public ISaveStrategy New(IEntity entity, bool requireAuthorisation)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            ISaveStrategy strategy = StrategyState.Strategies.Creator.NewSaver(entity.ShortTypeName);

            strategy.RequireAuthorisation = requireAuthorisation;
            return(strategy);
        }
Esempio n. 9
0
 public PersistentList(IDataStore dataStore, ISaveStrategy saveStrategy)
 {
     _dataStore = dataStore;
     _items     = new List <T>();
     if (saveStrategy == null)
     {
         saveStrategy = new SaveOnlyWhenRequested();
     }
     SaveStrategy = saveStrategy;
     SaveStrategy.NotifyUnsolicitedSave += (sender, args) => Save();
     Load();
 }
Esempio n. 10
0
        public StudentService(StrategySaveType typeValue,
                              ICache <StudentModel> memoryCache)
        {
            SaveType param = SaveType.json;

            if (typeValue == StrategySaveType.xml)
            {
                param = SaveType.xml;
            }

            _saveStrategy = new SystemReposytory <Student.DAL.Model.Student>(param);
            _memoryCache  = memoryCache;
        }
Esempio n. 11
0
 public App(IJsonService jsonService,
            IOptions <AppSettings> config,
            ILogger <App> logger,
            ISaveStrategy strategy,
            DbContextOptions options
            )
 {
     _jsonService = jsonService;
     _logger      = logger;
     _config      = config.Value;
     _strategy    = strategy;
     _options     = options;
 }
        public void Test_Save()
        {
            TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>();

            article.ID = Guid.NewGuid();

            StrategyInfo  info     = StrategyState.Strategies["Save", "IEntity"];
            ISaveStrategy strategy = SaveStrategy.New <TestArticle>(false);

            strategy.Save(article);

            TestArticle foundArticle = Data.DataAccess.Data.Reader.GetEntity <TestArticle>("ID", article.ID);

            Assert.IsNotNull(foundArticle);
        }
        public ElementWindow(IElementConfiguration appenderConfiguration,
                             IElementDefinition propertyDefinition,
                             IWindowSizeLocation windowSizeLocation,
                             ISaveStrategy saveStrategy)
            : base(windowSizeLocation.RetentionKey)
        {
            InitializeComponent();
            DataContext        = this;
            mMessageBoxService = new MessageBoxService(this);

            mConfiguration = appenderConfiguration;
            mSaveStrategy  = saveStrategy;
            SetWindowSizeLocation(windowSizeLocation);
            PropertyDefinition = propertyDefinition;
            PropertyDefinition.MessageBoxService = mMessageBoxService;
            Loaded += WindowOnLoaded;
            Icon    = new BitmapImage(new Uri(PropertyDefinition.Icon));
        }
Esempio n. 14
0
        public ElementWindow(IElementConfiguration appenderConfiguration,
                             IElementDefinition propertyDefinition,
                             IWindowSizeLocation windowSizeLocation,
                             ISaveStrategy saveStrategy)
            : base(windowSizeLocation.RetentionKey)
        {
            InitializeComponent();
            DataContext        = this;
            mMessageBoxService = new MessageBoxService(this);

            mConfiguration     = appenderConfiguration;
            WindowSizeLocation = windowSizeLocation;
            mSaveStrategy      = saveStrategy;
            SetWindowSizeLocation(windowSizeLocation);
            PropertyDefinition = propertyDefinition;
            PropertyDefinition.MessageBoxService = mMessageBoxService;
            Properties = new ObservableCollection <IProperty>();
            Loaded    += WindowOnLoaded;
            ((INotifyCollectionChanged)PropertyDefinition.Properties).CollectionChanged += PropertiesOnCollectionChanged;
            Icon = new BitmapImage(new Uri(PropertyDefinition.Icon));
        }
        protected virtual StorageBox ResolveNamedSubContainer(string name, ISaveStrategy saveStrategy)
        {
            this.AssertBoxIsNotDeleted();
            name = this.NomalizeName(name);
            if (this.InnerBoxes.ContainsKey(name))
            {
                return(this.InnerBoxes[name]);
            }

            try
            {
                PermanentInfoStorage.ModificationsSyncRoot.EnterReadLock();
                var appropriateBucket = this.GetOrCreateInnerBucket(name);
                var box = new StorageBox(appropriateBucket, saveStrategy, this.HandleSaveRequest);
                this.InnerBoxes[name] = box;
                return(box);
            }
            finally
            {
                PermanentInfoStorage.ModificationsSyncRoot.ExitReadLock();
                this.HandleSaveRequest();
            }
        }
Esempio n. 16
0
 public PersistentList <T> BackgroundSavingEveryMinute()
 {
     _saveStrategy = new BackgroundSave(TimeSpan.FromMinutes(1));
     return(Create());
 }
 public BeverageRepository() :
     base("Beverage")
 {
     InsertStrategy = new BeverageInsertStrategy(this);
     UpdateStrategy = new BeverageUpdateStrategy(this);
 }
 public ProductRepository() :
     base("Product")
 {
     InsertStrategy = new ProductInsertStrategy(this);
     UpdateStrategy = new ProductUpdateStrategy(this);
 }
 public virtual IDataBox GetOrCreateSubBox(string name, ISaveStrategy saveStrategy)
 {
     return(this.ResolveNamedSubContainer(name, saveStrategy));
 }
Esempio n. 20
0
 public SaveContext(ISaveStrategy strategy)
 {
     SaveStrategy = strategy;
 }
Esempio n. 21
0
 public OrderRepository() :
     base("Order")
 {
     InsertStrategy = new OrderInsertStrategy(this);
     UpdateStrategy = new OrderUpdateStrategy(this);
 }
Esempio n. 22
0
 public SaveContext(ISaveStrategy _strategy)
 {
     ContextStrategy = _strategy;
 }
Esempio n. 23
0
 public PersistentList <T> BackgroundSavingEvery(TimeSpan timeSpan)
 {
     _saveStrategy = new BackgroundSave(timeSpan);
     return(Create());
 }
Esempio n. 24
0
 public DataContext(ISaveStrategy <T> saveStrategy)
 {
     this._strategySave = saveStrategy;
 }
Esempio n. 25
0
 public static PersistentList <T> Create <T>(ISaveStrategy saveStrategy) where T : new()
 {
     return(Create <T>("", saveStrategy));
 }
Esempio n. 26
0
 public PersistentList <T> BackgroundSavingEveryFiveSeconds()
 {
     _saveStrategy = new BackgroundSave(TimeSpan.FromSeconds(5));
     return(Create());
 }
Esempio n. 27
0
 public static PersistentList <T> Create <T>(string path, ISaveStrategy saveStrategy) where T : new()
 {
     return(new PersistentList <T>(new FileSystem.FileSystem(path), saveStrategy));
 }
Esempio n. 28
0
 public PersistentList <T> SavingWhenCollectionChanges()
 {
     _saveStrategy = new SaveOnEveryChange();
     return(Create());
 }
Esempio n. 29
0
 public void ChangeStarategy(ISaveStrategy <T> anyStrategy)
 {
     this._strategySave = anyStrategy;
 }
Esempio n. 30
0
 public PersistentList <T> SavingWhenRequested()
 {
     _saveStrategy = new SaveOnlyWhenRequested();
     return(Create());
 }