コード例 #1
0
        public static List <YouTubeVideoQuality> GetYouTubeVideoUrls(params string[] videoUrls)
        {
            List <YouTubeVideoQuality> urls = new List <YouTubeVideoQuality>();

            foreach (var VideoUrl in videoUrls)
            {
                string html  = Helper.DownloadWebPage(VideoUrl);
                string title = GetTitle(html);
                // foreach (var videoLink in ExtractUrls(html))
                foreach (var videoLink in NewMethod.GetUrl(VideoUrl))
                {
                    YouTubeVideoQuality q = new YouTubeVideoQuality();
                    q.VideoUrl    = VideoUrl;
                    q.VideoTitle  = title;
                    q.DownloadUrl = videoLink + "&title=" + title;

                    if (!GetSize(q))
                    {
                        continue;
                    }

                    q.Length = long.Parse(Regex.Match(html, "\"length_seconds\":(.+?),", RegexOptions.Singleline).Groups[1].ToString());
                    bool IsWide = IsWideScreen(html);

                    if (GetQuality(q, IsWide))
                    {
                        urls.Add(q);
                    }
                }
            }
            return(urls);
        }
コード例 #2
0
        protected async Task ValidateMethod(int newMethodId)
        {
            // Start spinner
            Performance.NewMethods[newMethodId].Validating = true;

            // Clear any existing new method results
            Performance.NewMethods[newMethodId].Status = string.Empty;
            Performance.NewMethods[newMethodId].Title  = string.Empty;

            // Check for nothing entered
            if (!string.IsNullOrEmpty(Performance.NewMethods[newMethodId].Name) ||
                !string.IsNullOrEmpty(Performance.NewMethods[newMethodId].PlaceNotation) ||
                Performance.NewMethods[newMethodId].Stage != 0)
            {
                // Get a test from the API
                NewMethod newMethod = await CompLibService.GetHttpClient()
                                      .GetFromJsonAsync <NewMethod>($"method/validate?stage={Performance.NewMethods[newMethodId].Stage}" +
                                                                    $"&name={Performance.NewMethods[newMethodId].Name}" +
                                                                    $"&placenotation={Performance.NewMethods[newMethodId].PlaceNotation}");

                // Populate the NewMethod service
                if (newMethod.Method != null)
                {
                    NewMethod.Method.Title            = newMethod.Method.Title;
                    NewMethod.Method.PlaceNotation    = newMethod.Method.PlaceNotation;
                    NewMethod.Properties.LeadheadCode = newMethod.Properties.LeadheadCode;
                    NewMethod.Properties.LeadHead     = newMethod.Properties.LeadHead;

                    Performance.NewMethods[newMethodId].Title = newMethod.Method.Title;
                }
                else
                {
                    Performance.NewMethods[newMethodId].Title = "Error";
                }

                NewMethod.Messages.Clear();

                if (newMethod.Messages.Count != 0)
                {
                    foreach (var message in newMethod.Messages)
                    {
                        NewMethod.Messages.Add(message);
                    }

                    Performance.NewMethods[newMethodId].Status = "See messages";
                }
                else
                {
                    Performance.NewMethods[newMethodId].Status = "No messages";
                }
            }

            Performance.NewMethods[newMethodId].Validating = false;

            if (!string.IsNullOrEmpty(Performance.NewMethods[newMethodId].Title))
            {
                ActivatePopUp(PopUp.NewMethodResult);
            }
        }
コード例 #3
0
ファイル: MethodTests.cs プロジェクト: zuojiashun/ajcodekatas
        public void NewMethodCreateInstance()
        {
            NewMethod method = new NewMethod();
            object    result = method.Execute(new Machine(), typeof(System.IO.DirectoryInfo), new object[] { "." });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(System.IO.DirectoryInfo));
        }
