示例#1
0
        public Api_Result <List <Mem_tanker> > BackTanker(int area_id, int num)
        {
            Api_Result <List <Mem_tanker> > api_Result = new Api_Result <List <Mem_tanker> >();
            List <Mem_tanker> enableBackTanker         = this.GetEnableBackTanker(area_id);

            if (Enumerable.Count <Mem_tanker>(enableBackTanker) < num)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            IEnumerable <Mem_tanker> enumerable = Enumerable.Take <Mem_tanker>(enableBackTanker, num);

            using (IEnumerator <Mem_tanker> enumerator = enumerable.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Mem_tanker current = enumerator.get_Current();
                    current.BackTanker();
                }
            }
            api_Result.data = Enumerable.ToList <Mem_tanker>(enumerable);
            return(api_Result);
        }
示例#2
0
        public void CanParseQueryWithRelation()
        {
            var tree = new GraphQLCompiler(SchemaBuilder.FromObject <TestSchema>(), new DefaultMethodProvider()).Compile(@"
{
	people { id name user { field1 } }
}");
            // People.Select(p => new { Id = p.Id, Name = p.Name, User = new { Field1 = p.User.Field1 })
            var result = tree.ExecuteQuery(new TestSchema());

            Assert.Equal(1, Enumerable.Count((dynamic)result.Data["people"]));
            var person = Enumerable.ElementAt((dynamic)result.Data["people"], 0);

            // we only have the fields requested
            Assert.Equal(3, person.GetType().GetFields().Length);
            Assert.Equal("id", person.GetType().GetFields()[0].Name);
            Assert.Equal("name", person.GetType().GetFields()[1].Name);
            // make sure we sub-select correctly to make the requested object graph
            Assert.Equal("user", person.GetType().GetFields()[2].Name);
            var user = person.user;

            Assert.Single(user.GetType().GetFields());
            Assert.Equal("field1", user.GetType().GetFields()[0].Name);
        }
示例#3
0
        public Api_Result <List <Mem_tanker> > GoTanker(int area_id, int num)
        {
            Api_Result <List <Mem_tanker> > api_Result = new Api_Result <List <Mem_tanker> >();
            List <Mem_tanker> freeTanker = Mem_tanker.GetFreeTanker(Comm_UserDatas.Instance.User_tanker);

            if (Enumerable.Count <Mem_tanker>(freeTanker) < num)
            {
                api_Result.state = Api_Result_State.Parameter_Error;
                return(api_Result);
            }
            IEnumerable <Mem_tanker> enumerable = Enumerable.Take <Mem_tanker>(freeTanker, num);

            using (IEnumerator <Mem_tanker> enumerator = enumerable.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Mem_tanker current = enumerator.get_Current();
                    current.GoArea(area_id);
                }
            }
            api_Result.data = Enumerable.ToList <Mem_tanker>(enumerable);
            return(api_Result);
        }
示例#4
0
        internal string FormatMessageString(string messageText, params object[] args)
        {
            if (string.IsNullOrWhiteSpace(messageText))
            {
                return(string.Empty);
            }

            if (messageText.StartsWith(PackageManagement.Constants.MSGPrefix, true, CultureInfo.CurrentCulture))
            {
                // check with the caller first, then with the local resources, and fallback to using the messageText itself.
                messageText = GetMessageString(messageText.Substring(PackageManagement.Constants.MSGPrefix.Length), GetMessageStringInternal(messageText) ?? messageText) ?? GetMessageStringInternal(messageText) ?? messageText;
            }

            // if it doesn't look like we have the correct number of parameters
            // let's return a fix-me-format string.
            var c = Enumerable.Count(Enumerable.Where(messageText.ToCharArray(), each => each == '{'));

            if (c < args.Length)
            {
                return(FixMeFormat(messageText, args));
            }
            return(string.Format(CultureInfo.CurrentCulture, messageText, args));
        }
