Aspose.Tasks for C++
GenericProperty.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="GenericProperty.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/object_ext.h>
9 #include <system/multicast_delegate.h>
10 #include <system/exceptions.h>
11 #include <system/details/pointer_collection_helpers.h>
12 #include <system/default.h>
13 #include <system/constraints.h>
14 #include <cstdint>
15 
16 namespace Aspose
17 {
18 namespace Tasks
19 {
20 namespace Properties
21 {
22 class ProjectPropertyCollection;
23 class ResourceAssignmentPropertyCollection;
24 class ResourcePropertyCollection;
25 class TaskPropertyCollection;
26 } // namespace Properties
27 namespace Util
28 {
29 template <typename TResult> using Func2 = System::MulticastDelegate<TResult()>;
30 } // namespace Util
31 } // namespace Tasks
32 } // namespace Aspose
33 
34 namespace Aspose {
35 
36 namespace Tasks {
37 
38 namespace Properties {
39 
40 /// <summary>
41 /// Represents a container property.
42 /// </summary>
43 /// <typeparam name="TKey">The type of property value.</typeparam>
44 template<typename TKey>
45 class GenericProperty : public System::Object, public System::Details::BoxableObjectBase
46 {
47  assert_is_cs_struct(TKey);
48 
50  typedef System::Object BaseType;
51 
52  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
53  RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
54 
55  friend class Aspose::Tasks::Properties::ProjectPropertyCollection;
56  friend class Aspose::Tasks::Properties::ResourcePropertyCollection;
57  friend class Aspose::Tasks::Properties::ResourceAssignmentPropertyCollection;
58  friend class Aspose::Tasks::Properties::TaskPropertyCollection;
59  template<typename FT0> friend class Aspose::Tasks::Properties::GenericProperty;
60 
61 public:
62 
63  /// <summary>
64  /// Gets a name of the property.
65  /// </summary>
66  System::String get_Name()
67  {
68  return (*this).name != nullptr ? (*this).name : System::ObjectExt::ToString((*this).key);
69  }
70 
71  /// <summary>
72  /// Gets a value of the property.
73  /// </summary>
74  System::SharedPtr<System::Object> get_Value()
75  {
76  return (*this).getValue();
77  }
78 
79  /// <summary>Initializes a new instance of the <see cref="GenericProperty{TKey}"></see> struct.</summary>
80  /// <param name="name">The name of the property.</param>
81  GenericProperty(const System::String& name) : key(TKey())
82  {
83  (*this).name = name;
84  (*this).getValue = nullptr;
85  (*this).key = System::Default<TKey>();
86  }
87 
88  GenericProperty() : key(TKey())
89  {
90  }
91 
92  void SetTemplateWeakPtr(uint32_t argument) override
93  {
94  switch (argument)
95  {
96  case 0:
97  System::Details::CollectionHelpers::SetWeakPointer(key);
98  break;
99 
100  }
101  }
102 
103 protected:
104 
105  /// <summary>
106  /// Initializes a new instance of the <see cref="GenericProperty{TKey}"></see> struct.
107  /// </summary>
108  GenericProperty(Aspose::Tasks::Util::Func2<System::SharedPtr<System::Object>> getValue, TKey key) : key(TKey())
109  {
110  if (getValue == nullptr)
111  {
112  throw System::ArgumentNullException(u"getValue");
113  }
114 
115  (*this).getValue = getValue;
116  (*this).key = key;
117  (*this).name.reset();
118  }
119 
120  MEMBER_FUNCTION_MAKE_OBJECT(GenericProperty, CODEPORTING_ARGS(Aspose::Tasks::Util::Func2<System::SharedPtr<System::Object>> getValue, TKey key), CODEPORTING_ARGS(getValue,key));
121  #ifdef ASPOSE_GET_SHARED_MEMBERS
122  void GetSharedMembers(System::Object::shared_members_type& result) const override
123  {
124  System::Object::GetSharedMembers(result);
125 
126  result.Add("Aspose::Tasks::Properties::GenericProperty::getValue", this->getValue);
127  result.Add("Aspose::Tasks::Properties::GenericProperty::key", this->key);
128  }
129  #endif
130 
131 
132 
133 private:
134 
135  System::String name;
136  Aspose::Tasks::Util::Func2<System::SharedPtr<System::Object>> getValue;
137  TKey key;
138 
139 };
140 
141 } // namespace Properties
142 } // namespace Tasks
143 } // namespace Aspose
144 
145 
Represents a container property.
Definition: GenericProperty.h:46
System::String get_Name()
Gets a name of the property.
Definition: GenericProperty.h:66
System::SharedPtr< System::Object > get_Value()
Gets a value of the property.
Definition: GenericProperty.h:74
GenericProperty(const System::String &name)
Initializes a new instance of the GenericProperty<TKey> struct.
Definition: GenericProperty.h:81
Definition: Asn.h:13