public RootPlusDynamicIdItemPagesNavigator(NonNullList <NonBlankTrimmedString> parentSegments, IDispatcher dispatcher) : base(parentSegments, dispatcher)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            _getRoot = AddRelativeRoute(
                segments: NonNullList <string> .Empty,
                routeAction: new NavigateToRoot <T>(),
                urlGenerator: () => GetPath()
                );

            _getItem = AddRelativeRoute(
                routeDetails: RouteBuilder.Empty.Fixed("item").String(),
                routeActionGenerator: matchedValue => new NavigateToItem <T>(matchedValue),
                urlGenerator: matchedValue => GetPath("item", matchedValue)
                );

            _getItemSomething = AddRelativeRoute(
                routeDetails: RouteBuilder.Empty.Fixed("item").String().Int(),
                routeActionGenerator: (name, index) => new NavigateToItem <T>(name),
                urlGenerator: (name, index) => GetPath("item", name, index)
                );
        }
コード例 #2
0
        public NavigatorTestingDetails(TNavigator navigator, IInteractWithBrowserRouting historyHandler, IDispatcher dispatcher, Assert assert)
        {
            if (navigator == null)
            {
                throw new ArgumentNullException("navigator");
            }
            if (historyHandler == null)
            {
                throw new ArgumentNullException("historyHandler");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }
            if (assert == null)
            {
                throw new ArgumentNullException("assert");
            }

            _receivedNavigationActions = NonNullList <INavigationDispatcherAction> .Empty;
            dispatcher.Receive(action => {
                var navigationDispatcherAction = action as INavigationDispatcherAction;
                if (navigationDispatcherAction != null)
                {
                    _receivedNavigationActions = _receivedNavigationActions.Add(navigationDispatcherAction);
                }
            });

            _historyHandler        = historyHandler;
            _assert                = assert;
            _actionsConfirmedSoFar = 0;
            Navigator              = navigator;
        }
コード例 #3
0
        public RootPlusHotelAndRestaurantSectionsNavigator(IDispatcher dispatcher) : base(NonNullList <NonBlankTrimmedString> .Empty, dispatcher)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            // This is the only route that this class directly creates..
            _getRoot = AddRelativeRoute(
                segments: NonNullList <string> .Empty,
                routeAction: new NavigateToRoot(),
                urlGenerator: () => GetPath()
                );

            // .. however it does also create some other navigators that will declare routes under the "hotel" section and the "restaurant" section
            // (and we'll need to add the routes that these navigators declare to this instance's total set of known routes()
            PullInRoutesFrom(Hotels = new RootPlusDynamicIdItemPagesNavigator <Hotel>(
                                 parentSegments: NonNullList.Of(new NonBlankTrimmedString("hotel")),
                                 dispatcher: dispatcher
                                 ));
            PullInRoutesFrom(Restaurants = new RootPlusDynamicIdItemPagesNavigator <Restaurant>(
                                 parentSegments: NonNullList.Of(new NonBlankTrimmedString("restaurant")),
                                 dispatcher: dispatcher
                                 ));
        }
コード例 #4
0
        private Html5HistoryRouter()
        {
            _navigatedCallbacks = NonNullList <Action <UrlDetails> > .Empty;
            LastNavigatedToUrl  = null;

            Window.AddEventListener(EventType.PopState, e => RaiseNavigateToForCurrentLocation());
        }
コード例 #5
0
        public ActionsRaisers(Resolution resolution, Layers layers, NonNullList <IActionConfigurationMouse> actionConfigurations)
        {
            if (resolution == null)
            {
                throw new ArgumentNullException(nameof(resolution));
            }
            if (layers == null)
            {
                throw new ArgumentNullException(nameof(layers));
            }
            if (actionConfigurations == null)
            {
                throw new ArgumentNullException(nameof(actionConfigurations));
            }

            var controls = layers.Controls.CanvasElement;

            var actionsEvents = new Dictionary <int, IEvents>();

            foreach (var action in actionConfigurations)
            {
                actionsEvents.Add(action.Id, new Events(resolution, action, controls, layers.Wrapper));
            }

            Events = actionsEvents;

            controls.OnMouseDown = (e) => InputMouseDown(e);
            controls.OnMouseUp   = (e) => InputMouseUp(e);
            controls.OnMouseMove = (e) => InputMouseMove(e);
        }
コード例 #6
0
 public Props(string className,
              NonNullList <SavedMessageDetails> messages
              )
 {
     this.CtorSet(_ => _.ClassName, className);
     this.CtorSet(_ => _.Messages, messages);
 }
