public static NestableCoroutine <T> StartCoroutine <T>(this MonoBehaviour obj, IEnumerator coroutine)
        {
            NestableCoroutine <T> coroutineObject = new NestableCoroutine <T>(coroutine);

            coroutineObject.coroutine = coroutineObject.StartCoroutine(obj);
            return(coroutineObject);
        }
Пример #2
0
        public static IEnumerator GetVersion(string filePath)
        {
            NestableCoroutine <string> getTextR = new NestableCoroutine <string>(TextHelper.GetText(filePath));

            foreach (var x in getTextR.Routine)
            {
                yield return(x);
            }

            yield return(getTextR.Value.Map(XmlHelper.LoadXml)
                         .Bind(GetVersionNode)
                         .Map(n => n.InnerText));
        }
        public static IEnumerator GetSettings(string filePath)
        {
            NestableCoroutine <string> getTextR = new NestableCoroutine <string>(TextHelper.GetText(filePath));

            foreach (var x in getTextR.Routine)
            {
                yield return(x);
            }

            yield return(getTextR.Value.Map(XmlHelper.LoadXml)
                         .Map(x => x.GetElementsByTagName("parameter"))
                         .AsEither()
                         .AsEnumerable()
                         .Bind(l => l.Cast <XmlNode>())
                         .Bind(GetNameValuePair));
        }
Пример #4
0
        public static IEnumerator SetVersion(string filePath, string newVersion)
        {
            var getTextR = new NestableCoroutine <string>(TextHelper.GetText(filePath));

            foreach (var x in getTextR.Routine)
            {
                yield return(x);
            }

            yield return(getTextR.Value.Map(XmlHelper.LoadXml)
                         .Bind(GetVersionNode)
                         .ForEach(n =>
            {
                n.InnerText = newVersion;
                n.OwnerDocument.Save(filePath);
            }));
        }
Пример #5
0
        public static IEnumerator GetText(string filePath)
        {
            var opt = Url.Of(filePath);

            if (opt.IsSome())
            {
                var routine = opt.Map(WebRequest.GetWWWText);
                NestableCoroutine <string> coroutine = new NestableCoroutine <string>(routine);
                foreach (var x in coroutine.Routine)
                {
                    yield return(x);
                }
                yield return(coroutine.Value);
            }
            else
            {
                yield return(File.ReadAllText(filePath));
            }
        }