Esempio n. 1
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection props  = TypeDescriptor.GetProperties(value, attributes);
            List <PropertyDescriptor>    result = new List <PropertyDescriptor>(props.Count);

            foreach (PropertyDescriptor prop in props)
            {
                PropertyDescriptor addProperty = prop;

                if (ExcludedProperties.Contains(prop.Name))
                {
                    continue;
                }

                if (PropertyAttributes.ContainsKey(prop.PropertyType))
                {
                    List <Attribute> attributeList = new List <Attribute>(prop.Attributes.OfType <Attribute>());
                    attributeList.AddRange(PropertyAttributes[prop.PropertyType]);

                    addProperty = new PropertyGridPropertyDescriptor(prop, attributeList.ToArray());
                }

                result.Add(addProperty);
            }

            return(new PropertyDescriptorCollection(result.ToArray()));
        }
Esempio n. 2
0
        // Fired when an item in the collection has changed
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (Tracking)
            {
                var entity = sender as ITrackable;
                if (entity == null)
                {
                    return;
                }

                // Enable tracking on reference properties
#if SILVERLIGHT || NET40
                var prop = entity.GetType().GetProperty(e.PropertyName);
                if (prop != null && typeof(ITrackable).IsAssignableFrom(prop.PropertyType))
#else
                var prop = entity.GetType().GetTypeInfo().GetDeclaredProperty(e.PropertyName);
                if (prop != null && typeof(ITrackable).GetTypeInfo().IsAssignableFrom(prop.PropertyType.GetTypeInfo()))
#endif
                {
                    ITrackingCollection refPropChangeTracker = entity.GetRefPropertyChangeTracker(e.PropertyName);
                    if (refPropChangeTracker != null)
                    {
                        refPropChangeTracker.Tracking = Tracking;
                    }
                    return;
                }

                if (e.PropertyName != Constants.TrackingProperties.TrackingState &&
                    e.PropertyName != Constants.TrackingProperties.ModifiedProperties &&
                    !ExcludedProperties.Contains(e.PropertyName))
                {
                    // If unchanged mark item as modified, fire EntityChanged event
                    if (entity.TrackingState == TrackingState.Unchanged)
                    {
                        entity.TrackingState = TrackingState.Modified;
                        if (EntityChanged != null)
                        {
                            EntityChanged(this, EventArgs.Empty);
                        }
                    }

                    // Add prop to modified props, and fire EntityChanged event
                    if (entity.TrackingState == TrackingState.Unchanged ||
                        entity.TrackingState == TrackingState.Modified)
                    {
                        if (entity.ModifiedProperties == null)
                        {
                            entity.ModifiedProperties = new List <string>();
                        }
                        if (!entity.ModifiedProperties.Contains(e.PropertyName))
                        {
                            entity.ModifiedProperties.Add(e.PropertyName);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        // Fired when an item in the collection has changed
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (Tracking)
            {
                var entity = sender as ITrackable;
                if (entity == null)
                {
                    return;
                }

                // Enable tracking on reference properties
                var prop = PortableReflectionHelper.Instance.GetProperty(entity.GetType(), e.PropertyName);
                if (prop != null && PortableReflectionHelper.Instance.IsAssignable(typeof(ITrackable), prop.PropertyType))
                {
                    ITrackingCollection refPropChangeTracker = entity.GetRefPropertyChangeTracker(e.PropertyName);
                    if (refPropChangeTracker != null)
                    {
                        refPropChangeTracker.Tracking = Tracking;
                    }
                    return;
                }

                if (e.PropertyName != Constants.TrackingProperties.TrackingState &&
                    e.PropertyName != Constants.TrackingProperties.ModifiedProperties &&
                    !ExcludedProperties.Contains(e.PropertyName))
                {
                    // If unchanged mark item as modified, fire EntityChanged event
                    if (entity.TrackingState == TrackingState.Unchanged)
                    {
                        entity.TrackingState = TrackingState.Modified;
                        if (EntityChanged != null)
                        {
                            EntityChanged(this, EventArgs.Empty);
                        }
                    }

                    // Add prop to modified props, and fire EntityChanged event
                    if (entity.TrackingState == TrackingState.Unchanged ||
                        entity.TrackingState == TrackingState.Modified)
                    {
                        if (entity.ModifiedProperties == null)
                        {
                            entity.ModifiedProperties = new HashSet <string>();
                        }
                        entity.ModifiedProperties.Add(e.PropertyName);
                    }
                }
            }
        }
Esempio n. 4
0
        private bool FindUnFlattenedMatchRecursive(string sourcePropertyName, Stack <PropertyInfo> path, Type targetType)
        {
            var properties = ReflectionUtils.GetProperties(targetType);
            var prefix     = string.Join(string.Empty, path.Reverse().Select(p => p.Name));

            if (targetType.IsValueType || targetType.IsPrimitive || targetType == typeof(String))
            {
                return(false);
            }

            foreach (var property in properties)
            {
                // make sure we can write to it
                if (ExcludedProperties.Contains(property.Name) || !property.CanWrite || property.GetSetMethod() == null)
                {
                    continue;
                }

                bool isMatch = IsCaseSensitive
                    ? prefix + property.Name == sourcePropertyName
                    : (prefix + property.Name).Equals(sourcePropertyName, StringComparison.InvariantCultureIgnoreCase);

                // found it!
                if (isMatch)
                {
                    path.Push(property);
                    return(true);
                }

                // if we don't have a match and it's a value type then we're done, continue searching
                if (property.PropertyType.IsValueType)
                {
                    continue;
                }

                path.Push(property);

                // keep going down
                var result = FindUnFlattenedMatchRecursive(sourcePropertyName, path, property.PropertyType);
                if (result)
                {
                    return(true);
                }

                path.Pop();
            }

            return(false);
        }
        private void WriteInstances(TCLContainer nlc)
        {
            int instanceCount = 0;

            // GDN currnently only blockers re supported, overwrok twhen placing netlist!!!
            foreach (TCLInstance inst in nlc.Instances.Where(i => ((TCLInstance)i).BELType.Equals("GND")))
            {
                m_sw.WriteLine("# instance " + instanceCount++);

                if (!string.IsNullOrEmpty(inst.BELType) && inst.OmitPlaceCommand)
                {
                    // Used by blocker
                    m_sw.WriteLine("create_cell -reference " + inst.BELType + " " + inst.Name);
                }
                else
                {
                    m_sw.WriteLine("create_cell -reference " + inst.Properties.GetValue("REF_NAME") + " " + inst.Name);
                    string belName = inst.Properties.GetValue("BEL");
                    belName = belName.Remove(0, belName.IndexOf('.') + 1);

                    //this.m_sw.WriteLine("place_cell " + inst.Name + " " + inst.SliceName + "/" + belName);

                    bool wrapCatch =
                        inst.Properties.GetValue("REF_NAME").Equals("IBUF") ||
                        inst.Properties.GetValue("REF_NAME").Equals("OBUFT");

                    // we can not set "empty" values, e.g., "set_property ASYNC_REG  [get_sites IOB_X0Y1]"
                    foreach (TCLProperty prop in inst.Properties.Where(p => !string.IsNullOrEmpty(p.Value) && !p.ReadOnly && !ExcludedProperties.Contains(p.Name)))
                    {
                        string prefix = wrapCatch ? "catch {" : "";
                        string suffix = wrapCatch ? "}" : "";
                        string value  = prop.Value.Contains(" ") ? ("\"" + prop.Value + "\"") : prop.Value;
                        m_sw.WriteLine(prefix + "set_property " + prop.Name + " " + value + " [get_cells " + inst.Name + "]" + suffix);
                    }
                }
                m_sw.WriteLine("");
            }
        }