Ejemplo n.º 1
0
        private void SetupBuildArgs(List <KeyValuePair <string, string> > nameList)
        {
            // add common types
            var commonTypeList  = GetCommonTypes();
            var propertyTypeSet = new HashSet <Type>(commonTypeList);

            // load type
            foreach (var item in nameList)
            {
                // convert to .net type
                var typeName = item.Key.Replace('/', '+');

                // get type
                var type = BindingEditorUtility.GetClassByName(typeName).FirstOrDefault();
                if (type == null)
                {
                    Debug.LogWarningFormat("Invalid type name {0}", typeName);
                    continue;
                }

                // get property
                var property = type.GetProperty(item.Value);
                if (property == null)
                {
                    Debug.LogWarningFormat("Invalid property name {0}", item.Value);
                    continue;
                }

                var aotType = GetAotType(property.PropertyType);
                if (!propertyTypeSet.Contains(aotType))
                {
                    // add it
                    propertyTypeSet.Add(aotType);
                }
            }

            // combine with custom properties
            Combine(propertyTypeSet, GetCustomProperties());

            // sort type set
            var sortedList = GetSortedTypeList(propertyTypeSet);

            // set property list
            foreach (var item in sortedList)
            {
                var newItem = new BuildArgs.PropertyItem()
                {
                    propertyType = item,
                };

                buildArgs.propertyList.Add(newItem);
            }

            // get implicit operators
            var types = ImplicitConverter.GetTypes();
            var operatorDictionary = BindingUtility.GetImplicitOperators(types);

            // set implicit operator list
            foreach (var item in operatorDictionary)
            {
                var newItem = new BuildArgs.ImplicitOperatorItem()
                {
                    sourceType = item.Key.Item1,
                    targetType = item.Key.Item2,
                };

                buildArgs.implicitOperatorList.Add(newItem);
            }
        }