Beispiel #1
0
        public T Get <T> () where T : SState, new ()
        {
            SState state = null;

            this.states.TryGetValue(typeof(T), out state);

            if (state != null)
            {
                return((T)state);
            }

            FactoryFunc <SState> factoryMethod = null;

            this.factories.TryGetValue(typeof(T), out factoryMethod);

            if (factoryMethod != null)
            {
                return((T)factoryMethod.Invoke());
            }

            var newState = new T();

            newState.Context = this;

            return(newState);
        }
Beispiel #2
0
        public static void RegisterFactory <T>(FactoryFunc <T> factory)
        {
            FactoryFunc factoryWrapper = delegate {
                return(factory());
            };

            customFactoryTable[typeof(T)] = factoryWrapper;
        }
Beispiel #3
0
            static FactoryBuilder()
            {
                FactoryFunc nonPolymorphicFactory;
                var         ctor = typeof(TProxy).GetConstructor(new[] { typeof(DkmProcess), typeof(ulong) });

                if (ctor != null)
                {
                    var processParam     = Expression.Parameter(typeof(DkmProcess));
                    var addressParam     = Expression.Parameter(typeof(ulong));
                    var polymorphicParam = Expression.Parameter(typeof(bool));
                    nonPolymorphicFactory = Expression.Lambda <FactoryFunc>(
                        Expression.New(ctor, processParam, addressParam),
                        new[] { processParam, addressParam, polymorphicParam })
                                            .Compile();
                }
                else
                {
                    nonPolymorphicFactory = (process, address, polymorphic) =>
                    {
                        Debug.Fail("IDebuggeeReference-derived type " + typeof(TProxy).Name + " does not have a (DkmProcess, ulong) constructor.");
                        throw new NotSupportedException();
                    };
                }

                if (typeof(IPyObject).IsAssignableFrom(typeof(TProxy)))
                {
                    Factory = (process, address, polymorphic) =>
                    {
                        if (polymorphic)
                        {
                            return((TProxy)(object)PyObject.FromAddress(process, address));
                        }
                        else
                        {
                            return(nonPolymorphicFactory(process, address, polymorphic));
                        }
                    };
                }
                else
                {
                    Factory = nonPolymorphicFactory;
                }
            }
Beispiel #4
0
 public AnomalieCabFactory(FactoryFunc factoryFunc)
 {
     _factoryFunc = factoryFunc ?? throw new ArgumentNullException(nameof(factoryFunc));
 }
Beispiel #5
0
 public void AddFactoryFor <T> (FactoryFunc <T> method) where T : SState
 {
 }
Beispiel #6
0
 public InfosOpérationDépôtFactory(FactoryFunc factoryFunc)
 {
     _factoryFunc = factoryFunc;
 }
Beispiel #7
0
 public CabFactory(IDépôtParutions dépôtParutions,
                   FactoryFunc factoryFunc)
 {
     _dépôtParutions = dépôtParutions ?? throw new ArgumentNullException(nameof(dépôtParutions));
     _factoryFunc    = factoryFunc ?? throw new ArgumentNullException(nameof(factoryFunc));
 }