public T TryGetItem(ItemTemplate template, System.Collections.Generic.IEnumerable <EffectBase> effects) { System.Collections.Generic.IEnumerable <T> source = from entry in this.Items.Values where entry.Template.Id == template.Id && effects.CompareEnumerable(entry.Effects) select entry; return(source.FirstOrDefault <T>()); }
public T TryGetItem(ItemTemplate template) { System.Collections.Generic.IEnumerable <T> source = from entry in this.Items.Values where entry.Template.Id == template.Id select entry; return(source.FirstOrDefault <T>()); }
private async Task MontaCabecalho(ObterRelatorioParecerConclusivoQuery request, RelatorioParecerConclusivoDto retorno, System.Collections.Generic.IEnumerable <RelatorioParecerConclusivoRetornoDto> parecesParaTratar) { retorno.Ano = (request.filtroRelatorioParecerConclusivoDto.Anos != null && request.filtroRelatorioParecerConclusivoDto.Anos.Length > 0) ? request.filtroRelatorioParecerConclusivoDto.Anos[0] : "Todos"; retorno.AnoLetivo = parecesParaTratar.Any() ? parecesParaTratar.FirstOrDefault().AnoLetivo : request.filtroRelatorioParecerConclusivoDto.AnoLetivo.ToString(); if (request.filtroRelatorioParecerConclusivoDto.Ciclo == 0) { retorno.Ciclo = "Todos"; } else { retorno.Ciclo = parecesParaTratar.FirstOrDefault(a => a.CicloId == request.filtroRelatorioParecerConclusivoDto.Ciclo).Ciclo; } retorno.Data = DateTime.Now.ToString("dd/MM/yyyy"); if (string.IsNullOrEmpty(request.filtroRelatorioParecerConclusivoDto.DreCodigo)) { retorno.DreNome = "Todas"; } else { var dreDoCabecalho = await mediator.Send(new ObterDrePorCodigoQuery() { DreCodigo = request.filtroRelatorioParecerConclusivoDto.DreCodigo }); retorno.DreNome = dreDoCabecalho.Abreviacao; } if (string.IsNullOrEmpty(request.filtroRelatorioParecerConclusivoDto.UeCodigo)) { retorno.UeNome = "Todas"; } else { var ueDoCabecalho = await mediator.Send(new ObterUePorCodigoQuery(request.filtroRelatorioParecerConclusivoDto.UeCodigo)); retorno.UeNome = ueDoCabecalho.NomeComTipoEscola; } retorno.RF = request.UsuarioRf; retorno.Usuario = request.filtroRelatorioParecerConclusivoDto.UsuarioNome; }
/// <summary> /// Getting left navigation menu from Sitecore content tree based on context item's parent with its childs /// Also displays only the items which has the options "Include in Left navigation" selected in sitecore /// </summary> /// <returns>Left navigation</returns> public ILeftNavigation GetLeftNavigation() { IMvcContext mvcContext = _mvcContext(); INavigable rootItem = mvcContext.GetContextItem <INavigable>(); //Setting default to context item _leftNavigation.ParentNavigationItem = rootItem; _leftNavigation.CurrentNavigationItem = rootItem; //Getting current item is Mediacenter based on its template id System.Collections.Generic.IEnumerable <Item> mediaCenter = rootItem.ContextItem.Axes.GetAncestors().Where(p => ID.Parse(p.TemplateID.ToGuid()).Equals(ID.Parse(SitecoreSettings.MediaCenterTemplateID))); if (mediaCenter.Any()) { //If context item is child of media center item template then have parent has Mediacenter _leftNavigation.ParentNavigationItem = mvcContext.SitecoreService.GetItem <INavigable>(mediaCenter.FirstOrDefault().ID.ToGuid()); //All nested childs will always have CurrentItemNavigation has its Mediacenter immediate child from where its(context item) comes from. IEnumerable <Item> currentItem = mediaCenter.FirstOrDefault().Children.Where(p => rootItem.ContextItem.Paths.LongID.Contains(p.ID.ToString())).Select(p => p); if (currentItem.Any()) { _leftNavigation.CurrentNavigationItem = _mvcContext()?.SitecoreService.GetItem <INavigable>(currentItem.FirstOrDefault().ID.ToGuid()); } } else { //Setting Current navigation item to context item _leftNavigation.CurrentNavigationItem = rootItem; } //Getting Parent item based on the following templates (Mediacenter,Generic contentpage and contentpage) switch (rootItem) { case var template when ID.Parse(rootItem.TemplateId).Equals(ID.Parse(SitecoreSettings.MediaCenterTemplateID)): _leftNavigation.ParentNavigationItem = _mvcContext()?.SitecoreService.GetItem <INavigable>(rootItem.Id); break; case var template when rootItem.BaseTemplateId.AsEnumerable().Any(p => p.Equals(SitecoreSettings.GenericContentPageTemplateID)) || ID.Parse(rootItem.TemplateId).Equals(ID.Parse(SitecoreSettings.GenericContentPageTemplateID)): _leftNavigation.ParentNavigationItem = _mvcContext()?.SitecoreService.GetItem <INavigable>(rootItem.Parent.Id); break; case var template when rootItem.BaseTemplateId.AsEnumerable().Any(p => p.Equals(SitecoreSettings.GenericContentRootPageTemplateID)) || ID.Parse(rootItem.TemplateId).Equals(ID.Parse(SitecoreSettings.GenericContentRootPageTemplateID)): _leftNavigation.ParentNavigationItem = rootItem; break; default: break; } return(_leftNavigation); }
protected Type GetPropertyTypeFromName(string propertyTypeName) { if (!cahsedTypesNames.ContainsKey(propertyTypeName)) { if (cashedAssembliesTypes == null) { cashedAssembliesTypes = AppDomain.CurrentDomain .GetAssemblies() .SelectMany(x => x.GetTypes()); } cahsedTypesNames[propertyTypeName] = cashedAssembliesTypes.FirstOrDefault(t => t.Name == propertyTypeName); } return(cahsedTypesNames[propertyTypeName]); }
public static System.Collections.Generic.List <DepartureHotel> GetDepartureInfo(string lang, System.DateTime dateFrom, System.DateTime dateTill, int?hotel, int?claim) { System.Collections.Generic.List <DepartureHotel> result = new System.Collections.Generic.List <DepartureHotel>(); if (!hotel.HasValue && !claim.HasValue) { throw new System.ArgumentNullException("hotel || claim"); } bool useNameField = lang == null || string.Compare(lang, "en", true) != 0; DataSet ds = DatabaseOperationProvider.QueryProcedure("up_TransferReports", "transfers,people", new { reportType = 1, trnsType = "2,3", dateFrom = dateFrom, dateTill = dateTill, freightTime = new System.DateTime(1900, 1, 1, 6, 0, 0), hotel = hotel.HasValue ? hotel.Value : 0, claim = claim.HasValue ? claim.Value : 0 }); System.Collections.Generic.IEnumerable <DataRow> dsTransfers = ds.Tables["transfers"].Rows.Cast <DataRow>(); System.Collections.Generic.IEnumerable <DataRow> dsPeople = ds.Tables["people"].Rows.Cast <DataRow>(); foreach (int h in ( from row in dsTransfers select row.ReadInt("transfer$hoteldep")).Distinct <int>()) { DataRow hotelRow = dsTransfers.FirstOrDefault((DataRow row) => row.ReadInt("transfer$hoteldep") == h); if (hotelRow != null) { DepartureHotel dhotel = GuestProvider.factory.DepartureHotel(useNameField, hotelRow); dhotel.transfers = ( from row in dsTransfers where row.ReadInt("transfer$hoteldep") == dhotel.id select GuestProvider.factory.DepartureTransfer(useNameField, row)).ToList <DepartureTransfer>(); foreach (DepartureTransfer transfer in dhotel.transfers) { transfer.people = ( from row in dsPeople where row.ReadNullableInt("transfer$inc") == transfer.id orderby row.ReadNullableInt("ident") select GuestProvider.factory.DepartureMember(useNameField, row)).ToList <DepartureMember>(); } result.Add(dhotel); } } return(result); }
/// <summary> /// Parse command line arguments as application settings /// </summary> /// <param name="args"></param> private static void LoadSettings(string[] args) { System.Collections.Generic.IEnumerable <SettingsProperty> settings = Settings.Default.Properties.Cast <SettingsProperty>(); foreach (string item in args) { string[] parts = item.Split("=".ToCharArray(), 2); string settingName = parts[0]; SettingsProperty setting = settings.FirstOrDefault(p => p.Name == settingName); if (setting == null) { throw new ShipmentReconciliationException($"Invalid command line argument: {settingName}"); } if (parts.Length == 1) { if (setting.PropertyType == typeof(bool)) { Settings.Default[settingName] = true; } else { throw new ShipmentReconciliationException($"Missing value assignment of command line argument: {settingName}. Please use the form: Name=Value."); } } else if (parts.Length == 2) { string settingValue = parts[1].TrimStart('"').TrimEnd('"'); Settings.Default[settingName] = Convert.ChangeType(settingValue, setting.PropertyType); } } CsvHelper.Configuration.Configuration csvConfiguration = !string.IsNullOrEmpty(Settings.Default.CsvConfigurationCulture) ? new CsvHelper.Configuration.Configuration(new System.Globalization.CultureInfo(Settings.Default.CsvConfigurationCulture)) : new CsvHelper.Configuration.Configuration(); if (!string.IsNullOrEmpty(Settings.Default.CsvConfigurationDelimiter)) { csvConfiguration.Delimiter = Settings.Default.CsvConfigurationDelimiter; } if (!string.IsNullOrEmpty(Settings.Default.CsvConfigurationEncoding)) { csvConfiguration.Encoding = System.Text.Encoding.GetEncoding(Settings.Default.CsvConfigurationEncoding); } CsvFile.DefaultConfiguration = csvConfiguration; }
protected void Page_Load(object sender, System.EventArgs e) { base.NeedLogin = true; if (base.IsPost) { UserInfo dataById = SinGooCMS.BLL.User.GetDataById(base.UserID); dataById.NickName = WebUtils.GetFormString("NickName"); dataById.Gender = WebUtils.GetFormString("Gender"); dataById.Birthday = WebUtils.GetFormDatetime("Birthday"); string text = base.UploadFileByUser("headerphoto"); if (!string.IsNullOrEmpty(text)) { dataById.HeaderPhoto = text; } if (SinGooCMS.BLL.User.Update(dataById)) { base.Response.Redirect(UrlRewrite.Get("profile_url")); } else { this.Alert(base.GetCaption("Profile_UpdateFail")); } } else { System.Collections.Generic.IEnumerable <UserGroupInfo> enumerable = from p in UserGroup.GetCacheUserGroupList() where p.GroupName.Equals(base.LoginUserGroup.GroupName) select p; base.Put("usermodel", SinGooCMS.BLL.User.GetFieldListWithValue(base.UserID, (enumerable == null) ? 0 : enumerable.FirstOrDefault <UserGroupInfo>().AutoID)); base.UsingClient("user/个人资料.html"); } }
private void Editor_ContextMenuOpening(object sender, ContextMenuEventArgs e) { this.Editor.ContextMenu = this.EditorContextMenu; if (this.SpellCheckProvider == null) { return; } TextViewPosition?positionFromPoint = this.Editor.GetPositionFromPoint(Mouse.GetPosition(this.Editor)); if (!positionFromPoint.HasValue) { return; } int offset = this.Editor.Document.GetOffset(positionFromPoint.Value.Line, positionFromPoint.Value.Column); System.Collections.Generic.IEnumerable <TextSegment> spellCheckErrors = this.SpellCheckProvider.GetSpellCheckErrors(); TextSegment textSegment = spellCheckErrors.FirstOrDefault((TextSegment segment) => segment.StartOffset <= offset && segment.EndOffset >= offset); if (textSegment == null) { return; } DocumentLine lineByOffset = this.Editor.Document.GetLineByOffset(offset); if (offset == lineByOffset.Offset || offset == lineByOffset.EndOffset) { return; } System.Collections.Generic.IEnumerable <string> spellcheckSuggestions = this.SpellCheckProvider.GetSpellcheckSuggestions(this.Editor.Document.GetText(textSegment)); int num = 0; if (spellcheckSuggestions.Any <string>()) { foreach (string current in spellcheckSuggestions) { MenuItem menuItem = new MenuItem { Header = current, FontWeight = FontWeights.Bold, Tag = textSegment }; menuItem.Click += new RoutedEventHandler(this.SuggestionItem_Click); this.Editor.ContextMenu.Items.Insert(num, menuItem); num++; } } MenuItem menuItem2 = new MenuItem { Header = LocalizationProvider.GetLocalizedString("MenuItem_AddToDictionary", false, "MarkdownPadStrings"), Tag = textSegment }; menuItem2.Click += delegate(object o, RoutedEventArgs args) { MenuItem menuItem3 = args.OriginalSource as MenuItem; TextSegment segment = (TextSegment)menuItem3.Tag; string text = this.Editor.Document.GetText(segment); this.SpellingService.AddWordToCustomDictionary(text); this.SpellCheckProvider.DoSpellCheck(); }; this.Editor.ContextMenu.Items.Insert(num, menuItem2); num++; Separator insertItem = new Separator(); this.Editor.ContextMenu.Items.Insert(num, insertItem); }
public void AnalysePossibilities() { this.Possibilities = new System.Collections.Generic.List <SpellCastInformations>(); foreach (Spell current in this.Fighter.Spells.Values) { SpellCategory spellCategories = SpellIdentifier.GetSpellCategories(current); SpellLevelTemplate currentSpellLevel = current.CurrentSpellLevel; SpellCastInformations spellCastInformations = new SpellCastInformations(current); if ((long)this.Fighter.AP >= (long)((ulong)currentSpellLevel.ApCost) && !currentSpellLevel.StatesForbidden.Any(new Func <int, bool>(this.Fighter.HasState))) { if (!currentSpellLevel.StatesRequired.Any((int state) => !this.Fighter.HasState(state)) && this.Fighter.SpellHistory.CanCastSpell(current.CurrentSpellLevel)) { if ((spellCategories & SpellCategory.Summoning) != SpellCategory.None && this.Fighter.CanSummon()) { Cell freeAdjacentCell = this.m_environment.GetFreeAdjacentCell(); if (freeAdjacentCell == null) { continue; } spellCastInformations.IsSummoningSpell = true; spellCastInformations.SummonCell = freeAdjacentCell; } else { foreach (FightActor current2 in from fighter in this.Fighter.Fight.Fighters where fighter.IsAlive() && fighter.IsVisibleFor(this.Fighter) select fighter) { int mPToUse; if (this.CanReach(current2, current, out mPToUse) && this.Fighter.SpellHistory.CanCastSpell(current.CurrentSpellLevel, current2.Cell)) { spellCastInformations.MPToUse = mPToUse; SpellTarget spellTarget = this.ComputeSpellImpact(current, current2); if (spellTarget != null) { spellTarget.Target = current2; if (spellTarget.Damage >= 0.0) { spellCastInformations.Impacts.Add(spellTarget); } } } } } this.Possibilities.Add(spellCastInformations); } } } if (Brain.Brain.DebugMode) { Debug.WriteLine(this.Fighter.Name); using (System.Collections.Generic.Dictionary <int, Spell> .ValueCollection.Enumerator enumerator = this.Fighter.Spells.Values.GetEnumerator()) { while (enumerator.MoveNext()) { Spell spell = enumerator.Current; Debug.WriteLine("Spell {0} ({1}) :: {2}", new object[] { spell.Template.Name, spell.Id, SpellIdentifier.GetSpellCategories(spell) }); System.Collections.Generic.IEnumerable <SpellCastInformations> arg_2C4_0 = this.Possibilities; Func <SpellCastInformations, bool> predicate = (SpellCastInformations x) => x.Spell == spell; SpellCastInformations spellCastInformations2 = arg_2C4_0.FirstOrDefault(predicate); if (spellCastInformations2 != null) { if (spellCastInformations2.IsSummoningSpell) { Debug.WriteLine("\tSummon Spell"); } else { ObjectDumper objectDumper = new ObjectDumper(8); objectDumper.MemberPredicate = ((System.Reflection.MemberInfo member) => !member.Name.Contains("Target")); ObjectDumper objectDumper2 = objectDumper; Debug.WriteLine("\t{0} Targets", new object[] { spellCastInformations2.Impacts.Count }); foreach (SpellTarget spellTarget in spellCastInformations2.Impacts) { Debug.Write(objectDumper2.DumpElement(spellTarget)); if (spellTarget.Target != null) { Debug.WriteLine("\t\tTarget = " + spellTarget.Target + spellTarget.Target.Id.ToString()); } } } } } } Debug.WriteLine(""); } }