/// <exception cref="XmpException" /> public void AppendArrayItem(string schemaNs, string arrayName, PropertyOptions arrayOptions, string itemValue, PropertyOptions itemOptions) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertArrayName(arrayName); if (arrayOptions == null) { arrayOptions = new PropertyOptions(); } if (!arrayOptions.IsOnlyArrayOptions) { throw new XmpException("Only array form flags allowed for arrayOptions", XmpErrorCode.BadOptions); } // Check if array options are set correctly. arrayOptions = XmpNodeUtils.VerifySetOptions(arrayOptions, null); // Locate or create the array. If it already exists, make sure the array // form from the options // parameter is compatible with the current state. var arrayPath = XmpPathParser.ExpandXPath(schemaNs, arrayName); // Just lookup, don't try to create. var arrayNode = XmpNodeUtils.FindNode(_tree, arrayPath, false, null); if (arrayNode != null) { // The array exists, make sure the form is compatible. Zero // arrayForm means take what exists. if (!arrayNode.Options.IsArray) { throw new XmpException("The named property is not an array", XmpErrorCode.BadXPath); } } else { // if (arrayOptions != null && !arrayOptions.equalArrayTypes(arrayNode.getOptions())) // { // throw new XMPException("Mismatch of existing and specified array form", BADOPTIONS); // } // The array does not exist, try to create it. if (arrayOptions.IsArray) { arrayNode = XmpNodeUtils.FindNode(_tree, arrayPath, true, arrayOptions); if (arrayNode == null) { throw new XmpException("Failure creating array node", XmpErrorCode.BadXPath); } } else { // array options missing throw new XmpException("Explicit arrayOptions required to create new array", XmpErrorCode.BadOptions); } } DoSetArrayItem(arrayNode, XmpConstants.ArrayLastItem, itemValue, itemOptions, true); }
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); }
public PropertyOptions GetOrCreatePropertyOptions(PropertyInfo property) { var options = GetPropertyOptions(property); if (options is null) { options = new PropertyOptions(property); propertyOptions ??= new(); propertyOptions.Add(property, options); } return(options); }
protected override void AddProperties(PropertyList list, PropertyOptions options) { list.AddProperty("JVM id", JvmId); AccessBridgeVersionInfo versionInfo; if (AccessBridge.Functions.GetVersionInfo(JvmId, out versionInfo)) { list.AddProperty("JVM version", versionInfo.VMversion); list.AddProperty("AccessBridge.class version", versionInfo.bridgeJavaClassVersion); list.AddProperty("JavaAccessBridge.dll version", versionInfo.bridgeJavaDLLVersion); list.AddProperty("WindowsAccessBridge.dll version", versionInfo.bridgeWinDLLVersion); } base.AddProperties(list, options); }
private PropertyOptions ExtractExtraOptionsFromDisplayName(ref string displayName) { if (displayName.Contains("--")) { string[] parts = displayName.Split(new string[] { EXTRA_OPTIONS_PREFIX }, 2, System.StringSplitOptions.None); displayName = parts[0]; PropertyOptions options = Parser.ParseToObject <PropertyOptions>(parts[1]); if (options != null) { return(options); } } return(new PropertyOptions()); }
/// <seealso cref= XMPUtils#appendProperties(XMPMeta, XMPMeta, boolean, boolean) </seealso> /// <param name="source"> The source XMP object. </param> /// <param name="destination"> The destination XMP object. </param> /// <param name="doAllProperties"> Do internal properties in addition to external properties. </param> /// <param name="replaceOldValues"> Replace the values of existing properties. </param> /// <param name="deleteEmptyValues"> Delete destination values if source property is empty. </param> /// <exception cref="XmpException"> Forwards the Exceptions from the metadata processing </exception> public static void AppendProperties(IXmpMeta source, IXmpMeta destination, bool doAllProperties, bool replaceOldValues, bool deleteEmptyValues) { ParameterAsserts.AssertImplementation(source); ParameterAsserts.AssertImplementation(destination); XmpMetaImpl src = (XmpMetaImpl)source; XmpMetaImpl dest = (XmpMetaImpl)destination; for (IEnumerator it = src.Root.IterateChildren(); it.MoveNext();) { XmpNode sourceSchema = (XmpNode)it.Current; if (sourceSchema == null) { continue; } // Make sure we have a destination schema node XmpNode destSchema = XmpNodeUtils.FindSchemaNode(dest.Root, sourceSchema.Name, false); bool createdSchema = false; if (destSchema == null) { PropertyOptions propertyOptions = new PropertyOptions(); propertyOptions.SchemaNode = true; destSchema = new XmpNode(sourceSchema.Name, sourceSchema.Value, propertyOptions); dest.Root.AddChild(destSchema); createdSchema = true; } // Process the source schema's children. for (IEnumerator ic = sourceSchema.IterateChildren(); ic.MoveNext();) { XmpNode sourceProp = (XmpNode)ic.Current; if (sourceProp == null) { continue; } if (doAllProperties || !Utils.IsInternalProperty(sourceSchema.Name, sourceProp.Name)) { AppendSubtree(dest, sourceProp, destSchema, replaceOldValues, deleteEmptyValues); } } if (!destSchema.HasChildren() && (createdSchema || deleteEmptyValues)) { // Don't create an empty schema / remove empty schema. dest.Root.RemoveChild(destSchema); } } }
public void Property(string name, byte [] value, PropertyOptions options) { if (value == null && !options.HasFlag(PropertyOptions.SerializeIfNull)) { return; } if (value.Length == 0 && !options.HasFlag(PropertyOptions.SerializeIfEmpty)) { return; } StartProperty(name); writer.WriteJson(value); }
/// <exception cref="XmpException"/> public void SetProperty(string schemaNs, string propName, object propValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); options = XmpNodeUtils.VerifySetOptions(options, propValue); var expPath = XmpPathParser.ExpandXPath(schemaNs, propName); var propNode = XmpNodeUtils.FindNode(_tree, expPath, true, options); if (propNode != null) { SetNode(propNode, propValue, options, false); } else { throw new XmpException("Specified property does not exist", XmpErrorCode.BadXPath); } }
public virtual void InsertArrayItem(String schemaNS, String arrayName, int itemIndex , String itemValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertArrayName(arrayName); // Just lookup, don't try to create. XMPPath arrayPath = XMPPathParser.ExpandXPath(schemaNS, arrayName); XMPNode arrayNode = XMPNodeUtils.FindNode(tree, arrayPath, false, null); if (arrayNode != null) { DoSetArrayItem(arrayNode, itemIndex, itemValue, options, true); } else { throw new XMPException("Specified array does not exist", XMPError.BADXPATH); } }
/// <summary>Performs a <b>deep clone</b> of the node and the complete subtree.</summary> /// <seealso cref="ICloneable.Clone()"/> public virtual object Clone() { PropertyOptions newOptions; try { newOptions = new PropertyOptions(GetOptions().GetOptions()); } catch (XMPException) { // cannot happen newOptions = new PropertyOptions(); } Com.Adobe.Xmp.Impl.XMPNode newNode = new Com.Adobe.Xmp.Impl.XMPNode(name, value, newOptions); CloneSubtree(newNode); return(newNode); }
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); } }
/// <summary> /// Get all of the properties of an object /// </summary> /// <param name="type"></param> /// <param name="options"></param> /// <returns></returns> public static ICollection <ExtendedProperty> GetProperties(this Type type, PropertyOptions options) { if (type == null) { return(new List <ExtendedProperty>()); } var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; var allProperties = type.GetProperties(flags); IEnumerable <PropertyInfo> returnProperties = allProperties; if (options.HasFlag(PropertyOptions.Public)) { returnProperties = returnProperties.Where(x => x.GetGetMethod(true).IsPublic&& x.GetSetMethod(true).IsPublic); } if (options.HasFlag(PropertyOptions.Private)) { returnProperties = returnProperties.Where(x => x.GetGetMethod(true).IsPrivate&& x.GetSetMethod(true).IsPrivate); } #if FEATURE_CUSTOM_ATTRIBUTES if (options.HasFlag(PropertyOptions.HasSetter)) { returnProperties = returnProperties.Where(x => x.SetMethod != null); } if (options.HasFlag(PropertyOptions.HasGetter)) { returnProperties = returnProperties.Where(x => x.GetMethod != null); } #else if (options.HasFlag(PropertyOptions.HasSetter)) { returnProperties = returnProperties.Where(x => x.GetSetMethod(true) != null); } if (options.HasFlag(PropertyOptions.HasGetter)) { returnProperties = returnProperties.Where(x => x.GetGetMethod(true) != null); } #endif if (options.HasFlag(PropertyOptions.HasIndexer)) { returnProperties = returnProperties.Where(x => x.GetIndexParameters().Any()); } return(returnProperties .Select(x => (ExtendedProperty)x).ToList()); }
/// <summary>Performs a <b>deep clone</b> of the node and the complete subtree.</summary> /// <seealso cref="System.Object.Clone()"/> public virtual Object Clone() { PropertyOptions newOptions; try { newOptions = new PropertyOptions(GetOptions().GetOptions()); } catch (XMPException) { // cannot happen newOptions = new PropertyOptions(); } iText.Kernel.XMP.Impl.XMPNode newNode = new iText.Kernel.XMP.Impl.XMPNode (name, value, newOptions); CloneSubtree(newNode); return(newNode); }
/// <summary> /// Performs a <b>deep clone</b> of the node and the complete subtree. /// </summary> /// <seealso cref= java.lang.Object#clone() </seealso> public virtual object Clone() { PropertyOptions newOptions; try { newOptions = new PropertyOptions(Options.Options); } catch (XmpException) { // cannot happen newOptions = new PropertyOptions(); } XmpNode newNode = new XmpNode(_name, _value, newOptions); CloneSubtree(newNode); return(newNode); }
/// <summary>Performs a <b>deep clone</b> of the node and the complete subtree.</summary> public object Clone() { PropertyOptions newOptions; try { newOptions = new PropertyOptions(Options.GetOptions()); } catch (XmpException) { // cannot happen newOptions = new PropertyOptions(); } var newNode = new XmpNode(Name, Value, newOptions); CloneSubtree(newNode); return(newNode); }
public void ResetInfo() { cardImage.gameObject.GetOrAddComponent <AspectRatioFitter>().aspectRatio = CardGameManager.Current.CardAspectRatio; zoomPanel.GetChild(0).gameObject.GetOrAddComponent <AspectRatioFitter>().aspectRatio = CardGameManager.Current.CardAspectRatio; PropertyOptions.Clear(); PropertyOptions.Add(new Dropdown.OptionData() { text = SetLabel }); DisplayNameLookup.Clear(); foreach (PropertyDef propertyDef in CardGameManager.Current.CardProperties) { AddProperty(propertyDef); } propertySelection.options = PropertyOptions; propertySelection.value = PrimaryPropertyIndex; propertySelection.onValueChanged.Invoke(propertySelection.value); }
protected override void AddProperties(PropertyList list, PropertyOptions options) { list.AddProperty("WindowHandle", _hwnd); base.AddProperties(list, options); var group = list.AddGroup("Focused element"); group.LoadChildren = () => { int vmid; JavaObjectHandle ac; if (Failed(AccessBridge.Functions.GetAccessibleContextWithFocus(_hwnd, out vmid, out ac))) { group.AddProperty("<Error>", "Error retrieving focused element"); } else { AddSubContextProperties(group.Children, options, ac); } }; }
/// <summary> /// Undo the denormalization performed by the XMP used in Acrobat 5.<br> /// If a Dublin Core array had only one item, it was serialized as a simple /// property. <br> /// The <code>xml:lang</code> attribute was dropped from an /// <code>alt-text</code> item if the language was <code>x-default</code>. /// </summary> /// <param name="dcSchema"> the DC schema node </param> /// <exception cref="XmpException"> Thrown if normalization fails </exception> private static void NormalizeDcArrays(XmpNode dcSchema) { for (int i = 1; i <= dcSchema.ChildrenLength; i++) { XmpNode currProp = dcSchema.GetChild(i); PropertyOptions arrayForm = (PropertyOptions)_dcArrayForms[currProp.Name]; if (arrayForm == null) { continue; } if (currProp.Options.Simple) { // create a new array and add the current property as child, // if it was formerly simple XmpNode newArray = new XmpNode(currProp.Name, arrayForm); currProp.Name = XmpConst.ARRAY_ITEM_NAME; newArray.AddChild(currProp); dcSchema.ReplaceChild(i, newArray); // fix language alternatives if (arrayForm.ArrayAltText && !currProp.Options.HasLanguage) { XmpNode newLang = new XmpNode(XmpConst.XML_LANG, XmpConst.X_DEFAULT, null); currProp.AddQualifier(newLang); } } else { // clear array options and add corrected array form if it has been an array before currProp.Options.SetOption( PropertyOptions.ARRAY | PropertyOptions.ARRAY_ORDERED | PropertyOptions.ARRAY_ALTERNATE | PropertyOptions.ARRAY_ALT_TEXT, false); currProp.Options.MergeWith(arrayForm); if (arrayForm.ArrayAltText) { // applying for "dc:description", "dc:rights", "dc:title" RepairAltText(currProp); } } } }
public virtual void UpdateStringArray(int tagType, string[] strings) { base.SetStringArray(tagType, strings); try { string schemaNS = _tagSchemaMap.Get(tagType); string propName = _tagPropNameMap.Get(tagType); GetXMPMeta().DeleteProperty(schemaNS, propName); PropertyOptions po = new PropertyOptions().SetArray(true); foreach (string item in strings) { GetXMPMeta().AppendArrayItem(schemaNS, propName, po, item, null); } } catch (XMPException e) { Sharpen.Runtime.PrintStackTrace(e); } }
/// <summary> /// Utility to find or create the array used by <code>separateArrayItems()</code>. </summary> /// <param name="schemaNs"> a the namespace fo the array </param> /// <param name="arrayName"> the name of the array </param> /// <param name="arrayOptions"> the options for the array if newly created </param> /// <param name="xmp"> the xmp object </param> /// <returns> Returns the array node. </returns> /// <exception cref="XmpException"> Forwards exceptions </exception> private static XmpNode SeparateFindCreateArray(string schemaNs, string arrayName, PropertyOptions arrayOptions, XmpMetaImpl xmp) { arrayOptions = XmpNodeUtils.VerifySetOptions(arrayOptions, null); if (!arrayOptions.OnlyArrayOptions) { throw new XmpException("Options can only provide array form", XmpError.BADOPTIONS); } // Find the array node, make sure it is OK. Move the current children // aside, to be readded later if kept. XmpPath arrayPath = XmpPathParser.ExpandXPath(schemaNs, arrayName); XmpNode arrayNode = XmpNodeUtils.FindNode(xmp.Root, arrayPath, false, null); if (arrayNode != null) { // The array exists, make sure the form is compatible. Zero // arrayForm means take what exists. PropertyOptions arrayForm = arrayNode.Options; if (!arrayForm.Array || arrayForm.ArrayAlternate) { throw new XmpException("Named property must be non-alternate array", XmpError.BADXPATH); } if (arrayOptions.EqualArrayTypes(arrayForm)) { throw new XmpException("Mismatch of specified and existing array form", XmpError.BADXPATH); // *** Right error? } } else { // The array does not exist, try to create it. // don't modify the options handed into the method arrayOptions.Array = true; arrayNode = XmpNodeUtils.FindNode(xmp.Root, arrayPath, true, arrayOptions); if (arrayNode == null) { throw new XmpException("Failed to create named array", XmpError.BADXPATH); } } return(arrayNode); }
public static StyledProperty <TValue> Register <TOwner, TValue>( string name, TValue defaultValue = default !, PropertyOptions options = PropertyOptions.None, Action <TOwner, CommonPropertyChangedArgs <TValue> >?onChanged = null) where TOwner : DependencyObject { var metadataOptions = FrameworkPropertyMetadataOptions.None; if (options.Has(PropertyOptions.AffectsRender)) { metadataOptions |= FrameworkPropertyMetadataOptions.AffectsRender; } if (options.Has(PropertyOptions.AffectsArrange)) { metadataOptions |= FrameworkPropertyMetadataOptions.AffectsArrange; } if (options.Has(PropertyOptions.AffectsMeasure)) { metadataOptions |= FrameworkPropertyMetadataOptions.AffectsMeasure; } if (options.Has(PropertyOptions.Inherits)) { metadataOptions |= FrameworkPropertyMetadataOptions.Inherits; } if (options.Has(PropertyOptions.BindsTwoWay)) { metadataOptions |= FrameworkPropertyMetadataOptions.BindsTwoWayByDefault; } var changedCallback = onChanged != null ? new PropertyChangedCallback((o, e) => onChanged((TOwner)o, new CommonPropertyChangedArgs <TValue>((TValue)e.OldValue, (TValue)e.NewValue))) : null; var metadata = new FrameworkPropertyMetadata(defaultValue, metadataOptions, changedCallback); var property = DependencyProperty.Register(name, typeof(TValue), typeof(TOwner), metadata); return(new StyledProperty <TValue>(property)); }
private void LoadLocales() { MaterialProperty locales_property = null; locale = null; foreach (MaterialProperty m in current.properties) { if (m.name == PROPERTY_NAME_LOCALE) { locales_property = m; } } if (locales_property != null) { string displayName = locales_property.displayName; PropertyOptions options = ExtractExtraOptionsFromDisplayName(ref displayName); locale = new Locale(options.file_name); locale.selected_locale_index = (int)locales_property.floatValue; } }
/// <summary> /// Undo the denormalization performed by the XMP used in Acrobat 5.<br /> /// If a Dublin Core array had only one item, it was serialized as a simple /// property. /// </summary> /// <remarks> /// Undo the denormalization performed by the XMP used in Acrobat 5.<br /> /// If a Dublin Core array had only one item, it was serialized as a simple /// property. <br /> /// The <code>xml:lang</code> attribute was dropped from an /// <code>alt-text</code> item if the language was <code>x-default</code>. /// </remarks> /// <param name="dcSchema">the DC schema node</param> /// <exception cref="Com.Adobe.Xmp.XMPException">Thrown if normalization fails</exception> private static void NormalizeDCArrays(XMPNode dcSchema) { for (int i = 1; i <= dcSchema.GetChildrenLength(); i++) { XMPNode currProp = dcSchema.GetChild(i); PropertyOptions arrayForm = (PropertyOptions)dcArrayForms.Get(currProp.GetName()); if (arrayForm == null) { continue; } else { if (currProp.GetOptions().IsSimple()) { // create a new array and add the current property as child, // if it was formerly simple XMPNode newArray = new XMPNode(currProp.GetName(), arrayForm); currProp.SetName(XMPConstConstants.ArrayItemName); newArray.AddChild(currProp); dcSchema.ReplaceChild(i, newArray); // fix language alternatives if (arrayForm.IsArrayAltText() && !currProp.GetOptions().GetHasLanguage()) { XMPNode newLang = new XMPNode(XMPConstConstants.XmlLang, XMPConstConstants.XDefault, null); currProp.AddQualifier(newLang); } } else { // clear array options and add corrected array form if it has been an array before currProp.GetOptions().SetOption(PropertyOptions.Array | PropertyOptions.ArrayOrdered | PropertyOptions.ArrayAlternate | PropertyOptions.ArrayAltText, false); currProp.GetOptions().MergeWith(arrayForm); if (arrayForm.IsArrayAltText()) { // applying for "dc:description", "dc:rights", "dc:title" RepairAltText(currProp); } } } } }
/// <summary> /// The internals for setProperty() and related calls, used after the node is /// found or created. /// </summary> /// <param name="node">the newly created node</param> /// <param name="value">the node value, can be <c>null</c></param> /// <param name="newOptions">options for the new node, must not be <c>null</c>.</param> /// <param name="deleteExisting">flag if the existing value is to be overwritten</param> /// <exception cref="XmpException">thrown if options and value do not correspond</exception> internal void SetNode(XmpNode node, object value, PropertyOptions newOptions, bool deleteExisting) { if (deleteExisting) { node.Clear(); } // its checked by setOptions(), if the merged result is a valid options set node.Options.MergeWith(newOptions); if (!node.Options.IsCompositeProperty) { // This is setting the value of a leaf node. XmpNodeUtils.SetNodeValue(node, value); } else { if (value != null && value.ToString().Length > 0) { throw new XmpException("Composite nodes can't have values", XmpErrorCode.BadXPath); } node.RemoveChildren(); } }
public static CompositeObjectProperty RegisterProperty <TVal, TOwner>(string propName, PropertyOptions options, TVal defaultValue = default, Func <TOwner, TVal, TVal> coerceFunc = default, Action <TOwner, TVal, TVal> changeValueFunc = default) where TOwner : CompositeObject { IPropertyMetadata metadata = CreateMetadata <TOwner, TVal>(options, defaultValue, coerceFunc, changeValueFunc); var prop = new CompositeObjectProperty(propName, typeof(TVal), metadata); PropertyManager.Instance.RegisterProperty <TOwner>(prop); return(prop); }
/// <summary> /// Removes one qualifier node and fixes the options. </summary> /// <param name="qualNode"> qualifier to remove </param> public virtual void RemoveQualifier(XmpNode qualNode) { PropertyOptions opts = Options; if (qualNode.LanguageNode) { // if "xml:lang" is removed, remove hasLanguage-flag too opts.HasLanguage = false; } else if (qualNode.TypeNode) { // if "rdf:type" is removed, remove hasType-flag too opts.HasType = false; } Qualifier.Remove(qualNode); if (_qualifier.Count == 0) { opts.HasQualifiers = false; _qualifier = null; } }
/// <summary>Utility to find or create the array used by <code>SeparateArrayItems()</code>.</summary> /// <param name="schemaNS">a the namespace fo the array</param> /// <param name="arrayName">the name of the array</param> /// <param name="arrayOptions">the options for the array if newly created</param> /// <param name="xmp">the xmp object</param> /// <returns>Returns the array node.</returns> /// <exception cref="Com.Adobe.Xmp.XMPException">Forwards exceptions</exception> private static XMPNode SeparateFindCreateArray(string schemaNS, string arrayName, PropertyOptions arrayOptions, XMPMetaImpl xmp) { arrayOptions = XMPNodeUtils.VerifySetOptions(arrayOptions, null); if (!arrayOptions.IsOnlyArrayOptions()) { throw new XMPException("Options can only provide array form", XMPErrorConstants.Badoptions); } // Find the array node, make sure it is OK. Move the current children // aside, to be readded later if kept. XMPPath arrayPath = XMPPathParser.ExpandXPath(schemaNS, arrayName); XMPNode arrayNode = XMPNodeUtils.FindNode(xmp.GetRoot(), arrayPath, false, null); if (arrayNode != null) { // The array exists, make sure the form is compatible. Zero // arrayForm means take what exists. PropertyOptions arrayForm = arrayNode.GetOptions(); if (!arrayForm.IsArray() || arrayForm.IsArrayAlternate()) { throw new XMPException("Named property must be non-alternate array", XMPErrorConstants.Badxpath); } if (arrayOptions.EqualArrayTypes(arrayForm)) { throw new XMPException("Mismatch of specified and existing array form", XMPErrorConstants.Badxpath); } } else { // *** Right error? // The array does not exist, try to create it. // don't modify the options handed into the method arrayNode = XMPNodeUtils.FindNode(xmp.GetRoot(), arrayPath, true, arrayOptions.SetArray(true)); if (arrayNode == null) { throw new XMPException("Failed to create named array", XMPErrorConstants.Badxpath); } } return(arrayNode); }
/// <summary>Find or create a child node under a given parent node.</summary> /// <remarks> /// Find or create a child node under a given parent node. If the parent node is no /// Returns the found or created child node. /// </remarks> /// <param name="parent">the parent node</param> /// <param name="childName">the node name to find</param> /// <param name="createNodes">flag, if new nodes shall be created.</param> /// <returns>Returns the found or created node or <code>null</code>.</returns> /// <exception cref="iText.Kernel.XMP.XMPException">Thrown if</exception> internal static XMPNode FindChildNode(XMPNode parent, String childName, bool createNodes ) { if (!parent.GetOptions().IsSchemaNode() && !parent.GetOptions().IsStruct()) { if (!parent.IsImplicit()) { throw new XMPException("Named children only allowed for schemas and structs", XMPError .BADXPATH); } else { if (parent.GetOptions().IsArray()) { throw new XMPException("Named children not allowed for arrays", XMPError.BADXPATH ); } else { if (createNodes) { parent.GetOptions().SetStruct(true); } } } } XMPNode childNode = parent.FindChildByName(childName); if (childNode == null && createNodes) { PropertyOptions options = new PropertyOptions(); childNode = new XMPNode(childName, options); childNode.SetImplicit(true); parent.AddChild(childNode); } System.Diagnostics.Debug.Assert(childNode != null || !createNodes); return(childNode); }
/// <summary>Removes one qualifier node and fixes the options.</summary> /// <param name="qualNode">qualifier to remove</param> public virtual void RemoveQualifier(iText.Kernel.XMP.Impl.XMPNode qualNode) { PropertyOptions opts = GetOptions(); if (qualNode.IsLanguageNode()) { // if "xml:lang" is removed, remove hasLanguage-flag too opts.SetHasLanguage(false); } else { if (qualNode.IsTypeNode()) { // if "rdf:type" is removed, remove hasType-flag too opts.SetHasType(false); } } GetQualifier().Remove(qualNode); if (qualifier.Count == 0) { opts.SetHasQualifiers(false); qualifier = null; } }
public ComparatorGenericSelectionActions(PropertyOptions propertyOptions) { this.options = propertyOptions; }
/// <summary>Separate a single edit string into an array of strings.</summary> /// <param name="xmp">The XMP object containing the array to be updated.</param> /// <param name="schemaNs"> /// The schema namespace URI for the array. Must not be null or /// the empty string. /// </param> /// <param name="arrayName"> /// The name of the array. May be a general path expression, must /// not be null or the empty string. Each item in the array must /// be a simple string value. /// </param> /// <param name="catedStr">The string to be separated into the array items.</param> /// <param name="arrayOptions">Option flags to control the separation.</param> /// <param name="preserveCommas">Flag if commas shall be preserved</param> /// <exception cref="XmpException">Forwards the Exceptions from the metadata processing</exception> public static void SeparateArrayItems(IXmpMeta xmp, string schemaNs, string arrayName, string catedStr, PropertyOptions arrayOptions, bool preserveCommas) { Impl.XmpUtils.SeparateArrayItems(xmp, schemaNs, arrayName, catedStr, arrayOptions, preserveCommas); }
/// <summary> /// Determines whether the property has the specified option. /// </summary> /// <param name="option">The option.</param> /// <returns>True if the property has the specified option, otherwise false.</returns> public bool HasOption(PropertyOptions option) => (this.Options & option) == option;
/// <summary> /// Initializes a new instance of the <see cref="Property" /> class. /// </summary> /// <param name="defaultValue">The default value.</param> /// <param name="options">The property options.</param> public Property(object defaultValue, PropertyOptions options) { this.DefaultValue = defaultValue; this.Options = options; }
/// <summary> /// Draws the screen. /// </summary> /// <param name="width">The screen width.</param> /// <param name="height">The screen height.</param> public void Draw(float width, float height) { if (this.surface.Width != width || this.surface.Height != height) { this.pendingOperations |= PropertyOptions.AffectsMeasure; } if ((this.pendingOperations & PropertyOptions.AffectsMeasure) == PropertyOptions.AffectsMeasure) { this.Measure(new SizeF(width, height)); } if ((this.pendingOperations & PropertyOptions.AffectsArrange) == PropertyOptions.AffectsArrange) { this.Arrange(new RectangleF(0, 0, width, height)); } if ((this.pendingOperations & PropertyOptions.AffectsCompose) == PropertyOptions.AffectsCompose) { this.surface.Reset(width, height); this.Compose(this.surface); } GPU.Use(Cull.None, Depth.None, Stencil.None, Blend.Alpha); this.surface.Present(); this.pendingOperations = 0; }
/// <summary> /// Called when an element is invalidated. /// </summary> /// <param name="element">The invalidated element.</param> protected override void OnInvalidate(Element element) { this.pendingOperations |= PropertyOptions.AffectsMeasure; base.OnInvalidate(element); }
/// <summary> /// Called when a property value change affects the parent. /// </summary> /// <param name="source">The source element.</param> /// <param name="property">The property.</param> /// <param name="previousValue">The previous value.</param> protected override void OnParentAffected(Element source, Property property, object previousValue) { this.pendingOperations |= property.Options; base.OnParentAffected(source, property, previousValue); }
/// <summary>Merges the set options of a another options object with this.</summary> /// <remarks> /// Merges the set options of a another options object with this. /// If the other options set is null, this objects stays the same. /// </remarks> /// <param name="options">other options</param> /// <exception cref="XmpException">If illegal options are provided</exception> public void MergeWith(PropertyOptions options) { if (options != null) { SetOptions(GetOptions() | options.GetOptions()); } }
/// <summary>Compares two options set for array compatibility.</summary> /// <param name="options">other options</param> /// <returns>Returns true if the array options of the sets are equal.</returns> public bool EqualArrayTypes(PropertyOptions options) { return IsArray == options.IsArray && IsArrayOrdered == options.IsArrayOrdered && IsArrayAlternate == options.IsArrayAlternate && IsArrayAltText == options.IsArrayAltText; }