Exemplo n.º 1
0
            private void WriteSetProperty(BuildArgs.Item item)
            {
                string setPropertyStatement = null;

                if (item.memberType == MemberTypes.Field)
                {
#if NET_4_6
                    setPropertyStatement = string.Format("SetProperty(ref {0}, value);", item.name);
#else
                    setPropertyStatement = string.Format("SetProperty(ref {0}, value, \"{1}\");", item.name, item.propertyName);
#endif
                }
                else if (item.memberType == MemberTypes.Property)
                {
#if NET_4_6
                    setPropertyStatement = string.Format("SetProperty({0}, value, x => {0} = x);", item.name);
#else
                    setPropertyStatement = string.Format("SetProperty({0}, value, x => {0} = x, \"{1}\");", item.name, item.propertyName);
#endif
                }
                else
                {
                    throw new InvalidOperationException("Invalid member type");
                }

                // single line style
                WriteLine("\tset {{ {0} }}", setPropertyStatement);
            }
Exemplo n.º 2
0
        public void LoadTypeList()
        {
            // create build args
            buildArgs = new BuildArgs();

            // get types
            var types = BindingEditorUtility.GetImplicitOperatorTypes(true);

            foreach (var item in types)
            {
                var newItem = new BuildArgs.Item()
                {
                    type = item,
                };

                // add it
                buildArgs.itemList.Add(newItem);
            }
        }
Exemplo n.º 3
0
        public void UpdateMemberList()
        {
            if (buildArgs == null)
            {
                return;
            }

            // clear member list
            buildArgs.memberList.Clear();

            var type = buildArgs.type;

            var flags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;

            if (includePublic)
            {
                // add public
                flags |= BindingFlags.Public;
            }

            // get all fields
            var fields = type.GetFields(flags).Where(x => !x.Name.EndsWith("k__BackingField"));

            foreach (var item in fields)
            {
                // create member
                var member = new BuildArgs.Item()
                {
                    type       = item.FieldType,
                    name       = item.Name,
                    memberType = MemberTypes.Field,
                };

                member.propertyName = BindingEditorUtility.GetPropertyName(item.Name);

                // add it
                buildArgs.memberList.Add(member);
            }

            if (!includeProperty)
            {
                return;
            }

            // get all properties
            var properties = type.GetProperties(flags);

            foreach (var item in properties)
            {
                // create member
                var member = new BuildArgs.Item()
                {
                    type       = item.PropertyType,
                    name       = item.Name,
                    memberType = MemberTypes.Property,
                };

                member.propertyName = BindingEditorUtility.GetPropertyName(item.Name);

                // add it
                buildArgs.memberList.Add(member);
            }
        }