/// <summary> /// Constructor /// </summary> public Demo2Tenant() { //Initialize Disabled Features DisabledFeatures = new FeatureRegistry() { Features = new List <IFeature>() { //Controller new ComplexFeature("Store", new List <IFeature> { //Actions new Feature("Buy") }) } }; //Initialize Enrollment Fields EnrollmentFields = new List <IFormField>() { new FormField(ResourceKey.FirstName, "FirstName", 1), new FormField(ResourceKey.LastName, "LastName", 2), new FormField(ResourceKey.BirthDate, "BirthDate", 3), new FormField(ResourceKey.Phone, "Phone", 4) }; Name = "Demo2"; Languages = new List <Language>() { Language.En }; UrlPaths = new[] { "http://localhost:3456/" }; }
/// <summary> /// Constructor /// </summary> public Demo1Tenant() { //Initialize Disabled Features DisabledFeatures = new FeatureRegistry() { Features = new List <IFeature>() { //Controller new Feature("Store") //Entire controller is disabled } }; //Initialize Enrollment Fields EnrollmentFields = new List <IFormField>() { new FormField(ResourceKey.FirstName, "FirstName", 1), new FormField(ResourceKey.LastName, "LastName", 2), }; Name = "Demo1"; Languages = new List <Language>() { Language.En, Language.Fr }; UrlPaths = new[] { "http://localhost:3455/" }; }
public void FalseShouldBeReturnedForType() { var sut = new FeatureRegistry { [typeof(TestClass)] = false }; Assert.IsFalse(sut[typeof(TestClass)]); }
public void FalseShouldBeReturnedForEnum() { var sut = new FeatureRegistry { [TestEnum.Test] = false }; Assert.IsFalse(sut[TestEnum.Test]); }
public void ValueShouldBeSetForType(bool isEnabled) { var sut = new FeatureRegistry { [typeof(TestClass)] = isEnabled }; Assert.AreEqual(isEnabled, sut[typeof(TestClass)]); }
public void ValueShouldBeSetForString(bool isEnabled) { var sut = new FeatureRegistry { ["First"] = isEnabled }; Assert.AreEqual(isEnabled, sut["First"]); }
public void ValueShouldBeSetForEnum(bool isEnabled) { var sut = new FeatureRegistry { [TestEnum.Test] = isEnabled }; Assert.AreEqual(isEnabled, sut[TestEnum.Test]); }
public void FalseShouldBeReturnedForString() { var sut = new FeatureRegistry { ["First"] = true }; Assert.IsTrue(sut["First"]); }
public void ArgumentNullExceptionExceptionShouldBeThrownForString() { var sut = new FeatureRegistry(); Assert.Throws <ArgumentNullException>(() => { var _ = sut[default(string)]; }); }
public void A_feature_can_be_retrieved_from_the_registry_as_an_observable() { var registry = new FeatureRegistry { typeof(PrimaryFeature) }; Assert.That( registry.Get <PrimaryFeature>(), Is.InstanceOf <IObservable <PrimaryFeature> >()); }
public void A_feature_can_be_retrieved_from_the_registry_as_an_observable() { var registry = new FeatureRegistry { typeof (PrimaryFeature) }; Assert.That( registry.Get<PrimaryFeature>(), Is.InstanceOf<IObservable<PrimaryFeature>>()); }
public void When_a_feature_is_not_registered_it_returns_an_empty_and_uncompleted_observable() { var registry = new FeatureRegistry(); var initialized = false; registry .Get<SecondaryFeature>() .Timeout(TimeSpan.FromSeconds(2)) .Subscribe(f => { initialized = true; }, ex => { }); Assert.That(initialized, Is.False); }
public void When_a_feature_is_not_registered_it_returns_an_empty_and_uncompleted_observable() { var registry = new FeatureRegistry(); var initialized = false; registry .Get <SecondaryFeature>() .Timeout(TimeSpan.FromSeconds(2)) .Subscribe(f => { initialized = true; }, ex => { }); Assert.That(initialized, Is.False); }
public void Optional_features_can_throw_during_initialization_without_causing_other_features_to_fail_to_load() { SecondaryFeature.OnCtor = f => { throw new Exception("oops!"); }; var registry = new FeatureRegistry() .Add <SecondaryFeature>() .Add <PrimaryFeature>(); var initialized = false; registry .Get <SecondaryFeature>() .Timeout(TimeSpan.FromSeconds(2)) .Subscribe(f => { initialized = true; }, ex => { }); Assert.That(initialized, Is.False); }
public void When_a_feature_is_subscribed_before_it_is_registered_then_subscriber_is_notified_upon_registration() { var barrier = new Barrier(2); var initialized = false; var registry = new FeatureRegistry(); PrimaryFeature.OnActivate = barrier.SignalAndWait; registry .Get<SecondaryFeature>() .Timeout(TimeSpan.FromSeconds(2)) .Subscribe(f => { initialized = true; }, ex => { }); Assert.That(initialized, Is.False); registry.Add(r => new SecondaryFeature(new PrimaryFeature())); barrier.SignalAndWait(2000); Assert.That(initialized, Is.True); }
public void When_a_feature_is_subscribed_before_it_is_registered_then_subscriber_is_notified_upon_registration() { var barrier = new Barrier(2); var initialized = false; var registry = new FeatureRegistry(); PrimaryFeature.OnActivate = barrier.SignalAndWait; registry .Get <SecondaryFeature>() .Timeout(TimeSpan.FromSeconds(2)) .Subscribe(f => { initialized = true; }, ex => { }); Assert.That(initialized, Is.False); registry.Add(r => new SecondaryFeature(new PrimaryFeature())); barrier.SignalAndWait(2000); Assert.That(initialized, Is.True); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.maltparser.core.feature.function.Function newFunction(String functionName, org.maltparser.core.feature.FeatureRegistry registry) throws org.maltparser.core.exception.MaltChainedException public virtual Function.Function newFunction(string functionName, FeatureRegistry registry) { int i = 0; Function.Function func = null; while (true) { FunctionDescription funcDesc = get(functionName + "~~" + i); if (funcDesc == null) { break; } func = funcDesc.newFunction(registry); if (func != null) { break; } i++; } return(func); }
public MainWindowViewModel( FeatureRegistry featureRegistry, IExplicitConnectionCache explicitConnectionCache, IGeneralSettings generalSettings, IInitialLayoutStructureProvider initialLayoutStructureProvider, ISnackbarMessageQueue snackbarSnackbarMessageQueue) { if (featureRegistry == null) { throw new ArgumentNullException(nameof(featureRegistry)); } if (explicitConnectionCache == null) { throw new ArgumentNullException(nameof(explicitConnectionCache)); } if (generalSettings == null) { throw new ArgumentNullException(nameof(generalSettings)); } if (initialLayoutStructureProvider == null) { throw new ArgumentNullException(nameof(initialLayoutStructureProvider)); } _featureRegistry = featureRegistry; _explicitConnectionCache = explicitConnectionCache; _generalSettings = generalSettings; _initialLayoutStructureProvider = initialLayoutStructureProvider; SnackbarMessageQueue = snackbarSnackbarMessageQueue; DialogHostIdentifier = Guid.NewGuid(); StartupCommand = new Command(RunStartup); ShutDownCommand = new Command(o => RunShutdown()); OpenManagementCommand = new Command(o => Open <ManagementFeatureFactory>()); Tabs = new ObservableCollection <QueryDeveloperViewModel>(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public FeatureModel(org.maltparser.core.feature.spec.SpecificationModel _specModel, FeatureRegistry _registry, org.maltparser.core.feature.system.FeatureEngine _engine, String dataSplitColumn, String dataSplitStructure) throws org.maltparser.core.exception.MaltChainedException public FeatureModel(SpecificationModel _specModel, FeatureRegistry _registry, FeatureEngine _engine, string dataSplitColumn, string dataSplitStructure) { specModel = _specModel; registry = _registry; featureEngine = _engine; addressFunctionCache = new List <AddressFunction>(); featureFunctionCache = new List <FeatureFunction>(); FeatureVector tmpMainFeatureVector = null; foreach (SpecificationSubModel subModel in specModel) { FeatureVector fv = new FeatureVector(this, subModel); if (tmpMainFeatureVector == null) { if (subModel.SubModelName.Equals("MAIN")) { tmpMainFeatureVector = fv; } else { tmpMainFeatureVector = fv; put(subModel.SubModelName, fv); } } else { put(subModel.SubModelName, fv); } } mainFeatureVector = tmpMainFeatureVector; if (!ReferenceEquals(dataSplitColumn, null) && dataSplitColumn.Length > 0 && !ReferenceEquals(dataSplitStructure, null) && dataSplitStructure.Length > 0) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); sb.Append("InputColumn("); sb.Append(dataSplitColumn); sb.Append(", "); sb.Append(dataSplitStructure); sb.Append(')'); divideFeatureFunction = identifyFeature(sb.ToString()); // this.divideFeatureIndexVectorMap = new HashMap<String,ArrayList<Integer>>(); divideFeatureIndexVector = new List <int>(); for (int i = 0; i < mainFeatureVector.Count; i++) { if (mainFeatureVector[i].Equals(divideFeatureFunction)) { divideFeatureIndexVector.Add(i); } } foreach (SpecificationSubModel subModel in specModel) { FeatureVector featureVector = get(subModel.SubModelName); if (featureVector == null) { featureVector = mainFeatureVector; } string divideKeyName = "/" + subModel.SubModelName; // divideFeatureIndexVectorMap.put(divideKeyName, divideFeatureIndexVector); FeatureVector divideFeatureVector = (FeatureVector)featureVector.clone(); foreach (int?i in divideFeatureIndexVector) { divideFeatureVector.Remove(divideFeatureVector[i]); } put(divideKeyName, divideFeatureVector); } } else { divideFeatureFunction = null; // this.divideFeatureIndexVectorMap = null; divideFeatureIndexVector = null; } }
public void ArgumentNullExceptionExceptionShouldBeThrownForType() { var sut = new FeatureRegistry(); Assert.Throws <ArgumentNullException>(() => { sut[default(Type)] = false; }); }
public void FalseShouldBeReturnedForString() { var sut = new FeatureRegistry(); Assert.IsFalse(sut["First"]); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.maltparser.core.feature.function.Function makeFunction(String subFunctionName, org.maltparser.core.feature.FeatureRegistry registry) throws org.maltparser.core.exception.MaltChainedException public virtual Function makeFunction(string subFunctionName, FeatureRegistry registry) { AlgoritmInterface algorithm = ((ParserRegistry)registry).Algorithm; return(new CovingtonAddressFunction(subFunctionName, algorithm)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public FeatureModel getFeatureModel(org.maltparser.core.feature.spec.SpecificationModel specModel, FeatureRegistry registry, String dataSplitColumn, String dataSplitStructure) throws org.maltparser.core.exception.MaltChainedException public virtual FeatureModel getFeatureModel(SpecificationModel specModel, FeatureRegistry registry, string dataSplitColumn, string dataSplitStructure) { return(new FeatureModel(specModel, registry, featureEngine, dataSplitColumn, dataSplitStructure)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.maltparser.core.feature.function.Function newFunction(org.maltparser.core.feature.FeatureRegistry registry) throws org.maltparser.core.exception.MaltChainedException public virtual Function.Function newFunction(FeatureRegistry registry) { if (hasFactory) { // for (Class<?> c : registry.keySet()) { // try { // c.asSubclass(functionClass); // } catch (ClassCastException e) { // continue; // } // return ((AbstractFeatureFactory)registry.get(c)).makeFunction(name); // } // return null; return(registry.getFactory(functionClass).makeFunction(name, registry)); } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: Constructor<?>[] constructors = functionClass.getConstructors(); global::System.Reflection.ConstructorInfo <object>[] constructors = functionClass.GetConstructors(); if (constructors.Length == 0) { try { return((Function.Function)Activator.CreateInstance(functionClass)); } catch (InstantiationException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } catch (IllegalAccessException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } } Type[] @params = constructors[0].ParameterTypes; if (@params.Length == 0) { try { return((Function.Function)Activator.CreateInstance(functionClass)); } catch (InstantiationException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } catch (IllegalAccessException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } } object[] arguments = new object[@params.Length]; for (int i = 0; i < @params.Length; i++) { if (hasSubfunctions && @params[i] == typeof(string)) { arguments[i] = name; } else { arguments[i] = registry.get(@params[i]); if (arguments[i] == null) { return(null); } } } try { return((Function.Function)constructors[0].newInstance(arguments)); } catch (InstantiationException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } catch (IllegalAccessException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } catch (InvocationTargetException e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new FeatureException("The function '" + functionClass.FullName + "' cannot be initialized. ", e); } }
public void Optional_features_can_throw_during_initialization_without_causing_other_features_to_fail_to_load() { SecondaryFeature.OnCtor = f => { throw new Exception("oops!"); }; var registry = new FeatureRegistry() .Add<SecondaryFeature>() .Add<PrimaryFeature>(); var initialized = false; registry .Get<SecondaryFeature>() .Timeout(TimeSpan.FromSeconds(2)) .Subscribe(f => { initialized = true; }, ex => { }); Assert.That(initialized, Is.False); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public FeatureModel getFeatureModel(java.net.URL specModelURL, int specModelUrlIndex, FeatureRegistry registry, String dataSplitColumn, String dataSplitStructure) throws org.maltparser.core.exception.MaltChainedException public virtual FeatureModel getFeatureModel(URL specModelURL, int specModelUrlIndex, FeatureRegistry registry, string dataSplitColumn, string dataSplitStructure) { return(new FeatureModel(specModels.getSpecificationModel(specModelURL, specModelUrlIndex), registry, featureEngine, dataSplitColumn, dataSplitStructure)); }
private void App_OnStartup(object sender, StartupEventArgs e) { System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; IGeneralSettings generalSettings = null; IExplicitConnectionCache explicitConnectionCache = null; IInitialLayoutStructureProvider initialLayoutStructureProvider = null; string rawData; if (new Persistance().TryLoadRaw(out rawData)) { try { var settingsContainer = Serializer.Objectify(rawData); generalSettings = settingsContainer.GeneralSettings; explicitConnectionCache = settingsContainer.ExplicitConnectionCache; initialLayoutStructureProvider = new InitialLayoutStructureProvider(settingsContainer.LayoutStructure); } catch (Exception exc) { //TODO summit System.Diagnostics.Debug.WriteLine(exc.Message); } } generalSettings = generalSettings ?? new GeneralSettings(10); explicitConnectionCache = explicitConnectionCache ?? new ExplicitConnectionCache(); initialLayoutStructureProvider = initialLayoutStructureProvider ?? new InitialLayoutStructureProvider(); var container = new Container(_ => { _.ForSingletonOf <DispatcherScheduler>().Use(DispatcherScheduler.Current); _.ForSingletonOf <DispatcherTaskSchedulerProvider>().Use(DispatcherTaskSchedulerProvider.Create(Dispatcher)); _.ForSingletonOf <IGeneralSettings>().Use(generalSettings); _.ForSingletonOf <IExplicitConnectionCache>().Use(explicitConnectionCache); _.ForSingletonOf <IImplicitConnectionCache>(); _.ForSingletonOf <LocalEmulatorDetector>(); _.ForSingletonOf <IInitialLayoutStructureProvider>().Use(initialLayoutStructureProvider); _.ForSingletonOf <ISnackbarMessageQueue>().Use(new SnackbarMessageQueue(TimeSpan.FromSeconds(5))); _.ForSingletonOf <FeatureRegistry>() .Use( ctx => FeatureRegistry .WithDefault(ctx.GetInstance <QueryDeveloperFeatureFactory>()) .Add(ctx.GetInstance <ManagementFeatureFactory>())); _.AddRegistry <DoobryRegistry>(); _.Scan(scanner => { scanner.TheCallingAssembly(); scanner.WithDefaultConventions(); }); }); var windowInstanceManager = new WindowInstanceManager(container.GetInstance <MainWindowViewModel>); //grease the Dragablz wheels var featureRegistry = container.GetInstance <FeatureRegistry>(); NewItemFactory = () => { var contentLifetimeHost = featureRegistry.Default.CreateTabContent(); var tabContentContainer = new TabItemContainer(Guid.NewGuid(), featureRegistry.Default.FeatureId, contentLifetimeHost, featureRegistry.Default); return(tabContentContainer); }; InterTabClient = new InterTabClient(windowInstanceManager); ClosingItemCallback = OnItemClosingHandler; var localEmulatorSubscription = UseLocalEmulatorDetector(container); Exit += (o, args) => localEmulatorSubscription.Dispose(); ShutdownMode = ShutdownMode.OnExplicitShutdown; var mainWindow = windowInstanceManager.Create(); mainWindow.Show(); Task.Factory.StartNew(() => CheckForUpdates(container.GetInstance <ISnackbarMessageQueue>())); }