コード例 #1
0
        /// <summary>
        /// Ahead of time compilations that are available. The type maps to the
        /// object type the generated converter will serialize/deserialize, and
        /// the string is the text content for a converter that will do the
        /// serialization.
        /// <para/>
        /// The generated serializer is completely independent and you don't need
        /// to do anything. Simply add the file to your project and it'll get
        /// used instead of the reflection based one.
        /// </summary>
        public static string RunAotCompilationForType(fsConfig config, Type type)
        {
            fsMetaType metatype = fsMetaType.Get(config, type);

            metatype.EmitAotData(/*throwException:*/ true);
            return(GenerateDirectConverterForTypeInCSharp(type, metatype.Properties, metatype.IsDefaultConstructorPublic));
        }
コード例 #2
0
ファイル: fsMetaType.cs プロジェクト: tryonn/GameStartUP
        public static fsMetaType Get(Type type) {
            fsMetaType metaType;
            if (_metaTypes.TryGetValue(type, out metaType) == false) {
                metaType = new fsMetaType(type);
                _metaTypes[type] = metaType;
            }

            return metaType;
        }
コード例 #3
0
ファイル: fsMetaType.cs プロジェクト: jjhester/BattleshipGUI
        public static fsMetaType Get(Type type)
        {
            fsMetaType metaType;

            if (_metaTypes.TryGetValue(type, out metaType) == false)
            {
                metaType         = new fsMetaType(type);
                _metaTypes[type] = metaType;
            }

            return(metaType);
        }
コード例 #4
0
ファイル: fsMetaType.cs プロジェクト: Wuzseen/DIGM530-AWT
        public static fsMetaType Get(fsConfig config, Type type) {
            Dictionary<Type, fsMetaType> metaTypes;
            if (_configMetaTypes.TryGetValue(config, out metaTypes) == false)
                metaTypes = _configMetaTypes[config] = new Dictionary<Type, fsMetaType>();

            fsMetaType metaType;
            if (metaTypes.TryGetValue(type, out metaType) == false) {
                metaType = new fsMetaType(config, type);
                metaTypes[type] = metaType;
            }

            return metaType;
        }
コード例 #5
0
ファイル: fsConverterRegistrar.cs プロジェクト: ycarowr/Tools
        static fsConverterRegistrar()
        {
            Converters = new List <Type>();

            foreach (FieldInfo field in typeof(fsConverterRegistrar).GetDeclaredFields())
            {
                if (field.Name.StartsWith("Register_"))
                {
                    Converters.Add(field.FieldType);
                }
            }

            foreach (MethodInfo method in typeof(fsConverterRegistrar).GetDeclaredMethods())
            {
                if (method.Name.StartsWith("Register_"))
                {
                    method.Invoke(null, null);
                }
            }

            // Make sure we do not use any AOT Models which are out of date.
            List <Type> finalResult = new List <Type>(Converters);

            foreach (Type t in Converters)
            {
                object instance = null;
                try
                {
                    instance = Activator.CreateInstance(t);
                }
                catch (Exception)
                {
                }

                fsIAotConverter aotConverter = instance as fsIAotConverter;
                if (aotConverter != null)
                {
                    fsMetaType modelMetaType = fsMetaType.Get(new fsConfig(), aotConverter.ModelType);
                    if (fsAotCompilationManager.IsAotModelUpToDate(modelMetaType, aotConverter) == false)
                    {
                        finalResult.Remove(t);
                    }
                }
            }

            Converters = finalResult;
        }
コード例 #6
0
        public static fsMetaType Get(fsConfig config, Type type)
        {
            Dictionary <Type, fsMetaType> metaTypes;

            if (_configMetaTypes.TryGetValue(config, out metaTypes) == false)
            {
                metaTypes = _configMetaTypes[config] = new Dictionary <Type, fsMetaType>();
            }

            fsMetaType metaType;

            if (metaTypes.TryGetValue(type, out metaType) == false)
            {
                metaType        = new fsMetaType(config, type);
                metaTypes[type] = metaType;
            }

            return(metaType);
        }
コード例 #7
0
        // Token: 0x060004CE RID: 1230 RVA: 0x0001DAD4 File Offset: 0x0001BCD4
        public static fsMetaType Get(fsConfig config, Type type)
        {
            Dictionary <Type, fsMetaType> dictionary;

            if (!fsMetaType._configMetaTypes.TryGetValue(config, out dictionary))
            {
                Dictionary <Type, fsMetaType> dictionary2 = new Dictionary <Type, fsMetaType>();
                fsMetaType._configMetaTypes[config] = dictionary2;
                dictionary = dictionary2;
            }
            fsMetaType fsMetaType;

            if (!dictionary.TryGetValue(type, out fsMetaType))
            {
                fsMetaType       = new fsMetaType(config, type);
                dictionary[type] = fsMetaType;
            }
            return(fsMetaType);
        }
コード例 #8
0
        /// <summary>
        /// Returns true if the given aotModel can be used. Returns false if it needs to
        /// be recompiled.
        /// </summary>
        public static bool IsAotModelUpToDate(fsMetaType currentModel, fsIAotConverter aotModel)
        {
            if (currentModel.IsDefaultConstructorPublic != aotModel.VersionInfo.IsConstructorPublic)
            {
                return(false);
            }

            if (currentModel.Properties.Length != aotModel.VersionInfo.Members.Length)
            {
                return(false);
            }

            foreach (fsMetaProperty property in currentModel.Properties)
            {
                if (HasMember(aotModel.VersionInfo, new fsAotVersionInfo.Member(property)) == false)
                {
                    return(false);
                }
            }

            return(true);
        }