hasAdds() public method

public hasAdds ( ) : bool
return bool
Beispiel #1
0
        private void doParse_hasAddin(ISdViewModel viewModel, SdNode config, String url, String text)
        {
            String json = this.parse(config, url, text);

            if (isDebug)
            {
                Util.log(this, config, url, json, 0);
            }

            if (json != null)
            {
                viewModel.loadByJson(config, json);

                if (config.hasAdds())   //没有url的add
                {
                    foreach (SdNode n1 in config.adds())
                    {
                        if (string.IsNullOrEmpty(n1.buildUrl) == false || string.IsNullOrEmpty(n1.url) == false)
                        {
                            continue;
                        }

                        String json2 = this.parse(n1, url, text);
                        if (isDebug)
                        {
                            Util.log(this, n1, url, json2, 0);
                        }

                        if (json2 != null)
                        {
                            viewModel.loadByJson(n1, json2);
                        }
                    }
                }
            }
        }
Beispiel #2
0
    private void doParse_hasAddin(ISdViewModel viewModel, SdNode config, String url, String text) {
        String json = this.parse(config, url, text);

        if (isDebug) {
            Util.log(this, config, url, json);
        }

        if (json != null) {
            viewModel.loadByJson(config, json);

            if (config.hasAdds()) { //没有url的add
                foreach (SdNode n1 in config.adds()) {
                    if (string.IsNullOrEmpty(n1.buildUrl) == false)
                        continue;

                    String json2 = this.parse(n1, url, text);
                    if (isDebug) {
                        Util.log(this, n1, url, json2);
                    }

                    if (json2 != null)
                        viewModel.loadByJson(n1, json2);
                }
            }
        }
    }
Beispiel #3
0
        private void doGetNodeViewModel(ISdViewModel viewModel, bool isUpdate, __AsyncTag tag, String url, Dictionary <String, String> args, SdNode config, SdSourceCallback callback)
        {
            //需要对url进行转换成最新的格式(可能之前的旧的格式缓存)

            if (config.isEmpty())
            {
                return;
            }

            if (config.hasItems())
            {
                viewModel.loadByConfig(config);
                return;
            }

            if ("@null".Equals(config.method))
            {
                viewModel.loadByJson(config, config.getUrl(url));
                return;
            }

            if (string.IsNullOrEmpty(config.parse) == false && string.IsNullOrEmpty(url) == false)  //如果没有url 和 parse,则不处理

            {
                HttpMessage msg = new HttpMessage();
                if (args != null)
                {
                    msg.form = args;
                }

                var dataList = new Dictionary <int, String>();//如果有多个地址,需要排序

                //2.获取主内容
                tag.total++;

                msg.url      = config.getUrl(url);
                msg.callback = (code, sender, text, url302) => {
                    tag.value++;

                    if (code == 1)
                    {
                        if (string.IsNullOrEmpty(url302))
                        {
                            url302 = sender.url;
                        }

                        if (string.IsNullOrEmpty(config.parseUrl) == false)   //url需要解析出来(多个用;隔开)
                        {
                            List <String> newUrls = new List <String>();
                            String[]      rstUrls = parseUrl(config, url302, text).Split(';');

                            foreach (String url1 in rstUrls)
                            {
                                if (url1.Length == 0)
                                {
                                    continue;
                                }

                                if (url1.StartsWith(Util.NEXT_CALL))
                                {
                                    Util.log(this, "CALL::url=", url1);

                                    HttpMessage msg0 = new HttpMessage();
                                    msg0.url = url1.Replace(Util.NEXT_CALL, "")
                                               .Replace("GET::", "")
                                               .Replace("POST::", "");

                                    msg0.rebuild(config);

                                    if (url1.IndexOf("POST::") > 0)
                                    {
                                        msg0.method = "post";
                                        msg0.rebuildForm();
                                    }
                                    else
                                    {
                                        msg0.method = "get";
                                    }
                                    msg0.callback = msg.callback;

                                    tag.total++;
                                    Util.http(this, isUpdate, msg0);
                                }
                                else
                                {
                                    newUrls.Add(url1);
                                }
                            }

                            if (newUrls.Count > 0)
                            {
                                doParseUrl_Aft(viewModel, config, isUpdate, newUrls, args, tag, dataList, callback);
                            }
                            return;//下面的代码被停掉
                        }
                        else
                        {
                            doParse_hasAddin(viewModel, config, url302, text);
                        }
                    }

                    if (tag.total == tag.value)
                    {
                        callback(code);
                    }
                };

                //有缓存的话,可能会变成同步了
                msg.rebuild(config);
                Util.http(this, isUpdate, msg);
            }

            if (config.hasAdds())
            {
                //2.2 获取副内容(可能有多个)
                foreach (SdNode n1 in config.adds())
                {
                    if (n1.isEmptyUrl())
                    {
                        continue;
                    }

                    tag.total++;
                    HttpMessage msg = new HttpMessage();
                    //如果自己有url,则使用自己的url;;如果没有,则通过父级的url进行buildUrl(url)
                    msg.url      = (string.IsNullOrEmpty(n1.url) ? n1.getUrl(url) : n1.url);
                    msg.callback = (code, sender, text, url302) => {
                        if (code == 1)
                        {
                            if (string.IsNullOrEmpty(url302))
                            {
                                url302 = msg.url;
                            }

                            String json = this.parse(n1, url302, text);
                            if (isDebug)
                            {
                                Util.log(this, n1, url302, json, 0);
                            }

                            if (json != null)
                            {
                                viewModel.loadByJson(n1, json);
                            }
                        }

                        tag.value++;
                        if (tag.total == tag.value)
                        {
                            callback(code);
                        }
                    };

                    msg.rebuild(config);
                    Util.http(this, isUpdate, msg);
                }
            }
        }
