Esempio n. 1
0
        protected CodeMemberProperty RenderProperty(object instance, KeyValuePair <PropertyInfo, GenerateProperty> templateProperty)
        {
            var domObject = TemplateType.PropertyFromTypeProperty(templateProperty.Key.Name);

            CurrentMember    = domObject;
            CurrentAttribute = templateProperty.Value;
            //if (templateProperty.Value.AutoFill != AutoFillType.None)
            //{
            //    domObject.Name = string.Format(templateProperty.Value.NameFormat, this.Item.Name.Clean());
            //}

            //if (templateProperty.Value.AutoFill == AutoFillType.NameAndType ||
            //    templateProperty.Value.AutoFill == AutoFillType.NameAndTypeWithBackingField)
            //{
            //    var typedItem = Item as ITypedItem;
            //    if (typedItem != null)
            //    {
            //        if (domObject.Type.TypeArguments.Count > 0)
            //        {
            //            domObject.Type.TypeArguments.Clear();
            //            domObject.Type.TypeArguments.Add(typedItem.RelatedTypeName);
            //        }
            //        else
            //        {
            //            domObject.Type = new CodeTypeReference(typedItem.RelatedTypeName);
            //        }
            //    }
            //}
            PushStatements(domObject.GetStatements);
            templateProperty.Key.GetValue(instance, null);
            PopStatements();
            if (templateProperty.Key.CanWrite)
            {
                PushStatements(domObject.SetStatements);
                //CurrentStatements = domObject.SetStatements;
                templateProperty.Key.SetValue(instance,
                                              GetDefault(templateProperty.Key.PropertyType),
                                              null);
                PopStatements();
            }

            if (!IsDesignerFile && domObject.Attributes != MemberAttributes.Final && templateProperty.Value.Location == TemplateLocation.Both)
            {
                domObject.Attributes |= MemberAttributes.Override;
            }

            return(domObject);
        }