Beispiel #1
0
        /// <summary>
        /// Opens a file.
        /// </summary>
        /// <param name="fileName"></param>
        public void OpenFile(string fileName)
        {
            ICompositionFactory factory = AbstractCompositionFactory.GetFactory(Path.GetExtension(fileName));

            Composition composition = factory.ReadComposition(fileName);

            composition.FileName = fileName;
            SetComposition(composition, true);
        }
Beispiel #2
0
        public OrionClient(string baseUrl, Credentials apiCredentials)
        {
            client = new RestClient(baseUrl);
            client.Authenticator = new OrionAuthenticator(apiCredentials);
            client.ClearHandlers();

            client.AddHandler("application/json", OrionJsonSerializer.Default);
            client.AddHandler("text/json", OrionJsonSerializer.Default);
            client.AddHandler("text/x-json", OrionJsonSerializer.Default);
            client.AddHandler("text/javascript", OrionJsonSerializer.Default);
            client.AddHandler("*+json", OrionJsonSerializer.Default);

            // ICompositionFactory is the only singleton, by design.
            factory = new CompositionFactory(client);
        }
Beispiel #3
0
 public EntryOperations(
     ICompositionFactory compositionFactory,
     IBackendServiceClient storage,
     IEventAggregator eventAggregator,
     IStatusBusyService statusBusyService,
     Lazy<ITranslationService> translator,
     ILocalSettingsService settingsService,
     ITelemetryService telemetry)
 {
     this.compositionFactory = compositionFactory;
     this.storage = storage;
     this.eventAggregator = eventAggregator;
     this.statusBusyService = statusBusyService;
     this.translator = translator;
     this.settingsService = settingsService;
     this.telemetry = telemetry;
 }
        public OrionApiClient(string baseUrl, Credentials apiCredentials, Credentials serviceCredentials, TimeSpan?requestTimeout = null)
        {
            var handler = new HttpClientHandler()
            {
            };

            client             = new HttpClient(handler);
            client.BaseAddress = new Uri(baseUrl);
            client.Timeout     = (requestTimeout.HasValue) ? requestTimeout.Value : defaultTimeout;
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain"));

            authenticator = new Authenticator(apiCredentials, serviceCredentials);

            // ICompositionFactory is the only singleton, by design.
            factory = new CompositionFactory(this);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            ICompositionFactory composition;

            ICompositionFactory[] com = new ICompositionFactory[]
                                        //initializing templates to give a chance to choose one
            {
                new PolissyaFactory(),
                new EgyptFactory(),
                new YourFactory()
            };

            Console.WriteLine("Choose a number to see template or create your own");
            for (int i = 0; i < com.Length; i++)
            {
                Console.WriteLine($"{i + 1}. {com[i].ToString()}");
            }

            int userNum = Int32.Parse(Console.ReadLine());

            switch (userNum)
            {
            case 1:
                composition = new PolissyaFactory();
                break;

            case 2:
                composition = new EgyptFactory();
                break;

            case 3:
                composition = new YourFactory();
                break;

            default: throw new Exception("No such classes");
            }
            IFlowers    flowers    = composition.CreateF();
            IKustarniki kustarniki = composition.CreateK();
            ITravy      travy      = composition.CreateT();

            Console.WriteLine(composition.Description());
            Console.WriteLine("Here you have got {0}, {1} and {2}", flowers.ToString(), kustarniki.ToString(), travy.ToString());
        }
Beispiel #6
0
        public MainViewModel(
            ICompositionFactory compositionFactory,
            IBackendServiceClient storage,
            IEventAggregator eventAggregator,
            IStatusBusyService statusBusyService,
            IEntryOperations entryOperations,
            ILocalSettingsService localSettingsService,
            IStringResourceManager stringResourceManager,
            ILogSharingService logSharingService)
            : this()
        {
            Guard.NotNull(compositionFactory, nameof(compositionFactory));
            Guard.NotNull(storage, nameof(storage));
            Guard.NotNull(eventAggregator, nameof(eventAggregator));
            Guard.NotNull(statusBusyService, nameof(statusBusyService));
            Guard.NotNull(entryOperations, nameof(entryOperations));
            Guard.NotNull(localSettingsService, nameof(localSettingsService));
            Guard.NotNull(stringResourceManager, nameof(stringResourceManager));
            Guard.NotNull(logSharingService, nameof(logSharingService));

            this.storage = storage;
            this.eventAggregator = eventAggregator;
            this.statusBusyService = statusBusyService;
            this.entryOperations = entryOperations;
            this.localSettingsService = localSettingsService;
            this.stringResourceManager = stringResourceManager;
            this.logSharingService = logSharingService;

            CompositionFactory = compositionFactory;

            FullEntryListViewModel = compositionFactory.Create<FullEntryListViewModel>();
            RandomEntryListViewModel = compositionFactory.Create<RandomEntryListViewModel>();
            EntryTextEditorViewModel = compositionFactory.Create<EntryTextEditorViewModel>();

            eventAggregator.GetEvent<EntryEditingFinishedEvent>().Subscribe(OnEntryEditingFinished);
            eventAggregator.GetEvent<EntryEditingCancelledEvent>().Subscribe(OnEntryEditingCancelled);
            eventAggregator.GetEvent<EntryDeletedEvent>().Subscribe(OnEntryDeleted);
            eventAggregator.GetEvent<EntryIsLearntChangedEvent>().Subscribe(OnEntryIsLearntChanged);
            eventAggregator.GetEvent<EntryUpdatedEvent>().SubscribeWithAsync(OnEntryDefinitionChangedAsync);
            eventAggregator.GetEvent<EntryDetailsRequestedEvent>().Subscribe(OnEntryDetailsRequested);
            eventAggregator.GetEvent<EntryQuickEditRequestedEvent>().Subscribe(OnEntryQuickEditRequested);
        }
        public EntryDetailsViewModel(
            ICompositionFactory compositionFactory,
            IBackendServiceClient storage,
            IEventAggregator eventAggregator,
            IStatusBusyService statusBusyService,
            Lazy<ITranslationService> translator)
            : this(eventAggregator)
        {
            Guard.NotNull(compositionFactory, nameof(compositionFactory));
            Guard.NotNull(storage, nameof(storage));
            Guard.NotNull(eventAggregator, nameof(eventAggregator));
            Guard.NotNull(statusBusyService, nameof(statusBusyService));
            Guard.NotNull(translator, nameof(translator));

            this.storage = storage;
            this.statusBusyService = statusBusyService;
            this.translator = translator;

            EventAggregator = eventAggregator;
            CompositionFactory = compositionFactory;
        }
Beispiel #8
0
 /// <summary>Initializes a new ObjectManager</summary>
 public ObjectManager()
 {
     _objects = new WeakRefDictionary <TKey, T>();
     _factory = Composition.GetInstanceFactory <T>();
 }