コード例 #1
0
        static VersionsManager()
        {
            m_versionConverters = new List <VersionConverter>();
            AssemblyName assemblyName = new AssemblyName(typeof(VersionsManager).GetTypeInfo().Assembly.FullName);

            Version = $"{assemblyName.Version.Major}.{assemblyName.Version.Minor}.{assemblyName.Version.Build}.{assemblyName.Version.Revision}";
            SerializationVersion = $"{assemblyName.Version.Major}.{assemblyName.Version.Minor}";
            Assembly[] array = TypeCache.LoadedAssemblies.ToArray();
            for (int i = 0; i < array.Length; i++)
            {
                foreach (TypeInfo definedType in array[i].DefinedTypes)
                {
                    if (!definedType.IsAbstract && !definedType.IsInterface && typeof(VersionConverter).GetTypeInfo().IsAssignableFrom(definedType))
                    {
                        VersionConverter item = (VersionConverter)Activator.CreateInstance(definedType.AsType());
                        m_versionConverters.Add(item);
                    }
                }
            }
        }
コード例 #2
0
        // Methods
        static VersionsManager()
        {
            AssemblyName name = new AssemblyName(IntrospectionExtensions.GetTypeInfo((Type)typeof(VersionsManager)).Assembly.FullName);

            object[] objArray1 = new object[] { (int)name.Version.Major, (int)name.Version.Minor, (int)name.Version.Build, (int)name.Version.Revision };
            Version = string.Format("{0}.{1}.{2}.{3}", (object[])objArray1);
            object[] objArray2 = new object[] { (int)name.Version.Major, (int)name.Version.Minor };
            SerializationVersion = string.Format("{0}.{1}", (object[])objArray2);
            Assembly[] assemblyArray = Enumerable.ToArray <Assembly>((IEnumerable <Assembly>)TypeCache.LoadedAssemblies);
            for (int i = 0; i < assemblyArray.Length; i++)
            {
                foreach (TypeInfo info in assemblyArray[i].DefinedTypes)
                {
                    if ((!info.IsAbstract && !info.IsInterface) && IntrospectionExtensions.GetTypeInfo((Type)typeof(VersionConverter)).IsAssignableFrom(info))
                    {
                        VersionConverter converter = (VersionConverter)Activator.CreateInstance(info.AsType());
                        m_versionConverters.Add(converter);
                    }
                }
            }
        }