Beispiel #4
0
        private void doGetNodeViewModel(ISdViewModel viewModel, bool isUpdate,  __AsyncTag tag,  String url, Dictionary<String, String> args, SdNode config, SdSourceCallback callback) {
            //需要对url进行转换成最新的格式(可能之前的旧的格式缓存)

            if (config.isEmpty())
                return;

            if (config.hasItems()) {
                viewModel.loadByConfig(config);
                return;
            }

            if (string.IsNullOrEmpty(config.parse)) //没有解析的不处理
                return;

            //------------
            if (string.IsNullOrEmpty(url)) //url为空的不处理
                return;

            {
                //2.获取主内容
                tag.total++;
                String newUrl = buildUrl(config, url);

                //有缓存的话,可能会变成同步了
                Util.http(this, isUpdate, newUrl, args, config, (code, text) => {
                    if (code == 1) {

                        if (string.IsNullOrEmpty(config.parseUrl) == false) { //url需要解析出来
                            String newUrl2 = parseUrl(config, newUrl, text);

                            Util.http(this, isUpdate, newUrl2, args, config, (code2, text2) => {
                                if (code2 == 1) {
                                    doParse_hasAddin(viewModel, config, newUrl2, text2);
                                }

                                tag.value++;
                                if (tag.total == tag.value) {
                                    callback(code);
                                }
                            });
                            return;//下面的代码被停掉
                        }

                        doParse_hasAddin(viewModel, config, newUrl, text);
                    }

                    tag.value++;
                    if (tag.total == tag.value) {
                        callback(code);
                    }
                });
            }

            if (config.hasAdds()) {
                //2.2 获取副内容(可能有多个)
                foreach (SdNode n1 in config.adds()) {
                    if (string.IsNullOrEmpty(n1.buildUrl))
                        continue;

                    tag.total++;
                    String newUrl = buildUrl(n1, url); //有url的add //add 不能有自己的独立url

                    Util.http(this, isUpdate, newUrl, args, n1, (code, text) => {
                        if (code == 1) {
                            String json = this.parse(n1, newUrl, text);
                            if (isDebug) {
                                Util.log(this, n1, newUrl, json);
                            }

                            if (json != null) {
                                viewModel.loadByJson(n1, json);
                            }
                        }

                        tag.value++;
                        if (tag.total == tag.value) {
                            callback(code);
                        }
                    });
            }
        }
    }