This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ZooChecker | |
| { | |
| public string Check(Zoo zoo) | |
| { | |
| var checks = new List<string> | |
| { | |
| ValidateCats(zoo.Cats, zoo.facility), | |
| ValidateFrogs(zoo.Frogs, zoo.facility), | |
| ValidateDolphins(zoo.Dolphins, zoo.facility), | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (this code is written only once and never be changed again || | |
| ((the developer wrote it can make changes fairly quick && never leaves the company || | |
| next developer can make changes fairly quick && never leaves the company) && | |
| has tests cover && easy to write new tests) | |
| ) | |
| { | |
| return "Not a problem"; | |
| } | |
| else | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Linq; | |
| namespace Barin.RuleEngine.NonAsyncEngine | |
| { | |
| public abstract class Rule<T> | |
| { | |
| public int Priority { get; set; } | |
| public abstract bool IsValid(T ctx); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using Barin.RuleEngine.Util; | |
| namespace Barin.RuleEngine.NonAsyncRules | |
| { | |
| public class CatRuleCtx | |
| { | |
| public Guid Id { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ctx = new CatRuleCtx(); | |
| var catRules = new CatRules(ctx); | |
| var result = catRules.FirstFails(); | |
| result == "Ok" ? | |
| Console.WriteLine("Ok") : | |
| Console.WriteLine("Name of failed rule: " + result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| switch (action.type) { | |
| case actions.GET_CAT_REQUEST: | |
| return { ...state, isFetching: true } | |
| case actions.GET_CAT_SUCCESS: | |
| return { ...state, isFetching: false, payload: action.payload } | |
| case actions.GET_CAT_ERROR: | |
| return { ...state, isFetching: false, error: action.error } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as actions from '../actions/cats' | |
| const firstCat: ICat = { | |
| isFetching: false, | |
| error: undefined, | |
| payload: undefined | |
| } | |
| export const cat = (state: ICat = firstCat, action: any) => { | |
| // Computed property names (ES2015) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function* requestCat() { | |
| try { | |
| const resp = yield call(catService.get) | |
| yield put(actions.requestCatSuccess(resp)) | |
| } catch (err) { | |
| yield put(actions.requestCatError(err)) | |
| } | |
| } | |
| export function* requestDog() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as actions from '../actions' | |
| import { catService } from '../catServices' | |
| import { put, call, takeLatest } from 'redux-saga/effects' | |
| const safe = (handler:any = null, saga:any, ...args:any) => function* (action:any) { | |
| try { | |
| yield call(saga, ...args, action) | |
| } catch (err) { | |
| yield call(handler, ...args, err) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore, applyMiddleware, compose } from 'redux' | |
| import RootReducer from './reducers' | |
| import createSagaMiddleware from 'redux-saga' | |
| import rootSaga from './sagas' | |
| //option 1 | |
| const sagaMiddleware = createSagaMiddleware({ | |
| onError: (err) => { | |
| store.dispatch({ type: 'ERROR', payload: err }) | |
| } |
OlderNewer