示例#5
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            switch (binder.Name)
            {
            case "AsEnumerable":
                result = this;
                return(true);

            case "Count":
                if (args.Length == 0)
                {
                    result = Count;
                    return(true);
                }
                result = Enumerable.Count(this, (Func <object, bool>)args[0]);
                return(true);

            case "DefaultIfEmpty":
                result = inner.DefaultIfEmpty(new DynamicNullObject());
                return(true);
            }
            return(base.TryInvokeMember(binder, args, out result));
        }
        static void Main(string[] args)
        {
            int[] intArray = new int[] { 3, 4, 5, 6, 7, 9 };
            //方法语法
            var count1   = Enumerable.Count(intArray);
            var firstNum = Enumerable.First(intArray);
            //扩展语法
            var count2    = intArray.Count();
            var firstNum2 = intArray.First();

            Console.WriteLine($"count:{count1},firstNums:{firstNum}");
            Console.WriteLine($"count:{count2},firstNums:{firstNum2}");

            int howMany = (from n in intArray
                           where n < 7
                           select n).Count();

            Console.WriteLine($"count:{howMany}");

            var countOdd = intArray.Count(n => n % 2 == 1);

            Console.WriteLine($"count of odd numbers :{countOdd}");
        }
示例#7
0
        private String FindSubRouteBack(string SubRouteName, string SubRouteUID)
        {
            string backSubRouteUID         = "";
            IEnumerable <Route> backRoutes = RouteSQLiteRepository.Instance.GetBackRoute(SubRouteName);

            if (Enumerable.Count <Route>(backRoutes) == 1)
            {
                return(null);
            }
            ;
            foreach (Route backRoute in backRoutes)
            {
                if (backRoute.UID == SubRouteUID)
                {
                    continue;
                }
                else
                {
                    backSubRouteUID = backRoute.UID;
                }
            }
            return(backSubRouteUID);
        }
示例#8
0
        public void DoRepository(Table replaceClass, ref List <string> fileName)
        {
            string newValue1      = string.Empty;
            string newValue2      = string.Empty;
            string newValue3      = string.Empty;
            string str1           = string.Empty;
            string newValue4      = string.Empty;
            string primaryKeyType = replaceClass.PrimaryKeyType;

            if (replaceClass.refId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refId) > 0)
            {
                foreach (RefIdName refIdName in replaceClass.refId)
                {
                    newValue3 += this.m_ReposLocalDan.Replace(this.m_ReplaceAttribute, refIdName.Ref).Replace('@', '"');
                    newValue4 += this.m_ByRefId.Replace(this.m_String, refIdName.RefType).Replace(this.m_ReplaceClassCode, refIdName.Ref).Replace(this.m_ReplaceAttribute, replaceClass.Name).Replace(this.m_ReplaceClassName, replaceClass.Code).Replace('@', '"');
                }
            }
            string str2;

            if (replaceClass.refNotId != null && Enumerable.Count <RefIdName>((IEnumerable <RefIdName>)replaceClass.refNotId) > 0)
            {
                foreach (RefIdName refIdName in replaceClass.refNotId)
                {
                    newValue2 += this.m_ReposLocal.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_Id, refIdName.Id).Replace('@', '"');
                    newValue1 += this.m_RefGetSelectDuo.Replace(this.m_ReplaceClassCode, refIdName.RefTableCode).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace('@', '"').Replace("^SysRole^", replaceClass.Code);
                }
                str2 = Common.Read(BaseClass.m_DempDirectory + this.m_DuoMoban).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_GetByRefId, newValue4).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_ReposDan, newValue3).Replace(this.m_RefGetSelectList, newValue1).Replace(this.m_Repos, newValue2).Replace(this.m_String, primaryKeyType);
            }
            else
            {
                str2 = Common.Read(BaseClass.m_DempDirectory + this.m_DanMoban).Replace(this.m_ReplaceClassName, replaceClass.Name).Replace(this.m_GetByRefId, newValue4).Replace(this.m_ReplaceClassCode, replaceClass.Code).Replace(this.m_Id, Common.GetFirstPrimaryKeyCode(replaceClass)).Replace(this.m_ReposDan, newValue3).Replace(this.m_String, primaryKeyType);
            }
            string content = str2.Replace(BaseClass.m_DALnamespace, replaceClass.NameSpace + "DAL");

            Common.Write(BaseClass.m_RootDirectory + "/" + this.m_DAL + "/" + replaceClass.Code + "Repository.cs", content);
            fileName.Add(replaceClass.Code);
        }
