private void RegisterTypes() { IResourceTypeCollection resTypes = Core.ResourceStore.ResourceTypes; resTypes.Register("Weblink", "Web Bookmark", "Name", ResourceTypeFlags.NoIndex, this); resTypes["Weblink"].DisplayName = "Web Bookmark"; resTypes.Register("Folder", "Name", ResourceTypeFlags.Internal | ResourceTypeFlags.NoIndex); IPropTypeCollection propTypes = Core.ResourceStore.PropTypes; _propURL = propTypes.Register("URL", PropDataType.String); _propParent = propTypes.Register("Parent", PropDataType.Link, PropTypeFlags.DirectedLink); _propETag = propTypes.Register("ETag", PropDataType.String, PropTypeFlags.Internal); _propLastUpdated = propTypes.Register("LastUpdated", PropDataType.Date, PropTypeFlags.Internal); _propUpdateFreq = propTypes.Register("UpdateFreq", PropDataType.Int, PropTypeFlags.Internal); _propIsUnread = propTypes.Register("IsUnread", PropDataType.Bool); _propContent = propTypes.Register("Content", PropDataType.Blob, PropTypeFlags.Internal); _propBookmarkId = propTypes.Register("BookmarkId", PropDataType.String, PropTypeFlags.Internal); _propChangesLog = propTypes.Register("ChangesLog", PropDataType.StringList, PropTypeFlags.Internal); _propFaviconUrl = propTypes.Register("FaviconUrl", PropDataType.String, PropTypeFlags.Internal); _propInvisible = propTypes.Register("Invisible", PropDataType.Bool, PropTypeFlags.Internal); if (propTypes.Exist("Path")) { propTypes.Delete(propTypes["Path"].Id); } if (propTypes.Exist("IsIEFavoritesRoot")) { IResource ieRoot = Core.ResourceStore.FindUniqueResource("Folder", "IsIEFavoritesRoot", true); if (ieRoot != null) { ieRoot.SetProp(Core.Props.Name, ieRoot.DisplayName); ieRoot.DisplayName = ""; } propTypes.Delete(propTypes["IsIEFavoritesRoot"].Id); } if (propTypes.Exist("IsMozillaRoot")) { IResource mozillaRoot = Core.ResourceStore.FindUniqueResource("Folder", "IsMozillaRoot", true); if (mozillaRoot != null) { _bookmarkService.DeleteFolder(mozillaRoot); } propTypes.Delete(propTypes["IsMozillaRoot"].Id); } }
/// <summary> /// Return true if property with such name exists (registered) in the system and /// its underlying type is Date. /// </summary> /// <param name="propName">Name of a property.</param> public static bool IsDateProperty(string propName) { if (propName == null) { return(false); } IPropTypeCollection propTypes = Core.ResourceStore.PropTypes; return(propTypes.Exist(propName) && (propTypes[propName].DataType == PropDataType.Date)); }
private void RegisterIndexVersioningTypes() { IPropTypeCollection props = Core.ResourceStore.PropTypes; _needDiscard = !File.Exists(OMEnv.TokenTreeFileName); // _needDiscard = !props.Exist( "InTextIndex" ) || !File.Exists( OMEnv.TokenTreeFileName ); // DocInIndexProp = props.Register( "InTextIndex", PropDataType.Bool, PropTypeFlags.Internal ); // The resource (single and unique) of this type keeps the current version of the // text index. It has the single property "TextIndexVersion" (see below). Core.ResourceStore.ResourceTypes.Register("TextIndexVersion", "Name", ResourceTypeFlags.Internal | ResourceTypeFlags.NoIndex); // This property keeps the current version of the text index (do not mix it with // the version of text index format. Each time the index is rebuilt, the value of this // property is increased by 1, thus invalidating all resource which reference to the // older version of the index through their "InTextIndexVersion" property (see below). TextIndexVersionProp = props.Register("TextIndexVersion", PropDataType.Int, PropTypeFlags.Internal); // Property "InTextIndexVersion" keeps the version of text index in which the // resource was indexed. If the value of this property is less than current version of // the index (in the "TextIndexVersion" property, see above), then this resource will be // reindexed. DocInVersionIndexProp = props.Register("InTextIndexVersion", PropDataType.Int, PropTypeFlags.Internal); // Delete the old property. if (props.Exist("InTextIndex")) { props.Delete(props["InTextIndex"].Id); } // Load the current version of the index. In the case of the very first loading // (when switching to the new versioning scheme) version is set to 1 and written back // to the ResourceStore. IResourceList versions = Core.ResourceStore.FindResourcesWithProp(null, TextIndexVersionProp); if (versions.Count == 0) { _indexVersionRes = Core.ResourceStore.BeginNewResource("TextIndexVersion"); _indexVersionRes.SetProp(TextIndexVersionProp, 1); _indexVersionRes.EndUpdate(); } else { _indexVersionRes = versions[0]; } _indexVersion = _indexVersionRes.GetIntProp(TextIndexVersionProp); }