Esempio n. 1
0
        /// <summary>
        /// Helper.
        /// </summary>
        void SetObjectPropertyValueByTag(object tag, object value)
        {
            if (tag is string)
            {// This is a dynamic generic property.
                SystemMonitor.CheckThrow(SelectedContainerObject != null);
                SelectedContainerObject.SetGenericDynamicPropertyValue(tag as string, value);
            }
            else if (tag is PropertyInfo)
            {// Direct property of the indicator.
                PropertyInfo info = (PropertyInfo)tag;
                if (info.CanWrite)
                {
                    info.SetValue(_selectedObject, value, null);
                }
                else
                {
                    SystemMonitor.OperationError("Property set method not found [" + info.DeclaringType.Name + ":" + info.Name + "].");
                }
            }
            else
            {
                SystemMonitor.Error("Unrecognized tag type for indicator property.");
            }

            if (SelectedContainerObject != null)
            {
                SelectedContainerObject.PropertyChanged();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the user of this interface to force an update to an object.
        /// Also the object itself can raise an request to be updated (saved).
        /// </summary>
        public bool RestoreObjectState(IPersistentEx persistent)
        {
            TracerHelper.Trace("[" + ActualPersistentId(persistent) + "] invoked by :" + ReflectionHelper.GetFullCallingMethodName(3));

            lock (this)
            {
                string persistentName = ActualPersistentId(persistent);
                SystemMonitor.CheckThrow(_verificationObjects.ContainsKey(persistentName) == false || _verificationObjects[persistentName] == persistent);

                if (_restoredObjects.ContainsKey(persistentName) == false
                    /*|| _restoredObjects[persistentName].Values.Count == 0*/)
                {// Object restoration infromation not found.
                    return(false);
                }

                PersistentData dataCopy = _restoredObjects[persistentName].Clone();
                bool           result   = persistent.OnRestoreState(this, dataCopy);

                if (result)
                {// Object restored successfully, remove pending restoration information.
                    _restoredObjects.Remove(persistentName);
                }

                return(result);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="handlerClassType"></param>
        public AutomatedControlEventHandlerAttribute(Type[] handlerClassTypes)
        {
            foreach (Type handlerClassType in handlerClassTypes)
            {
                SystemMonitor.CheckThrow(handlerClassType.IsSubclassOf(typeof(AutomatedControlEventHandler)), "Only shortcut handler classes can be used as attribute parameter.");
            }

            _handlerClassTypes = handlerClassTypes;
        }
Esempio n. 4
0
        /// <summary>
        /// Helper.
        /// </summary>
        protected Type GetPropertyTypeByTag(object tag)
        {
            if (tag is string)
            {// Is generic dynamic property.
                SystemMonitor.CheckThrow(SelectedContainerObject != null);
                return(SelectedContainerObject.GetGenericDynamicPropertyType(tag as string));
            }

            // Is normal property.
            PropertyInfo info = (PropertyInfo)tag;

            if (Nullable.GetUnderlyingType(info.PropertyType) != null)
            {// Is nullable, establish underlying.
                return(Nullable.GetUnderlyingType(info.PropertyType));
            }
            else
            {// Direct aquisition.
                return(info.PropertyType);
            }
        }
Esempio n. 5
0
        public void RegisterObject(IPersistentEx persistent)
        {
            lock (this)
            {
                if (persistent.PersistencyIsInitialzed == false)
                {
                    TracerHelper.Trace("[" + ActualPersistentId(persistent) + "] invoked by: " + ReflectionHelper.GetFullCallingMethodName(2));

                    persistent.InitializePersistency(this);

                    if (_pendingSaveObjects.ContainsKey(ActualPersistentId(persistent)) == false)
                    {
                        _pendingSaveObjects.Add(ActualPersistentId(persistent), new PersistentData());
                    }

                    SystemMonitor.CheckThrow(_verificationObjects.ContainsKey(ActualPersistentId(persistent)) == false);
                    _verificationObjects.Add(ActualPersistentId(persistent), persistent);
                }

                System.Diagnostics.Debug.Assert(_verificationObjects.ContainsKey(ActualPersistentId(persistent)));
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Make sure this is not the initial clause, since operation (OR) pre-pended to the current operation.
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="value"></param>
 public void AddORClause(string fieldName, object value)
 {
     SystemMonitor.CheckThrow(ClauseCount != 0);
     _clauses.Add(new MatchClause(MatchClause.OperationEnum.OR, fieldName, value));
 }