示例#9
0
        public void Execute(ServerCore server, ClientConnection connection, string[] arguments)
        {
            connection.SendChat(string.Format("Total {0} users", Enumerable.Count <ClientConnection>(server.ConnectionManager.Connections(), c => c.Authorized)));

            foreach (var group in Enumerable.Where <ClientConnection>(server.ConnectionManager.Connections(), c => c.Authorized).GroupBy(c => c.UserRole).OrderByDescending(g => g.Key))
            {
                if (!group.Any())
                {
                    continue;
                }

                switch (group.Key)
                {
                case UserRole.Guest:
                    connection.SendChat("Guests:");
                    break;

                case UserRole.Member:
                    connection.SendChat("Members:");
                    break;

                case UserRole.Moderator:
                    connection.SendChat("Moderators:");
                    break;

                case UserRole.Administrator:
                    connection.SendChat("Administrators:");
                    break;

                default:
                    connection.SendChat("Other:");
                    break;
                }

                connection.SendChat(string.Join(", ", group.Select(c => c.DisplayName)));
            }
        }
        public List <PerformaItemDetails> performaItemInformation()
        {
            var output = JObject.Parse(result);

            if (Enumerable.Count(output["d"]["results"][0]["profomaLinesSet"]["results"]) > 0)
            {
                int performaItemsHeight = 0;
                int initialItem         = 1;
                for (int i = 0; i < Enumerable.Count(output["d"]["results"][0]["profomaLinesSet"]["results"]); i++)
                {
                    if (initialItem == 1)
                    {
                        performaItemsHeight = 60;
                    }
                    else
                    {
                        performaItemsHeight = performaItemsHeight + 30;
                    }

                    performaItemDetails.Add(new PerformaItemDetails(
                                                FormatChanges.changedateformat(Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["StartDate"])),
                                                FormatChanges.changedateformat(Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["EndDate"])),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["Description"]),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["RoomType"]),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["MealPlan"]),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["Occu"]),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["Nos"]),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["RoomNights"]),
                                                serviceDataValidation.decimalTruncating(Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["Rate"])),
                                                Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["RateCur"]),
                                                serviceDataValidation.decimalTruncating(Convert.ToString(output["d"]["results"][0]["profomaLinesSet"]["results"][i]["Amount"]))));
                    initialItem = 0;
                }
                MessagingCenter.Send <PerformaInformation, int>(this, Constants._performaListHeight, performaItemsHeight);
            }
            return(performaItemDetails);
        }
        public override Raigeki GetResultData(FormationDatas formation, BattleCommandParams cParam)
        {
            this.commandParams = cParam;
            this.setTargetingKind(formation);
            int num  = Enumerable.Count <int>(this.f_AtkIdxs);
            int num2 = Enumerable.Count <int>(this.e_AtkIdxs);

            if (num == 0 && num2 == 0)
            {
                return(null);
            }
            if (num > 0)
            {
                this.setHitHoseiFromBattleCommand();
            }
            Raigeki raigeki = new Raigeki();

            this.formationData = formation;
            raigeki.F_Rai      = this.getRaigekiData(false);
            raigeki.E_Rai      = this.getRaigekiData(true);
            using (var enumerator = Enumerable.Select(this.F_Data.ShipData, (Mem_ship obj, int idx) => new
            {
                obj,
                idx
            }).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.get_Current();
                    if (current.obj.Nowhp <= 0)
                    {
                        bool flag = base.RecoveryShip(current.idx);
                    }
                }
            }
            return(raigeki);
        }
