コード例 #1
0
        public string[] RepopulateCandidateList(
            SerializedProperty targetProperty,
            SerializedProperty candidateNamesProperty,
            SerializedProperty indexProperty
            )
        {
            System.Type        type          = targetProperty.objectReferenceValue.GetType();
            System.Type[]      paramTypes    = this.paramTypes;
            IList <MemberInfo> candidateList = new List <MemberInfo>();

            string[] candidateNames;
            int      i = 0;

            Debug.Log("Candidate Criteria:");
            Debug.Log("\treturn type:" + returnType.ToString());
            Debug.Log("\tparam count:" + paramTypes.Length);
            foreach (System.Type paramType in paramTypes)
            {
                Debug.Log("\t\t" + paramType.ToString());
            }

            type.FindMembers(
                MemberTypes.Method,
                BindingFlags.Instance | BindingFlags.Public,
                (member, criteria) => {
                Debug.Log("matching " + member.Name);
                MethodInfo method;
                if ((method = type.GetMethod(member.Name, paramTypes)) != null && method.ReturnType == returnType)
                {
                    candidateList.Add(method);
                    return(true);
                }
                return(false);
            },
                null
                );

            // clear/resize/initialize storage containers
            candidateNamesProperty.ClearArray();
            candidateNamesProperty.arraySize = candidateList.Count;
            candidateNames = new string[candidateList.Count];

            // assign storage containers
            i = 0;
            foreach (SerializedProperty element in candidateNamesProperty)
            {
                element.stringValue = candidateNames[i] = candidateList[i++].Name;
            }

            // reset popup index
            indexProperty.intValue = 0;

            return(candidateNames);
        }
コード例 #2
0
ファイル: VsMsdeploy.cs プロジェクト: ZeroInfinite/websdk
 // Utility function to log all public instance property to CustomerBuildEventArgs
 private static void AddAllPropertiesToCustomBuildWithPropertyEventArgs(CustomBuildWithPropertiesEventArgs cbpEventArg, System.Object obj)
 {
     if (obj != null)
     {
         System.Type thisType = obj.GetType();
         cbpEventArg.Add("ArgumentType", thisType.ToString());
         System.Reflection.MemberInfo[] arrayMemberInfo = thisType.FindMembers(System.Reflection.MemberTypes.Property, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, null);
         if (arrayMemberInfo != null)
         {
             foreach (System.Reflection.MemberInfo memberinfo in arrayMemberInfo)
             {
                 object val = thisType.InvokeMember(memberinfo.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty, null, obj, null, System.Globalization.CultureInfo.InvariantCulture);
                 if (val != null)
                 {
                     cbpEventArg.Add(memberinfo.Name, val);
                 }
             }
         }
     }
 }
 public MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria) => t.FindMembers(memberType, bindingAttr, filter, filterCriteria);