Beispiel #1
0
        public void UpdateMeta(int serialLength)
        {
            BulkDataStartOffset += serialLength - Exports.First().SerialSize;
            Exports.First().SerialSize = serialLength;
            NameCount = Names.Length;
            int num  = 193;
            int num2 = 0;

            FNameEntry[] names = Names;
            foreach (FNameEntry fNameEntry in names)
            {
                num2 += fNameEntry.GetLength();
            }
            int num3 = ImportCount * 28;
            int num4 = ExportCount * 108;

            ImportOffset            = num + num2;
            ExportOffset            = num + num2 + num3;
            DependsOffset           = num + num2 + num3 + num4 - 4;
            TotalHeaderSize         = num + num2 + num3 + num4 + 4;
            AssetRegistryDataOffset = num + num2 + num3 + num4;
            PreloadDependencyOffset = TotalHeaderSize;
            Generations.First().NameCount = Names.Length;
            Exports.First().SerialOffset  = TotalHeaderSize;
        }
Beispiel #2
0
        /// <summary>
        /// Expects there to be only one export of the interface T
        /// If several exists the first export will be used
        ///
        /// To get a specific type use the the overloads of Get
        /// </summary>
        /// <returns></returns>
        public static T Get()
        {
            if (ExportAttribute.InstanceRule == InstanceRule.Multiple)
            {
                Activator.CreateInstance(Exports.First());
            }
            //throw new Exception("Cant get singleton from type marked as multiple");

            return(Singleton);
        }
Beispiel #3
0
        public static T Get(Type t)
        {
            if (ExportAttribute.InstanceRule == InstanceRule.Singleton)
            {
                return(Get());
            }

            if (t.IsInterface)
            {
                return((T)Exports.First().GetInstance()); //(T)Activator.CreateInstance(Exports.First());
            }
            return((T)Activator.CreateInstance(Exports.First(p => p == t)));
        }