示例#12
0
 internal static void ExecuteSwitches(OpenXmlElement element, string[] switches)
 {
     if (switches == null || Enumerable.Count <string>((IEnumerable <string>)switches) == 0)
     {
         return;
     }
     if (Enumerable.Contains <string>((IEnumerable <string>)switches, "dp"))
     {
         Paragraph firstParent = DocumentMerge.GetFirstParent <Paragraph>(element);
         if (firstParent == null)
         {
             return;
         }
         firstParent.Remove();
     }
     else if (Enumerable.Contains <string>((IEnumerable <string>)switches, "dr"))
     {
         TableRow firstParent = DocumentMerge.GetFirstParent <TableRow>(element);
         if (firstParent == null)
         {
             return;
         }
         firstParent.Remove();
     }
     else
     {
         if (!Enumerable.Contains <string>((IEnumerable <string>)switches, "dt"))
         {
             return;
         }
         Table firstParent = DocumentMerge.GetFirstParent <Table>(element);
         if (firstParent != null)
         {
             firstParent.Remove();
         }
     }
 }
 private void InitRewardInfoDisplay(MobileWorldQuest worldQuest)
 {
     if (worldQuest.Item != null && Enumerable.Count <MobileWorldQuestReward>(worldQuest.Item) > 0)
     {
         MobileWorldQuestReward[] item = worldQuest.Item;
         int num = 0;
         if (num < item.Length)
         {
             MobileWorldQuestReward mobileWorldQuestReward = item[num];
             Sprite rewardSprite = GeneralHelpers.LoadIconAsset(AssetBundleType.Icons, mobileWorldQuestReward.FileDataID);
             this.m_rewardInfo.SetReward(MissionRewardDisplay.RewardType.item, mobileWorldQuestReward.RecordID, mobileWorldQuestReward.Quantity, rewardSprite, mobileWorldQuestReward.ItemContext);
         }
     }
     else if (worldQuest.Money > 0)
     {
         Sprite iconSprite = Resources.Load <Sprite>("MiscIcons/INV_Misc_Coin_01");
         this.m_rewardInfo.SetGold(worldQuest.Money / 10000, iconSprite);
     }
     else if (worldQuest.Experience > 0)
     {
         Sprite localizedFollowerXpIcon = GeneralHelpers.GetLocalizedFollowerXpIcon();
         this.m_rewardInfo.SetFollowerXP(worldQuest.Experience, localizedFollowerXpIcon);
     }
     else
     {
         MobileWorldQuestReward[] currency = worldQuest.Currency;
         int num2 = 0;
         if (num2 < currency.Length)
         {
             MobileWorldQuestReward mobileWorldQuestReward2 = currency[num2];
             Sprite           iconSprite2 = GeneralHelpers.LoadCurrencyIcon(mobileWorldQuestReward2.RecordID);
             CurrencyTypesRec record      = StaticDB.currencyTypesDB.GetRecord(mobileWorldQuestReward2.RecordID);
             int quantity = mobileWorldQuestReward2.Quantity / (((record.Flags & 8u) == 0u) ? 1 : 100);
             this.m_rewardInfo.SetCurrency(mobileWorldQuestReward2.RecordID, quantity, iconSprite2);
         }
     }
 }
        public void MoveOn()
        {
            CurrentTime += TimeStep;

            bool newRequestReceived = client.MoveOn(TimeStep);

            if (newRequestReceived)
            {
                var availableOperators =
                    from o in operators
                    where o.Active == false
                    orderby o.ProcessingSystem.QueueLength, o.MinServiceTime
                select o;

                if (Enumerable.Count(availableOperators) == 0)
                {
                    NumDeclinedRequests++;
                }
                else
                {
                    availableOperators.First().StartServing();
                }
            }

            foreach (var o in operators)
            {
                o.ContinueServing(TimeStep);
            }

            foreach (var s in processingSystems)
            {
                if (s.ContinueServing(TimeStep))
                {
                    NumHandledRequests++;
                }
            }
        }
示例#15
0
        protected virtual double getHougItemAtackHosei(Mem_ship ship, List <Mst_slotitem> mst_item)
        {
            if (mst_item.Count == 0)
            {
                return(0.0);
            }
            if (ship.Stype != 3 && ship.Stype != 4 && ship.Stype != 21)
            {
                return(0.0);
            }
            ILookup <int, Mst_slotitem> lookup = Enumerable.ToLookup <Mst_slotitem, int>(mst_item, (Mst_slotitem x) => x.Id);
            int num = 0;

            if (lookup.Contains(4))
            {
                num += Enumerable.Count <Mst_slotitem>(lookup[4]);
            }
            if (lookup.Contains(11))
            {
                num += Enumerable.Count <Mst_slotitem>(lookup[11]);
            }
            int num2 = 0;

            if (lookup.Contains(119))
            {
                num2 += Enumerable.Count <Mst_slotitem>(lookup[119]);
            }
            if (lookup.Contains(65))
            {
                num2 += Enumerable.Count <Mst_slotitem>(lookup[65]);
            }
            if (lookup.Contains(139))
            {
                num2 += Enumerable.Count <Mst_slotitem>(lookup[139]);
            }
            return(1.0 * Math.Sqrt((double)num) + 2.0 * Math.Sqrt((double)num2));
        }
        public CollectionQuerySimplification(List <object> coll)
        {
            var x = coll.Select(element => element as object).Any(element => element != null);  // Noncompliant {{Use 'OfType<object>()' here instead.}}

//                       ^^^^^^
            x = coll.Select((element) => ((element as object))).Any(element => (element != null) && CheckCondition(element) && true); // Noncompliant use OfType
            var y = coll.Where(element => element is object).Select(element => element as object);                                    // Noncompliant use OfType
//                       ^^^^^
            var y = coll.Where(element => element is object).Select(element => element as object[]);

            y = coll.Where(element => element is object).Select(element => (object)element); // Noncompliant use OfType
            x = coll.Where(element => element == null).Any();                                // Noncompliant use Any([expression])
//                   ^^^^^
            var z = coll.Where(element => element == null).Count();                          // Noncompliant {{Drop 'Where' and move the condition into the 'Count'.}}

            z = Enumerable.Count(coll.Where(element => element == null));                    // Noncompliant
            z = Enumerable.Count(Enumerable.Where(coll, element => element == null));        // Noncompliant
            y = coll.Select(element => element as object);
            y = coll.ToList().Select(element => element as object);                          // Noncompliant
            y = coll
                .ToList()                                                                    // Noncompliant {{Drop 'ToList' from the middle of the call chain.}}
//               ^^^^^^
                .ToArray()                                                                   // Noncompliant
                .Select(element => element as object);

            var z = coll
                    .Select(element => element as object)
                    .ToList();

            var c = coll.Count(); //Noncompliant

//                       ^^^^^
            c = coll.OfType <object>().Count();

            x = Enumerable.Select(coll, element => element as object).Any(element => element != null);             //Noncompliant
            x = Enumerable.Any(Enumerable.Select(coll, element => element as object), element => element != null); //Noncompliant
        }
