| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace SolidEdgeCommunity.Extensions; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// SolidEdgeFileProperties.PropertySets extensions. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class PropertySetsExtensions |
| | | 9 | | { |
| | | 10 | | ///// <summary> |
| | | 11 | | ///// Returns all property sets as an IEnumerable. |
| | | 12 | | ///// </summary> |
| | | 13 | | ///// <param name="propertySets"></param> |
| | | 14 | | //public static IEnumerable<SolidEdgeFileProperties.Properties> AsEnumerable(this SolidEdgeFileProperties.PropertySe |
| | | 15 | | //{ |
| | | 16 | | // List<SolidEdgeFileProperties.Properties> list = new List<SolidEdgeFileProperties.Properties>(); |
| | | 17 | | |
| | | 18 | | // foreach (var properties in propertySets) |
| | | 19 | | // { |
| | | 20 | | // list.Add((SolidEdgeFileProperties.Properties)properties); |
| | | 21 | | // } |
| | | 22 | | |
| | | 23 | | // return list.AsEnumerable(); |
| | | 24 | | //} |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Closes an open document with the option to save changes. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <param name="propertySets"></param> |
| | | 30 | | /// <param name="saveChanges"></param> |
| | | 31 | | public static void Close(this SolidEdgeFileProperties.PropertySets propertySets, bool saveChanges) |
| | | 32 | | { |
| | 4 | 33 | | if (saveChanges) |
| | | 34 | | { |
| | 2 | 35 | | propertySets.Save(); |
| | | 36 | | } |
| | | 37 | | |
| | 4 | 38 | | propertySets.Close(); |
| | 4 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Adds or modifies a custom property. |
| | | 43 | | /// </summary> |
| | | 44 | | internal static SolidEdgeFileProperties.Property InternalUpdateCustomProperty(this SolidEdgeFileProperties.PropertyS |
| | | 45 | | { |
| | | 46 | | // Get a reference to the custom property set. |
| | 6 | 47 | | SolidEdgeFileProperties.Properties customPropertySet = (SolidEdgeFileProperties.Properties)propertySets["Custom" |
| | | 48 | | |
| | | 49 | | try |
| | | 50 | | { |
| | | 51 | | // Attempt to get the custom property. |
| | 6 | 52 | | SolidEdgeFileProperties.Property property = (SolidEdgeFileProperties.Property)customPropertySet[propertyName |
| | | 53 | | |
| | | 54 | | // If we get here, the custom property exists so update the value. |
| | 4 | 55 | | property.Value = propertyValue; |
| | 4 | 56 | | } |
| | 2 | 57 | | catch (System.Runtime.InteropServices.COMException) |
| | | 58 | | { |
| | | 59 | | // If we get here, the custom property does not exist so add it. |
| | 2 | 60 | | customPropertySet.Add(propertyName, propertyValue); |
| | 2 | 61 | | } |
| | | 62 | | |
| | 6 | 63 | | return null; |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Adds or modifies a custom property. |
| | | 68 | | /// </summary> |
| | 1 | 69 | | public static SolidEdgeFileProperties.Property UpdateCustomProperty(this SolidEdgeFileProperties.PropertySets proper |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Adds or modifies a custom property. |
| | | 73 | | /// </summary> |
| | 1 | 74 | | public static SolidEdgeFileProperties.Property UpdateCustomProperty(this SolidEdgeFileProperties.PropertySets proper |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// Adds or modifies a custom property. |
| | | 78 | | /// </summary> |
| | 1 | 79 | | public static SolidEdgeFileProperties.Property UpdateCustomProperty(this SolidEdgeFileProperties.PropertySets proper |
| | | 80 | | |
| | | 81 | | /// <summary> |
| | | 82 | | /// Adds or modifies a custom property. |
| | | 83 | | /// </summary> |
| | 1 | 84 | | public static SolidEdgeFileProperties.Property UpdateCustomProperty(this SolidEdgeFileProperties.PropertySets proper |
| | | 85 | | |
| | | 86 | | /// <summary> |
| | | 87 | | /// Adds or modifies a custom property. |
| | | 88 | | /// </summary> |
| | 2 | 89 | | public static SolidEdgeFileProperties.Property UpdateCustomProperty(this SolidEdgeFileProperties.PropertySets proper |
| | | 90 | | } |