public static IApplication SetupApplication(MockRepository repository, IFactory<IView> viewFactory, IFactory<ICommand> cmdFactory) { var app = new VIMApplication(); var container = repository.StrictMock<IContainer>(); var elementFactory = repository.StrictMock<IFactory<IBrowseElement>>(); var list = new LinkedList<IBrowseElement>(); var keyGen = new KeyCommandGenerator(cmdFactory); keyGen.InitializeKeysToCommands(); container.Expect(a => a.Get<IKeyCommandGenerator>()).Return(keyGen); container.Expect(a => a.Get<IFactory<IBrowseElement>>()).Return(elementFactory); elementFactory.Expect(a => a.Create("Command Stack")).Return(new CreateBrowseElement{DisplayName = "Command Stack"}); elementFactory.Expect(a => a.Create("Files")).Return(new CreateBrowseElement{DisplayName = "Files"}); elementFactory.Expect(a => a.Create("Audio")).Return(new CreateBrowseElement{DisplayName = "Audio"}); elementFactory.Expect(a => a.Create("Movies")).Return(new CreateBrowseElement{DisplayName = "Movies"}); elementFactory.Expect(a => a.Create("Objects")).Return(new CreateBrowseElement{DisplayName = "Objects"}); elementFactory.Expect(a => a.Create("Notes")).Return(new CreateBrowseElement{DisplayName = "Notes"}); container.Expect(a => a.Get<ILinkedList<IBrowseElement>>()).Return(list); container.Expect(a => a.Get<IBrowser>(list)).Return(new LinkedListBrowser(app, list)); container.Expect(a => a.Get<IFactory<IView>>()).Return(viewFactory); repository.ReplayAll(); app.Initialize(container); return app; }
public Property(DomPath domPath, bool isNonEmpty, IFactory factory) { HasHadNonEmptyValue |= isNonEmpty; _defaultPropertyDefinitionSet = new Lazy<PropertyDefinitionSet>(CreateDefaultPropertyDefinitionSet); _domPath = domPath; _factory = factory; }
public static double[,] DoubleArray2DFromIList(IList list, IFactory factory) { var dim0 = list.Count; var dim1 = 0; foreach(var item in list) { var sublist = item as IList; if(sublist != null) { if (dim1 < sublist.Count) dim1 = sublist.Count; } } double[,] result = new double[dim0, dim1]; for(int i = 0; i < list.Count; ++i) { for(int j = 0; j < dim1; ++j) { var value = 0.0; var sublist = list[i] as IList; if(sublist != null) { if (sublist.Count > j) value = Convert.ToDouble(sublist[j]); } result[i, j] = value; } } return result; }
public SearchResultFactory( ITweetFactory tweetFactory, IFactory<ISearchQueryResult> searchResultFactory) { _tweetFactory = tweetFactory; _searchResultFactory = searchResultFactory; }
public TwitterQueryFactory( IFactory<ITwitterQuery> twitterQueryFactory, ITweetinviSettingsAccessor tweetinviSettingsAccessor) { _twitterQueryFactory = twitterQueryFactory; _tweetinviSettingsAccessor = tweetinviSettingsAccessor; }
// ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- public Main(IFactory factory) : base(factory) { this.factory = factory; this.config = factory.Resolve<IConfig>(); }
public ExceptionHandler(IFactory<ITwitterException> twitterExceptionUnityFactory) { _twitterExceptionUnityFactory = twitterExceptionUnityFactory; _exceptionInfos = new List<ITwitterException>(); SwallowWebExceptions = true; LogExceptions = true; }
// ------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------- public Main(IFactory factory) : base(factory) { this.config = factory.Resolve<IConfig>(); this.logic = factory.Resolve<IBuildLogic>(); this.configRuntime = factory.Resolve<ICrystalBuildConfigurationRunTime>(); }
internal HMDManager(IFactory factory, IDeviceManager manager) { if (factory == null) throw new ArgumentNullException(); if (manager == null) throw new ArgumentNullException(); _factory = factory; _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); _manager = manager; _handler = new InternalMessageHandler(this); _manager.MessageHandler = _handler; _nativeResources = new Dictionary<DeviceKey, DeviceResources>(); _devices = new Dictionary<DeviceKey, HMD>(); _defaultprofile = manager.DeviceDefaultProfile; // Initially, we must to enumerate all devices, which are currently attached // to the computer. using (var handles = _manager.HMDDevices) { foreach (var handle in handles) { AddDevice(handle); } } }
public AutoCreationController( IDispatcherExecute dispatcher, CreationViewModel viewModel, ITypesManager typesManager, SessionConfiguration sessionConfiguration, OptionsModel options, IFactory<SessionCreator> sessionCreatorFactory, IDispatcherExecute execute, CommonServices svc) { _dispatcher = dispatcher; _viewModel = viewModel; _typesManager = typesManager; _sessionConfiguration = sessionConfiguration; _options = options; _sessionCreatorFactory = sessionCreatorFactory; _execute = execute; _svc = svc; _viewModel.CommandCreateMutants = new SmartCommand(CommandOk, () => _viewModel.TypesTreeMutate.Assemblies != null && _viewModel.TypesTreeMutate.Assemblies.Count != 0 && _viewModel.TypesTreeToTest.TestAssemblies != null && _viewModel.TypesTreeToTest.TestAssemblies.Count != 0 && _viewModel.MutationsTree.MutationPackages.Count != 0) .UpdateOnChanged(_viewModel.TypesTreeMutate, _ => _.Assemblies) .UpdateOnChanged(_viewModel.TypesTreeToTest, _ => _.TestAssemblies) .UpdateOnChanged(_viewModel.MutationsTree, _ => _.MutationPackages); }
public EntityService( IFactory factory, stagemanagerEntities entities) { this.factory = factory; this.entities = entities; }
public static IPrimaryModel FromIDictionary(IDictionary source, IFactory factory) { if (source == null) return null; var itypeName = factory.Create<ITypeName>(source,null); if (itypeName != null) { var typeName = itypeName.TypeName; if (!IgnoreTypes.Contains(typeName)) { var model3D = factory.Create<Model3D>(typeName, null); if (model3D != null) { var material = GetMaterial(source, factory); if (material != null) { var geoModel = model3D as GeometryModel3D; if (geoModel != null) { geoModel.Material = material; } } var model3DGroup = new Model3DGroup { Transform = GetTransform(source, factory) }; model3DGroup.Children.Add(model3D); return new PrimaryModel { Model3D = model3DGroup }; } } } return null; }
private static void Initialize() { _messageFactory = TweetinviContainer.Resolve<IMessageFactory>(); _messageController = TweetinviContainer.Resolve<IMessageController>(); _messageGetLatestsReceivedRequestParametersFactory = TweetinviContainer.Resolve<IFactory<IMessageGetLatestsReceivedRequestParameters>>(); _messageGetLatestsSentRequestParametersFactory = TweetinviContainer.Resolve<IFactory<IMessageGetLatestsSentRequestParameters>>(); }
public NeuralConnectionDefinition(IFactory<NeuralConnection> connectionFactory, bool isRecurrent) { Contract.Requires(connectionFactory != null); ConnectionFactory = connectionFactory; IsRecurrent = isRecurrent; }
public GeoFactory( IFactory<ICoordinates> coordinatesUnityFactory, IFactory<ILocation> locationUnityFactory) { _coordinatesUnityFactory = coordinatesUnityFactory; _locationUnityFactory = locationUnityFactory; }
/// <summary> /// Adds a <see cref="IFactory"/> to the current <see cref="IFactoryStorage"/> object. /// </summary> /// <param name="serviceInfo">The <see cref="IServiceInfo"/> object that describes the target factory.</param> /// <param name="factory">The <see cref="IFactory"/> instance that will create the object instance.</param> public virtual void AddFactory(IServiceInfo serviceInfo, IFactory factory) { lock (_lock) { _entries[serviceInfo] = factory; } }
public HandyDandyManufacturingCompany(IFactory factory) { _factory = factory; _computers = new List<IComputer>(); _tablets = new List<ITablet>(); _phones = new List<ISmartPhone>(); }
public object Create(Type targetType, object source,IFactory helper) { if (source != null) { if (source.GetType() == typeof(string)) { var key = source.ToString(); if (cache.ContainsKey(key)) return cache[key]; if (Assembly != null) { var manifestResourceName = GetManifestResourceName(key); if(manifestResourceName != null) { var value = ReadFunction(Assembly.GetManifestResourceStream(manifestResourceName)); if(value != null) { cache.Add(key, value); return value; } } } } } return null; }
/// <summary> /// Loads the CSV Extent out of the settings and stores the extent Uri /// </summary> /// <param name="extent">The uri being used for an extent</param> /// <param name="factory">Factory being used to create a new instance</param> /// <param name="path">Path being used to load the extent</param> /// <param name="settings">Settings to load the extent</param> /// <returns>The loaded extent</returns> public void Load(IUriExtent extent, IFactory factory, string path, CSVSettings settings) { using (var fileStream = new FileStream(path, FileMode.Open)) { Load(extent, factory, fileStream, settings); } }
public void SetMemberFactory(MemberInfo memberInfo, IFactory factory) { if (memberFactories.ContainsKey(memberInfo)) memberFactories[memberInfo] = factory; else memberFactories.Add(memberInfo, factory); }
public ChatBot(IFactory injector) { _chatContextHolder = new ChatContextHolder(injector) .ListenTo<DeployCoreContext>() .ListenTo<JenkinsMonitorContext>() .ListenTo<GreetingsContext>() .ListenTo<JenkinsStatusContext>() .ListenTo<SetVolumeContext>() .ListenTo<GetServerVersionContext>() .ListenTo<MonitorServerVersionChanges>() .ListenTo<GetSettingsContext>() .ListenTo<SetSettingsContext>() .ListenTo<SetIoContext>() .ListenTo<SaySomethingContext>() .ListenTo<SayContext>() .ListenTo<HelpContext>() .ListenTo<AboutContext>() .ListenTo<RunJenkinsMonitorOnBotChatContext>() .ListenTo<TellMeAJokeContext>() .ListenTo<TellMeAInsultContext>() .ListenTo<TellMeAQuotesContext>() .ListenTo<FailedToRespondContext>() .ListenTo<RandomJokeResponse>(); }
public Engine() { this.factory = new BlobFactory(); this.Reader = new Reader(); this.Writer = new Writer(); this.Blobs = new List<IBlob>(); }
public void Verify(IFactory factory, string message, params object[] arguments) { factory.Verify(this.Structures.Count, Is.EqualTo(2), message, arguments); factory.Verify(this.Structures[0], message, arguments); factory.Verify(this.Structures[1], message, arguments); factory.Verify(this.Classes.Count, Is.EqualTo(2), message, arguments); factory.Verify(this.Classes[0] as ComplexClass, message, arguments); factory.Verify(this.Classes[1], message, arguments); factory.Verify(this.Objects.Count, Is.EqualTo(4), message, arguments); factory.Verify(this.Objects[0] as ComplexClass, message, arguments); factory.Verify(this.Objects[1] as Class, message, arguments); factory.Verify((bool)this.Objects[2], message, arguments); factory.Verify((DateTime)this.Objects[3], message, arguments); factory.Verify(this.Floats.Count, Is.EqualTo(10), message, arguments); for (int i = 0; i < 10; i++) factory.Verify(this.Floats[i], Is.EqualTo(i + 0.1337f), message, arguments); factory.Verify(this.Empty.Count, Is.EqualTo(0), message, arguments); factory.Verify(this.Single.Count, Is.EqualTo(1), message, arguments); factory.Verify(this.Single[0], Is.EqualTo(1337), message, arguments); factory.Verify(this.SingleObject.Count, Is.EqualTo(1), message, arguments); factory.Verify(this.SingleObject[0] as Class, message, arguments); }
public Model( ProgramInfoViewModel programInfoVM, InstalledProgramViewModel installedProgramVM, IFactory<SemiautomaticSync.Model, SemiautomaticSync.IModelParameters> semiautoSyncModelFactory ) { Initialize( programInfoVM, installedProgramVM, semiautoSyncModelFactory ); RegisterPropertyChangedEvents(); }
public SessionController( IDispatcherExecute dispatcher, CommonServices svc, MutantDetailsController mutantDetailsController, IMutantsContainer mutantsContainer, ITestsContainer testsContainer, IFactory<ResultsSavingController> resultsSavingFactory, IFactory<TestingProcess> testingProcessFactory, IRootFactory<TestingMutant> testingMutantFactory, MutationSessionChoices choices) { _dispatcher = dispatcher; _svc = svc; _mutantDetailsController = mutantDetailsController; _mutantsContainer = mutantsContainer; _testsContainer = testsContainer; _resultsSavingFactory = resultsSavingFactory; _testingProcessFactory = testingProcessFactory; _testingMutantFactory = testingMutantFactory; _choices = choices; _sessionState = SessionState.NotStarted; _sessionEventsSubject = new Subject<SessionEventArgs>(); _subscriptions = new List<IDisposable>(); }
public WebExceptionInfoExtractor( IJObjectStaticWrapper jObjectStaticWrapper, IFactory<ITwitterExceptionInfo> twitterExceptionInfoUnityFactory) { _jObjectStaticWrapper = jObjectStaticWrapper; _twitterExceptionInfoUnityFactory = twitterExceptionInfoUnityFactory; }
static Stream() { _userStreamFactory = TweetinviContainer.Resolve<IFactory<IUserStream>>(); _tweetStreamUnityFactory = TweetinviContainer.Resolve<IFactory<ITweetStream>>(); _sampleStreamUnityFactory = TweetinviContainer.Resolve<IFactory<ISampleStream>>(); _trackedStreamUnityFactory = TweetinviContainer.Resolve<IFactory<ITrackedStream>>(); _filteredStreamUnityFactory = TweetinviContainer.Resolve<IFactory<IFilteredStream>>(); }
public AsteroidSpawner(Settings settings, IFactory<Asteroid> asteroidFactory, LevelHelper level) { _settings = settings; _timeIntervalBetweenSpawns = _settings.maxSpawnTime / (_settings.maxSpawns - _settings.startingSpawns); _timeToNextSpawn = _timeIntervalBetweenSpawns; _asteroidFactory = asteroidFactory; _level = level; }
private static void Initialize() { _timelineController = TweetinviContainer.Resolve<ITimelineController>(); _homeTimelineParameterFactory = TweetinviContainer.Resolve<IFactory<IHomeTimelineParameters>>(); _userTimelineParameterFactory = TweetinviContainer.Resolve<IFactory<IUserTimelineParameters>>(); _mentionsTimelineParameterFactory = TweetinviContainer.Resolve<IFactory<IMentionsTimelineParameters>>(); _retweetsOfMeTimelineParameterFactory = TweetinviContainer.Resolve<IFactory<IRetweetsOfMeTimelineParameters>>(); }
public MsTestService( ISettingsManager settingsManager, IFactory<MsTestRunContext> contextFactory) { _settingsManager = settingsManager; _contextFactory = contextFactory; MsTestConsolePath = @"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe"; }
public ExpenseService(IIdentityService identityService, IFactory <VinanceContext> factory, IMapper mapper) { _factory = factory; _mapper = mapper; _userId = identityService.GetCurrentUserId(); }
public static IFactory CreateUserFactory(this IFactory source) { return(source.CreateFactory <UserFactory>()); }
protected ViewModelDetailBase(IFactory entityFactory, T item) { EntityFactory = entityFactory; OriginalItem = item; InitCommands(); }
public BattleViewModel(IFactory <Battle> battleFactory, IGame game, IServiceLocator container, IBattleInitializer initializer) : base(game, container, initializer) { this.battleFactory = battleFactory; Battle = this.battleFactory.Create(); }
public NodeBuilder(List <IItem> nestedItems, IFactory <IItem> factory) { _nestedItems = nestedItems; _factory = factory; }
public static void ExcuteNonQueryWithTransaction(string query, DGCParameter[] param, IFactory factory) { DbCommand cmd = factory.MakeCommand(query); GenerateQuery.PrepareParametersList(cmd, param); cmd.ExecuteNonQuery(); }
/// <summary> /// Initializes a new instance of the <see cref="StateDictionary<TState, TEvent>"/> class. /// </summary> /// <param name="factory">The factory.</param> public StateDictionary(IFactory <TState, TEvent> factory) { this.factory = factory; }
public OutcomeHandler(IFactory <IRepository <Outcome, IKey> > repositoryFactory) : base(repositoryFactory) { }
static public void Stream2Obj <T>(Stream s, T obj, IFactory f = null) where T : IMarshallable { var reader = new MsgPackDataReader(s); Sync(SyncContext.NewReader(reader, f), ref obj); }
public ReferenceParserService([NotNull] IConfiguration configuration, [NotNull] IFactory factory, [NotNull] IPipelineService pipelines) { Configuration = configuration; Factory = factory; Pipelines = pipelines; }
public GetItemByIdHandler(IItemRepository items, IFactory <IBuilder <APIGatewayProxyResponse> > response) { _items = items; _response = response; }
public TestService(TestTransient testTransient, TestSingleton testSingleton, IFactory <TestTransient> transientFactory, IFactory <TestSingleton> singletonFactory) { TestTransient = testTransient; TestSingleton = testSingleton; TransientFactory = transientFactory; SingletonFactory = singletonFactory; }
/// <summary> /// Deserializes the specified config. /// </summary> /// <param name="config">The config.</param> /// <param name="dataExchangeFactory">The data exchange factory.</param> /// <param name="waitResultPropertyResolution">The wait result property resolution delegate.</param> /// <param name="waitDiscriminatorResolution">The wait discriminator resolution.</param> /// <returns></returns> public static ResultMap Deserialize( IConfiguration config, DataExchangeFactory dataExchangeFactory, WaitResultPropertyResolution waitResultPropertyResolution, WaitDiscriminatorResolution waitDiscriminatorResolution ) { string id = config.Id; string className = ConfigurationUtils.GetMandatoryStringAttribute(config, ConfigConstants.ATTRIBUTE_CLASS); string extends = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_EXTENDS); string groupBy = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_GROUPBY); string keyColumns = config.GetAttributeValue(ConfigConstants.ATTRIBUTE_KEYS_PROPERTIES); string suffix = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_SUFFIX, string.Empty); string prefix = ConfigurationUtils.GetStringAttribute(config.Attributes, ConfigConstants.ATTRIBUTE_PREFIX, string.Empty); Type type = dataExchangeFactory.TypeHandlerFactory.GetType(className); IDataExchange dataExchange = dataExchangeFactory.GetDataExchangeForClass(type); IFactory factory = null; ArgumentPropertyCollection arguments = new ArgumentPropertyCollection(); #region Get the constructor & associated parameters ConfigurationCollection constructors = config.Children.Find(ConfigConstants.ELEMENT_CONSTRUCTOR); if (constructors.Count > 0) { IConfiguration constructor = constructors[0]; Type[] argumentsType = new Type[constructor.Children.Count]; string[] argumentsName = new string[constructor.Children.Count]; // Builds param name list for (int i = 0; i < constructor.Children.Count; i++) { argumentsName[i] = ConfigurationUtils.GetStringAttribute(constructor.Children[i].Attributes, ConfigConstants.ATTRIBUTE_ARGUMENTNAME); } // Find the constructor ConstructorInfo constructorInfo = GetConstructor(id, type, argumentsName); // Build ArgumentProperty and parameter type list for (int i = 0; i < constructor.Children.Count; i++) { ArgumentProperty argumentMapping = ArgumentPropertyDeSerializer.Deserialize( constructor.Children[i], type, constructorInfo, dataExchangeFactory); arguments.Add(argumentMapping); if (argumentMapping.NestedResultMapName.Length > 0) { waitResultPropertyResolution(argumentMapping); } argumentsType[i] = argumentMapping.MemberType; } // Init the object factory factory = dataExchangeFactory.ObjectFactory.CreateFactory(type, argumentsType); } else { if (!dataExchangeFactory.TypeHandlerFactory.IsSimpleType(type) && type != typeof(DataRow)) { factory = dataExchangeFactory.ObjectFactory.CreateFactory(type, Type.EmptyTypes); } } #endregion ResultPropertyCollection properties = BuildResultProperties( id, config, type, prefix, suffix, dataExchangeFactory, waitResultPropertyResolution); Discriminator discriminator = BuildDiscriminator(config, type, dataExchangeFactory, waitDiscriminatorResolution); ResultMap resultMap = new ResultMap( id, className, extends, groupBy, keyColumns, type, dataExchange, factory, dataExchangeFactory.TypeHandlerFactory, properties, arguments, discriminator ); return(resultMap); }
public static int ProcessUpdateStoreWithTransaction(DataSet ds, string insert, string update, string delete, DGCParameter[] paramInsert, DGCParameter[] paramUpdate, DGCParameter[] paramDelete, DGCParameter[] paramInsertNotSource, DGCParameter[] paramUpdateNotSource, IFactory factory) { Database db = CreateDB(); int rowsAffected = 0; DbCommand cmdInsert = factory.MakeCommandFromStore(insert); GenerateQuery.PrepareParametersListWithSourceColumn(cmdInsert, paramInsert); GenerateQuery.PrepareParametersList(cmdInsert, paramInsertNotSource); DbCommand cmdUpdate = factory.MakeCommandFromStore(update); GenerateQuery.PrepareParametersListWithSourceColumn(cmdUpdate, paramUpdate); GenerateQuery.PrepareParametersList(cmdUpdate, paramUpdateNotSource); DbCommand cmdDelete = factory.MakeCommandFromStore(delete); GenerateQuery.PrepareParametersListWithSourceColumn(cmdDelete, paramDelete); rowsAffected = db.UpdateDataSet(ds, "Table", cmdInsert, cmdUpdate, cmdDelete, factory.GetTransaction()); return(rowsAffected); }
protected Continent(IFactory factory) => this.factory = factory;
public void RegisterFactory(string entry, IFactory <T> factory) { _catalog[entry] = factory; }
public NpcDomainBuilder(string domainName, IFactory factory) : base(domainName, factory) { }
public T To <T>(IFactory <T> factory) { return(symbolicConditions.To(factory)); }
public RecipientService(IRecipientRepository repo, IFactory factory) { this.repo = repo; this.factory = factory; }
public static T CreateFactory <T>(this IFactory source) where T : IFactory, new() { return(new T()); }
public static IFactory CreateNullFactory(this IFactory source) { return(source.CreateFactory <NullFactory>()); }
public ParseService([NotNull] IConfiguration configuration, [NotNull] ITraceService trace, [NotNull] IFactory factory, [NotNull] ISnapshotService snapshotService, [NotNull] IPathMapperService pathMapper, [ImportMany, NotNull, ItemNotNull] IEnumerable <IParser> parsers) { Configuration = configuration; Trace = trace; Factory = factory; SnapshotService = snapshotService; PathMapper = pathMapper; Parsers = parsers; }
public ArtistRepository(IStore store, ICache <IArtist> cache, IFactory <IArtist> factory, ISchema <IArtist> schema, ISchemaMapper <IArtist> schemaMapper, IModelMapper <IArtist> modelMapper, IPersistMapper <IArtist> persistMapper, IQueryMapper <IArtist> queryMapper, IFactory <ICommand> commandFactory, ISQLiteStatementFactory statementFactory, IFactory <IBatch> batchFactory, IFactory <IQuery <IArtist> > queryFactory) : base(store, cache, factory, schema, schemaMapper, modelMapper, persistMapper, queryMapper, commandFactory, statementFactory, batchFactory, queryFactory) { }
public void StandaloneTest() { IFactory factory = null; // clear foreach (var file in Directory.GetFiles(Path.Combine(IOHelper.MapPath("~/App_Data")), "NuCache.*")) { File.Delete(file); } // settings // reset the current version to 0.0.0, clear connection strings ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus] = ""; // FIXME: we need a better management of settings here (and, true config files?) // create the very basic and essential things we need var logger = new ConsoleLogger(); var profiler = new LogProfiler(logger); var profilingLogger = new ProfilingLogger(logger, profiler); var appCaches = new AppCaches(); // FIXME: has HttpRuntime stuff? var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy <IMapperCollection>(() => factory.GetInstance <IMapperCollection>())); var typeLoader = new TypeLoader(appCaches.RuntimeCache, IOHelper.MapPath("~/App_Data/TEMP"), profilingLogger); var mainDom = new SimpleMainDom(); var runtimeState = new RuntimeState(logger, null, null, new Lazy <IMainDom>(() => mainDom), new Lazy <IServerRegistrar>(() => factory.GetInstance <IServerRegistrar>())); // create the register and the composition var register = RegisterFactory.Create(); var composition = new Composition(register, typeLoader, profilingLogger, runtimeState); composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState); // create the core runtime and have it compose itself var coreRuntime = new CoreRuntime(); coreRuntime.Compose(composition); // determine actual runtime level runtimeState.DetermineRuntimeLevel(databaseFactory, logger); Console.WriteLine(runtimeState.Level); // going to be Install BUT we want to force components to be there (nucache etc) runtimeState.Level = RuntimeLevel.Run; var composerTypes = typeLoader.GetTypes <IComposer>() // all of them .Where(x => !x.FullName.StartsWith("Umbraco.Tests.")) // exclude test components .Where(x => x != typeof(WebInitialComposer) && x != typeof(WebFinalComposer)); // exclude web runtime var composers = new Composers(composition, composerTypes, profilingLogger); composers.Compose(); // must registers stuff that WebRuntimeComponent would register otherwise // FIXME: UmbracoContext creates a snapshot that it does not register with the accessor // and so, we have to use the UmbracoContextPublishedSnapshotAccessor // the UmbracoContext does not know about the accessor // else that would be a catch-22 where they both know about each other? //composition.Register<IPublishedSnapshotAccessor, TestPublishedSnapshotAccessor>(Lifetime.Singleton); composition.Register <IPublishedSnapshotAccessor, UmbracoContextPublishedSnapshotAccessor>(Lifetime.Singleton); composition.Register <IUmbracoContextAccessor, TestUmbracoContextAccessor>(Lifetime.Singleton); composition.Register <IVariationContextAccessor, TestVariationContextAccessor>(Lifetime.Singleton); composition.Register <IDefaultCultureAccessor, TestDefaultCultureAccessor>(Lifetime.Singleton); composition.Register <ISiteDomainHelper>(_ => Mock.Of <ISiteDomainHelper>(), Lifetime.Singleton); composition.RegisterUnique(f => new DistributedCache()); composition.WithCollectionBuilder <UrlProviderCollectionBuilder>().Append <DefaultUrlProvider>(); composition.RegisterUnique <IDistributedCacheBinder, DistributedCacheBinder>(); composition.RegisterUnique <IExamineManager>(f => ExamineManager.Instance); composition.RegisterUnique <IUmbracoContextFactory, UmbracoContextFactory>(); composition.RegisterUnique <IMacroRenderer, MacroRenderer>(); composition.RegisterUnique <MediaUrlProviderCollection>(_ => new MediaUrlProviderCollection(Enumerable.Empty <IMediaUrlProvider>())); // initialize some components only/individually composition.WithCollectionBuilder <ComponentCollectionBuilder>() .Clear() .Append <DistributedCacheBinderComponent>(); // configure composition.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); composition.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); // create and register the factory Current.Factory = factory = composition.CreateFactory(); // instantiate and initialize components var components = factory.GetInstance <ComponentCollection>(); // do stuff Console.WriteLine(runtimeState.Level); // install if (true || runtimeState.Level == RuntimeLevel.Install) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var file = databaseFactory.Configured ? Path.Combine(path, "UmbracoNPocoTests.sdf") : Path.Combine(path, "Umbraco.sdf"); if (File.Exists(file)) { File.Delete(file); } // create the database file // databaseBuilder.ConfigureEmbeddedDatabaseConnection() can do it too, // but then it wants to write the connection string to web.config = bad var connectionString = databaseFactory.Configured ? databaseFactory.ConnectionString : "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;"; using (var engine = new SqlCeEngine(connectionString)) { engine.CreateDatabase(); } //var databaseBuilder = factory.GetInstance<DatabaseBuilder>(); //databaseFactory.Configure(DatabaseBuilder.EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe); //databaseBuilder.CreateDatabaseSchemaAndData(); if (!databaseFactory.Configured) { databaseFactory.Configure(DatabaseBuilder.EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe); } var scopeProvider = factory.GetInstance <IScopeProvider>(); using (var scope = scopeProvider.CreateScope()) { var creator = new DatabaseSchemaCreator(scope.Database, logger); creator.InitializeDatabaseSchema(); scope.Complete(); } } // done installing runtimeState.Level = RuntimeLevel.Run; components.Initialize(); // instantiate to register events // should be done by Initialize? // should we invoke Initialize? _ = factory.GetInstance <IPublishedSnapshotService>(); // at that point, Umbraco can run! // though, we probably still need to figure out what depends on HttpContext... var contentService = factory.GetInstance <IContentService>(); var content = contentService.GetById(1234); Assert.IsNull(content); // create a document type and a document var contentType = new ContentType(-1) { Alias = "ctype", Name = "ctype" }; factory.GetInstance <IContentTypeService>().Save(contentType); content = new Content("test", -1, contentType); contentService.Save(content); // assert that it is possible to get the document back content = contentService.GetById(content.Id); Assert.IsNotNull(content); Assert.AreEqual("test", content.Name); // need an UmbracoCOntext to access the cache // FIXME: not exactly pretty, should not depend on HttpContext var httpContext = Mock.Of <HttpContextBase>(); var umbracoContextFactory = factory.GetInstance <IUmbracoContextFactory>(); var umbracoContextReference = umbracoContextFactory.EnsureUmbracoContext(httpContext); var umbracoContext = umbracoContextReference.UmbracoContext; // assert that there is no published document var pcontent = umbracoContext.ContentCache.GetById(content.Id); Assert.IsNull(pcontent); // but a draft document pcontent = umbracoContext.ContentCache.GetById(true, content.Id); Assert.IsNotNull(pcontent); Assert.AreEqual("test", pcontent.Name); Assert.IsTrue(pcontent.IsDraft()); // no published url Assert.AreEqual("#", pcontent.GetUrl()); // now publish the document + make some unpublished changes contentService.SaveAndPublish(content); content.Name = "testx"; contentService.Save(content); // assert that snapshot has been updated and there is now a published document pcontent = umbracoContext.ContentCache.GetById(content.Id); Assert.IsNotNull(pcontent); Assert.AreEqual("test", pcontent.Name); Assert.IsFalse(pcontent.IsDraft()); // but the url is the published one - no draft url Assert.AreEqual("/test/", pcontent.GetUrl()); // and also an updated draft document pcontent = umbracoContext.ContentCache.GetById(true, content.Id); Assert.IsNotNull(pcontent); Assert.AreEqual("testx", pcontent.Name); Assert.IsTrue(pcontent.IsDraft()); // and the published document has a url Assert.AreEqual("/test/", pcontent.GetUrl()); umbracoContextReference.Dispose(); mainDom.Stop(); components.Terminate(); // exit! }
/// <summary> /// Initializes a new instance of the <see cref="FactoryLogAdapter"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="paramtersTypes">The paramters types.</param> /// <param name="factory">The factory.</param> public FactoryLogAdapter(Type type, Type[] paramtersTypes, IFactory factory) { _factory = factory; _typeName = type.FullName; _parametersTypeName = GenerateParametersName(paramtersTypes); }
public static RubiksCube CreateRubiksCube(Vector3D origin, int cubieNum, double cubieSize, OneOpDone oneOpDone, IFactory factory) { //if(cubieNum!=3) throw new ArgumentException("Invalid CubieNum"); RubiksCube rubiksCube = new RubiksCube(); rubiksCube.CubieSize = cubieSize; rubiksCube._model = factory.CreateModel(); rubiksCube._oneOpDone = oneOpDone; CubeSize size = new CubeSize(cubieNum, cubieNum, cubieNum); rubiksCube.CubeSize = size; Vector3D start = origin; start.X -= (size.Width - 1) * cubieSize / 2; start.Y -= (size.Height - 1) * cubieSize / 2; start.Z -= (size.Depth - 1) * cubieSize / 2; Vector3D min = origin; min.X -= size.Width * cubieSize / 2; min.Y -= size.Height * cubieSize / 2; min.Z -= size.Depth * cubieSize / 2; Vector3D max = origin; max.X += size.Width * cubieSize / 2; max.Y += size.Height * cubieSize / 2; max.Z += size.Depth * cubieSize / 2; rubiksCube.BoundingBox = new BoundingBox3D(min, max); for (int i = 0; i < size.Width; i++) { for (int j = 0; j < size.Height; j++) { for (int k = 0; k < size.Depth; k++) { //if (k == 0 || j == 0) //for debug { Vector3D cubieOri = start; cubieOri.X += i * cubieSize; cubieOri.Y += j * cubieSize; cubieOri.Z += k * cubieSize; string cubicleName = CubeConfiguration.GetCubicleName(size, i, j, k); //Debug.WriteLine(string.Format("({0},{1},{2}): {3}", i,j,k, cubicleName)); if (!string.IsNullOrEmpty(cubicleName)) { string cubieName = cubicleName; //solved configuration Cubicle cubicle = Cubicle.CreateCubicle(cubicleName, cubieName, cubieOri, cubieSize, factory); rubiksCube._cubicles.Add(cubicleName, cubicle); } } } } } return(rubiksCube); }
public ValidationRunner(IFactory factory) { ProviderFactory = factory; }
public MainWindowViewModel( IAppArguments appArguments, IFactory <IStartupManager, StartupManagerArgs> startupManagerFactory, IMicSwitchOverlayViewModel overlay, IMicrophoneControllerViewModel microphoneControllerViewModel, IOverlayWindowController overlayWindowController, IAudioNotificationsManager audioNotificationsManager, IFactory <IAudioNotificationSelectorViewModel> audioSelectorFactory, IApplicationUpdaterViewModel appUpdater, [Dependency(WellKnownWindows.MainWindow)] IWindowTracker mainWindowTracker, IConfigProvider <MicSwitchConfig> configProvider, IConfigProvider <MicSwitchOverlayConfig> overlayConfigProvider, IImageProvider imageProvider, IAudioNotificationsManager notificationsManager, IWindowViewController viewController, [Dependency(WellKnownSchedulers.UI)] IScheduler uiScheduler) { Title = $"{(appArguments.IsDebugMode ? "[D]" : "")} {appArguments.AppName} v{appArguments.Version}"; this.appArguments = appArguments; this.MicrophoneController = microphoneControllerViewModel.AddTo(Anchors); this.mainWindowTracker = mainWindowTracker; this.configProvider = configProvider; this.overlayConfigProvider = overlayConfigProvider; this.notificationsManager = notificationsManager; this.viewController = viewController; ApplicationUpdater = appUpdater.AddTo(Anchors); ImageProvider = imageProvider; AudioSelectorWhenMuted = audioSelectorFactory.Create().AddTo(Anchors); AudioSelectorWhenUnmuted = audioSelectorFactory.Create().AddTo(Anchors); WindowState = WindowState.Minimized; Overlay = overlay.AddTo(Anchors); var startupManagerArgs = new StartupManagerArgs { UniqueAppName = $"{appArguments.AppName}{(appArguments.IsDebugMode ? "-debug" : string.Empty)}", ExecutablePath = appUpdater.GetLatestExecutable().FullName, CommandLineArgs = appArguments.StartupArgs, AutostartFlag = appArguments.AutostartFlag }; this.startupManager = startupManagerFactory.Create(startupManagerArgs); this.RaiseWhenSourceValue(x => x.IsActive, mainWindowTracker, x => x.IsActive, uiScheduler).AddTo(Anchors); this.RaiseWhenSourceValue(x => x.RunAtLogin, startupManager, x => x.IsRegistered, uiScheduler).AddTo(Anchors); this.RaiseWhenSourceValue(x => x.ShowOverlaySettings, Overlay, x => x.OverlayVisibilityMode).AddTo(Anchors); audioNotificationSource = Observable.Merge( AudioSelectorWhenMuted.ObservableForProperty(x => x.SelectedValue, skipInitial: true), AudioSelectorWhenUnmuted.ObservableForProperty(x => x.SelectedValue, skipInitial: true)) .Select(x => new TwoStateNotification { On = AudioSelectorWhenUnmuted.SelectedValue, Off = AudioSelectorWhenMuted.SelectedValue }) .ToPropertyHelper(this, x => x.AudioNotification) .AddTo(Anchors); this.WhenAnyValue(x => x.AudioNotificationVolume) .Subscribe(x => { AudioSelectorWhenUnmuted.Volume = AudioSelectorWhenMuted.Volume = x; }) .AddTo(Anchors); MicrophoneController.ObservableForProperty(x => x.MicrophoneMuted, skipInitial: true) .DistinctUntilChanged() .Where(x => !MicrophoneController.MicrophoneLine.IsEmpty) .SubscribeSafe(isMuted => { var notificationToPlay = (isMuted.Value ? AudioNotification.Off : AudioNotification.On) ?? default(AudioNotificationType).ToString(); Log.Debug($"Playing notification {notificationToPlay} (cfg: {AudioNotification.DumpToTextRaw()})"); audioNotificationsManager.PlayNotification(notificationToPlay, audioNotificationVolume); }, Log.HandleUiException) .AddTo(Anchors); this.WhenAnyValue(x => x.WindowState) .SubscribeSafe(x => ShowInTaskbar = x != WindowState.Minimized, Log.HandleUiException) .AddTo(Anchors); viewController .WhenClosing .SubscribeSafe(x => HandleWindowClosing(viewController, x), Log.HandleUiException) .AddTo(Anchors); ToggleOverlayLockCommand = CommandWrapper.Create(ToggleOverlayCommandExecuted); ExitAppCommand = CommandWrapper.Create(ExitAppCommandExecuted); ShowAppCommand = CommandWrapper.Create(ShowAppCommandExecuted); OpenAppDataDirectoryCommand = CommandWrapper.Create(OpenAppDataDirectory); ResetOverlayPositionCommand = CommandWrapper.Create(ResetOverlayPositionCommandExecuted); RunAtLoginToggleCommand = CommandWrapper.Create <bool>(RunAtLoginCommandExecuted); SelectMicrophoneIconCommand = CommandWrapper.Create(SelectMicrophoneIconCommandExecuted); SelectMutedMicrophoneIconCommand = CommandWrapper.Create(SelectMutedMicrophoneIconCommandExecuted); ResetMicrophoneIconsCommand = CommandWrapper.Create(ResetMicrophoneIconsCommandExecuted); AddSoundCommand = CommandWrapper.Create(AddSoundCommandExecuted); Observable.Merge(configProvider.ListenTo(x => x.Notifications).ToUnit(), configProvider.ListenTo(x => x.NotificationVolume).ToUnit()) .Select(_ => new { configProvider.ActualConfig.Notifications, configProvider.ActualConfig.NotificationVolume }) .ObserveOn(uiScheduler) .SubscribeSafe(cfg => { Log.Debug($"Applying new notification configuration: {cfg.DumpToTextRaw()} (current: {AudioNotification.DumpToTextRaw()}, volume: {AudioNotificationVolume})"); AudioSelectorWhenMuted.SelectedValue = cfg.Notifications.Off; AudioSelectorWhenUnmuted.SelectedValue = cfg.Notifications.On; AudioNotificationVolume = cfg.NotificationVolume; }, Log.HandleException) .AddTo(Anchors); configProvider.ListenTo(x => x.MinimizeOnClose) .ObserveOn(uiScheduler) .SubscribeSafe(x => MinimizeOnClose = x, Log.HandleException) .AddTo(Anchors); viewController .WhenLoaded .Take(1) .Select(_ => configProvider.ListenTo(y => y.StartMinimized)) .Switch() .Take(1) .ObserveOn(uiScheduler) .SubscribeSafe( x => { if (x) { Log.Debug($"StartMinimized option is active - minimizing window, current state: {WindowState}"); StartMinimized = true; viewController.Hide(); } else { Log.Debug($"StartMinimized option is not active - showing window as Normal, current state: {WindowState}"); StartMinimized = false; viewController.Show(); } }, Log.HandleUiException) .AddTo(Anchors); configProvider.WhenChanged .Subscribe() .AddTo(Anchors); Observable.Merge( microphoneControllerViewModel.ObservableForProperty(x => x.MuteMode, skipInitial: true).ToUnit(), this.ObservableForProperty(x => x.AudioNotification, skipInitial: true).ToUnit(), this.ObservableForProperty(x => x.MinimizeOnClose, skipInitial: true).ToUnit(), this.ObservableForProperty(x => x.AudioNotificationVolume, skipInitial: true).ToUnit(), this.ObservableForProperty(x => x.StartMinimized, skipInitial: true).ToUnit()) .Throttle(ConfigThrottlingTimeout) .ObserveOn(uiScheduler) .SubscribeSafe(() => { var config = configProvider.ActualConfig.CloneJson(); config.Notifications = AudioNotification; config.NotificationVolume = AudioNotificationVolume; config.StartMinimized = StartMinimized; config.MinimizeOnClose = MinimizeOnClose; configProvider.Save(config); }, Log.HandleUiException) .AddTo(Anchors); viewController.WhenLoaded .SubscribeSafe(() => { Log.Debug($"Main window loaded - loading overlay, current process({CurrentProcess.ProcessName} 0x{CurrentProcess.Id:x8}) main window: {CurrentProcess.MainWindowHandle} ({CurrentProcess.MainWindowTitle})"); overlayWindowController.RegisterChild(Overlay).AddTo(Anchors); Log.Debug("Overlay loaded successfully"); }, Log.HandleUiException) .AddTo(Anchors); var theme = Theme.Create( Theme.Light, primary: SwatchHelper.Lookup[(MaterialDesignColor)PrimaryColor.BlueGrey], accent: SwatchHelper.Lookup[(MaterialDesignColor)SecondaryColor.LightBlue]); var paletteHelper = new PaletteHelper(); paletteHelper.SetTheme(theme); }
public RolePermissionService(IFactory <RolePermissionDTO, RolePermission> entityFactory, IRepository <RolePermission> entityRepository) : base(entityFactory, entityRepository) { }
public SequenceDiagramVisualizerPresenterLazyProxy(IFactory factory) { this.factory = factory; }