private SerializationMode GetSerializationMode(IResourceSerializer serializer, IResource resource, IResourceProperty property) { SerializationMode serMode = serializer.GetSerializationMode(resource, property.Name); if (serMode == SerializationMode.Default) { IPropType propType = Core.ResourceStore.PropTypes [property.Name]; if (propType.HasFlag(PropTypeFlags.AskSerialize)) { return(SerializationMode.AskSerialize); } if (propType.HasFlag(PropTypeFlags.NoSerialize)) { return(SerializationMode.NoSerialize); } if (property.DataType == PropDataType.Link && propType.HasFlag(PropTypeFlags.Internal)) { return(SerializationMode.NoSerialize); } return(SerializationMode.Serialize); } return(serMode); }
private void WriteResource2Entry(IResource res, XmlTextWriter writer) { writer.WriteStartElement("resource"); writer.WriteAttributeString("type", res.Type); writer.WriteAttributeString("id", res.Id.ToString()); IPropertyCollection props = res.Properties; foreach (IResourceProperty prop in props) { IPropType type = Core.ResourceStore.PropTypes[prop.Name]; if (!type.HasFlag(PropTypeFlags.Internal)) { WriteResourceProperty2Entry(res, prop, writer); } } writer.WriteEndElement(); }
/** * Checks if any of the resources in the list has the property with * the specified ID. */ public virtual bool HasProp(int propID) { lock (this) { if (_propertyProviders != null) { for (int i = 0; i < _propertyProviders.Count; i++) { if ((_propertyProviders [i] as IPropertyProvider).HasProp(propID)) { return(true); } } } IPropType propType = MyPalStorage.Storage.PropTypes [propID]; if (propType.HasFlag(PropTypeFlags.Virtual)) { return(false); } PropDataType dataType = propType.DataType; if (dataType == PropDataType.LongString || dataType == PropDataType.Blob || dataType == PropDataType.Double) { Instantiate(); for (int i = 0; i < _list.Count; i++) { IResource res = MyPalStorage.Storage.TryLoadResource(_list [i]); if (res != null && res.HasProp(propID)) { return(true); } } return(false); } } return(Intersect(MyPalStorage.Storage.FindResourcesWithProp(null, propID)).Count > 0); }
/// <summary> /// Return true if link with the given Id is an "account" link, that /// is connects a Contact and Account resource types. /// </summary> /// <param name="linkId">Id of a link.</param> public static bool IsAccountLink(int linkId) { IPropType type = Core.ResourceStore.PropTypes[linkId]; return((type != null) && type.HasFlag(PropTypeFlags.ContactAccount)); }