Ejemplo n.º 1
0
        private void UpdateAttributes()
        {
            var viewModel = ViewModel;

            if (viewModel == null)
            {
                return;
            }

            List <string> attributesList            = new List <string>();
            IDictionary <string, object> attributes = currentTemplate.GetAttributes();

            if (attributes != null)
            {
                foreach (var attribute in attributes)
                {
                    object value     = attribute.Value;
                    IList  valueList = value as IList;
                    if (valueList != null)
                    {
                        value = valueList.ToListString();
                    }

                    if (currentTemplate.addAttrEvents != null)
                    {
                        List <AddAttributeEvent> events;
                        currentTemplate.addAttrEvents.TryGetValue(attribute.Key, out events);
                        StringBuilder locations = new StringBuilder();
                        int           i         = 0;
                        if (events != null)
                        {
                            foreach (AddAttributeEvent ae in events)
                            {
                                if (i > 0)
                                {
                                    locations.Append(", ");
                                }

                                locations.AppendFormat("{0}:{1}", Path.GetFileName(ae.GetFileName()), ae.GetLine());
                                i++;
                            }
                        }

                        attributesList.Add(string.Format("{0} = {1} @ {2}", attribute.Key, value, locations));
                    }
                    else
                    {
                        attributesList.Add(string.Format("{0} = {1}", attribute.Key, value));
                    }
                }
            }

            viewModel.Attributes = attributesList;
        }