8 #include <system/type_info.h>
9 #include <system/object_ext.h>
10 #include <system/exceptions.h>
11 #include <system/enumerator_adapter.h>
12 #include <system/details/pointer_collection_helpers.h>
13 #include <system/constraints.h>
14 #include <system/collections/keyvalue_pair.h>
15 #include <system/collections/ienumerator.h>
16 #include <system/collections/icollection.h>
17 #include <system/collections/dictionary.h>
18 #include <system/array.h>
21 #include "aspose.tasks.cpp/PropertyCollections/PropertyCollection.h"
22 #include "aspose.tasks.cpp/PropertyCollections/Property.h"
30 class CustomProjectPropertyWrapperCollection;
31 template <
typename>
class PropertyCollection;
40 namespace Properties {
54 typedef System::Collections::Generic::ICollection<T> BaseType1;
56 typedef ::System::BaseTypesInfo<BaseType, BaseType1> ThisTypeBaseTypesInfo;
57 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
59 friend class Aspose::Tasks::Properties::CustomProjectPropertyWrapperCollection;
67 System::SharedPtr<System::Collections::Generic::ICollection<System::String>>
get_Names()
69 return this->dictionary->get_Keys();
77 return this->dictionary->get_Count();
92 return this->Get(name);
98 this->ThrowIfReadOnly();
99 this->ClearInternal();
109 return this->dictionary->ContainsKey(name);
116 void Add(
const T& item)
override
118 this->ThrowIfReadOnly();
119 this->AddInternal(item);
122 void SetTemplateWeakPtr(uint32_t argument)
override
127 System::Details::CollectionHelpers::SetWeakPointer(0, dictionary);
128 BaseType::SetTemplateWeakPtr(0);
137 PropertyKeyedCollection()
138 : dictionary(System::MakeObject<System::Collections::Generic::Dictionary<System::String, T>>())
147 void idx_set(
const System::String& name, T value)
149 this->ThrowIfReadOnly();
150 this->Set(name, value);
153 System::SharedPtr<System::Collections::Generic::IEnumerator<T>> GetEnumeratorInternal()
override
155 return this->dictionary->get_Values()->GetEnumerator();
158 bool TryGetValue(
const System::String& key, T& value)
160 return this->dictionary->TryGetValue(key, value);
168 void AddInternal(T value)
170 if (System::ObjectExt::UnknownIsNull(value))
172 throw System::ArgumentNullException(u
"value");
175 this->dictionary->Add(value->get_Name(), value);
182 bool RemoveInternal(
const System::String& key)
184 return this->dictionary->Remove(key);
190 virtual void ClearInternal()
192 this->dictionary->Clear();
195 void ThrowIfReadOnly()
199 throw System::NotSupportedException(this->GetType().get_Name() + u
" is read-only.");
207 bool RemoveInternal(T item)
210 for (
auto&& kvp : this->dictionary)
212 if (System::ObjectExt::Equals(kvp.get_Value(), item))
218 return key !=
nullptr && this->RemoveInternal(key);
230 virtual void Set(System::String key, T value)
232 this->dictionary->idx_set(key, value);
241 virtual T Get(System::String key)
243 return this->dictionary->idx_get(key);
246 virtual ~PropertyKeyedCollection()
250 #ifdef ASPOSE_GET_SHARED_MEMBERS
251 void GetSharedMembers(System::Object::shared_members_type& result)
const override
255 result.Add(
"Aspose::Tasks::Properties::PropertyKeyedCollection::dictionary", this->dictionary);
263 System::SharedPtr<System::Collections::Generic::Dictionary<System::String, T>> dictionary;
266 bool Contains(
const T& item)
const override
268 for (
auto&& kvp : this->dictionary)
270 if (System::ObjectExt::Equals(kvp.get_Value(), item))
280 bool Remove(
const T& item)
override
282 this->ThrowIfReadOnly();
283 return this->RemoveInternal(item);
287 void CopyTo(System::ArrayPtr<T> array, int32_t arrayIndex)
override
289 this->dictionary->get_Values()->CopyTo(array, arrayIndex);
A base class of collection of properties.
Definition: PropertyCollection.h:26
Represents a base class of a property.
Definition: Property.h:34
A base class of collection of properties.
Definition: PropertyKeyedCollection.h:48
int32_t get_Count() const override
Gets the number of properties in the collection.
Definition: PropertyKeyedCollection.h:75
void Clear() override
Definition: PropertyKeyedCollection.h:96
bool Contains(const System::String &name) const
Determines whether the Aspose::Tasks::Properties::PropertyCollection<T> contains a property with the ...
Definition: PropertyKeyedCollection.h:107
T idx_get(const System::String &name)
Gets the Property associated with the specified key.
Definition: PropertyKeyedCollection.h:90
System::SharedPtr< System::Collections::Generic::ICollection< System::String > > get_Names()
Gets the collection of all property names.
Definition: PropertyKeyedCollection.h:67
void Add(const T &item) override
Creates a new custom property.
Definition: PropertyKeyedCollection.h:116
bool get_IsReadOnly() const override=0
Gets a value indicating whether this collection is read-only; otherwise, false.