Ejemplo n.º 1
0
        public SimulatedDateTimeProvider(SimulatedDateTimeProviderParameter parameter)
        {
            _parameter             = parameter;
            _instantiationDateTime = DateTime.Now;

            _parameter.Logger.Info($"Instantiated. Parameter DateTime: {_parameter.DateTimeToStart}, current DateTime: {_instantiationDateTime}");
        }
Ejemplo n.º 2
0
        public object Create(Type t, string name)
        {
            if (t.IsAssignableFrom(typeof(IDateTimeProvider)) && name.Contains("Fake"))
            {
                if (!_fakeDateTimeProviderDict.ContainsKey(name))
                {
                    FakeDateTimeProviderParameter param = new FakeDateTimeProviderParameter();
                    if (param.Load(name))
                    {
                        IDateTimeProvider instance = new FakeDateTimeProvider(param);
                        _fakeDateTimeProviderDict.Add(name, instance);
                        return(instance);
                    }
                }
                else
                {
                    return(_fakeDateTimeProviderDict[name]);
                }
            }

            if (t.IsAssignableFrom(typeof(IDateTimeProvider)) && name.Contains("Simulated"))
            {
                if (!_simulatedDateTimeProviderDict.ContainsKey(name))
                {
                    SimulatedDateTimeProviderParameter param = new SimulatedDateTimeProviderParameter();
                    if (param.Load(name))
                    {
                        IDateTimeProvider instance = new SimulatedDateTimeProvider(param);
                        _simulatedDateTimeProviderDict.Add(name, instance);
                        return(instance);
                    }
                }
                else
                {
                    return(_simulatedDateTimeProviderDict[name]);
                }
            }

            if (t.IsAssignableFrom(typeof(IDateTimeProvider)))
            {
                if (!_standardDateTimeProviderDict.ContainsKey(name))
                {
                    IDateTimeProvider instance = new StandardDateTimeProvider(name);
                    _standardDateTimeProviderDict.Add(name, instance);
                    return(instance);
                }
                else
                {
                    return(_standardDateTimeProviderDict[name]);
                }
            }

            return(null);
        }