public static AssertPropName ( string propName ) : void | ||
propName | string | a property name or path |
Результат | void |
/// <exception cref="XmpException"> </exception> /// <seealso cref= XMPMeta#getQualifier(String, String, String, String) </seealso> public virtual IXmpProperty GetQualifier(string schemaNs, string propName, string qualNs, string qualName) { // qualNs and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); string qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); return(GetProperty(schemaNs, qualPath)); }
private void RegisterAlias(string aliasNs, string aliasProp, string actualNs, string actualProp, AliasOptions aliasForm) { ParameterAsserts.AssertSchemaNs(aliasNs); ParameterAsserts.AssertPropName(aliasProp); ParameterAsserts.AssertSchemaNs(actualNs); ParameterAsserts.AssertPropName(actualProp); // Fix the alias options AliasOptions aliasOpts = aliasForm != null ? new AliasOptions( XmpNodeUtils.VerifySetOptions(aliasForm.ToPropertyOptions(), null). Options) : new AliasOptions(); if (_regex.IsMatch(aliasProp) || _regex.IsMatch(actualProp)) { throw new XmpException("Alias and actual property names must be simple", XmpError.BADXPATH); } // check if both namespaces are registered string aliasPrefix = GetNamespacePrefix(aliasNs); string actualPrefix = GetNamespacePrefix(actualNs); if (aliasPrefix == null) { throw new XmpException("Alias namespace is not registered", XmpError.BADSCHEMA); } if (actualPrefix == null) { throw new XmpException("Actual namespace is not registered", XmpError.BADSCHEMA); } string key = aliasPrefix + aliasProp; // check if alias is already existing if (_aliasMap.Contains(key)) { throw new XmpException("Alias is already existing", XmpError.BADPARAM); } if (_aliasMap.Contains(actualPrefix + actualProp)) { throw new XmpException("Actual property is already an alias, use the base property", XmpError.BADPARAM); } IXmpAliasInfo aliasInfo = new XmpAliasInfoImpl(actualNs, actualPrefix, actualProp, aliasOpts); _aliasMap[key] = aliasInfo; }
/// <seealso cref= XMPMeta#doesQualifierExist(String, String, String, String) </seealso> public virtual bool DoesQualifierExist(string schemaNs, string propName, string qualNs, string qualName) { try { // qualNs and qualName are checked inside composeQualifierPath() ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); string path = XmpPathFactory.ComposeQualifierPath(qualNs, qualName); return(DoesPropertyExist(schemaNs, propName + path)); } catch (XmpException) { return(false); } }
/// <seealso cref= XMPMeta#doesPropertyExist(String, String) </seealso> public virtual bool DoesPropertyExist(string schemaNs, string propName) { try { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); XmpPath expPath = XmpPathParser.ExpandXPath(schemaNs, propName); XmpNode propNode = XmpNodeUtils.FindNode(_tree, expPath, false, null); return(propNode != null); } catch (XmpException) { return(false); } }
/// <seealso cref= XMPMeta#deleteQualifier(String, String, String, String) </seealso> public virtual void DeleteQualifier(string schemaNs, string propName, string qualNs, string qualName) { try { // Note: qualNs and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); string qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); DeleteProperty(schemaNs, qualPath); } catch (XmpException) { // EMPTY, exceptions within delete are ignored } }
/// <exception cref="XmpException"> </exception> /// <seealso cref= XMPMeta#setQualifier(String, String, String, String, String, /// PropertyOptions) </seealso> public virtual void SetQualifier(string schemaNs, string propName, string qualNs, string qualName, string qualValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); if (!DoesPropertyExist(schemaNs, propName)) { throw new XmpException("Specified property does not exist!", XmpError.BADXPATH); } string qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); SetProperty(schemaNs, qualPath, qualValue, options); }
/// <seealso cref= XMPMeta#deleteProperty(String, String) </seealso> public virtual void DeleteProperty(string schemaNs, string propName) { try { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); XmpPath expPath = XmpPathParser.ExpandXPath(schemaNs, propName); XmpNode propNode = XmpNodeUtils.FindNode(_tree, expPath, false, null); if (propNode != null) { XmpNodeUtils.DeleteNode(propNode); } } catch (XmpException) { // EMPTY, exceptions are ignored within delete } }
/// <summary> /// Returns a property, but the result value can be requested. /// </summary> /// <seealso cref= XMPMeta#GetProperty(String, String) </seealso> /// <param name="schemaNs"> /// a schema namespace </param> /// <param name="propName"> /// a property name or path </param> /// <param name="valueType"> /// the type of the value, see VALUE_... </param> /// <returns> Returns the node value as an object according to the /// <code>valueType</code>. </returns> /// <exception cref="XmpException"> /// Collects any exception that occurs. </exception> protected internal virtual object GetPropertyObject(string schemaNs, string propName, int valueType) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); XmpPath expPath = XmpPathParser.ExpandXPath(schemaNs, propName); XmpNode propNode = XmpNodeUtils.FindNode(_tree, expPath, false, null); if (propNode != null) { if (valueType != VALUE_STRING && propNode.Options.CompositeProperty) { throw new XmpException("Property must be simple when a value type is requested", XmpError.BADXPATH); } return(evaluateNodeValue(valueType, propNode)); } return(null); }
/// <exception cref="XmpException"> </exception> /// <seealso cref= XMPMeta#SetProperty(String, String, Object, PropertyOptions) </seealso> public virtual void SetProperty(string schemaNs, string propName, object propValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); options = XmpNodeUtils.VerifySetOptions(options, propValue); XmpPath expPath = XmpPathParser.ExpandXPath(schemaNs, propName); XmpNode propNode = XmpNodeUtils.FindNode(_tree, expPath, true, options); if (propNode != null) { SetNode(propNode, propValue, options, false); } else { throw new XmpException("Specified property does not exist", XmpError.BADXPATH); } }