Пример #1
0
        internal static FluidityContext EnsureContext(FluidityConfig config,
                                                      FluidityDataContext data,
                                                      FluidityServiceContext services,
                                                      bool replaceContext = false)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            // if there's already a singleton, and we're not replacing then there's no need to ensure anything
            if (Current != null)
            {
                if (replaceContext == false)
                {
                    return(Current);
                }
            }

            var fluidityContext = new FluidityContext(config, data, services);

            // assign the singleton
            Current = fluidityContext;

            return(Current);
        }
Пример #2
0
 internal FluidityContext(FluidityConfig config,
                          FluidityDataContext data,
                          FluidityServiceContext services)
 {
     Config   = config;
     Data     = data;
     Services = services;
 }