public void CanSerializeAndDeserializeXML()
        {
            var obj = new FieldDefinition();
            var service = new DefaultXMLSerializationService();

            var strValue = service.Serialize(obj);
            service.Deserialize(obj.GetType(), strValue);
        }
        public void CanSerializeAndDeserializeJSON()
        {
            var obj = new FieldDefinition();
            var jsonService = new DefaultJSONSerializationService();

            var strValue = jsonService.Serialize(obj);
            jsonService.Deserialize(obj.GetType(), strValue);

        }
        // protected Site HostSite { get; set; }

        protected Field GetField(object modelHost, FieldDefinition definition)
        {
            if (modelHost is SiteModelHost)
                return FindExistingSiteField(modelHost as SiteModelHost, definition);
            if (modelHost is WebModelHost)
                return FindExistingWebField(modelHost as WebModelHost, definition);
            else if (modelHost is ListModelHost)
                return FindExistingListField((modelHost as ListModelHost).HostList, definition);
            else
            {
                throw new SPMeta2NotSupportedException(
                    string.Format("Validation for artifact of type [{0}] under model host [{1}] is not supported.",
                    definition.GetType(),
                    modelHost.GetType()));
            }
        }
Beispiel #4
0
        protected Field FindField(object modelHost, FieldDefinition definition)
        {
            if (modelHost is SiteModelHost)
                return FindExistingSiteField(modelHost as SiteModelHost, definition);

            if (modelHost is WebModelHost)
                return FindExistingWebField(modelHost as WebModelHost, definition);

            if (modelHost is ListModelHost)
                return FindExistingListField((modelHost as ListModelHost).HostList, definition);

            TraceService.ErrorFormat((int)LogEventId.ModelProvisionCoreCall, "FindField() does not support modelHost of type: [{0}]. Throwing SPMeta2NotSupportedException", modelHost);

            throw new SPMeta2NotSupportedException(
                string.Format("Validation for artifact of type [{0}] under model host [{1}] is not supported.",
                    definition.GetType(),
                    modelHost.GetType()));
        }