00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 using System;
00013 using System.Collections.Generic;
00014 using System.Diagnostics;
00015 using Mcs.Epm.MicrosoftProject.mpFx.ResourcesWebService;
00016
00017 namespace Mcs.Epm.MicrosoftProject.mpFx
00018 {
00019
00020
00021
00022 public class ResourceCustomField
00023 {
00024 #region Instance data
00025
00026 private readonly ResourceCustomFieldsCollection _Parent;
00027 private object _Value;
00028
00029 #endregion
00030
00031 #region Constructor
00032
00033
00034
00035
00036
00037
00038 internal ResourceCustomField(ResourceCustomFieldsCollection parent,
00039 Guid propertyGuid,
00040 string name)
00041 {
00042 if (parent == null)
00043 {
00044 throw new ArgumentNullException( );
00045 }
00046
00047 _Parent = parent;
00048
00049 Name = name;
00050
00051 PropertyGuid = propertyGuid;
00052 }
00053
00054 #endregion
00055
00056 #region Public Properties
00057
00058
00059
00060
00061 public bool IsList
00062 {
00063 get
00064 {
00065 object temp = Value;
00066
00067 return _Value as List<object> != null;
00068 }
00069 }
00070
00071
00072
00073
00074 public List<object> List
00075 {
00076 get
00077 {
00078 if (IsList)
00079 {
00080 return _Value as List<object>;
00081 }
00082 return null;
00083 }
00084 }
00085
00086
00087
00088
00089 public CustomFieldValueType Type { get; private set; }
00090
00091
00092
00093
00094 public Guid PropertyGuid { get; private set; }
00095
00096
00097
00098
00099 public string Name { get; private set; }
00100
00101
00102
00103
00104 public object Value
00105 {
00106 get
00107 {
00108 if (_Value == null)
00109 {
00110 LoadResourceCustomFieldValue();
00111 }
00112
00113 return _Value;
00114 }
00115 }
00116
00117 #endregion
00118
00119 #region Private Methods
00120
00121
00122
00123
00124 private void LoadResourceCustomFieldValue()
00125 {
00126 List<object> values = new List<object>();
00127
00128 CustomFieldValueType type = CustomFieldValueType.None;
00129
00130 foreach (ResourceDataSet.ResourceCustomFieldsRow customField in _Parent.Parent.CustomFieldsDataSet.Rows)
00131 {
00132 if (customField.MD_PROP_UID == PropertyGuid)
00133 {
00134 object value;
00135
00136 if (ResourceCustomFieldsCollection.TryGetFieldValueInformation(_Parent.Parent.Parent.Parent,
00137 _Parent.Parent.Parent.CustomFieldsDataSet.CustomFields.FindByMD_PROP_UID(PropertyGuid),
00138 customField,
00139 true,
00140 out value,
00141 out type))
00142 {
00143 values.Add(value);
00144 }
00145 }
00146 }
00147
00148 if (values.Count > 1)
00149 {
00150 _Value = values;
00151 }
00152 else
00153 {
00154 if (values.Count == 1)
00155 {
00156 _Value = values[0];
00157
00158 Type = type;
00159 }
00160 else
00161 {
00162 Debug.Assert(values.Count == 0);
00163
00164 _Value = null;
00165
00166 Type = CustomFieldValueType.None;
00167 }
00168 }
00169 }
00170
00171 #endregion
00172 }
00173 }
00174
00175
00176
00177
00178
00179
00180