/// <summary>Store whether the plugin asset is enabled using the application settings.</summary> /// <param name="resource"></param> /// <param name="value"></param> protected override void SetIsPluginAssetEnabled(PluginAsset resource, bool value) { if (value != GetIsPluginAssetEnabled(resource)) { if (value) DisabledPluginResources.Remove(GetType().FullName); else DisabledPluginResources.Add(GetType().FullName); Properties.Settings.Default.Save(); } }
/// <summary>Get whether the plugin asset is enabled, using the application settings.</summary> /// <param name="resource"></param> /// <returns></returns> protected override bool GetIsPluginAssetEnabled(PluginAsset resource) { return !DisabledPluginResources.Contains(resource.GetType().FullName); }
/// <summary> /// /// </summary> /// <param name="pluginResource">The context for the <see cref="AssetFormat"/>, used to find the <see cref="AssetPlugin"/>.</param> /// <param name="primaryType">The primary <see cref="Asset"/> type that this <see cref="AssetFormat"/> operates with.</param> /// <param name="canLoad">Whether this can load <see cref="Asset"/>s; if <c>true</c>, then <see cref="Load"/> and <see cref="LoadMatch"/> must be implemented.</param> /// <param name="loadTypes">Any additional <see cref="Asset"/> types that could be loaded beyond the <paramref name="primaryType"/>; this can only be provided if <paramref name="canLoad"/> is <c>true</c>.</param> /// <param name="canSave">Whether this can save <see cref="Asset"/>s; if <c>true</c>, then <see cref="Save"/> and <see cref="SaveCheck"/> must be implemented, and <paramref name="saveTypes"/> can be provided for additional types this can save beyond the <paramref name="primaryType"/>.</param> /// <param name="saveTypes">Any additional <see cref="Asset"/> types that this can save beyond the <paramref name="primaryType"/>; this can only be provided if <paramref name="canSave"/> is <c>true</c>.</param> /// <param name="canCreate">Whether this can create an <see cref="Asset"/>. If so, <see cref="Create"/> must be implemented, and <paramref name="createTypes"/> can be provided for additional types this can create beyond the <paramref name="primaryType"/>.</param> /// <param name="createTypes">Any additional <see cref="Asset"/> types that this can create beyond the <paramref name="primaryType"/>; this can only be provided if <paramref name="canCreate"/> is <c>true</c>.</param> /// <param name="extension">File extension that this format uses in the form of ".ext".</param> /// <param name="extensions">File extensions that this format uses in the form of <c>new string[] { ".ext", ".ext2" }</c></param> public AssetFormat(PluginAsset pluginResource, Type primaryType, bool canLoad = false, IList <Type> loadTypes = null, bool canSave = false, IList <Type> saveTypes = null, bool canCreate = false, IList <Type> createTypes = null, string extension = null, IList <string> extensions = null) : base(pluginResource.Plugin) { if (primaryType == null) { throw new ArgumentNullException("primaryType"); } PrimaryType = primaryType; CanLoad = canLoad; CanSave = canSave; CanCreate = canCreate; if (loadTypes != null) { if (!CanLoad && loadTypes.Count > 0) { throw new ArgumentException("CanLoad is false, so no loadTypes should be added.", "loadTypes"); } LoadTypesMutable.AddRange(loadTypes); } else if (CanLoad) { LoadTypesMutable.Add(PrimaryType); } if (saveTypes != null) { if (!CanSave && saveTypes.Count > 0) { throw new ArgumentException("CanSave is false, so no saveTypes should be added.", "saveTypes"); } SaveTypesMutable.AddRange(saveTypes); } else if (CanSave) { SaveTypesMutable.Add(PrimaryType); } if (createTypes != null) { if (!CanCreate && CreateTypes.Count > 0) { throw new ArgumentException("CanCreate is false, so no createTypes should be added.", "createTypes"); } CreateTypesMutable.AddRange(createTypes); } else if (CanCreate) { CreateTypesMutable.Add(PrimaryType); } if (extension != null) { ExtensionsMutable.Add(extension); } if (extensions != null) { ExtensionsMutable.AddRange(extensions); } }
/// <summary>Set whether a plugin asset is enabled.</summary> /// <param name="resource"></param> /// <param name="value"></param> internal protected abstract void SetIsPluginAssetEnabled(PluginAsset resource, bool value);
/// <summary>Retrieve whether a plugin asset is enabled.</summary> /// <param name="resource"></param> /// <returns></returns> internal protected abstract bool GetIsPluginAssetEnabled(PluginAsset resource);
/// <summary> /// /// </summary> /// <param name="pluginResource">The context for the <see cref="AssetFormat"/>, used to find the <see cref="AssetPlugin"/>.</param> /// <param name="primaryType">The primary <see cref="Asset"/> type that this <see cref="AssetFormat"/> operates with.</param> /// <param name="canLoad">Whether this can load <see cref="Asset"/>s; if <c>true</c>, then <see cref="Load"/> and <see cref="LoadMatch"/> must be implemented.</param> /// <param name="loadTypes">Any additional <see cref="Asset"/> types that could be loaded beyond the <paramref name="primaryType"/>; this can only be provided if <paramref name="canLoad"/> is <c>true</c>.</param> /// <param name="canSave">Whether this can save <see cref="Asset"/>s; if <c>true</c>, then <see cref="Save"/> and <see cref="SaveCheck"/> must be implemented, and <paramref name="saveTypes"/> can be provided for additional types this can save beyond the <paramref name="primaryType"/>.</param> /// <param name="saveTypes">Any additional <see cref="Asset"/> types that this can save beyond the <paramref name="primaryType"/>; this can only be provided if <paramref name="canSave"/> is <c>true</c>.</param> /// <param name="canCreate">Whether this can create an <see cref="Asset"/>. If so, <see cref="Create"/> must be implemented, and <paramref name="createTypes"/> can be provided for additional types this can create beyond the <paramref name="primaryType"/>.</param> /// <param name="createTypes">Any additional <see cref="Asset"/> types that this can create beyond the <paramref name="primaryType"/>; this can only be provided if <paramref name="canCreate"/> is <c>true</c>.</param> /// <param name="extension">File extension that this format uses in the form of ".ext".</param> /// <param name="extensions">File extensions that this format uses in the form of <c>new string[] { ".ext", ".ext2" }</c></param> public AssetFormat(PluginAsset pluginResource, Type primaryType, bool canLoad = false, IList<Type> loadTypes = null, bool canSave = false, IList<Type> saveTypes = null, bool canCreate = false, IList<Type> createTypes = null, string extension = null, IList<string> extensions = null) : base(pluginResource.Plugin) { if (primaryType == null) throw new ArgumentNullException("primaryType"); PrimaryType = primaryType; CanLoad = canLoad; CanSave = canSave; CanCreate = canCreate; if (loadTypes != null) { if (!CanLoad && loadTypes.Count > 0) throw new ArgumentException("CanLoad is false, so no loadTypes should be added.", "loadTypes"); LoadTypesMutable.AddRange(loadTypes); } else if (CanLoad) LoadTypesMutable.Add(PrimaryType); if (saveTypes != null) { if (!CanSave && saveTypes.Count > 0) throw new ArgumentException("CanSave is false, so no saveTypes should be added.", "saveTypes"); SaveTypesMutable.AddRange(saveTypes); } else if (CanSave) SaveTypesMutable.Add(PrimaryType); if (createTypes != null) { if (!CanCreate && CreateTypes.Count > 0) throw new ArgumentException("CanCreate is false, so no createTypes should be added.", "createTypes"); CreateTypesMutable.AddRange(createTypes); } else if (CanCreate) CreateTypesMutable.Add(PrimaryType); if (extension != null) ExtensionsMutable.Add(extension); if (extensions != null) ExtensionsMutable.AddRange(extensions); }