コード例 #7
0
        public ActionsRaisers(NonNullList <IActionConfiguration> actionConfigurations, NonNullList <IActionsRaisers> actionsRaisers)
        {
            if (actionConfigurations == null)
            {
                throw new ArgumentNullException(nameof(actionConfigurations));
            }
            if (actionsRaisers == null)
            {
                throw new ArgumentNullException(nameof(actionsRaisers));
            }

            var actionsEvents = new Dictionary <int, IEvents>();

            foreach (var action in actionConfigurations)
            {
                actionsEvents.Add(
                    action.Id,
                    new Events(
                        NonNullList.Of(
                            actionsRaisers
                            .SelectMany(actionsRaiser => actionsRaiser.Events)
                            .Where(eventsDictionary => eventsDictionary.Key == action.Id)
                            .Select(eventsDictionary => eventsDictionary.Value)
                            .ToArray()
                            )
                        )
                    );
            }

            Events = actionsEvents;
        }
コード例 #8
0
 public void RegisterForNavigatedCallback(Action <UrlDetails> callback)
 {
     if (callback == null)
     {
         throw new ArgumentNullException("callback");
     }
     _navigatedCallbacks = _navigatedCallbacks.Add(callback);
 }
コード例 #9
0
        public QueryString(NonNullList <Segment> segments)
        {
            if (segments == null)
            {
                throw new ArgumentNullException("segments");
            }

            _segments = segments;
        }
コード例 #10
0
        private RouteBuilder(NonNullList <NonBlankTrimmedString> segments)
        {
            if (segments == null)
            {
                throw new ArgumentNullException("segments");
            }

            _segments = segments;
        }
コード例 #11
0
        public Events(NonNullList <IEvents> eventsReaders)
        {
            if (eventsReaders == null)
            {
                throw new ArgumentNullException(nameof(eventsReaders));
            }

            _eventsReaders = eventsReaders;
        }
コード例 #12
0
        private NavigateActionMatcher(NonNullList <Matcher> navigateActionMatchers)
        {
            if (navigateActionMatchers == null)
            {
                throw new ArgumentNullException("navigateActionMatchers");
            }

            _navigateActionMatchers = navigateActionMatchers;
        }
コード例 #13
0
 internal DataPackagePropertySet()
 {
     _fileTypes = new Lazy <IList <string> >(() =>
     {
         var fileTypes = new NonNullList <string>();
         SetValue(fileTypes, false, nameof(FileTypes));
         return(fileTypes);
     });
 }
コード例 #14
0
        public ActionRaisers(NonNullList <IActionRaisers> actionsRaisers)
        {
            if (actionsRaisers == null)
            {
                throw new ArgumentNullException(nameof(actionsRaisers));
            }

            _actionsRaisers = actionsRaisers;
        }
コード例 #15
0
 public MessageHistory(
     NonNullList <SavedMessageDetails> messages,
     string className
     )
     : base(new Props(
                className,
                messages
                ))
 {
 }
コード例 #16
0
        public static Action GetAction(this NonNullList <Action> actions, int actionId)
        {
            var action = actions.Where(_ => _.Id == actionId).FirstOrDefault();

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            return(action);
        }
コード例 #17
0
            private BuilderWithExtractedValues(NonNullList <IMatchSegments> segmentMatchers, Optional <Func <NonNullList <object>, TValues> > extractedValueBuilder)
            {
                if (segmentMatchers == null)
                {
                    throw new ArgumentNullException("segmentMatchers");
                }

                _segmentMatchers       = segmentMatchers;
                _extractedValueBuilder = extractedValueBuilder;
            }
コード例 #18
0
        private Actions(Resolution resolution, Layers layers, NonNullList <IActionTouch> actionConfigurations)
        {
            var controls = layers.Controls.CanvasElement;

            controls.OnTouchEnd    = OnTouchEndLeaveAndCancel;
            controls.OnTouchLeave  = OnTouchEndLeaveAndCancel;
            controls.OnTouchCancel = OnTouchEndLeaveAndCancel;

            controls.OnTouchStart = (e) =>
            {
                e.PreventDefault();

                var touches = e.ChangedTouches;
                foreach (var touch in touches)
                {
                    if (_currentTouches.ContainsKey(touch.Identifier))
                    {
                        continue;
                    }



                    _currentTouches.Add(
                        touch.Identifier,
                        new DynamicPoint(
                            resolution.GetEventX(layers.Wrapper, touch),
                            resolution.GetEventY(layers.Wrapper, touch),
                            resolution.RenderAmount(1)
                            )
                        );

                    InputTouchDown(touch);
                }
            };

            controls.OnTouchMove = (e) =>
            {
                var touches = e.ChangedTouches;
                foreach (var touch in touches)
                {
                    if (!_currentTouches.ContainsKey(touch.Identifier))
                    {
                        continue;
                    }

                    _currentTouches.Get(touch.Identifier)
                    .Reset(
                        resolution.GetEventX(layers.Wrapper, touch),
                        resolution.GetEventY(layers.Wrapper, touch)
                        );

                    InputTouchMove(touch);
                }
            };
        }