示例#17
0
        public override void OnEnter()
        {
            var go = InputPath.Value as FsmPath;

            if (go == null || go.Value == null)
            {
                Debug.Log("Input incomplete");
                Finish();
                return;
            }             // it would continue for a frame without return

            var a   = 1 / 0f;
            var doo = InputPath.Value as FsmPath;
            var coo = new FsmNode();

            if (doo.Value == null)
            {
                return;
            }
            else
            {
                var pathNodes = doo.Value.vectorPath;
                for (var i = 0; i < Enumerable.Count(pathNodes); i++)
                {
                    var o = (pathNodes[i] - Fsm.GetOwnerDefaultTarget(DistanceFrom).transform.position).sqrMagnitude;
                    if (o < a)
                    {
                        position.Value = pathNodes[i];
                        coo.Value      = doo.Value.path[i];
                        a = o;
                    }
                }
            }
            node.Value = coo;
            Finish();
        }
        public void CanParseQueryWithRelationDeep()
        {
            var tree = new DataApiCompiler(SchemaBuilder.FromObject <TestSchema>(), new DefaultMethodProvider()).Compile(@"
{
	people { id, name,
		User {
			field1,
			nestedRelation { id, name }
		}
	}
}");

            // People.Select(p => new { Id = p.Id, Name = p.Name, User = new { Field1 = p.User.Field1, NestedRelation = new { Id = p.User.NestedRelation.Id, Name = p.User.NestedRelation.Name } })
            Assert.Single(tree.Fields);
            dynamic result = tree.Fields.ElementAt(0).AsLambda().Compile().DynamicInvoke(new TestSchema());

            Assert.Equal(1, Enumerable.Count(result));
            var person = Enumerable.ElementAt(result, 0);

            // we only have the fields requested
            Assert.Equal(3, person.GetType().GetFields().Length);
            Assert.Equal("Id", person.GetType().GetFields()[0].Name);
            Assert.Equal("Name", person.GetType().GetFields()[1].Name);
            // make sure we sub-select correctly to make the requested object graph
            Assert.Equal("User", person.GetType().GetFields()[2].Name);
            var user = person.User;

            Assert.Equal(2, user.GetType().GetFields().Length);
            Assert.Equal("Field1", user.GetType().GetFields()[0].Name);
            Assert.Equal("NestedRelation", user.GetType().GetFields()[1].Name);
            var nested = person.User.NestedRelation;

            Assert.Equal(2, nested.GetType().GetFields().Length);
            Assert.Equal("Id", nested.GetType().GetFields()[0].Name);
            Assert.Equal("Name", nested.GetType().GetFields()[1].Name);
        }
示例#19
0
        protected void ddlModel_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlTrim.Visible = true;
            ddlTrim.Items.Clear();

            string year  = ddlYear.SelectedItem.ToString();
            string make  = ddlMake.SelectedItem.ToString();
            string model = ddlModel.SelectedItem.ToString();

            string  Json_Trim = formater(Get("https://www.carqueryapi.com/api/0.3/?callback=?&cmd=getTrims&make=" + make + "&model=" + model + "&year=" + year));
            dynamic dynJson   = JsonConvert.DeserializeObject(Json_Trim);

            if (Enumerable.Count(dynJson.Trims) != 0)
            {
                foreach (var item in dynJson.Trims)
                {
                    ddlTrim.Items.Add((string)item.model_trim);
                }
            }
            else
            {
                ddlTrim.Items.Add("N/A");
            }
        }
