Exemplo n.º 1
0
 public override void OnCreated()
 {
     BloxSettingsWindow.onSavedBlocksSettings = (Action)Delegate.Remove(BloxSettingsWindow.onSavedBlocksSettings, new Action(MemberBindProviderEd.OnBlockSelectionChanged));
     BloxSettingsWindow.onSavedBlocksSettings = (Action)Delegate.Combine(BloxSettingsWindow.onSavedBlocksSettings, new Action(MemberBindProviderEd.OnBlockSelectionChanged));
     BloxSettingsWindow.onSavedBlocksSettings = (Action)Delegate.Remove(BloxSettingsWindow.onSavedBlocksSettings, new Action(this.OnBlockSelectionChanged2));
     BloxSettingsWindow.onSavedBlocksSettings = (Action)Delegate.Combine(BloxSettingsWindow.onSavedBlocksSettings, new Action(this.OnBlockSelectionChanged2));
     if (MemberBindProviderEd.loader == null)
     {
         MemberBindProviderEd.loader = plyEdCoroutine.Start(MemberBindProviderEd.Loader(), true);
     }
 }
Exemplo n.º 2
0
 private static void OnBlockSelectionChanged()
 {
     if (MemberBindProviderEd.loader != null)
     {
         MemberBindProviderEd.loader.Stop();
         MemberBindProviderEd.loader = null;
     }
     MemberBindProviderEd.scanTypes       = null;
     MemberBindProviderEd.getterBindables = null;
     MemberBindProviderEd.setterBindables = null;
     MemberBindProviderEd.loader          = plyEdCoroutine.Start(MemberBindProviderEd.Loader(), true);
 }
Exemplo n.º 3
0
        private void InitCurrBindables(MemberBindProvider target, bool isForSetter)
        {
            if (this.currBindables != null && this.currBindableLabels != null)
            {
                return;
            }
            Dictionary <string, BindableData> dictionary = isForSetter ? MemberBindProviderEd.setterBindables : MemberBindProviderEd.getterBindables;

            this.currBindables = new BindableData[dictionary.Count];
            dictionary.Values.CopyTo(this.currBindables, 0);
            this.currBindableLabels = new GUIContent[this.currBindables.Length];
            for (int i = 0; i < this.currBindables.Length; i++)
            {
                this.currBindableLabels[i] = new GUIContent(this.currBindables[i].visibleName);
            }
            this.memberBindIdx = -1;
            BloxMemberInfo member     = target.member;
            string         memberName = MemberBindProviderEd.GetMemberName((member != null) ? member.MI : null);

            if (!string.IsNullOrEmpty(memberName))
            {
                int num = 0;
                while (num < this.currBindables.Length)
                {
                    if (!(memberName == this.currBindables[num].visibleName))
                    {
                        num++;
                        continue;
                    }
                    this.memberBindIdx = num;
                    break;
                }
            }
            if (target.sourceObjType == MemberBindProvider.DataSourceOject.Instance && target.member != null)
            {
                this.InitSubBindables(target, target.member.ReflectedType);
            }
        }
Exemplo n.º 4
0
        private static void ProcessBindableMember(MemberInfo mi, Type valType, bool inclOnlySpecifiedMembers)
        {
            Debug.Log("ProcessBindableMember", "MemberBindProviderEd", Color.red);
            bool flag = inclOnlySpecifiedMembers;

            object[] customAttributes = mi.GetCustomAttributes(true);
            for (int i = 0; i < customAttributes.Length; i++)
            {
                Type type = customAttributes[i].GetType();
                if (type == typeof(IncludeInBloxAttribute))
                {
                    flag = false;
                }
                if (type == typeof(ExcludeFromBloxAttribute))
                {
                    flag = true;
                    break;
                }
                if (type == typeof(BloxEventAttribute))
                {
                    flag = true;
                    break;
                }
                if (type == typeof(ObsoleteAttribute))
                {
                    flag = true;
                    break;
                }
                if (type == typeof(ExcludeFromDocsAttribute))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                Type           _              = mi.ReflectedType;
                string         memberName     = MemberBindProviderEd.GetMemberName(mi);
                BloxMemberInfo bloxMemberInfo = new BloxMemberInfo(mi, null);
                if (bloxMemberInfo.CanGetValue && valType != null && valType != typeof(void) && !MemberBindProviderEd.getterBindables.ContainsKey(memberName))
                {
                    MemberBindProviderEd.getterBindables.Add(memberName, new BindableData
                    {
                        visibleName = memberName,
                        mi          = bloxMemberInfo,
                        type        = valType
                    });
                }
                if (!bloxMemberInfo.CanSetValue && bloxMemberInfo.MemberType != MemberTypes.Method)
                {
                    return;
                }
                if (!MemberBindProviderEd.setterBindables.ContainsKey(memberName))
                {
                    MemberBindProviderEd.setterBindables.Add(memberName, new BindableData
                    {
                        visibleName = memberName,
                        mi          = bloxMemberInfo,
                        type        = ((bloxMemberInfo.MemberType == MemberTypes.Method) ? typeof(object) : valType)
                    });
                }
            }
        }
