Exemplo n.º 1
0
 public MainFormPresenter(IPropertiesRepository propertiesRepository)
 {
     statusTimer           = new System.Timers.Timer();
     statusTimer.Elapsed  += StatusTimer_Elapsed;
     statusTimer.Interval  = 5000;
     _propertiesRepository = propertiesRepository;
 }
Exemplo n.º 2
0
        public MainForm(IFormOpener formManager, IMainFormPresenter presenter, MainFormStyler mainFormStyler, IPubSub pubsub, IPropertiesRepository propertiesRepository)
        {
            InitializeComponent();

            _mainFormStyler = mainFormStyler;
            _pubsub         = pubsub;
            RenderTheme();
            if (propertiesRepository.GetValue <bool>(Constants.AppProperties.UpdateSettings))
            {
                propertiesRepository.Upgrade();
                propertiesRepository.SetValue(Constants.AppProperties.UpdateSettings, false);
                propertiesRepository.Save();
            }

            _formManager = formManager;
            presenter.InitializePresenter(new
            {
                MainForm = this,
                PubSub   = _pubsub
            });

            var selectedPath = propertiesRepository.GetValue <string>(Constants.AppProperties.SelectedPath);

            if (!string.IsNullOrEmpty(selectedPath))
            {
                Presenter.PopulateTreeView(selectedPath);
            }

            _propertiesRepository = propertiesRepository;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Retrieves the list of default Architectures supported by Snip2Code
 /// </summary>
 /// <returns>an empty list if any error occurred, the actual list otherwise</returns>
 public static List <string> GetDefaultArchitectures(this IPropertiesRepository repo)
 {
     if (!LoadDefaultProperties(repo))
     {
         return(new List <string>());
     }
     return(s_architectures);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Retrieves the list of default Browsers supported by Snip2Code
 /// </summary>
 /// <returns>an empty list if any error occurred, the actual list otherwise</returns>
 public static List <string> GetDefaultBrowsers(this IPropertiesRepository repo)
 {
     if (!LoadDefaultProperties(repo))
     {
         return(new List <string>());
     }
     return(s_browsers);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Retrieves the list of default Windows Versions supported by Snip2Code
 /// </summary>
 /// <returns>an empty list if any error occurred, the actual list otherwise</returns>
 public static List <string> GetDefaultWinVersions(this IPropertiesRepository repo)
 {
     if (!LoadDefaultProperties(repo))
     {
         return(new List <string>());
     }
     return(s_windowsVersions);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Retrieves the list of default Languages supported by Snip2Code
 /// </summary>
 /// <returns>an empty list if any error occurred, the actual list otherwise</returns>
 public static List <string> GetDefaultLanguages(this IPropertiesRepository repo)
 {
     if (!LoadDefaultProperties(repo))
     {
         return(new List <string>());
     }
     return(s_languages);
 }
Exemplo n.º 7
0
        public Property(IPropertiesRepository propertiesRepository, IEventBus eventBus)
        {
            Guard.AgainstNullOrEmpty(propertiesRepository);
            Guard.AgainstNullOrEmpty(eventBus);

            _propertiesRepository = propertiesRepository;
            _eventBus             = eventBus;
        }
 public StateSynchronizer(PageNavigator navigator, PageLocator pageLocator,
                          AccountService accountService, IPropertiesRepository propertiesRepository,
                          BotService botService)
 {
     this.navigator            = navigator;
     this.pageLocator          = pageLocator;
     this.accountService       = accountService;
     this.propertiesRepository = propertiesRepository;
     this.botService           = botService;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Returns all the default properties that don't have any dependency from other default properties.
        /// The first time they are fetched from DB, the other ones from in-memory cache.
        /// </summary>
        /// <returns>an empty map if any error occurred; the default basic properties otherwise,
        /// where the keys are the properties names and the values are the actual possible values of that basic property</returns>
        public static IDictionary <string, List <string> > GetBasicProperties(this IPropertiesRepository repo)
        {
            if (s_basicProps == null)
            {
                //init default properties if needed:
                ICollection <DefaultProperty> defProperties = repo.GetDefaultProperties();

                s_basicProps = DefaultProperty.FilterBasicProperties(defProperties);
            }
            return(s_basicProps);
        }
 public BaseViewModel(PageNavigator pageNavigator,
                      SafeCommandFactory commandFactory,
                      Func <DateTimeOffset> timeStamp,
                      ILoggerService loggerService,
                      IPropertiesRepository propertiesRepository)
 {
     this.loggerService        = loggerService;
     this.propertiesRepository = propertiesRepository;
     TimeStamp      = timeStamp;
     PageNavigator  = pageNavigator;
     CommandFactory = commandFactory;
 }
Exemplo n.º 11
0
        public BaseTelegramViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory,
                                     Func <DateTimeOffset> timeStamp, ILoggerService loggerService,
                                     IPropertiesRepository propertiesRepository,
                                     BotService botService)
            : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository)
        {
            BotService = botService;

            SendMessage        = CommandFactory.Create <string>(SendMessageAsync);
            SendInlineKeyboard = CommandFactory.Create <InlineMenu>(SendInlineKeyboardAsync);
            SendReplyKeyboard  = CommandFactory.Create <ReplyMenu>(SendKeyboardAsync);
            GoBack             = CommandFactory.Create(GoBackAsync);
        }
Exemplo n.º 12
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        #region Reset Methods
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Resets the inmemory caches so that at the next invocation the methods will re-fetch
        /// the default properties from DB.
        /// </summary>
        public static void Reset(this IPropertiesRepository repo)
        {
            if (repo != null)
            {
                repo.ResetCaches();
            }
            s_defPropertyValues           = null;
            s_defPropertyItemsSet         = null;
            s_basicProps                  = null;
            s_browsers                    = null;
            s_architectures               = null;
            s_osTypes                     = null;
            s_windowsVersions             = null;
            s_languages                   = null;
            s_defValuesRelatedToSingleKey = null;
        }
Exemplo n.º 13
0
        private static bool LoadDefaultProperties(this IPropertiesRepository repo)
        {
            //check whether the lists have been already retrieved
            if (s_osTypes != null)
            {
                return(true);
            }

            //get the list of default values:
            ICollection <DefaultProperty> defaultProps = repo.GetDefaultProperties();

            if (defaultProps == null)
            {
                log.ErrorFormat("Cannot retrieve default properties");
                return(false);
            }

            //fill all the list with the proper values:
            foreach (DefaultProperty defProp in defaultProps)
            {
                switch (defProp.Name)
                {
                case DefaultProperty.Architecture:
                    s_architectures = defProp.PossibleValues;
                    break;

                case DefaultProperty.Browser:
                    s_browsers = defProp.PossibleValues;
                    break;

                case DefaultProperty.OS:
                    s_osTypes = defProp.PossibleValues;
                    break;

                case DefaultProperty.WindowsVersion:
                    s_windowsVersions = defProp.PossibleValues;
                    break;

                case DefaultProperty.Language:
                    s_languages = defProp.PossibleValues;
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Returns the set of default properties names and values: the complete collection of names and values that constitutes the
        /// default properties managed in Snip2Code.
        /// The first time they are fetched from DB, the other ones from in-memory cache.
        /// </summary>
        /// <returns>an empty set if any error occurred; the default properties names and values otherwise</returns>
        public static HashSet <string> GetDefaultPropertiesItems(this IPropertiesRepository repo)
        {
            if (repo == null)
            {
                return(new HashSet <string>());
            }
            if (s_defPropertyItemsSet == null)
            {
                //init default properties if needed:
                Dictionary <string, List <string> > defPropertyValues = repo.GetDefaultPropertiesValues();

                //fill all the list with the proper values:
                s_defPropertyItemsSet = new HashSet <string>(defPropertyValues.Keys, new IgnoreCaseComparer());
                foreach (string key in defPropertyValues.Keys)
                {
                    s_defPropertyItemsSet.UnionWith(defPropertyValues[key]);
                }
            }
            return(s_defPropertyItemsSet);
        }
Exemplo n.º 15
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////


        #region Get Methods
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Returns all the default properties that can be associated to a snippet.
        /// The first time they are fetched from DB, the other ones from in-memory cache.
        /// </summary>
        /// <returns>an empty map if any error occurred; the default properties otherwise,
        /// where the keys are the properties names and the values are the actual possible values of that property</returns>
        public static Dictionary <string, List <string> > GetDefaultPropertiesValues(this IPropertiesRepository repo)
        {
            if (repo == null)
            {
                return(new Dictionary <string, List <string> >());
            }
            if (s_defPropertyValues == null)
            {
                //init default properties if needed:
                ICollection <DefaultProperty> defProperties = repo.GetDefaultProperties();

                //fill all the list with the proper values:
                s_defPropertyValues = new Dictionary <string, List <string> >();
                foreach (DefaultProperty defProp in defProperties)
                {
                    s_defPropertyValues.Add(defProp.Name, defProp.PossibleValues);
                }
            }
            return(s_defPropertyValues);
        }
 public FiltersController(IPropertiesRepository repo)
 {
     _repo = repo;
 }
Exemplo n.º 17
0
 public PropertiesController(IPropertiesRepository propertiesRepository)
 {
     this.propertiesRepository = propertiesRepository;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Map of values related to a single name for default property.
        /// It can be used to guess the use of a default property instead of simple tag
        /// </summary>
        /// <returns>an mepty map if any error occurred; the map with keys: default properties values (lower case); values, the related property name </returns>
        public static IDictionary <string, string> GetDefaultValuesRelatedToSingleKey(this IPropertiesRepository repo)
        {
            if (repo == null)
            {
                return(new Dictionary <string, string>());
            }

            if (s_defValuesRelatedToSingleKey == null)
            {
                s_defValuesRelatedToSingleKey = new Dictionary <string, string>();
                Dictionary <string, List <string> > defPropVal = repo.GetDefaultPropertiesValues();
                foreach (string defPropKey in defPropVal.Keys)
                {
                    List <string> values = defPropVal[defPropKey];
                    if (values != null)
                    {
                        foreach (string value in values)
                        {
                            string valueLower = value.ToLower();

                            // put an empty value to signal that the property value is linked to multiple keys
                            if (s_defValuesRelatedToSingleKey.ContainsKey(valueLower))
                            {
                                s_defValuesRelatedToSingleKey[valueLower] = string.Empty;
                            }
                            else
                            {
                                s_defValuesRelatedToSingleKey.Add(valueLower, defPropKey);
                            }
                        }
                    }
                }

                //purge eventual values with multiple keys:
                List <string> keyToRemove = new List <string>(s_defValuesRelatedToSingleKey.Keys);
                foreach (string key in keyToRemove)
                {
                    if (string.IsNullOrEmpty(s_defValuesRelatedToSingleKey[key]))
                    {
                        s_defValuesRelatedToSingleKey.Remove(key);
                    }
                }
            }

            return(s_defValuesRelatedToSingleKey);
        }
Exemplo n.º 19
0
 public Handler(IPropertiesRepository propertiesRepository)
 {
     _propertiesRepository = propertiesRepository;
 }
        public MainMenuViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory,
                                 Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository,
                                 BotService botService) : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository,
                                                               botService)
        {
            GoToCreateDocumentPage = commandFactory.Create(async() =>
            {
                await PageNavigator.PushPageAsync <ChoicePartnerNicknamePage>(Identifier, DialogContext,
                                                                              NavigationType.PageToPage);
            });

            GoToMyDocumentsPage = commandFactory.Create(async() =>
            {
                await PageNavigator.PushPageAsync <MyDocumentsPage>(Identifier, DialogContext,
                                                                    NavigationType.PageToPage);
            });
        }
 public UserProvider(IPropertiesRepository propertiesRepository,
                     IUserDataRepository userRepository)
 {
     this.propertiesRepository = propertiesRepository;
     this.userRepository       = userRepository;
 }
 public PreferencesFormPresenter(IPropertiesRepository propertiesRepository)
 {
     _propertiesRepository = propertiesRepository;
 }
Exemplo n.º 23
0
 public PropService(IPropertiesRepository propRepsitory)
 {
     _propRepsitory = propRepsitory;
 }
Exemplo n.º 24
0
 public PropertiesController(IPropertiesRepository propertiesRepository)
 {
     this.propertiesRepository = propertiesRepository;
 }
 public CreateDocumentViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory,
                                Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository,
                                BotService botService, GuidService guidService, BlockChainConfiguration config,
                                AccountService accountService)
     : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository, botService)
 {
     this.guidService    = guidService;
     this.config         = config;
     this.accountService = accountService;
 }
Exemplo n.º 26
0
 public UserService(IOptions <AppSettings> appSettings, IPropertiesRepository repo)
 {
     this._repo        = repo;
     this._appSettings = appSettings.Value;
 }
Exemplo n.º 27
0
 public MyDocumentsViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory,
                             Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository,
                             BotService botService) : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository,
                                                           botService)
 {
 }
Exemplo n.º 28
0
        public ChoicePartnerNicknameViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory,
                                              Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository,
                                              BotService botService, IUserDataRepository userDataRepository) : base(pageNavigator, commandFactory,
                                                                                                                    timeStamp, loggerService, propertiesRepository,
                                                                                                                    botService)
        {
            this.userDataRepository = userDataRepository;

            GoToCreateDocument = commandFactory.Create(async() =>
                                                       await PageNavigator.PushPageAsync <CreateDocumentPage>(Identifier, DialogContext,
                                                                                                              NavigationType.PageToPage));
        }
        public CreateAccountViewModel(PageNavigator pageNavigator, SafeCommandFactory commandFactory,
                                      Func <DateTimeOffset> timeStamp, ILoggerService loggerService, IPropertiesRepository propertiesRepository,
                                      BotService botService, AccountService accountService, GuidService guidService,
                                      BlockChainConfiguration config, StateSynchronizer stateSynchronizer)
            : base(pageNavigator, commandFactory, timeStamp, loggerService, propertiesRepository, botService)
        {
            this.accountService = accountService;
            this.guidService    = guidService;
            this.config         = config;

            RemoteState = CommandFactory.Create(async() => { await stateSynchronizer.SetStartState(Identifier); });
        }