public StoryBuilder( IStoryFactory factory, IStoryAccess access = null) { _access = access; _factory = factory; }
public StoryService(ITravelGuideContext context, IStoryFactory storyFactory, IStoryLikeFactory likesFactory, IStoryCommentFactory commentsFactory) { if (context == null) { throw new ArgumentNullException(); } if (storyFactory == null) { throw new ArgumentNullException(); } if (likesFactory == null) { throw new ArgumentNullException(); } if (commentsFactory == null) { throw new ArgumentNullException(); } this.context = context; this.storyFactory = storyFactory; this.likesFactory = likesFactory; this.commentsFactory = commentsFactory; }
/// <summary> /// Initializes a new instance of the <see cref="StoryReturn{TStoryContext}"/> class. /// </summary> /// <param name="access">Доступность к стои</param> /// <param name="factory">Фабрика истории</param> /// <param name="context">Контекст истории</param> public StoryReturn( IStoryAccess access, IStoryFactory factory, TStoryContext context) { _access = access; _factory = factory ?? throw new ArgumentNullException(nameof(factory)); _context = context; }
/// <summary> /// Creates a story and starts it. /// </summary> /// <param name="storyFactory">The story factory.</param> /// <param name="name">The name.</param> /// <returns> /// The new started story. /// </returns> public static IStory StartNew(this IStoryFactory storyFactory, string name) { Ensure.ArgumentNotNull(storyFactory, "storyFactory"); IStory story = storyFactory.CreateStory(name); story.Start(); return(story); }
/// <summary> /// Invokes the task to be observed by this story. /// </summary> /// <param name="storyFactory">The story factory.</param> /// <param name="name">The name.</param> /// <param name="func">Function returning a task to observe.</param> /// <returns> /// The task observed by this story. /// </returns> public static Task StartNewAsync(this IStoryFactory storyFactory, string name, Func <Task> func) { Ensure.ArgumentNotNull(storyFactory, "storyFactory"); Ensure.ArgumentNotNull(func, "func"); IStory story = storyFactory.CreateStory(name); story.Start(); Task result = func(); result.ContinueWith(story.Stop, TaskContinuationOptions.ExecuteSynchronously); return(result); }
/// <summary> /// Invokes the task to be observed by this story. /// </summary> /// <param name="storyFactory">The story factory.</param> /// <param name="name">The name.</param> /// <param name="action">Action to observe.</param> public static void StartNew(this IStoryFactory storyFactory, string name, Action action) { Ensure.ArgumentNotNull(storyFactory, "storyFactory"); Ensure.ArgumentNotNull(action, "action"); IStory story = storyFactory.CreateStory(name); try { story.Start(); action(); } catch (Exception exception) { story.Data["exception"] = exception; throw; } finally { story.Stop(); } }
/// <summary> /// Invokes the task to be observed by this story. /// </summary> /// <typeparam name="T">The task result type.</typeparam> /// <param name="storyFactory">The story factory.</param> /// <param name="name">The name.</param> /// <param name="func">Function returning a task to observe.</param> /// <returns> /// The result. /// </returns> public static T StartNew <T>(this IStoryFactory storyFactory, string name, Func <T> func) { Ensure.ArgumentNotNull(storyFactory, "storyFactory"); Ensure.ArgumentNotNull(func, "func"); IStory story = storyFactory.CreateStory(name); try { story.Start(); return(func()); } catch (Exception exception) { story.Data["exception"] = exception; throw; } finally { story.Stop(); } }
public StoryRepository(IStoryFactory StoryFactory, IConcernFactory concern_factory) { this.StoryFactory = StoryFactory; this.concern_factory = concern_factory; }