Esempio n. 1
0
        private static Entity Load(Type type)
        {
            Attribute[] attribs  = Attribute.GetCustomAttributes(type);
            bool        isEntity = false;
            string      name     = null;

            for (int i = 0; i < attribs.Length; i++)
            {
                if (attribs[i] is ProtoContractAttribute)
                {
                    ProtoContractAttribute pca = (ProtoContractAttribute)attribs[i];
                    name     = pca.Name;
                    isEntity = true;
                    break;
                }
            }
            if (!isEntity)
            {
                for (int i = 0; i < attribs.Length; i++)
                {
                    if (attribs[i].GetType().FullName == Serializer.DataContractAttributeFullName)
                    {
                        Serializer.ParseDataContractAttribute(attribs[i], out name);
                        isEntity = true;
                        break;
                    }
                }
            }
            if (!isEntity)
            {
                for (int i = 0; i < attribs.Length; i++)
                {
                    if (attribs[i] is XmlTypeAttribute)
                    {
                        XmlTypeAttribute xta = (XmlTypeAttribute)attribs[i];
                        name     = xta.TypeName;
                        isEntity = true;
                        break;
                    }
                }
            }
            return(isEntity ? new Entity(type, name, null) : null);
        }