コード例 #1
0
 public virtual void NotifyReadProperty(object obj, string propertyName, ref object value)
 {
     if (this.isDisposed) { return; }
     if (notification != Notification.Full) { return; }
     PropertyEventArgs e = new PropertyEventArgs(obj, propertyName, null, value, this.Context.ObjectManager.GetNullValueStatus(obj, propertyName));
     this.Context.EventManager.OnReadProperty(this, e);
     value = e.Value;
 }
コード例 #2
0
		public virtual void NotifyWroteProperty(object obj, string propertyName, object value, object oldValue)
		{
			if (this.isDisposed) { return; }
			if (notification != Notification.Full) { return; }
			PropertyEventArgs e = new PropertyEventArgs(obj, propertyName, value, this.Context.ObjectManager.GetPropertyValue(obj, propertyName), this.Context.ObjectManager.GetNullValueStatus(obj, propertyName));
			this.Context.EventManager.OnWroteProperty(this, e);
		}
コード例 #3
0
 public virtual void OnLoadedProperty(object sender, PropertyEventArgs e)
 {
 }
コード例 #4
0
 public virtual void OnWroteProperty(object sender, PropertyEventArgs e)
 {
 }
コード例 #5
0
		public virtual void LoadProperty(object obj, string propertyName)
		{
			this.SqlEngineManager.Context.LogManager.Info(this, "Loading property", "Property: " + propertyName + ", Object Type: " + obj.GetType().ToString()); // do not localize
			IList parameters;
			object value;
			object orgValue;
			IContext ctx = m_SqlEngineManager.Context;
			PropertyCancelEventArgs e = new PropertyCancelEventArgs(obj, propertyName);
			ctx.EventManager.OnLoadingProperty(this, e);
			if (e.Cancel)
			{
				return;
			}
			IClassMap classMap = ctx.DomainMap.MustGetClassMap(obj.GetType());
			IPropertyMap propertyMap = classMap.MustGetPropertyMap(propertyName);
			if (propertyMap.IsCollection)
			{
				LoadCollectionProperty(obj, propertyMap);
				return;
			}
			if (!(propertyMap.ReferenceType == ReferenceType.None))
			{
				LoadReferenceProperty(obj, propertyMap);
				return;
			}
			if (!(propertyMap.MustGetTableMap() == classMap.MustGetTableMap()))
			{
				LoadNonPrimaryProperty(obj, propertyMap);
				return;
			}
			parameters = new ArrayList() ;
			IObjectManager om = ctx.ObjectManager;
			IPersistenceManager pm = ctx.PersistenceManager;
			string sql = GetSelectPropertyStatement(obj, propertyName, parameters);
			IDataSource ds = ctx.DataSourceManager.GetDataSource(obj);
			object[,] result = (object[,]) ctx.SqlExecutor.ExecuteArray(sql, ds, parameters);
			if (Util.IsArray(result))
			{
				orgValue = result[0, 0];
				value = pm.ManageLoadedValue(obj, propertyMap, orgValue);
				om.SetPropertyValue(obj, propertyName, value);
				om.SetOriginalPropertyValue(obj, propertyName, orgValue);
				om.SetNullValueStatus(obj, propertyName, DBNull.Value.Equals(orgValue));
			}
			else
			{
				throw new ObjectNotFoundException("Object not found!"); // do not localize
			}
			PropertyEventArgs e2 = new PropertyEventArgs(obj, propertyName);
			ctx.EventManager.OnLoadedProperty(this, e2);
		}
コード例 #6
0
 public void Context_WroteProperty_Cnt(object sender, PropertyEventArgs e)
 {
     wroteCnt++;
 }
コード例 #7
0
 public void Context_ReadProperty_Cnt(object sender, PropertyEventArgs e)
 {
     readCnt++;
 }
コード例 #8
0
 public void Context_ReadProperty_Cancel(object sender, PropertyEventArgs e)
 {
     if (e.Value.Equals("Nancy"))
     {
         e.Value = "Name hidden";
     }
     readCnt++;
 }
コード例 #9
0
		public virtual void OnWroteProperty(object sender, PropertyEventArgs e)
		{
			if (this.ValidationManager.ValidateOnWroteProperty)
			{
				if (e.EventObject is IValidatable)
				{
					((IValidatable) (e.EventObject)).Validate();
				}
			}
			if (!(m_RaiseEvents))
			{
				return;
			}
			if (!(m_RaiseAfterEvents))
			{
				return;
			}
			if (!(m_RaisePropertyEvents))
			{
				return;
			}
			foreach (IObserver observer in m_Observers)
			{
				observer.OnWroteProperty(sender, e);
			}
			foreach (IObserver observer in m_AllTypeObservers)
			{
				observer.OnWroteProperty(sender, e);
			}
			foreach (IObserver observer in GetTypeObservers(e.EventObject))
			{
				observer.OnWroteProperty(sender, e);
			}
			foreach (IObserver observer in GetObjectObservers(e.EventObject))
			{
				observer.OnWroteProperty(sender, e);
			}
			if (e.EventObject is IObservable)
			{
				foreach (IEventListener eventListener in ((IObservable) (e.EventObject)).GetEventListeners())
				{
					eventListener.OnWroteProperty(sender, e);
				}
			}
			this.Observer.OnWroteProperty(sender, e);
			if (e.EventObject is IEventListener)
			{
				((IEventListener) (e.EventObject)).OnWroteProperty(sender, e);
			}
		}