コード例 #19
0
ファイル: TodoApp.cs プロジェクト: widra/Bridge.React
 protected override State GetInitialState()
 {
     return(new State(
                inputValue: "",
                todos: NonNullList.Of(
                    new TaskDetails(_nextAvailableId++, "Learn C#", done: true),
                    new TaskDetails(_nextAvailableId++, "Learn React", done: false),
                    new TaskDetails(_nextAvailableId++, "Build an awesome app with C# and React", done: false)
                    )
                ));
 }
コード例 #20
0
        public MockHistoryHandler(UrlDetails initialUrl)
        {
            if (initialUrl == null)
            {
                throw new ArgumentNullException("initialUrl");
            }

            _navigatedCallbacks = NonNullList <Action <UrlDetails> > .Empty;
            CurrentLocation     = initialUrl;
            LastNavigatedToUrl  = null;
        }
コード例 #21
0
        public One(ICore core)
        {
            if (core == null)
            {
                throw new ArgumentNullException(nameof(core));
            }

            _core = core;
            _core.Layers.Reset(NonNullList.Of(0));
            _core.Layers.Controls.Clear();
        }
コード例 #22
0
        public Level(ICore core)
        {
            if (core == null)
            {
                throw new ArgumentNullException(nameof(core));
            }

            _core = core;
            _core.Layers.Reset(NonNullList.Of(0));
            _core.ActivateActions();
            _resourcePool = new ResourcePool();
        }
コード例 #23
0
            public StaticRouteDetails(NonNullList <NonBlankTrimmedString> segments, Action <Optional <QueryString> > ifMatched)
            {
                if (segments == null)
                {
                    throw new ArgumentNullException("segments");
                }
                if (ifMatched == null)
                {
                    throw new ArgumentNullException("ifMatched");
                }

                _segments  = segments;
                _ifMatched = ifMatched;
            }
コード例 #24
0
        public Touch(ICore core)
        {
            if (core == null)
            {
                throw new ArgumentNullException(nameof(core));
            }

            _core = core;
            _core.Layers.Reset(NonNullList.Of(0));
            _core.Layers.Controls.Clear();

            _textBox = new TextBox("Touch", _core.Resolution.MultiplyClamp(10), _core.Resolution);
            _textBox.UpdatePosition(_core.Resolution.MultiplyClamp(4), _core.Resolution.MultiplyClamp(4));
        }
コード例 #25
0
                public VariableRouteDetails(NonNullList <IMatchSegments> segmentMatchers, Optional <Func <NonNullList <object>, TValues> > extractedValueBuilder, Action <TValues, Optional <QueryString> > ifMatched)
                {
                    if (segmentMatchers == null)
                    {
                        throw new ArgumentNullException("segmentMatchers");
                    }
                    if (ifMatched == null)
                    {
                        throw new ArgumentNullException("ifMatched");
                    }

                    _segmentMatchers       = segmentMatchers;
                    _extractedValueBuilder = extractedValueBuilder;
                    _ifMatched             = ifMatched;
                }
コード例 #26
0
        public RouteBuilder Fixed(NonNullList <NonBlankTrimmedString> segments)
        {
            if (segments == null)
            {
                throw new ArgumentNullException("segments");
            }

            var newRouteBuilder = this;

            foreach (var segment in segments)
            {
                newRouteBuilder = newRouteBuilder.Fixed(segment);
            }
            return(newRouteBuilder);
        }
