Example #1
0
        private InterlockedPropertyInfo GetPropertyInfo(INotifyPropertyChanged target, string propertyName, params Type[] allowedTypes)
        {
            ObjectEntry entry;

            if ((target == null) || !this.Client.ObjectsManager.TryGetValue(target, out entry))
            {
                throw new ArgumentException("Target specified is not found or is not valid.", "target");
            }

            SharedProperty property = entry.Properties.Values.FirstOrDefault(p => p.Name == propertyName);

            if (property == null)
            {
                throw new ArgumentException("propertyName specified is not found or is not valid.", "propertyName");
            }

            Type propertyType = target.GetPropertyType(propertyName);

            if (allowedTypes.FirstOrDefault(t => t == propertyType) == null)
            {
                throw new ArgumentException("Property type is not supported or compatible with parameter", "propertyName");
            }

            return(new InterlockedPropertyInfo {
                ObjectId = entry.Id, Property = property, PropertyType = propertyType
            });
        }