Exemple #1
0
        private IAmf3Serializer GetSerializerForType(System.Type type)
        {
            IAmf3Serializer serializer;

            if (!typeToSerializer.TryGetValue(type, out serializer))
            {
                var alias = Amf3ClassDef.GetAliasFromType(type);
                if (alias != null)
                {
                    serializer = Amf3ClassDef.GetSerializerFromAlias(alias);
                    if (serializer == null)
                    {
                        // create reflection serializer
                        serializer = new ReflectionSerializer(alias, type, true, false);
                        // automatically register it
                        Amf3ClassDef.RegisterSerializer(alias, serializer);
                    }
                }
                else
                {
                    // create anonymous serializer
                    serializer = new ReflectionSerializer("*", type, true, false);
                }
                // store serializer in our local cache
                typeToSerializer.Add(type, serializer);
            }
            return(serializer);
        }
Exemple #2
0
        // gets serializer for a class alias string
        private IAmf3Serializer GetSerializerFromAlias(string alias)
        {
            IAmf3Serializer serializer = Amf3ClassDef.GetSerializerFromAlias(alias);

            if (serializer == null)
            {
                var type = Amf3ClassDef.GetTypeFromAlias(alias);
                if (type != null)
                {
                    // create reflection serializer
                    serializer = new ReflectionSerializer(alias, type, true, false);
                    // automatically register it
                    Amf3ClassDef.RegisterSerializer(alias, serializer);
                }
            }
            return(serializer);
        }