示例#20
0
        public List <FileInfo> SaveSubtitle(Subtitle subtitle)
        {
            this.CreateConnectionAndLogin();
            subdata subdata = this.openSubtitlesProxy.DownloadSubtitles(this.token, new string[1]
            {
                subtitle.Id
            });

            if (subdata == null || subdata.data == null || Enumerable.Count <subtitle>((IEnumerable <subtitle>)subdata.data) <= 0)
            {
                throw new Exception("Subtitle not found with ID '" + subtitle.Id + "'");
            }
            string str = Path.GetTempPath() + subtitle.FileName;

            if (File.Exists(str))
            {
                File.Delete(str);
            }
            FileUtils.WriteNewFile(str, Decoder.DecodeAndDecompress(subdata.data[0].data));
            return(new List <FileInfo>()
            {
                new FileInfo(str)
            });
        }
        static public IPlayReadyLicense[] FindMultipleLicenses(Guid keyId, string keyIdString, bool bFullyEvaluated)
        {
            TestLogger.LogMessage("Enter LicenseManagement.FindMultipleLicenses()");

            PlayReadyContentHeader contentHeader = new PlayReadyContentHeader(
                keyId,
                keyIdString,
                PlayReadyEncryptionAlgorithm.Aes128Ctr,
                null,
                null,
                String.Empty,
                Guid.Empty);

            TestLogger.LogMessage("Creating PlayReadyLicenseIterable...");
            PlayReadyLicenseIterable licenseIterable = new PlayReadyLicenseIterable(contentHeader, bFullyEvaluated);

            foreach (PlayReadyLicense lic in licenseIterable)
            {
                DumpLicenseValues(lic);
            }

            IPlayReadyLicense[]             licenses          = null;
            IEnumerable <IPlayReadyLicense> licenseEnumerable = licenseIterable;

            int licenseCount = Enumerable.Count <IPlayReadyLicense>(licenseEnumerable);

            TestLogger.LogMessage("License count  :" + licenseCount);
            if (licenseCount > 0)
            {
                licenses = Enumerable.ToArray <IPlayReadyLicense>(licenseEnumerable);
            }

            TestLogger.LogMessage("Leave LicenseManagement.FindMultipleLicenses()");

            return(licenses);
        }
示例#22
0
        static CountExpressionNode()
        {
            var supportedMethods =
                new List <MethodInfo>
            {
                GetSupportedMethod(() => Queryable.Count <object> (null)),
                GetSupportedMethod(() => Queryable.Count <object> (null, null)),
                GetSupportedMethod(() => Enumerable.Count <object> (null)),
                GetSupportedMethod(() => Enumerable.Count <object> (null, null)),
                GetSupportedMethod(() => ((List <int>)null).Count),
                GetSupportedMethod(() => ((ICollection <int>)null).Count),
                GetSupportedMethod(() => ((ICollection)null).Count),
                GetSupportedMethod(() => (((Array)null).Length)),
            };

            var arrayListCountExpression = GetArrayListCountExpression();

            if (arrayListCountExpression != null)
            {
                supportedMethods.Add(GetSupportedMethod(arrayListCountExpression));
            }

            SupportedMethods = supportedMethods.ToArray();
        }