コード例 #4
0
 public void Clone()
 {
     var action = NewMethod.Create <Func <Test, Test> >(builder =>
                                                        builder
                                                        .MethodBody(@"
            
 
     "));
 }
コード例 #5
0
        public void TestBuilder2()
        {
            var result = NewMethod.Create <Func <Type> >(builder => builder
                                                         .Using("NatashaUT.Model")
                                                         .MethodBody($@"return typeof(FieldSelfLinkModel);")
                                                         );

            Assert.NotNull(result.Method());
            Assert.Equal(typeof(FieldSelfLinkModel), result.Method());
        }
コード例 #6
0
ファイル: Message.cs プロジェクト: zuojiashun/ajcodekatas
        static Message()
        {
            globalMethods["+"]  = new AddMethod();
            globalMethods["-"]  = new SubtractMethod();
            globalMethods["*"]  = new MultiplyMethod();
            globalMethods["/"]  = new DivideMethod();
            globalMethods["=="] = new EqualsNativeMethod();
            globalMethods["!="] = new NotEqualsNativeMethod();

            // TODO put not in global, but associated with types
            globalMethods["new"] = new NewMethod();
        }
コード例 #7
0
        public static async void RunAsyncDelegate3()
        {
            var delegateAction = NewMethod.Create <Func <string, string, Task <string> > >(builder => builder
                                                                                           .UseAsync()
                                                                                           .MethodBody(@"
                            string result = arg1 +"" ""+ arg2;
                            Console.WriteLine(result);
                            return result;")
                                                                                           );

            string result = await delegateAction.Method("Hello", "World2!");

            Assert.Equal("Hello World2!", result);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            //C#中的委托机制(匿名的方式去调用各种方法,面向对象的,类型是安全的)
            //先定义一个委托,将需要调用的方法,像传递参数一样传递到委托中,之后使用委托的方法类似于方法的使用
            //通过委托调用静态方法
            AddNewNum add = new AddNewNum(Addnum);

            add(25);
            Console.WriteLine(num);
            //c#中委托调用实例化方法,调用多个方法
            NewMethod newMethod = new NewMethod();
            AddNewNum add_      = new AddNewNum(newMethod.addNum);

            add_(35);
            Console.WriteLine(newMethod.num);

            AddNewNum multiply = new AddNewNum(newMethod.multiplyNum);

            multiply(2);
            Console.WriteLine(newMethod.num);

            //Multi-casting delegates
            //c#中的委托是有一个调用列表的,一个委托可以调按照顺序调用多个方法
            //调用类中的静态方法(类名.方法名)
            Delegates d1 = new Delegates(TestMultiCastingDelegates.M1);

            d1(-1);
            Delegates d2 = new Delegates(TestMultiCastingDelegates.M2);

            d2(-2);
            Delegates d3 = d1 + d2;

            d3(-1);
            TestMultiCastingDelegates tcd = new TestMultiCastingDelegates();
            Delegates d4 = new Delegates(tcd.M3);

            d3 += d4;
            d3(10);

            d3 += d1;
            d3(20);
            //可以使用-=来删除委托,如果调用了相同的函数,则从最后添加的函数开始删除
            d3 -= d1;
            d3(30);
            //删除委托可以不管委托列表的顺序,只要委托中有这个方法就可以删除,若果没有对应的委托,或者委托列表为空,删除(-=)也不会报错,但是如果调用列表中没有方法再去调用委托会报错
            d3 -= d1;
            d3(10);

            Console.ReadLine();
        }
コード例 #9
0
ファイル: BuilderTools.cs プロジェクト: studentutu/SharpUtils
        public static MethodBuilder DefineMethod(this TypeBuilder builder, string name, MethodAttributes attributes, MethodSignature signature)
        {
            var t    = TypeOf <MethodBuilder> .TypeID;
            var modb = (ModuleBuilder)builder.Module;
            var mod  = GetNativeModule(modb);

            byte[]        sig = signature.GetSignature(modb);
            int           tok = DefineMethodInternal.Invoke(mod, builder.TypeToken.Token, name, sig, sig.Length, attributes);
            MethodBuilder mb  = NewMethod.Invoke(
                name, attributes, signature.CallingConvention, signature.ReturnType,
                signature.ParameterTypes, modb, builder, false
                );

            mb.GetToken();             //returns 0 but circumvents the RSA error (?)
            SetToken.Invoke(mb, NewMethodToken(tok));
            GetMethodList.Invoke(builder).Add(mb);
            return(mb);
        }
コード例 #10
0
ファイル: CorpStaffSzJSJ.cs プロジェクト: SHNXJMG/Small
        protected override IList ExecuteCrawl(bool crawlAll)
        {
            IList list = new ArrayList();
            //GetCorpStaffDui(crawlAll, list);
            //GetCorpStaffShuili(crawlAll, list);
            //GetCorpStaffXiao(crawlAll, list);
            NewType      newType1 = new NewType(GetCorpStaffDui);
            IAsyncResult irr1     = newType1.BeginInvoke(crawlAll, list, null, null);
            NewType      newTypw2 = new NewType(GetCorpStaffShuili);
            IAsyncResult irr2     = newTypw2.BeginInvoke(crawlAll, list, null, null);
            NewType      newType3 = new NewType(GetCorpStaffXiao);
            IAsyncResult irr3     = newType3.BeginInvoke(crawlAll, list, null, null);
            NewMethod    newMeth1 = new NewMethod(GetCorpStaffJzao);
            IAsyncResult ir1      = newMeth1.BeginInvoke(2, crawlAll, list, null, null);
            NewMethod    newMeth2 = new NewMethod(GetCorpStaffJLi);
            IAsyncResult ir2      = newMeth2.BeginInvoke(3, crawlAll, list, null, null);
            NewMethod    newMeth3 = new NewMethod(GetCorpStaffZJia);
            IAsyncResult ir3      = newMeth3.BeginInvoke(4, crawlAll, list, null, null);
            NewMethod    newMeth4 = new NewMethod(GetCorpStaffZLZR);
            IAsyncResult ir4      = newMeth4.BeginInvoke(7, crawlAll, list, null, null);
            NewMethod    newMeth5 = new NewMethod(GetCorpStaffAQZR);
            IAsyncResult ir5      = newMeth5.BeginInvoke(8, crawlAll, list, null, null);
            NewMethod    newMeth6 = new NewMethod(GetCorpStaffXXXM);
            IAsyncResult ir6      = newMeth6.BeginInvoke(1, crawlAll, list, null, null);
            NewMethod    newMeth7 = new NewMethod(GetCorpStaffJZGCS);
            IAsyncResult ir7      = newMeth7.BeginInvoke(5, crawlAll, list, null, null);
            NewMethod    newMeth8 = new NewMethod(GetCorpStaffJGGCS);
            IAsyncResult ir8      = newMeth8.BeginInvoke(6, crawlAll, list, null, null);



            //GetCorpStaffJzao(2, crawlAll, list);//采集建造工程师
            //GetCorpStaffJLi(3, crawlAll, list);//采集监理工程师
            //GetCorpStaffZJia(4, crawlAll, list); //采集造价工程师
            //GetCorpStaffZLZR(7, crawlAll, list);//采集质量主任
            //GetCorpStaffAQZR(8, crawlAll, list);//采集安全主任
            //GetCorpStaffXXXM(1, crawlAll, list);// 采集小型工程项目负责人
            //GetCorpStaffJZGCS(5, crawlAll, list);// 采集建筑工程师
            //GetCorpStaffJGGCS(6, crawlAll, list);//采集结构工程师
            return(list);
        }
コード例 #11
0
ファイル: GraphQLTestBase.cs プロジェクト: zxbe/squidex
throw new InvalidOperationException(NewMethod(result));