public TrinketProxyEgg() { streamFactory = new StreamFactory(); processProxy = new ProcessProxy(); var pofContext = new PofContext().With(x => { x.MergeContext(new DspPofContext()); x.MergeContext(new TrinketsApiPofContext()); x.MergeContext(new TrinketsImplPofContext()); }); ICollectionFactory collectionFactory = new CollectionFactory(); IFileSystemProxy fileSystemProxy = new FileSystemProxy(streamFactory); IThreadingProxy threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory()); var dnsProxy = new DnsProxy(); INetworkingProxy networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(dnsProxy), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(dnsProxy)); pofSerializer = new PofSerializer(pofContext); PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer); ProxyGenerator proxyGenerator = new ProxyGenerator(); var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory); // construct libdsp local service node ClusteringConfiguration clusteringConfiguration = new ClientClusteringConfiguration(); ServiceClient localServiceClient = serviceClientFactory.Construct(clusteringConfiguration); keepaliveObjects.Add(localServiceClient); temporaryFileService = localServiceClient.GetService<TemporaryFileService>(); var processInjector = new ProcessInjectorImpl(); ProcessInjectionConfiguration processInjectionConfiguration = new ProcessInjectionConfigurationImpl(injectionAttempts: 10, injectionAttemptsDelay: 200); processInjectionService = new ProcessInjectionServiceImpl(processInjector, processInjectionConfiguration); IDtpNodeFactory transportNodeFactory = new DefaultDtpNodeFactory(); BootstrapConfigurationGenerator bootstrapConfigurationGenerator = new BootstrapConfigurationGeneratorImpl(); trinketInternalUtilities = new TrinketInternalUtilitiesImpl(fileSystemProxy); trinketDtpServerFactory = new TrinketDtpServerFactoryImpl(streamFactory, transportNodeFactory, bootstrapConfigurationGenerator); }
public void CollectionFactory_Should_Be_Initializable() { // arrange + act var target = new CollectionFactory(); // assert target.Should().NotBeNull(); }
public void CollectionFactory_List_Should_Return_Collection() { // arrange var factory = new CollectionFactory(); // act var target = factory.List<Name>(); // assert target.Should().NotBeNull(); target.Count().Should().BeGreaterOrEqualTo(1); }
/// <summary> /// Generates a new collection scanning recursively the specified dir /// for music files. /// </summary> /// <param name="musicScanDir">A dir containing music files.</param> public void ScanDirectory(string musicScanDir) { if (musicScanDir == null) { throw new ArgumentNullException("musicScanDir", "The collection data load path cant be null"); } Collection data = CollectionFactory.ScanDirectory(musicScanDir); data.Reconnect(); Collections.Add(data); RefreshBands(); }
public void setUp() { s1 = CollectionFactory.CreateSet <int>(); s1.Add(1); s1.Add(2); s1.Add(3); s1.Add(4); s2 = CollectionFactory.CreateSet <int>(); s2.Add(4); s2.Add(5); s2.Add(6); }
public void UpdateOrAddItem_Should_UpdateAllMatches_When_MultipleMatches() { var collection = CollectionFactory.GetDefaultList(); var value = CollectionFactory.GetDefaultValue(CollectionFactory.StartingValue); collection.UpdateOrAddItem(value, x => x.value == value.value, true, true); Assert.Equal(3, collection.Count); Assert.Empty(collection.Where(x => x.key == CollectionFactory.StartingValue)); Assert.Empty(collection.Where(x => x.key == CollectionFactory.StartingValue + 1)); Assert.Single(collection.Where(x => x.key == CollectionFactory.StartingValue + 2)); Assert.Equal(2, collection.Count(x => x.key == CollectionFactory.StartingValue + 3)); }
/** * Returns a copy which contains a copy of the domains list and is in all * other aspects a flat copy of this. */ public CSP <VAR, VAL> copyDomains() { CSP <VAR, VAL> result; result = new CSP <VAR, VAL>(); result.domains = CollectionFactory.CreateQueue <Domain <VAL> >(); result.domains.AddAll(domains); result.variables.AddAll(variables); result.constraints.AddAll(constraints); result.varIndexHash.AddAll(varIndexHash); result.cnet.AddAll(cnet); return(result); }
/// <summary> Method will make a copy and return it. When a copy is made, the /// Method classes are not cloned. Instead, just the HashMap is cloned. /// </summary> /// <returns> /// /// </returns> public virtual Defclass cloneDefclass() { Defclass dcl = new Defclass(OBJECT_CLASS); dcl.addListener = addListener; dcl.INFO = INFO; dcl.ISBEAN = ISBEAN; dcl.PROPS = PROPS; dcl.removeListener = removeListener; dcl.methods = CollectionFactory.localMap(); dcl.methods.putAll(methods); return(dcl); }
public void test_getValue() { Assert.IsTrue(0.0 == fitnessFunction.apply( new Individual <int>(CollectionFactory.CreateQueue <int>(new[] { 0, 0, 0, 0, 0, 0, 0, 0 })))); Assert.IsTrue(0.0 == fitnessFunction.apply( new Individual <int>(CollectionFactory.CreateQueue <int>(new[] { 0, 1, 2, 3, 4, 5, 6, 7 })))); Assert.IsTrue(0.0 == fitnessFunction.apply( new Individual <int>(CollectionFactory.CreateQueue <int>(new[] { 7, 6, 5, 4, 3, 2, 1, 0 })))); Assert.IsTrue(23.0 == fitnessFunction.apply( new Individual <int>(CollectionFactory.CreateQueue <int>(new[] { 5, 6, 1, 3, 6, 4, 7, 7 })))); Assert.IsTrue(28.0 == fitnessFunction.apply( new Individual <int>(CollectionFactory.CreateQueue <int>(new[] { 0, 4, 7, 5, 2, 6, 1, 3 })))); }
private void initializeHypothesisWeights(int size) { if (size == 0) { throw new RuntimeException("cannot initialize Ensemble learning with Zero Learners"); } learnerWeights = CollectionFactory.CreateInsertionOrderedMap <ILearner, double>(); foreach (ILearner le in learners) { learnerWeights.Put(le, 1.0); } }
public RecipeController(CollectionFactory cf) { recipeCollection = cf.GetCollection <Recipe>(); foodCollection = cf.GetCollection <Food>(); categoryCollection = cf.GetCollection <Category>(); bucket = new GridFSBucket(cf.GetDatabase(), new GridFSBucketOptions { BucketName = "RecipeImages", ChunkSizeBytes = 1048576, // 1MB WriteConcern = WriteConcern.WMajority, ReadPreference = ReadPreference.Primary }); }
public ICollection <int> GetActions(ConnectFourState state) { ICollection <int> result = CollectionFactory.CreateQueue <int>(); for (int i = 0; i < state.getCols(); ++i) { if (state.getPlayerNum(0, i) == 0) { result.Add(i); } } return(result); }
public bool addEntry(string category, string word, float prob) { if (this.ContainsKey(category)) { this.Get(category).Add(new LexWord(word, prob)); } else { this.Put(category, CollectionFactory.CreateQueue <LexWord>(new[] { new LexWord(word, prob) })); } return(true); }
public void testListOfSymbolsClone() { ICollection <PropositionSymbol> l = CollectionFactory.CreateQueue <PropositionSymbol>(); l.Add(new PropositionSymbol("A")); l.Add(new PropositionSymbol("B")); l.Add(new PropositionSymbol("C")); ICollection <PropositionSymbol> l2 = CollectionFactory.CreateQueue <PropositionSymbol>(l); l2.Remove(new PropositionSymbol("B")); Assert.AreEqual(3, l.Size()); Assert.AreEqual(2, l2.Size()); }
public ICollection <XYLocation> getPositions() { ICollection <XYLocation> retVal = CollectionFactory.CreateQueue <XYLocation>(); for (int i = 0; i < 9; i++) { int absPos = getPositionOf(i); XYLocation loc = new XYLocation(getXCoord(absPos), getYCoord(absPos)); retVal.Add(loc); } return(retVal); }
public virtual object visitFunction(Function function, object arg) { ICollection <Term> terms = function.getTerms(); ICollection <Term> newTerms = CollectionFactory.CreateQueue <Term>(); for (int i = 0; i < terms.Size(); ++i) { Term t = terms.Get(i); Term subsTerm = (Term)t.accept(this, arg); newTerms.Add(subsTerm); } return(new Function(function.getFunctionName(), newTerms)); }
/** * Fetches and returns all pages that match the query * * @param query * @return * @throws UnsupportedEncodingException */ public ICollection <Page> relevantPages(string query) { ICollection <Page> relevantPages = CollectionFactory.CreateQueue <Page>(); foreach (Page p in pTable.GetValues()) { if (matches(query, p.getContent())) { relevantPages.Add(p); } } return(relevantPages); }
public virtual object visitPredicate(Predicate predicate, object arg) { ICollection <Term> terms = predicate.getTerms(); ICollection <Term> newTerms = CollectionFactory.CreateQueue <Term>(); for (int i = 0; i < terms.Size(); ++i) { Term t = terms.Get(i); Term subsTerm = (Term)t.accept(this, arg); newTerms.Add(subsTerm); } return(new Predicate(predicate.getPredicateName(), newTerms)); }
/** * Returns the path from the root node to this node. * * @return the path from the root node to this node. */ public static ICollection <Node <S, A> > getPathFromRoot <S, A>(Node <S, A> node) { ICollection <Node <S, A> > path = CollectionFactory.CreateQueue <Node <S, A> >(); while (!node.isRootNode()) { path.Insert(0, node); node = node.getParent(); } // ensure the root node is added path.Insert(0, node); return(path); }
public SearchAgent(IProblem <S, A> p, ISearchForActions <S, A> search) { ICollection <A> actions = search.findActions(p); actionList = CollectionFactory.CreateQueue <A>(); if (null != actions) { actionList.AddAll(actions); } // actionIterator = actionList.iterator(); searchMetrics = search.getMetrics(); }
public virtual ICollection <string> getNamesOfStringAttributes() { ICollection <string> names = CollectionFactory.CreateQueue <string>(); foreach (IAttributeSpecification spec in attributeSpecifications) { if (spec is StringAttributeSpecification) { names.Add(spec.GetAttributeName()); } } return(names); }
/** * Whenever a new rule is added to the grammar, we want to * update the list of variables and terminals with any new grammar symbols */ public virtual void updateVarsAndTerminals() { if (rules == null) { vars = CollectionFactory.CreateQueue <string>(); terminals = CollectionFactory.CreateQueue <string>(); return; } foreach (Rule r in rules) { updateVarsAndTerminals(r); // update the variables and terminals for this rule } }
ConvertCollection <TConverted>(IEnumerable <TCollectionType> collection) { if (collection == null) { return(null); } var itemsConverted = collection.Select(x => Mapper.Map <TConverted>(x)); var converted = CollectionFactory.Create(itemsConverted); return(converted); }
public void UpdateOrAddItem_Should_Insert_When_NoMatches() { var collection = CollectionFactory.GetDefaultList(); var value = CollectionFactory.GetDefaultValue(CollectionFactory.StartingValue - 1); collection.UpdateOrAddItem(value, x => x.value == value.value, true, true); Assert.Equal(4, collection.Count); Assert.Single(collection.Where(x => x.key == CollectionFactory.StartingValue)); Assert.Single(collection.Where(x => x.key == CollectionFactory.StartingValue + 1)); Assert.Single(collection.Where(x => x.key == CollectionFactory.StartingValue + 2)); Assert.Single(collection.Where(x => x.key == CollectionFactory.StartingValue + 3)); }
public FiniteIntegerDomain(params int[] pValues) { // Keep consistent order possibleValues = CollectionFactory.CreateSet <int>(); foreach (int v in pValues) { possibleValues.Add(v); } // Ensure cannot be modified possibleValues = CollectionFactory.CreateReadOnlySet <int>(possibleValues); indexPossibleValues(possibleValues); }
public IMap <Variable, Term> standardizeApart(ICollection <Literal> l1Literals, ICollection <Literal> l2Literals, StandardizeApartIndexical standardizeApartIndexical) { ISet <Variable> toRename = CollectionFactory.CreateSet <Variable>(); foreach (Literal pl in l1Literals) { toRename.AddAll(variableCollector.collectAllVariables(pl .getAtomicSentence())); } foreach (Literal nl in l2Literals) { toRename.AddAll(variableCollector.collectAllVariables(nl.getAtomicSentence())); } IMap <Variable, Term> renameSubstitution = CollectionFactory.CreateInsertionOrderedMap <Variable, Term>(); foreach (Variable var in toRename) { Variable v = null; do { v = new Variable(standardizeApartIndexical.getPrefix() + standardizeApartIndexical.getNextIndex()); // Ensure the new variable name is not already // accidentally used in the sentence } while (toRename.Contains(v)); renameSubstitution.Put(var, v); } ICollection <Literal> posLits = CollectionFactory.CreateQueue <Literal>(); ICollection <Literal> negLits = CollectionFactory.CreateQueue <Literal>(); foreach (Literal pl in l1Literals) { posLits.Add(substVisitor.subst(renameSubstitution, pl)); } foreach (Literal nl in l2Literals) { negLits.Add(substVisitor.subst(renameSubstitution, nl)); } l1Literals.Clear(); l1Literals.AddAll(posLits); l2Literals.Clear(); l2Literals.AddAll(negLits); return(renameSubstitution); }
/** * * @return the set of disjoint sets being maintained. */ public ISet <ISet <E> > getDisjointSets() { // Note: Instantiate normal sets to ensure IdentityHashSet // is not exposed outside of this class. // This also ensures the internal logic cannot // be corrupted externally due to changing sets. ISet <ISet <E> > result = CollectionFactory.CreateSet <ISet <E> >(); foreach (ISet <E> disjointSet in disjointSets) { result.Add(CollectionFactory.CreateSet <E>(disjointSet)); } return(result); }
/** * Returns the specified sentence in its logically equivalent conjunction of * clauses. * * @param s * a propositional logic sentence * * @return the input sentence converted to it logically equivalent * conjunction of clauses. */ public static ConjunctionOfClauses convert(Sentence s) { ConjunctionOfClauses result = null; Sentence cnfSentence = ConvertToCNF.convert(s); ICollection <Clause> clauses = CollectionFactory.CreateQueue <Clause>(); clauses.AddAll(ClauseCollector.getClausesFrom(cnfSentence)); result = new ConjunctionOfClauses(clauses); return(result); }
/** * * @return a map for each element and the corresponding disjoint set that it * belongs to. */ public IMap <E, ISet <E> > getElementToDisjointSet() { // Note: Instantiate normal sets to ensure IdentityHashSet // is not exposed outside of this class. // This also ensures the internal logic cannot // be corrupted externally due to changing sets. IMap <E, ISet <E> > result = CollectionFactory.CreateInsertionOrderedMap <E, ISet <E> >(); foreach (KeyValuePair <E, ISet <E> > entry in elementToSet) { result.Put(entry.GetKey(), CollectionFactory.CreateSet <E>(entry.GetValue())); } return(result); }
public void setUp() { ICollection <string> rowHeaders = CollectionFactory.CreateQueue <string>(); ICollection <string> columnHeaders = CollectionFactory.CreateQueue <string>(); rowHeaders.Add("row1"); rowHeaders.Add("ravi"); rowHeaders.Add("peter"); columnHeaders.Add("col1"); columnHeaders.Add("iq"); columnHeaders.Add("age"); table = new Table <string, string, int?>(rowHeaders, columnHeaders); }
/// <summary> the current implementation will try to find the memory for the node. /// If it doesn't find it, it will create a new Left memory, which is /// HashMap. /// </summary> public virtual IGenericMap <object, object> getBetaLeftMemory(Object key) { IGenericMap <object, object> m = betaLeftMemories.Get(key); if (m == null) { // it should create a new memory // and return it. String mname = "blmem" + ((BaseNode)key).nodeID; m = CollectionFactory.newBetaMemoryMap(mname); betaLeftMemories.Put(key, m); } return(m); }
public static ProbContextFreeGrammar buildWumpusGrammar() { ProbContextFreeGrammar g = new ProbContextFreeGrammar(); ICollection <Rule> rules = CollectionFactory.CreateQueue <Rule>(); // Start Rules rules.Add(new Rule("S", "NP,VP", (float)0.90)); rules.Add(new Rule("S", "CONJ,S", (float)0.10)); // Noun Phrase Rules rules.Add(new Rule("NP", "PRONOUN", (float)0.30)); rules.Add(new Rule("NP", "NAME", (float)0.10)); rules.Add(new Rule("NP", "NOUN", (float)0.10)); rules.Add(new Rule("NP", "ARTICLE,NOUN", (float)0.25)); rules.Add(new Rule("NP", "AP,NOUN", (float)0.05)); rules.Add(new Rule("NP", "DIGIT,DIGIT", (float)0.05)); rules.Add(new Rule("NP", "NP,PP", (float)0.10)); rules.Add(new Rule("NP", "NP,RELCLAUSE", (float)0.05)); // add verb phrase rules rules.Add(new Rule("VP", "VERB", (float)0.40)); rules.Add(new Rule("VP", "VP,NP", (float)0.35)); rules.Add(new Rule("VP", "VP,ADJS", (float)0.05)); rules.Add(new Rule("VP", "VP,PP", (float)0.10)); rules.Add(new Rule("VP", "VP,ADVERB", (float)0.10)); // add adjective rules rules.Add(new Rule("AJD", "AJDS", (float)0.80)); rules.Add(new Rule("AJD", "AJD,AJDS", (float)0.20)); // add Article Phrase // This deviates from the text because the text provides the rule: // NP -> Article Adjs Noun, which is NOT in Chomsky Normal Form // // We instead define AP (Article Phrase) AP -> Article Adjs, to get around this rules.Add(new Rule("AP", "ARTICLE,ADJS", (float)1.0)); // add preposition phrase rules.Add(new Rule("PP", "PREP,NP", (float)1.00)); // add relative clause rules.Add(new Rule("RELCLAUSE", "RELPRO,VP", (float)1.00)); // Now we can add all rules that derive terminal symbols, which are in // this case words. Lexicon wumpusLex = LexiconExamples.buildWumpusLex(); ICollection <Rule> terminalRules = CollectionFactory.CreateQueue <Rule>(wumpusLex.getAllTerminalRules()); rules.AddAll(terminalRules); // Add all these rules into the grammar if (!g.addRules(rules)) { return(null); } return(g); }
public ThumbnailGenerationEgg() { collectionFactory = new CollectionFactory(); var streamFactory = new StreamFactory(); var processProxy = new ProcessProxy(); threadingProxy = new ThreadingProxy(new ThreadingFactory(), new SynchronizationFactory()); pofContext = new PofContext().With(x => { x.MergeContext(new ManagementPofContext()); x.MergeContext(new ThumbnailGeneratorApiPofContext()); }); pofSerializer = new PofSerializer(pofContext); networkingProxy = new NetworkingProxy(new SocketFactory(new TcpEndPointFactory(new DnsProxy()), new NetworkingInternalFactory(threadingProxy, streamFactory)), new TcpEndPointFactory(new DnsProxy())); thumbnailGeneratorService = new ThumbnailGeneratorServiceImpl(); }
public ManagerDetailsViewModel(Application app, CollectionFactory collection, ViewModelBrowser browser, ISquadRepository squadRepository) { App = app; Browser = browser; Collections = collection; SquadRepository = squadRepository; SetManager(); ChooseManagerVisibility = Managers.Count > 0; Cancel = new RelayCommand(NavigateToMenu); Save = new RelayCommand(SaveManager, CanSave); }
public void LoadsCardsOnStart() { var navigation = new Mock<INavigationService>(); var cardProvider = new Mock<BaseCardProvider>(); var collectionFactory = new CollectionFactory(); var statistics = new Mock<StatisticsService>(); cardProvider.Setup(x => x.LoadCards()) .Returns(() => new List<Card> {GetCard()}); var target = new MainViewModel(navigation.Object, cardProvider.Object, collectionFactory, statistics.Object); cardProvider.Verify(x => x.LoadCards(), Times.Once()); Assert.AreEqual(1, target.Cards.Count); Assert.AreEqual(1, target.Cards[0].Id); }
public void NavigatesToAboutPage() { var navigation = new Mock<INavigationService>(); var statistics = new Mock<StatisticsService>(); var collectionFactory = new CollectionFactory(); ; var pageName = string.Empty; navigation.Setup(x => x.Navigate(It.IsAny<string>(), It.IsAny<string>())) .Callback((string s, string q) => pageName = s); var cardProvider = new Mock<BaseCardProvider>(); var target = new MainViewModel(navigation.Object, cardProvider.Object, collectionFactory, statistics.Object); target.AboutCommand.Execute(null); navigation.Verify(x => x.Navigate(It.IsAny<string>(), It.IsAny<string>()), Times.Once()); Assert.AreEqual(Pages.About, pageName); }
public static int Main() { ICollectionFactory collectionFactory = new CollectionFactory(); ProxyGenerator proxyGenerator = new ProxyGenerator(); IThreadingFactory threadingFactory = new ThreadingFactory(); ISynchronizationFactory synchronizationFactory = new SynchronizationFactory(); IThreadingProxy threadingProxy = new ThreadingProxy(threadingFactory, synchronizationFactory); IDnsProxy dnsProxy = new DnsProxy(); ITcpEndPointFactory tcpEndPointFactory = new TcpEndPointFactory(dnsProxy); IStreamFactory streamFactory = new StreamFactory(); INetworkingInternalFactory networkingInternalFactory = new NetworkingInternalFactory(threadingProxy, streamFactory); ISocketFactory socketFactory = new SocketFactory(tcpEndPointFactory, networkingInternalFactory); INetworkingProxy networkingProxy = new NetworkingProxy(socketFactory, tcpEndPointFactory); IPofContext pofContext = new ClientPofContext(); IPofSerializer pofSerializer = new PofSerializer(pofContext); PofStreamsFactory pofStreamsFactory = new PofStreamsFactoryImpl(threadingProxy, streamFactory, pofSerializer); var serviceConfiguration = new ClientClusteringConfiguration(); var serviceClientFactory = new ServiceClientFactoryImpl(proxyGenerator, streamFactory, collectionFactory, threadingProxy, networkingProxy, pofSerializer, pofStreamsFactory); var localEndPoint = tcpEndPointFactory.CreateLoopbackEndPoint(serviceConfiguration.Port); var reconnectAttempts = 10; var reconnectDelay = 1000; var serviceClient = TryConnectToEndpoint(reconnectAttempts, reconnectDelay, serviceClientFactory, serviceConfiguration); if (serviceClient == null) { Console.Error.WriteLine("Failed to connect to endpoint."); return 1; } else { var dispatcher = new DispatcherCommand("registered commands"); dispatcher.RegisterCommand(new ShutdownCommand(serviceClient)); // dispatcher.RegisterCommand(new ModCommand(serviceClient)); dispatcher.RegisterCommand(new ExitCommand()); dispatcher.RegisterCommand(new ServiceCommand(serviceClient)); var repl = new DargonREPL(dispatcher); repl.Run(); return 0; } }
public DishTypeLogic(string assemblyName) { _collectionFactory = new CollectionFactory(assemblyName); _dishTypeSite = _collectionFactory.CreateDishTypeSecretary(); }
public CatalogueLogic(string assemblyName) { var collectionFactory = new CollectionFactory(assemblyName); _catalogueSite = collectionFactory.CreateCatalogueSecretary(); }
public PictureLogic(string assemblyName) { _collectionFactory = new CollectionFactory(assemblyName); _pictureSite = _collectionFactory.CreatePictureSecretary(); }
public DishesLogic(string assemblyName) { var collectionFactory = new CollectionFactory(assemblyName); _dishesSite = collectionFactory.CreateDishesSecretary(); }