示例#23
0
        private String FindBackSubRouteUID(String routeUID, Route route)
        {
            string backSubRouteUID         = "";
            string subRouteName            = route.Name.Zh_tw;
            IEnumerable <Route> backRoutes = RouteSQLiteRepository.Instance.GetBackRoute(subRouteName);

            if (Enumerable.Count <Route>(backRoutes) == 1)
            {
                return(null);
            }
            ;
            foreach (Route backRoute in backRoutes)
            {
                if (backRoute.UID == routeUID)
                {
                    continue;
                }
                else
                {
                    backSubRouteUID = backRoute.UID;
                }
            }
            return(backSubRouteUID);
        }
        public static void Refresh()
        {
            if (clsGlobalSkills.skills != null)
            {
                return;
            }
            clsGlobalSkills.skills = new Dictionary <int, string>();
            string message = "https://api.freelancehunt.com/skills";
            string str1    = clsGlobalSkills.cmdExecWithWait("curl -u " + clsUpdate.id + ":" + clsUpdate.CreateToken(message) + " -k --user-agent \"freelancehunt client (VERSION 1.0)\" " + message).Replace("{", string.Empty).Replace("}", string.Empty).Replace("} ,", string.Empty).Replace("},", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty);

            char[] chArray = new char[2] {
                '\r', '\n'
            };
            foreach (string str2 in str1.Split(chArray))
            {
                if (!string.IsNullOrEmpty(str2) && str2.CompareTo(",") != 0)
                {
                    IEnumerable <string> source = Enumerable.Where <string>((IEnumerable <string>)str2.Split(new char[2] {
                        '"', ':'
                    }),
                                                                            (Func <string, bool>)(s => !string.IsNullOrEmpty(s)));
                    if (source != null)
                    {
                        string[] strArray = Enumerable.ToArray <string>(source);
                        if (Enumerable.Count <string>((IEnumerable <string>)strArray) == 5)
                        {
                            int result = 0;
                            if (int.TryParse(strArray[1], out result))
                            {
                                clsGlobalSkills.skills.Add(result, strArray[4].Replace("/", ",").Replace("&laquo;", "\"").Replace("&raquo;", "\""));
                            }
                        }
                    }
                }
            }
        }
示例#25
0
        public AuthenticationResponse Authenticate(ISession session, AuthenticationRequest request)
        {
            var response = request.CreateResponse <AuthenticationResponse>();

            response.Result = AuthenticationResponseType.Success;

            using (var uow = UnitOfWorkFactory.Create())
            {
                var user = uow.UsersRepository.FirstMatching(UserSpecification.NameAndPassword(request.Name, request.Password));
                if (user == null)
                {
                    response.Result = AuthenticationResponseType.InvalidNameOrPassword;
                    return(response);
                }
                else
                {
                    if (user.IsBanned)
                    {
                    }
                    else if (user.Huid != request.Huid)
                    {
                        user.ChangeHuid(request.Huid);
                    }
                }

                uow.Commit();

                if (response.Result == AuthenticationResponseType.Success)
                {
                    Enumerable.Count(user.Friends);
                    session.SetUser(user);
                    response.User = user.ProjectedAs <UserDto>();
                }
            }
            return(response);
        }
        public Api_Result <Dictionary <int, Mem_ship> > Ship(int area_id)
        {
            List <DeckShips> list             = new List <DeckShips>();
            Mem_esccort_deck mem_esccort_deck = Enumerable.FirstOrDefault <Mem_esccort_deck>(Comm_UserDatas.Instance.User_EscortDeck.get_Values(), (Mem_esccort_deck x) => x.Maparea_id == area_id);

            if (mem_esccort_deck != null)
            {
                list.Add(mem_esccort_deck.Ship);
            }
            IEnumerable <DeckShips> enumerable = Enumerable.Select <Mem_deck, DeckShips>(Enumerable.Where <Mem_deck>(Comm_UserDatas.Instance.User_deck.get_Values(), (Mem_deck deck) => deck.Area_id == area_id), (Mem_deck deck) => deck.Ship);

            if (Enumerable.Count <DeckShips>(enumerable) > 0)
            {
                list.AddRange(enumerable);
            }
            if (list.get_Count() == 0)
            {
                return(new Api_Result <Dictionary <int, Mem_ship> >
                {
                    state = Api_Result_State.Parameter_Error
                });
            }
            List <int> list2 = new List <int>();

            using (List <DeckShips> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DeckShips  current = enumerator.get_Current();
                    List <int> list3   = null;
                    current.Clone(out list3);
                    list2.AddRange(list3);
                }
            }
            return(this.Ship(list2));
        }
