Пример #1
0
        /// <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/" };
        }
Пример #2
0
        /// <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/" };
        }
Пример #3
0
                public void FalseShouldBeReturnedForType()
                {
                    var sut = new FeatureRegistry {
                        [typeof(TestClass)] = false
                    };

                    Assert.IsFalse(sut[typeof(TestClass)]);
                }
Пример #4
0
                public void FalseShouldBeReturnedForEnum()
                {
                    var sut = new FeatureRegistry {
                        [TestEnum.Test] = false
                    };

                    Assert.IsFalse(sut[TestEnum.Test]);
                }
Пример #5
0
            public void ValueShouldBeSetForType(bool isEnabled)
            {
                var sut = new FeatureRegistry {
                    [typeof(TestClass)] = isEnabled
                };

                Assert.AreEqual(isEnabled, sut[typeof(TestClass)]);
            }
Пример #6
0
            public void ValueShouldBeSetForString(bool isEnabled)
            {
                var sut = new FeatureRegistry {
                    ["First"] = isEnabled
                };

                Assert.AreEqual(isEnabled, sut["First"]);
            }
Пример #7
0
            public void ValueShouldBeSetForEnum(bool isEnabled)
            {
                var sut = new FeatureRegistry {
                    [TestEnum.Test] = isEnabled
                };

                Assert.AreEqual(isEnabled, sut[TestEnum.Test]);
            }
Пример #8
0
                public void FalseShouldBeReturnedForString()
                {
                    var sut = new FeatureRegistry {
                        ["First"] = true
                    };

                    Assert.IsTrue(sut["First"]);
                }
Пример #9
0
                public void ArgumentNullExceptionExceptionShouldBeThrownForString()
                {
                    var sut = new FeatureRegistry();

                    Assert.Throws <ArgumentNullException>(() =>
                    {
                        var _ = sut[default(string)];
                    });
                }
Пример #10
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #16
0
        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);
        }
Пример #17
0
//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);
        }
Пример #18
0
        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>();
        }
Пример #19
0
//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;
            }
        }
Пример #20
0
                public void ArgumentNullExceptionExceptionShouldBeThrownForType()
                {
                    var sut = new FeatureRegistry();

                    Assert.Throws <ArgumentNullException>(() => { sut[default(Type)] = false; });
                }
Пример #21
0
                public void FalseShouldBeReturnedForString()
                {
                    var sut = new FeatureRegistry();

                    Assert.IsFalse(sut["First"]);
                }
Пример #22
0
//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));
        }
Пример #23
0
//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));
        }
Пример #24
0
//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);
        }
Пример #26
0
//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));
        }
Пример #27
0
        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>()));
        }