コード例 #1
0
        public SyncDelegate(Type delegateType, MethodInfo method, string[] fieldPaths)
        {
            this.delegateType = delegateType;
            this.method       = method;

            argTypes = method.GetParameters().Types();

            if (fieldPaths == null)
            {
                List <string> fieldList = new List <string>();
                Sync.AllDelegateFieldsRecursive(delegateType, path => { fieldList.Add(path); return(false); });
                this.fieldPaths = fieldList.ToArray();
            }
            else
            {
                var temp = new UniqueList <string>();
                foreach (string path in fieldPaths.Select(p => MpReflection.AppendType(p, delegateType)))
                {
                    string[] parts     = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    string   increment = parts[0] + "/" + parts[1];
                    for (int i = 2; i < parts.Length; i++)
                    {
                        if (!MpReflection.PathType(increment).IsCompilerGenerated())
                        {
                            break;
                        }
                        temp.Add(increment);
                        increment += "/" + parts[i];
                    }

                    temp.Add(path);
                }

                this.fieldPaths = temp.ToArray();
            }

            fieldTypes = this.fieldPaths.Select(path => MpReflection.PathType(path)).ToArray();
        }