Esempio n. 1
0
        private void ConfigureOrCreateSearchContract( BehaviorCollection behaviors )
        {
            Contract.Requires( behaviors != null );

            if ( !searchOptions.IsValueCreated )
                return;

            var options = searchOptions.Value;
            var searchContract = behaviors.OfType<SearchContractBehavior>().FirstOrDefault();

            if ( searchContract == null )
            {
                searchContract = new SearchContractBehavior();
                behaviors.Add( searchContract );
            }

            searchContract.SearchHistoryEnabled = options.SearchHistoryEnabled;
            searchContract.ShowOnKeyboardInput = options.ShowOnKeyboardInput;

            if ( !string.IsNullOrEmpty( options.PlaceholderText ) )
                searchContract.PlaceholderText = options.PlaceholderText;

            if ( !string.IsNullOrEmpty( options.SearchHistoryContext ) )
                searchContract.SearchHistoryContext = options.SearchHistoryContext;
        }
Esempio n. 2
0
        private void ConfigureOrCreateSettingsContract( BehaviorCollection behaviors )
        {
            Contract.Requires( behaviors != null );

            var settingsContract = behaviors.OfType<SettingsContractBehavior>().FirstOrDefault();

            if ( settingsContract == null )
            {
                settingsContract = new SettingsContractBehavior();
                behaviors.Add( settingsContract );
            }

            foreach ( var appSetting in appSettings )
            {
                var setting = new ApplicationSetting()
                {
                    Name = appSetting.Item2,
                    ViewTypeName = appSetting.Item3
                };

                if ( !string.IsNullOrEmpty( appSetting.Item1 ) )
                    setting.Id = appSetting.Item1;

                settingsContract.ApplicationSettings.Add( setting );
            }
        }