Exemplo n.º 1
0
        internal static void RegisterXmlElements(YamsterModelType modelType,
                                                 Type classType, Type enumType)
        {
            if (!typeof(YqlPropertyNode).IsAssignableFrom(classType))
            {
                throw new ArgumentException("The classType must inherit from YqlPropertyNode");
            }
            if (!enumType.IsEnum)
            {
                throw new ArgumentException("The enumType must be an enum");
            }

            foreach (Enum enumValue in Enum.GetValues(enumType))
            {
                // E.g. "Message_UserIdRepliedTo"
                string xmlName = modelType.ToString() + "_" + enumValue.ToString();
                YqlNode.RegisterXmlElement(classType, xmlName);
            }
        }
Exemplo n.º 2
0
        static public Type GetModelClass(YamsterModelType modelType)
        {
            switch (modelType)
            {
            case YamsterModelType.Group:
                return(typeof(YamsterGroup));

            case YamsterModelType.Thread:
                return(typeof(YamsterThread));

            case YamsterModelType.Message:
                return(typeof(YamsterMessage));

            case YamsterModelType.User:
                return(typeof(YamsterUser));

            default:
                throw new NotSupportedException("Unsupported model type: " + modelType.ToString());
            }
        }