コード例 #27
0
                protected ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression> MaterializeArray <Elements>(
                    APC postPC, ArraySegmentationEnvironment <Elements, BoxedVariable <Variable>, BoxedExpression> preState,
                    Func <BoxedExpression, FlatAbstractDomain <bool> > CheckIfNonZero, Variable arrayValue, Elements initialValue, Elements bottom)
                    where Elements : class, IAbstractDomainForArraySegmentationAbstraction <Elements, BoxedVariable <Variable> >
                {
                    Contract.Requires(preState != null);
                    Contract.Requires(initialValue != null);

                    var boxSym = new BoxedVariable <Variable>(arrayValue);

                    ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression> arraySegment;

                    if (preState.TryGetValue(boxSym, out arraySegment))
                    {
                        return(arraySegment); // already materialized
                    }

                    Variable array_Length;

                    if (this.Context.ValueContext.TryGetArrayLength(postPC, arrayValue, out array_Length))
                    {
                        var isNonEmpty = CheckIfNonZero(this.ToBoxedExpression(postPC, array_Length)).IsTrue();

                        var limits = new NonNullList <SegmentLimit <BoxedVariable <Variable> > >()
                        {
                            new SegmentLimit <BoxedVariable <Variable> >(NormalizedExpression <BoxedVariable <Variable> > .For(0), false),                                               // { 0 }
                            new SegmentLimit <BoxedVariable <Variable> >(NormalizedExpression <BoxedVariable <Variable> > .For(new BoxedVariable <Variable>(array_Length)), !isNonEmpty) // { symb.Length }
                        };

                        var elements = new NonNullList <Elements>()
                        {
                            initialValue
                        };

                        var newSegment = new ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression>(
                            limits, elements,
                            bottom,
                            this.ExpressionManager);

                        preState.AddElement(new BoxedVariable <Variable>(arrayValue), newSegment);

                        return(newSegment);
                    }

                    return(null);
                }
コード例 #28
0
        public void Reset(NonNullList <int> ids)
        {
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }

            _stageLayers            = NonNullList.Of(ids.Select(id => new Layer(_resolution, Wrapper, id)).ToArray()); // Build up new layers.
            _stageWrapper.InnerHTML = "";                                                                              // reset HTML (there is no event listeners on the children, so this should be fine.

            foreach (var layer in _stageLayers)
            {
                _stageWrapper.AppendChild(layer.CanvasElement);
            }

            Resize(true);             // There is a chance that the window dimensions have not changed, so force the resize, otherwise it would exit early.
        }
コード例 #29
0
        public static void NoOptDeserializationWorks()
        {
            var items = new NonNullList <KeyValuePairDataModelBase>(new KeyValuePairDataModelBase[]
            {
                new KeyValuePairDataModel(),
                new AlternativeKeyValuePairDataModel()
            });
            var settings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Objects
            };

            var json         = JsonConvert.SerializeObject(items, settings);
            var cloneAsArray = JsonConvert.DeserializeObject <NonNullList <KeyValuePairDataModelBase> >(json, settings).ToArray();

            Assert.AreEqual(2, cloneAsArray.Length, "Non-optimized deserialization length");
            Assert.AreEqual(typeof(KeyValuePairDataModel), cloneAsArray[0].GetType(), "Non-optimized deserialization index 0 data type");
            Assert.AreEqual(typeof(AlternativeKeyValuePairDataModel), cloneAsArray[1].GetType(), "Non-optimized deserialization index 1 data type");
        }
コード例 #30
0
        public Zoom(ICore core)
        {
            if (core == null)
            {
                throw new ArgumentNullException(nameof(core));
            }

            _core = core;
            _core.Layers.Reset(NonNullList.Of(0));
            _core.DeactivateActions();
            _core.ActivateActions(NonNullList.Of(
                                      DefaultActions.Up,
                                      DefaultActions.Left,
                                      DefaultActions.Down,
                                      DefaultActions.Button1
                                      ));

            _resourcePool = new ResourcePool();
        }
コード例 #31
0
ファイル: Program.cs プロジェクト: Minions/Minions
 private Program([NotNull] Program program, [NotNull] ProgramFragment new_data)
 {
     _declarations = program._declarations.Concat(new_data.declarations)
         .ToNonNullList();
 }
コード例 #32
0
 public FeatureSpecification([NotNull] string feature, [NotNull] IEnumerable<Node> body)
 {
     _body = body.without_nulls()
         .ToNonNullList();
     this.feature = feature;
 }
コード例 #33
0
ファイル: RunMissions.cs プロジェクト: Minions/Minions
 public void init()
 {
     _orcs = new NonNullList<OrcishRaidProgress>();
     _all_orcs_are_sent = new ManualResetEventSlim(false);
     _target_number_of_orcs = 0;
 }
コード例 #34
0
ファイル: Program.cs プロジェクト: Minions/Minions
 private Program()
 {
     _declarations = new NonNullList<Declaration>();
 }