Exemplo n.º 5
0
        private static IEnumerator Loader()
        {
            Debug.Log("Loader", "MemberBindProviderEd", Color.blue);
            int count            = 0;
            int countBeforeYield = 20;

            if (MemberBindProviderEd.getterBindables == null || MemberBindProviderEd.setterBindables == null)
            {
                MemberBindProviderEd.getterBindables = new Dictionary <string, BindableData>();
                MemberBindProviderEd.setterBindables = new Dictionary <string, BindableData>();
                if (MemberBindProviderEd.scanTypes == null)
                {
                    MemberBindProviderEd.scanTypes = new List <Type>();
                    List <Type> usedValueTypes = new List <Type>(20)
                    {
                        typeof(bool),
                        typeof(int),
                        typeof(float),
                        typeof(string),
                        typeof(Vector2),
                        typeof(Vector3),
                        typeof(Rect),
                        typeof(Color)
                    };
                    new List <Type>();
                    List <string> lines = plyEdUtil.ReadCompressedLines(plyEdUtil.ProjectFullPath + BloxEdGlobal.MiscPath + "blocks.bin");
                    if (lines.Count > 0)
                    {
                        yield return((object)null);

                        for (int i = 0; i < lines.Count; i++)
                        {
                            string text = lines[i];
                            if (!string.IsNullOrEmpty(text))
                            {
                                BloxMemberInfo bloxMemberInfo = BloxMemberInfo.DecodeMember(text);
                                if (bloxMemberInfo != null && !MemberBindProviderEd.scanTypes.Contains(bloxMemberInfo.ReflectedType))
                                {
                                    MemberBindProviderEd.scanTypes.Add(bloxMemberInfo.ReflectedType);
                                }
                                count++;
                                if (count >= countBeforeYield)
                                {
                                    count = 0;
                                    yield return((object)null);
                                }
                            }
                        }
                    }
                    foreach (Type item in usedValueTypes)
                    {
                        if (!MemberBindProviderEd.scanTypes.Contains(item))
                        {
                            MemberBindProviderEd.scanTypes.Add(item);
                        }
                    }
                    yield return((object)null);

                    MemberBindProviderEd.scanTypes.Sort((Type a, Type b) => a.FullName.CompareTo(b.FullName));
                }
                List <Type> .Enumerator enumerator2 = MemberBindProviderEd.scanTypes.GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        Type current2 = enumerator2.Current;
                        if (current2.IsClass && !current2.IsEnum && (!current2.IsAbstract || current2.IsSealed) && !current2.IsSpecialName && !current2.IsSubclassOf(typeof(Attribute)) && current2 != typeof(Attribute) && !current2.IsSubclassOf(typeof(Delegate)) && current2 != typeof(Delegate) && !current2.IsSubclassOf(typeof(Exception)) && current2 != typeof(Exception) && !current2.IsSubclassOf(typeof(BloxEventHandler)) && current2 != typeof(BloxEventHandler))
                        {
                            bool     inclOnlySpecifiedMembers = false;
                            object[] customAttributes         = current2.GetCustomAttributes(typeof(ExcludeFromBloxAttribute), true);
                            if (customAttributes.Length != 0)
                            {
                                if (!((ExcludeFromBloxAttribute)customAttributes[0]).ExceptForSpecifiedMembers)
                                {
                                    continue;
                                }
                                inclOnlySpecifiedMembers = true;
                            }
                            bool         flag         = true;
                            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
                            if (BloxEd.Instance.includeDeclaredOnly | flag)
                            {
                                bindingFlags = (BindingFlags)((int)bindingFlags | 2);
                            }
                            PropertyInfo[] properties = current2.GetProperties(bindingFlags);
                            for (int j = 0; j < properties.Length; j++)
                            {
                                PropertyInfo propertyInfo = properties[j];
                                MemberBindProviderEd.ProcessBindableMember(propertyInfo, propertyInfo.PropertyType, inclOnlySpecifiedMembers);
                            }
                            FieldInfo[] fields = current2.GetFields(bindingFlags);
                            for (int j = 0; j < fields.Length; j++)
                            {
                                FieldInfo fieldInfo = fields[j];
                                MemberBindProviderEd.ProcessBindableMember(fieldInfo, fieldInfo.FieldType, inclOnlySpecifiedMembers);
                            }
                            MethodInfo[] methods = current2.GetMethods(bindingFlags);
                            for (int j = 0; j < methods.Length; j++)
                            {
                                MethodInfo methodInfo = methods[j];
                                if (!methodInfo.IsSpecialName)
                                {
                                    MemberBindProviderEd.ProcessBindableMember(methodInfo, methodInfo.ReturnType, inclOnlySpecifiedMembers);
                                }
                            }
                            count++;
                            if (count >= countBeforeYield)
                            {
                                count = 0;
                                yield return((object)null);
                            }
                        }
                    }
                }
                finally
                {
                    ((IDisposable)enumerator2).Dispose();
                }
                enumerator2 = default(List <Type> .Enumerator);
            }
            yield return((object)null);

            MemberBindProviderEd.loader.Stop();
            MemberBindProviderEd.loader = null;
        }