示例#27
0
        public Message.AccountCreateResponse CreateAccount(Stream jsonRequestMessage)
        {
            Message.AccountCreateRequest requestMessage = (Message.AccountCreateRequest) new DataContractJsonSerializer
                                                              (typeof(Message.AccountCreateRequest)).ReadObject(jsonRequestMessage);

            Message.AccountCreateResponse responseMessage = new Message.AccountCreateResponse();

            if (requestMessage.password != requestMessage.confirm)
            {
                responseMessage.errorCode = (int)CommonErrorCode.Auth_Fail_Mismatch_Confirm_Password;
                return(responseMessage);
            }

            using (var connection = ConnectionFactory.GetConnection())
            {
                int userCount = Enumerable.Count <Account>(connection.Query <Account>("select * from Account where username = @username",
                                                                                      new { username = requestMessage.username }));

                if (userCount > 0)
                {
                    responseMessage.errorCode = (int)CommonErrorCode.Auth_Add_User_Fail;
                    return(responseMessage);
                }

                connection.Open();
                connection.Query <Account>(
                    "insert Account(username,password) values(@username,@password)",
                    new
                {
                    username = requestMessage.username,
                    password = requestMessage.password
                });
            }

            return(responseMessage);
        }
        private void loadTransactions()
        {
            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item   = requisition.makeRequisition("http://localhost:60010/api/Card/getUserCards?userLogin="******"userLogged"], "GET", null);
            string  sucess = item["Sucess"];

            if ("true".Equals(sucess))
            {
                dynamic data = item["Data"];

                for (int i = 0; i < Enumerable.Count(data); i++)
                {
                    lvCardData.Items.Add(new lvCardItem {
                        cardName    = data[i]["cardholderName"],
                        cardNumber  = data[i]["number"],
                        cardExpDate = data[i]["expirationDate"],
                        cardBrand   = data[i]["cardBrand"],
                        cardBalance = data[i]["balance"],
                        cardType    = data[i]["type"]
                    });
                }
            }
        }
示例#29
0
 public void GroupJoinTest()
 {
     Tuple <int, string>[] categories = new Tuple <int, string>[]
     {
         new Tuple <int, string>(1, "A"),
         new Tuple <int, string>(2, "B"),
         new Tuple <int, string>(3, "C"),
     };
     Tuple <int, string, int>[] products = new Tuple <int, string, int>[]
     {
         new Tuple <int, string, int>(1, "aa", 1),
         new Tuple <int, string, int>(2, "bb", 1),
         new Tuple <int, string, int>(3, "cc", 2),
         new Tuple <int, string, int>(4, "dd", 2),
         new Tuple <int, string, int>(5, "ee", 2),
     };
     Tuple <string, int>[] expected = Enumerable.ToArray(Enumerable.GroupJoin(
                                                             categories,
                                                             products,
                                                             category => category.Item1,
                                                             product => product.Item3,
                                                             (category, categoryProducts) => new Tuple <string, int>(category.Item2, EnumerableExtensions.Count(categoryProducts))));
     Tuple <string, int>[] actual = Enumerable.ToArray(EnumerableExtensions.GroupJoin(
                                                           categories,
                                                           products,
                                                           category => category.Item1,
                                                           product => product.Item3,
                                                           (category, categoryProducts) => new Tuple <string, int>(category.Item2, EnumerableExtensions.Count(categoryProducts)),
                                                           EqualityComparer <int> .Default));
     Assert.AreEqual(Enumerable.Count(expected), Enumerable.Count(actual));
     expected.ForEach((product, index) =>
     {
         Assert.AreEqual(product.Item1, actual[index].Item1);
         Assert.AreEqual(product.Item2, actual[index].Item2);
     });
 }
        public void GetAll()
        {
            const string name     = "testFirst";
            const string lastName = "testLast";


            var users = new List <STUDENT>()
            {
                new STUDENT
                {
                    NETNAME     = StudentHelper.GenerateNetName(name, lastName),
                    ID          = 21941097,
                    FIRSTNAME   = name,
                    LASTNAME    = lastName,
                    DOB         = DateTime.UtcNow,
                    UGRADSTATUS = "U"
                },

                new STUDENT
                {
                    NETNAME     = StudentHelper.GenerateNetName(name, lastName),
                    ID          = 11141097,
                    FIRSTNAME   = name,
                    LASTNAME    = lastName,
                    DOB         = DateTime.UtcNow,
                    UGRADSTATUS = "U"
                }
            };

            _mySetStudent.Object.AddRange(users);
            ConnectMocksToDataStore(users);

            var result = _repo.GetAllAsync().Result;

            Assert.Equal(2, Enumerable.Count(result));
        }