Пример #1
0
        public static void ScanType(Type type)
        {
            foreach (Type nestedType in type.GetNestedTypes())
            {
                ScanType(nestedType);
            }

            LispCustomSerializerAttribute customSerializer =
                (LispCustomSerializerAttribute)
                Attribute.GetCustomAttribute(type, typeof(LispCustomSerializerAttribute));

            if (customSerializer != null)
            {
                object instance = CreateObject(type);
                typeSerializers.Add(customSerializer.Type, (ILispSerializer)instance);
                return;
            }

            LispRootAttribute rootAttrib = (LispRootAttribute)
                                           Attribute.GetCustomAttribute(type, typeof(LispRootAttribute));

            if (rootAttrib != null)
            {
                LispRootSerializer serializer = new LispRootSerializer(type);
                typeSerializers.Add(type, serializer);
                return;
            }
        }
Пример #2
0
        public void Write(TextWriter TextWriter, string Dest, object Object)
        {
            LispRootAttribute rootAttrib = (LispRootAttribute)
                                           Attribute.GetCustomAttribute(RootType, typeof(LispRootAttribute));

            if (rootAttrib == null)
            {
                throw new LispException("Type needs to have LispRoot attribute");
            }

            Writer Writer = new Writer(TextWriter);

            Write(Writer, rootAttrib.Name, Object);
        }