コード例 #1
0
ファイル: FuncSet.cs プロジェクト: flippynips/EFZ
        override public bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            FuncSet <TReturn> funcSet = obj as FuncSet <TReturn>;

            if (funcSet == null)
            {
                return(false);
            }
            return(this.Equals(funcSet));
        }
コード例 #2
0
        /// <summary>
        /// This function will find all Singleton classes, instantiate them
        /// and call their 'initialize' methods in order of Priority.
        /// </summary>
        public static void Initialize()
        {
            // load assemblies - only once
            LoadAssemblies();

            // get all singleton types
            ArrayRig <Type> singletonTypes = new ArrayRig <Type>();

            foreach (var type in Generic.GetTypes(typeof(ISingleton)))
            {
                singletonTypes.Add(type);
            }

            FuncSet <ISingleton>[] constructors = new FuncSet <ISingleton> [singletonTypes.Count];
            ArrayRig <ISingleton>  singles      = new ArrayRig <ISingleton>(singletonTypes.Count);

            // get singleton constructors
            for (int i = 0; i < singletonTypes.Count; ++i)
            {
                constructors[i] = Dynamic.Constructor <FuncSet <ISingleton> >(singletonTypes[i]);
            }
            // create all singletons
            for (int i = 0; i < constructors.Length; ++i)
            {
                singles.Add(constructors[i].Func());
            }

            // sort singletons in order of decending priority
            singles.Sort((a, b) => Generic.GetValue <byte>(a, "SingletonPriority") > Generic.GetValue <byte>(b, "SingletonPriority"));

            // get the array
            _singletons = singles.ToArray();

            // initialize in decending order of priority
            for (int i = 0; i < _singletons.Length; ++i)
            {
                // invoke generic initialize method
                Type type = _singletons[i].GetType();
                type.BaseType.GetMethod("initialize", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(_singletons[i], null);
                Log.Info("Created " + type.Name);
            }
        }
コード例 #3
0
ファイル: FuncSet.cs プロジェクト: flippynips/EFZ
 public bool Equals(FuncSet <TReturn> other)
 {
     return(other.Func.Equals(Func));
 }