Beispiel #1
0
            /// <summary>
            /// 安装完成处理
            /// </summary>
            protected override void onCreated()
            {
                int methodIndex = methods.Length;

                ViewMethods = new WebView.Generator {
                    AutoParameter = AutoParameter
                }.GetTypeAttributes()
                .getFind(value => typeof(AutoCSer.WebView.View <>).isAssignableFromGenericDefinition(value.Key) ? (value.Value == null || value.Value.IsAjax) : (value.Value != null && value.Value.IsAjax))
                .GetArray(value => new ViewMethod
                {
                    MethodIndex       = methodIndex++,
                    WebViewMethodType = value.Key,
                    Attribute         = value.Value ?? AutoCSer.WebView.View.DefaultAttribute,
                    CallName          = new WebView.Generator.ViewType {
                        Type = value.Key, Attribute = value.Value ?? AutoCSer.WebView.View.DefaultAttribute, DefaultNamespace = AutoParameter.DefaultNamespace + ".", IgnoreCase = AutoParameter.WebConfig.IgnoreCase
                    }.CallName,
                    IsAwaitMethod = WebView.Generator.AjaxAwaitMethodTypes.Contains(value.Key)
                });
                if (methodIndex != 0)
                {
                    LeftArray <KeyValuePair <string, int> > names = (Methods = methods.ToArray()).getArray(value => value.CallName)
                                                                    .concat(ViewMethods.getArray(value => value.CallName))
                                                                    .groupCount(value => value)
                                                                    .getFind(value => value.Value != 1);
                    if (names.Length == 0)
                    {
                        IsPubError = false;
                        ParameterBuilder parameterBuilder = new ParameterBuilder();
                        foreach (AjaxMethod method in Methods)
                        {
                            if (!IsPubError)
                            {
                                IsPubError = method.CallName == AutoCSer.WebView.AjaxBase.PubErrorCallName;
                            }
                            parameterBuilder.Add(method);
                        }
                        ParameterTypes = parameterBuilder.Get();
                        MethodCount    = Methods.Length + ViewMethods.Length + (IsPubError ? 0 : 1);
                        _code_.Length  = 0;
                        create(false);
                        Coder.Add("namespace " + AutoParameter.DefaultNamespace + @"
{
" + _code_.ToString() + @"
}");
                        typeScript.OnCreated();
                    }
                    else
                    {
                        Messages.Add(@"AJAX调用名称冲突:
" + names.JoinString(@"
", value => value.Key + "[" + value.Value.toString() + "]"));
                    }
                }
            }