Ejemplo n.º 1
0
 public MethodInstance(Method method, ILiveObject target, bool isCoroutine, object returnObject = null, params object[] parameters)
 {
     this.method       = method;
     this.target       = target;
     this.isCoroutine  = isCoroutine;
     this.parameters   = parameters;
     this.returnObject = returnObject;
 }
Ejemplo n.º 2
0
            public SilencedProperty(PropertyChangeSilencer silencer, ILiveObject obj, string propertyName)
            {
                Silencer     = silencer;
                Object       = obj;
                PropertyName = propertyName;

                lock (silencer)
                    silencer.Properties.Add(this);
            }
Ejemplo n.º 3
0
        public void PublishObject(ILiveObject obj)
        {
            var typeDesc = (ObjectDescriptor)TypeContext.GetTypeDescriptor(obj.GetType());

            var objId = obj.ResourceId;

            if (String.IsNullOrEmpty(objId))
            {
                throw new Exception("Cannot publish a LiveObject with missing ResourceId!");
            }

            var existingObj = ObjectRepository.GetValueOrDefault(objId);

            //if (existingObj != null && existingObj != obj)
            //    throw new Exception($"Object's key is not unique: {objId}");
            if (existingObj != null && existingObj != obj)
            {
                Logger.Log($"[Warning] Object's key is not unique: {objId}");
            }
            ObjectRepository[objId] = obj;

            if (TrackChanges)
            {
                if (obj is INotifyPropertyChanged)
                {
                    ((INotifyPropertyChanged)obj).PropertyChanged += OnObjectPropertyChanged;
                }

                foreach (var propDesc in typeDesc.Properties.Values.Where(x => typeof(INotifyCollectionChanged).IsAssignableFrom(x.PropertyInfo.PropertyType)))
                {
                    var propValue = (INotifyCollectionChanged)propDesc.PropertyInfo.GetValue(obj);
                    if (propValue == null)
                    {
                        continue;
                    }

                    propValue.CollectionChanged += (sender, args) => ListChanged?.Invoke(this, obj, propDesc, args);
                }
            }
        }
Ejemplo n.º 4
0
 public IDisposable SilenceThis(ILiveObject obj, PropertyDescriptor propDesc)
 {
     return(new SilencedProperty(this, obj, propDesc.PropertyInfo.Name));
 }
Ejemplo n.º 5
0
 public bool IsSilenced(ILiveObject obj, string propName)
 {
     lock (this)
         return(Properties.Any(x => x.Object == obj && x.PropertyName == propName));
 }