public ListMenu(string DataPath, AppsModules Modul, ListType Type, string ModLabel) { InitializeComponent(); //Set Label Format Lbl_List.Foreground = new SolidColorBrush(FontColor); Lbl_List.FontFamily = TitleFont; //Set Title Lbl_List.Content = ModLabel; //Search for the Files or Directories if (Type == ListType.Folder) { //Search all Directories DirectoryPaths = Directory.GetDirectories(DataPath).ToList(); } else if (Type == ListType.None) { //Dummy } else { DirectoryPaths = new List<string>(); //Search all Files in diferents formats for(int x=0; x < FileMgr.GetFileFormats(Type).Length; x++) DirectoryPaths.AddRange(Directory.GetFiles(DataPath, FileMgr.GetFileFormats(Type)[x]).ToList()); } //Copy the Option Information CurrentModul = Modul; SelModul = 0; myType = Type; }
public MainForm(string path, bool loadNames, bool loadBrstms, bool groupSongs) { InitializeComponent(); loadNamesFromInfopacToolStripMenuItem.Checked = songPanel1.LoadNames = loadNames; loadBRSTMPlayerToolStripMenuItem.Checked = songPanel1.LoadBrstms = loadBrstms; groupSongsByStageToolStripMenuItem.Checked = groupSongs; listType = groupSongs ? ListType.GroupByStage : ListType.FilesInDir; // Later commands to change the titlebar assume there is a hypen in the title somewhere this.Text += " -"; loadNames = loadNamesFromInfopacToolStripMenuItem.Checked; loadBrstms = loadBRSTMPlayerToolStripMenuItem.Checked; RightControl = chooseLabel; // Drag and drop for the left and right sides of the window. The dragEnter and dragDrop methods will check which panel the file is dropped onto. listBox1.AllowDrop = true; listBox1.DragEnter += dragEnter; listBox1.DragDrop += dragDrop; this.FormClosing += closing; this.FormClosed += closed; changeDirectory(path); }
/// <summary> /// Get file formats for each kind of App /// </summary> public static string[] GetFileFormats(ListType type) { string[] Formats; switch (type) { case ListType.PDF: Formats = new string[] { "*.pdf" }; break; case ListType.Video: Formats = new string[] { "*.avi", "*.wmv", "*.flv", "*.mp4", "*.mpg"}; break; case ListType.Maps: Formats = new string[] { "*.png", "*.jpg" }; break; case ListType.Web: Formats = new string[] { "*.txt" }; break; case ListType.Voting: Formats = new string[] { "*.xml" }; break; default: Formats = new string[] { "*.*" }; break; } return Formats; }
public NamespaceList(string namespaces, string targetNamespace) { Debug.Assert(targetNamespace != null); this.targetNamespace = targetNamespace; namespaces = namespaces.Trim(); if (namespaces == "##any" || namespaces.Length == 0) { type = ListType.Any; } else if (namespaces == "##other") { type = ListType.Other; } else { type = ListType.Set; set = new Hashtable(); foreach(string ns in XmlConvert.SplitString(namespaces)) { if (ns == "##local") { set[string.Empty] = string.Empty; } else if (ns == "##targetNamespace") { set[targetNamespace] = targetNamespace; } else { XmlConvert.ToUri (ns); // can throw set[ns] = ns; } } } }
public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL) { ship = s; shipNode = s.SaveShip(); shipName = s.shipName; //Get total ship cost float dry, fuel; s.GetShipCosts(out dry, out fuel); cost = dry + fuel; TotalMass = 0; foreach (Part p in s.Parts) { TotalMass += p.mass; TotalMass += p.GetResourceMass(); } launchSite = ls; buildPoints = bP; progress = 0; flag = flagURL; if (launchSite == "LaunchPad") type = ListType.VAB; else type = ListType.SPH; InventoryParts = new Dictionary<string, int>(); id = Guid.NewGuid(); cannotEarnScience = false; }
public NamespaceList(string namespaces, string targetNamespace) { this.targetNamespace = targetNamespace; namespaces = namespaces.Trim(); if ((namespaces == "##any") || (namespaces.Length == 0)) { this.type = ListType.Any; } else if (namespaces == "##other") { this.type = ListType.Other; } else { this.type = ListType.Set; this.set = new Hashtable(); string[] strArray = XmlConvert.SplitString(namespaces); for (int i = 0; i < strArray.Length; i++) { if (strArray[i] == "##local") { this.set[string.Empty] = string.Empty; } else if (strArray[i] == "##targetNamespace") { this.set[targetNamespace] = targetNamespace; } else { XmlConvert.ToUri(strArray[i]); this.set[strArray[i]] = strArray[i]; } } } }
public static List<string> ImportListFile(string fileName, ListType type) { using (var sr = File.OpenText(fileName)) { switch (type) { case ListType.M3U8: { var line = sr.ReadLine().ToUpper(); if (!line.Contains("#EXTM3U")) return null; line = sr.ReadLine(); var temp = new List<string>(); while (!string.IsNullOrWhiteSpace(line)) { if (line[0] == '#') { line = sr.ReadLine(); continue; } temp.Add(line); line = sr.ReadLine(); } return temp; } default: return null; } } }
private static string ConvertListTypeToString(ListType type) { string s; switch (type) { case ListType.RECOMMENDED: s = "recommended"; break; case ListType.LIKED: s = "liked"; break; case ListType.LISTEN_LATER: s = "listen_later"; break; case ListType.FEED: s = "feed"; break; case ListType.PUBLISHED: s = "dj"; break; case ListType.HISTORY: s = "listened"; break; default: throw new System.ArgumentException("Invalid ListType argument passed"); } return s; }
public NamespaceList(string namespaces, string targetNamespace) { Debug.Assert(targetNamespace != null); this.targetNamespace = targetNamespace; namespaces = namespaces.Trim(); if (namespaces == "##any" || namespaces.Length == 0) { type = ListType.Any; } else if (namespaces == "##other") { type = ListType.Other; } else { type = ListType.Set; set = new Hashtable(); string[] splitString = XmlConvert.SplitString(namespaces); for (int i = 0; i < splitString.Length; ++i) { if (splitString[i] == "##local") { set[string.Empty] = string.Empty; } else if (splitString[i] == "##targetNamespace") { set[targetNamespace] = targetNamespace; } else { XmlConvert.ToUri (splitString[i]); // can throw set[splitString[i]] = splitString[i]; } } } }
/// <summary> /// Constructor for the GroupEnumeratorHelper. At construction /// time, you specify the GroupingCollection to use, and the type /// of enumerator you wish to get. /// </summary> /// <remarks> /// </remarks> /// <owner>DavidLe</owner> /// <param name="groupingCollection"></param> /// <param name="type"></param> /// <returns>IEnumerator</returns> internal GroupEnumeratorHelper ( GroupingCollection groupingCollection, ListType type ) { error.VerifyThrow(groupingCollection != null, "GroupingCollection is null"); this.groupingCollection = groupingCollection; this.type = type; }
public static string CloseList(ListType type) { switch (type) { case ListType.Bulletted: return CloseBulletedList(); case ListType.Numbered: return CloseNumberedList(); default: return CloseNumberedList(); } }
public virtual int GetListId(ListType listType, SchoolCategory schoolCategory) { switch(schoolCategory) { case SchoolCategory.None: case SchoolCategory.Ungraded: schoolCategory = SchoolCategory.HighSchool; break; } return GetListId(listType.ToString(), schoolCategory); }
public static int GetLayoutForType(ListType type) { switch (type) { case ListType.Regular: return Resource.Layout.sino_droid_md_listitem; case ListType.Single: return Resource.Layout.sino_droid_md_listitem_singlechoice; case ListType.Multi: return Resource.Layout.sino_droid_md_listitem_multichoice; default: throw new InvalidOperationException("Not a valid list type"); } }
private static string GetTagName(ListType listType) { switch (listType) { case ListType.BulletedList: return "ul"; case ListType.NumberedList: return "ol"; default: throw new ArgumentOutOfRangeException("listType"); } }
public KCT_BuildListVessel(String name, String ls, double bP, String flagURL, float spentFunds) { ship = new ShipConstruct(); launchSite = ls; shipName = name; buildPoints = bP; progress = 0; flag = flagURL; if (launchSite == "LaunchPad") type = ListType.VAB; else type = ListType.SPH; InventoryParts = new List<string>(); cannotEarnScience = false; cost = spentFunds; }
public static DataTable Select(ListType ListType, int DepartmentId, int Days, int TechnicianId, int AccountId) { System.Data.SqlClient.SqlParameter[] sqlParams = { new System.Data.SqlClient.SqlParameter("@DId", DBNull.Value), new System.Data.SqlClient.SqlParameter("@UId", "-1"), new System.Data.SqlClient.SqlParameter("@intAcctId", DBNull.Value), new System.Data.SqlClient.SqlParameter("@sintDayAdvance", DBNull.Value), new System.Data.SqlClient.SqlParameter("@tintListType", (int)ListType) }; if (DepartmentId > 0) sqlParams[0].SqlValue = DepartmentId; if (TechnicianId > 0) sqlParams[1].SqlValue = TechnicianId; if (AccountId > 0) sqlParams[2].SqlValue = AccountId; if (Days > 0) sqlParams[3].SqlValue = Days; return SelectRecords("sp_SelectFollowUpList", sqlParams); }
public virtual EdFiGridModel GetEdFiGridModel(bool displayInteractionMenu, bool displayAddRemoveColumns, int fixedHeight, string name, int? metricVariantId, GridTable gridTable, IList<MetricFootnote> metricFootnotes, string nonPersistedSettings, bool sizeToWindow, string listType, IList<string> legendViewNames, string hrefToUse, bool usePagination, string paginationCallbackUrl, bool allowMaximizeGrid, EdFiGridWatchListModel studentWatchList = null, string selectedDemographicOption = null, string selectedSchoolCategoryOption = null, string selectedGradeOption = null, string previousNextSessionPage = null, string exportGridDataUrl = null, ListType gridListType = default(ListType)) { var model = new EdFiGridModel { DisplayInteractionMenu = displayInteractionMenu, DisplayAddRemoveColumns = displayAddRemoveColumns, FixedHeight = fixedHeight, GridName = name, GridTable = gridTable, SizeToWindow = sizeToWindow, UniqueTableName = name, MetricFootnotes = metricFootnotes, NonPersistedSettings = nonPersistedSettings, EntityList = string.IsNullOrEmpty(listType) ? null : new EntityListModel { ListType = listType, MetricVariantId = metricVariantId.HasValue ? metricVariantId.Value.ToString(CultureInfo.InvariantCulture) : string.Empty, RowIndexForId = 1 }, LegendViewNames = legendViewNames, DefaultSortColumn = 1, HrefToUse = hrefToUse, UsePagination = usePagination, PaginationCallbackUrl = paginationCallbackUrl, AllowMaximizeGrid = allowMaximizeGrid, StudentWatchList = studentWatchList, SelectedDemographicOption = selectedDemographicOption, SelectedSchoolCategoryOption = selectedSchoolCategoryOption, SelectedGradeOption = selectedGradeOption, PreviousNextSessionPage = previousNextSessionPage, ExportGridDataUrl = exportGridDataUrl, ListType = gridListType }; return model; }
void SpreadRender(Vector2 position, byte distance) { if (position.y < 0 || position.x < 0 || position.y >= Map.MatrixHeight.GetLength (0) || position.x >= Map.MatrixHeight.GetLength (0)) return; short index = (short)RenderedHexes.FindIndex (x => x.Hex.GetComponent<HexData> ().MapCoords == position); if (index == -1) { Quaternion rot = new Quaternion (); ListType hex = new ListType{Hex= Instantiate (Hex, new Vector2 (position.x * 0.96f, position.y * 0.64f + ((position.x % 2) != 0 ? 1 : 0) * 0.32f), rot) as GameObject,InSign= true}; hex.Hex.GetComponent<HexData> ().MapCoords = position; ChooseSprite (hex.Hex, position); RenderedHexes.Add (hex); } else { if (RenderedHexes [index].InSign) return; else RenderedHexes [index].InSign = true; } if (distance != 0) { byte k = (byte)((position.x % 2) != 0 ? 1 : 0); // Учитываем чётность/нечётность ряда хексов SignQueue.Enqueue (new QueueType{Position=new Vector2 (position.x - 1, position.y - 1 + k),Distance=(byte)(distance - 1)}); SignQueue.Enqueue (new QueueType{Position=new Vector2 (position.x - 1, position.y + k),Distance= (byte)(distance - 1)}); SignQueue.Enqueue (new QueueType{Position=new Vector2 (position.x, position.y - 1), Distance=(byte)(distance - 1)}); SignQueue.Enqueue (new QueueType{Position=new Vector2 (position.x, position.y + 1), Distance=(byte)(distance - 1)}); SignQueue.Enqueue (new QueueType{Position=new Vector2 (position.x + 1, position.y - 1 + k),Distance=(byte) (distance - 1)}); SignQueue.Enqueue (new QueueType{Position=new Vector2 (position.x + 1, position.y + k), Distance=(byte)(distance - 1)}); } }
public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL) { ship = s; shipNode = s.SaveShip(); shipName = s.shipName; //Get total ship cost float dry, fuel; s.GetShipCosts(out dry, out fuel); cost = dry + fuel; launchSite = ls; buildPoints = bP; progress = 0; flag = flagURL; if (launchSite == "LaunchPad") type = ListType.VAB; else type = ListType.SPH; InventoryParts = new List<string>(); id = Guid.NewGuid(); cannotEarnScience = false; }
public List<SmsDeliverMessage> List(ListType type) { List<SmsDeliverMessage> result = new List<SmsDeliverMessage>(); // set format to pdu Debug.WriteLine("Asking for PDU format"); WriteCommandExpectResponse("AT+CMGF=0", "\rOK\r"); // list storages Debug.WriteLine("Asking for storage enumeration"); string response = WriteCommandExpectResponse("AT+CPMS?", "\rOK\r"); string[] data = response.Split('\r'); if (data[1].Substring(0, 7).ToUpper() != "+CPMS: ") throw new UnexpectedResponseException("Phone message storages could not be enumerated"); // walk storages string[] storages = data[1].Substring(7).Split(','); for (int x = 0; x < storages.Length; x += 3) { Debug.WriteLine("Memory " + storages[x] + ": " + storages[x + 1] + " used, " + storages[x + 2] + " total"); // select storage WriteCommandExpectResponse("AT+CPMS=" + storages[x], "\rOK\r"); // list messages in storage response = WriteCommandExpectResponse("AT+CMGL=" + (int)type, "\rOK\r"); data = response.Split('\r'); for (int y = 2; y < data.Length - 2; y = y + 2) { try { result.Add(new SmsDeliverMessage(data[y], new MessageLocation(storages[x], int.Parse(data[y - 1].Substring(6, data[y - 1].IndexOf(",", 6) - 6))))); } catch (Exception ex) { Debug.WriteLine("Failed to read message: " + ex.Message + ", " + ex.StackTrace); } } } MergeMultipartMessages(result); return result; }
public KCT_BuildListVessel(ShipConstruct s, String ls, double bP, String flagURL) { ship = s; shipNode = s.SaveShip(); shipName = s.shipName; //Get total ship cost float fuel; cost = s.GetShipCosts(out emptyCost, out fuel); TotalMass = s.GetShipMass(out emptyMass, out fuel); launchSite = ls; buildPoints = bP; progress = 0; flag = flagURL; if (s.shipFacility == EditorFacility.VAB) type = ListType.VAB; else if (s.shipFacility == EditorFacility.SPH) type = ListType.SPH; else type = ListType.None; InventoryParts = new Dictionary<string, int>(); id = Guid.NewGuid(); cannotEarnScience = false; }
/// <summary> /// Inserts a list /// </summary> /// <param name="ordered">Indicates whether the list should be ordered or not</param> /// <param name="type">The type of the list</param> /// <param name="items">The list items</param> public void InsertList(bool ordered, ListType type, List<string> items) { StringBuilder htmlText = new StringBuilder(); string listType = string.Empty; switch (type) { case ListType.CapitalLetters: listType = "upper-alpha"; break; case ListType.CapitalRoman: listType = "upper-roman"; break; case ListType.Circle: listType = "circle"; break; case ListType.Decimal: listType = "decimal"; break; case ListType.Disc: listType = "disc"; break; case ListType.LowerLetters: listType = "lower-alpha"; break; case ListType.LowerRoman: listType = "lower-roman"; break; case ListType.Square: listType = "square"; break; } if (ordered) { htmlText.AppendLine("<ol>"); } else { htmlText.AppendLine("<ul>"); } foreach (string item in items) { htmlText.AppendLine("<li>" + item + "</li>"); } if (ordered) { htmlText.AppendLine("</ol>"); } else { htmlText.AppendLine("</ul"); } IHTMLTxtRange range = this.document.selection.createRange() as IHTMLTxtRange; range.pasteHTML(htmlText.ToString()); range.select(); if (this.GetSelectedElementType() != "BODY") { this.GetSelectedElement().parentElement.style.listStyleType = listType; } }
public FormControlListFor(BootstrapHelper helper, bool editor, Expression <Func <TModel, IEnumerable <TValue> > > expression, ListType listType) : base(helper, editor, expression) { _listType = listType; }
public void Visit(ListType listType) { throw new NotImplementedException(); }
public static void build() { ReportBuilder rptbuild = new ReportBuilder(); ReportType vReport = rptbuild.Report; BodyType vBody = vReport.Body; double x = 0, y = 0, wd = 0, ht = 0; vReport.Width.Value = RPT_WIDTH; vBody.Height.Value = RPT_HEIGHT; DataSetType dataSet = rptbuild.Report.DataSets[0]; ReportUtil.AddFields(dataSet.Fields, new string[] { PInvoice.COPIES , PInvoice.COMPANY_NAME , PInvoice.ADDRESS1 , PInvoice.ADDRESS2 , PInvoice.COMPANY_TIN , PInvoice.COMPANY_GST , PInvoice.SALES_TYPE , PInvoice.INVOICE_ID , PInvoice.INVOICE_NO , PInvoice.INVOICE_DATE , PInvoice.TRANSPORT , PInvoice.VEHICLE_NO , PInvoice.PLACE , PInvoice.PARTY_NAME , PInvoice.STREET1 , PInvoice.STREET2 , PInvoice.CITY , PInvoice.STATE , PInvoice.COUNTRY , PInvoice.PINCODE , PInvoice.GSTIN , PInvoice.SHIPPING_NAME , PInvoice.SHIPPING_STREET1 , PInvoice.SHIPPING_STREET2 , PInvoice.SHIPPING_CITY , PInvoice.SHIPPING_STATE , PInvoice.SHIPPING_COUNTRY , PInvoice.SHIPPING_PINCODE , PInvoice.SHIPPING_GSTIN , PInvoice.TOTAL_QTY , PInvoice.TOTAL_AREASQ , PInvoice.TAXABLE_VALUE , PInvoice.LBL_SGST , PInvoice.TOTAL_SGST , PInvoice.LBL_CGST , PInvoice.TOTAL_CGST , PInvoice.TOTAL_SUB , PInvoice.LEDGER , PInvoice.ADDITIONAL , PInvoice.ROUNDS , PInvoice.GSTTOTAL , PInvoice.GRANDTOTAL , PInvoice.AMOUNT_IN_WORDS , PInvoice.NOTES , PInvoice.ENTRY_BY }); x = 0; y = 0; wd = RPT_WIDTH; ht = RPT_HEIGHT; ListType Reportlist = ReportUtil.AddList("Reportlist", vBody.ReportItems, x, y, wd, ht); Reportlist.Grouping = new GroupingType("group_" + PInvoice.INVOICE_ID + ""); Reportlist.Grouping.GroupExpressions.Add("=Fields!" + PInvoice.INVOICE_ID + ".Value"); Reportlist.Grouping.GroupExpressions.Add("=Fields!" + PInvoice.COPIES + ".Value"); Reportlist.Grouping.PageBreakAtEnd = true; EmbeddedImageType myEmbeddedImage1 = ReportUtil.EmbedImage("Image1", Global.GetAbsolutePath("PRINTS\\sms_logo.png"), vReport); ImageType myImage1 = ReportUtil.AddImage("Image1", myEmbeddedImage1, Reportlist.ReportItems, 0.5, 0.4, 1.25, 1); myImage1.Sizing = SizingEnum.FitProportional; //.AutoSize //.Fit //.Clip x = 0; y = 0; wd = RPT_WIDTH; ht = RPT_HEIGHT; RectangleType rectWarper = ReportUtil.AddRectangle("rectWarper", Reportlist.ReportItems, x, y, wd, ht); rectWarper.Style.BorderStyle.Default = BorderStyleEnum.None; BuildDetail(rectWarper); rptbuild.SaveAs(PRINT_FOLDER + @"\P_Invoice.rdlc"); }
public ObjectList(string _name, ListType _type) { name = _name; type = _type.ToString().ToLower(); list = new List <object>(); }
private static void Get2DValue <T>(string key, T list, ListType arrayType, int vectorNumber, Action <IList, byte[]> convert) where T : IList { if (PlayerPrefs.HasKey(key)) { var bytes = System.Convert.FromBase64String(PlayerPrefs.GetString(key)); // Make sure the min header length is intact if (bytes.Length < 5) { Debug.LogError(string.Format(GDMConstants.ErrorCorruptPrefFormat, key)); return; } int listCount = BitConverter.ToInt32(bytes, 1); byte[] headerBytes = new byte[listCount * 4 + 5]; Array.Copy(bytes, 0, headerBytes, 0, headerBytes.Length); List <byte> allBytes = new List <byte>(bytes); allBytes.RemoveRange(1, headerBytes.Length - 1); bytes = allBytes.ToArray(); if ((bytes.Length - 1) % (vectorNumber * 4) != 0) { Debug.LogError(string.Format(GDMConstants.ErrorCorruptPrefFormat, key)); return; } if ((ListType)bytes[0] != arrayType) { Debug.LogError(string.Format(GDMConstants.ErrorCorruptPrefFormat, key, arrayType.ToString())); return; } Initialize(); IList masterList; GetNewListForType(arrayType, out masterList); var end = (bytes.Length - 1) / (vectorNumber * 4); for (int i = 0; i < end; i++) { convert(masterList, bytes); } // Construct the sublists int currentListCount = 0; int itr = 0; int headerIndex = 5; IList subList; for (int x = 0; x < listCount; x++) { currentListCount = BitConverter.ToInt32(headerBytes, headerIndex); headerIndex += 4; GetNewListForType(arrayType, out subList); for (int y = 0; y < currentListCount; y++) { subList.Add(masterList[itr++]); } list.Add(subList); } } }
internal void UpdateObjectsList(string scope, ListType listType) { if (UpdateList != null) { List<ListData> objects = new List<ListData>(); foreach (Element obj in GetObjectsInScope(scope)) { if (Version <= WorldModelVersion.v520 || !m_elements.ContainsKey(ElementType.Function, "GetDisplayVerbs")) { if (scope == "ScopeInventory") { objects.Add(new ListData(GetListDisplayAlias(obj), obj.Fields[FieldDefinitions.InventoryVerbs], obj.Name, GetDisplayAlias(obj))); } else { objects.Add(new ListData(GetListDisplayAlias(obj), obj.Fields[FieldDefinitions.DisplayVerbs], obj.Name, GetDisplayAlias(obj))); } } else { objects.Add(new ListData(GetListDisplayAlias(obj), GetDisplayVerbs(obj), obj.Name, GetDisplayAlias(obj))); } } // The "Places and Objects" list is generated by function, so we also // need to add any exits. (The UI is responsible for filtering out the // directional exits so they only display in the compass) if (scope == "GetPlacesObjectsList") objects.AddRange(GetExitsListData()); UpdateList(listType, objects); } }
public FilterList(ListType type, params T[] entries) { this.elements = new HashSet <T>(entries); this.type = type; }
public static object ReadSyncObject(ByteReader data, SyncType syncType) { MpContext context = data.MpContext(); Map map = context.map; Type type = syncType.type; try { if (typeof(object) == type) { return(null); } if (type.IsByRef) { return(null); } if (syncWorkersEarly.TryGetValue(type, out SyncWorkerEntry syncWorkerEntryEarly)) { object res = null; if (syncWorkerEntryEarly.shouldConstruct || type.IsValueType) { res = Activator.CreateInstance(type); } syncWorkerEntryEarly.Invoke(new ReadingSyncWorker(data), ref res); return(res); } if (syncType.expose) { if (!typeof(IExposable).IsAssignableFrom(type)) { throw new SerializationException($"Type {type} can't be exposed because it isn't IExposable"); } byte[] exposableData = data.ReadPrefixedBytes(); return(ReadExposable.MakeGenericMethod(type).Invoke(null, new[] { exposableData, null })); } if (typeof(ISynchronizable).IsAssignableFrom(type)) { var obj = Activator.CreateInstance(type); ((ISynchronizable)obj).Sync(new ReadingSyncWorker(data)); return(obj); } if (type.IsEnum) { Type enumType = Enum.GetUnderlyingType(type); return(ReadSyncObject(data, enumType)); } if (type.IsArray && type.GetArrayRank() == 1) { Type elementType = type.GetElementType(); ushort length = data.ReadUShort(); Array arr = Array.CreateInstance(elementType, length); for (int i = 0; i < length; i++) { arr.SetValue(ReadSyncObject(data, elementType), i); } return(arr); } if (type.IsGenericType) { if (type.GetGenericTypeDefinition() == typeof(List <>)) { ListType specialList = ReadSync <ListType>(data); if (specialList == ListType.MapAllThings) { return(map.listerThings.AllThings); } if (specialList == ListType.MapAllDesignations) { return(map.designationManager.allDesignations); } Type listType = type.GetGenericArguments()[0]; ushort size = data.ReadUShort(); IList list = (IList)Activator.CreateInstance(type, size); for (int j = 0; j < size; j++) { list.Add(ReadSyncObject(data, listType)); } return(list); } if (type.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { Type element = type.GetGenericArguments()[0]; return(ReadSyncObject(data, typeof(List <>).MakeGenericType(element))); } if (type.GetGenericTypeDefinition() == typeof(Nullable <>)) { bool isNull = data.ReadBool(); if (isNull) { return(null); } bool hasValue = data.ReadBool(); if (!hasValue) { return(Activator.CreateInstance(type)); } Type nullableType = type.GetGenericArguments()[0]; return(Activator.CreateInstance(type, ReadSyncObject(data, nullableType))); } } // Def is a special case until the workers can read their own type if (typeof(Def).IsAssignableFrom(type)) { ushort shortHash = data.ReadUShort(); if (shortHash == 0) { return(null); } Def def = (Def)GetDefByIdMethod.MakeGenericMethod(type).Invoke(null, new object[] { shortHash }); if (def == null) { throw new Exception($"Couldn't find {type} with short hash {shortHash}"); } return(def); } // Designators can't be handled by SyncWorkers due to the type change if (typeof(Designator).IsAssignableFrom(type)) { ushort desId = Sync.ReadSync <ushort>(data); type = Sync.designatorTypes[desId]; // Replaces the type! } // Where the magic happens if (syncWorkers.TryGetValue(type, out var syncWorkerEntry)) { object res = null; if (syncWorkerEntry.shouldConstruct || type.IsValueType) { res = Activator.CreateInstance(type); } syncWorkerEntry.Invoke(new ReadingSyncWorker(data), ref res); return(res); } throw new SerializationException("No reader for type " + type); } catch (Exception e) { MpLog.Error($"Error reading type: {type}, {e}"); throw; } }
public IListEditorConfig <TEntity> SetListType(ListType listType) { ListEditorType = listType; return(this); }
public static void WriteSyncObject(ByteWriter data, object obj, SyncType syncType) { MpContext context = data.MpContext(); Type type = syncType.type; LoggingByteWriter log = data as LoggingByteWriter; log?.LogEnter(type.FullName + ": " + (obj ?? "null")); if (obj != null && !type.IsAssignableFrom(obj.GetType())) { throw new SerializationException($"Serializing with type {type} but got object of type {obj.GetType()}"); } try { if (typeof(object) == type) { return; } if (type.IsByRef) { return; } if (syncWorkersEarly.TryGetValue(type, out var syncWorkerEntryEarly)) { syncWorkerEntryEarly.Invoke(new WritingSyncWorker(data), ref obj); return; } if (syncType.expose) { if (!typeof(IExposable).IsAssignableFrom(type)) { throw new SerializationException($"Type {type} can't be exposed because it isn't IExposable"); } IExposable exposable = obj as IExposable; data.WritePrefixedBytes(ScribeUtil.WriteExposable(exposable)); return; } if (typeof(ISynchronizable).IsAssignableFrom(type)) { ((ISynchronizable)obj).Sync(new WritingSyncWorker(data)); return; } if (type.IsEnum) { Type enumType = Enum.GetUnderlyingType(type); WriteSyncObject(data, Convert.ChangeType(obj, enumType), enumType); return; } if (type.IsArray && type.GetArrayRank() == 1) { Type elementType = type.GetElementType(); Array arr = (Array)obj; if (arr.Length > ushort.MaxValue) { throw new Exception($"Tried to serialize a {elementType}[] with too many ({arr.Length}) items."); } data.WriteUShort((ushort)arr.Length); foreach (object e in arr) { WriteSyncObject(data, e, elementType); } return; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>)) { ListType specialList = ListType.Normal; Type listType = type.GetGenericArguments()[0]; if (listType == typeof(Thing) && obj == Find.CurrentMap.listerThings.AllThings) { context.map = Find.CurrentMap; specialList = ListType.MapAllThings; } else if (listType == typeof(Designation) && obj == Find.CurrentMap.designationManager.allDesignations) { context.map = Find.CurrentMap; specialList = ListType.MapAllDesignations; } WriteSync(data, specialList); if (specialList == ListType.Normal) { IList list = (IList)obj; if (list.Count > ushort.MaxValue) { throw new Exception($"Tried to serialize a {type} with too many ({list.Count}) items."); } data.WriteUShort((ushort)list.Count); foreach (object e in list) { WriteSyncObject(data, e, listType); } } return; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { bool isNull = obj == null; data.WriteBool(isNull); if (isNull) { return; } bool hasValue = (bool)obj.GetPropertyOrField("HasValue"); data.WriteBool(hasValue); Type nullableType = type.GetGenericArguments()[0]; if (hasValue) { WriteSyncObject(data, obj.GetPropertyOrField("Value"), nullableType); } return; } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { IEnumerable e = (IEnumerable)obj; Type elementType = type.GetGenericArguments()[0]; var listType = typeof(List <>).MakeGenericType(elementType); IList list = (IList)Activator.CreateInstance(listType); foreach (var o in e) { if (list.Count > ushort.MaxValue) { throw new Exception($"Tried to serialize a {type} with too many ({list.Count}) items."); } list.Add(o); } WriteSyncObject(data, list, listType); return; } // special case if (typeof(Def).IsAssignableFrom(type)) { Def def = obj as Def; data.WriteUShort(def != null ? def.shortHash : (ushort)0); return; } // special case for Designators to change the type if (typeof(Designator).IsAssignableFrom(type)) { data.WriteUShort((ushort)Array.IndexOf(Sync.designatorTypes, obj.GetType())); } // Where the magic happens if (syncWorkers.TryGetValue(type, out var syncWorkerEntry)) { syncWorkerEntry.Invoke(new WritingSyncWorker(data), ref obj); return; } log?.LogNode("No writer for " + type); throw new SerializationException("No writer for type " + type); } catch (Exception e) { MpLog.Error($"Error writing type: {type}, obj: {obj}, {e}"); throw; } finally { log?.LogExit(); } }
public void Visit(ListType type) => _array = new ListArray(_data);
public BlackWhiteListEntry(string word, ListType list_type) { this.word = word; this.list_type = list_type; is_deleted = false; }
public UserListEventArgs(List<User> users, int teamNumber, ListType type) { UserList = users; Id = teamNumber; Type = type; }
public Filter(ListType ListType, int DepartmentId, int Days, int TechnicianId, int AccountId) { this.accountId = AccountId; this.days = Days; this.departmentId = DepartmentId; this.listType = ListType; this.technicianId = TechnicianId; }
public ListItemComparer(ListType compareType) { this.compareType = compareType; }
public BuildListVessel(ShipConstruct s, string ls, double effCost, double bP, string flagURL) { _ship = s; ShipNode = s.SaveShip(); // Override KSP sizing of the ship construct ShipSize = Utilities.GetShipSize(s, true); ShipNode.SetValue("size", KSPUtil.WriteVector(ShipSize)); ShipName = s.shipName; Cost = Utilities.GetTotalVesselCost(ShipNode, true); EmptyCost = Utilities.GetTotalVesselCost(ShipNode, false); TotalMass = Utilities.GetShipMass(s, true, out EmptyMass, out _); HashSet <int> stages = new HashSet <int>(); NumStageParts = 0; StagePartCost = 0d; foreach (Part p in s.Parts) { if (p.stagingOn) { stages.Add(p.inverseStage); ++NumStageParts; StagePartCost += p.GetModuleCosts(p.partInfo.cost, ModifierStagingSituation.CURRENT) + p.partInfo.cost; } } NumStages = stages.Count; LaunchSite = ls; EffectiveCost = effCost; BuildPoints = bP; Progress = 0; Flag = flagURL; if (s.shipFacility == EditorFacility.VAB) { Type = ListType.VAB; FacilityBuiltIn = EditorFacility.VAB; } else if (s.shipFacility == EditorFacility.SPH) { Type = ListType.SPH; FacilityBuiltIn = EditorFacility.SPH; } else { Type = ListType.None; } Id = Guid.NewGuid(); KCTPersistentID = Guid.NewGuid().ToString("N"); CannotEarnScience = false; //get the crew from the editorlogic DesiredManifest = new List <string>(); if (CrewAssignmentDialog.Instance?.GetManifest()?.CrewCount > 0) { foreach (ProtoCrewMember crew in CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List <ProtoCrewMember>()) { DesiredManifest.Add(crew?.name ?? string.Empty); } } if (EffectiveCost == default) { // Can only happen in older saves that didn't have Effective cost persisted as a separate field // This code should be safe to remove after a while. EffectiveCost = Utilities.GetEffectiveCost(ShipNode.GetNodes("PART").ToList()); } IntegrationPoints = MathParser.ParseIntegrationTimeFormula(this); IntegrationCost = (float)MathParser.ParseIntegrationCostFormula(this); }
// List public static ComponentBuilder <TConfig, Typography.List> List <TConfig, TComponent>(this BootstrapHelper <TConfig, TComponent> helper, ListType listType = ListType.Unstyled) where TConfig : BootstrapConfig where TComponent : Component, ICanCreate <Typography.List> { return(new ComponentBuilder <TConfig, Typography.List>(helper.Config, new Typography.List(helper, listType))); }
public override void ReorderItems(ListType listType, string[] titles) { _listItemCache.Clear(); base.ReorderItems(listType, titles); }
public override void DeleteItem(ListType listType, int itemID) { ResetCache(itemID); base.DeleteItem(listType, itemID); }
private static (string Left, string Right) ToBracket(ListType listType) => List2BracketMap.Find((ListTypeAndMap)(int)listType);
//utility cache method to get Player list from cache depending on type (ALL|LATEST) private async Task <IEnumerable <PlayerModel> > GetAllPlayersAsync(ListType listType = ListType.ALL_PLAYERS) { try { //get list of players in cache as it doesn't change regularly IEnumerable <PlayerModel> players = null; var listkey = listType == ListType.LATEST_PLAYERS ? "LatestPlayers" : "AllPlayers"; // get list key by listtype // await _cache.RemoveAsync(listkey); var playersString = await _cache.GetStringAsync(listkey); if (string.IsNullOrEmpty(playersString)) //if(no list in cache) { // get the endpoint key from AppSettings var endpointKey = listType == ListType.LATEST_PLAYERS ? "LatestPlayersUrl" : "AllPlayersUrl"; var client = new HttpClient(handler); client.Timeout = Timeout; //use interpolation to get the right Url var response = await client.GetAsync(_config.GetValue <string>($"Settings:{endpointKey}")); //endpoint should be configurable if (response.IsSuccessStatusCode) { var stringData = await response.Content.ReadAsStringAsync(); var dataResponse = JsonConvert.DeserializeObject <DataResponseModel>(stringData, settings); // combin all playrs to one list and check for nullable lists var AllplayersList = Enumerable.Empty <PlayerModel>(); if (dataResponse.Rushing != null) { AllplayersList = AllplayersList.Concat(dataResponse.Rushing); } if (dataResponse.Kicking != null) { AllplayersList = AllplayersList.Concat(dataResponse.Kicking); } if (dataResponse.Passing != null) { AllplayersList = AllplayersList.Concat(dataResponse.Passing); } if (dataResponse.Receiving != null) { AllplayersList = AllplayersList.Concat(dataResponse.Receiving); //ensure list is unique } players = AllplayersList.Distinct(new PlayerComparer()); int refreshDays = _config.GetValue <int>($"Settings:RefreshDays"); var options = new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(refreshDays), //invalidate cache in 7 days SlidingExpiration = TimeSpan.FromDays(1) //invalidate if no reqeust in 1 day }; //save list of players to cache; _ = _cache.SetStringAsync(listkey, JsonConvert.SerializeObject(players), options); } } else { players = JsonConvert.DeserializeObject <IEnumerable <PlayerModel> >(playersString, settings); } //return player list to caller return(players); } catch (Exception ex) { _logger.LogError(ex, nameof(DataProvider)); //log exception for futher investigation; return(null); } }
public ActionResult Create([FromBody] ListType listType) { var newListType = _listTypesApplication.Create(listType); return(Created("api/0_1/ListTypes?id=" + newListType.Id, newListType)); }
private static void StartDrag([NotNull] BusinessData data, FrameworkElement o, ListType listType) { // initialize the drag operation of a business data object if (o != null) { DataObject dao = new DataObject(); dao.SetData(typeof(BusinessData), data); dao.SetData(typeof(ListType), listType); DragDrop.DoDragDrop(o, dao, DragDropEffects.Link | DragDropEffects.Copy | DragDropEffects.Move); } }
public ActionResult Update([FromBody] ListType listType) { var changedList = _listTypesApplication.Update(listType); return(Ok(changedList)); }
public ListItemMgrStrategy(List cfg, ListBase listbase) { this.cfg = cfg; this.listbase = listbase; this.type = this.cfg.type; }
/// <summary> /// PEBakery uses 1-based index for concated list /// </summary> /// <param name="s"></param> /// <param name="cmd"></param> /// <returns></returns> public static List <LogInfo> List(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(); CodeInfo_List info = cmd.Info.Cast <CodeInfo_List>(); string listStr = string.Empty; string listVar = info.SubInfo.ListVar; if (Variables.ContainsKey(s, listVar) == true) { listStr = StringEscaper.Preprocess(s, listVar); } ListType type = info.Type; string delimiter = "|"; switch (type) { case ListType.Get: { ListInfo_Get subInfo = info.SubInfo.Cast <ListInfo_Get>(); string indexStr = StringEscaper.Preprocess(s, subInfo.Index); if (!NumberHelper.ParseInt32(indexStr, out int index)) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (index <= 0) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); string destStr = list[index - 1]; List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.DestVar, destStr); logs.AddRange(varLogs); } break; case ListType.Set: { ListInfo_Set subInfo = info.SubInfo.Cast <ListInfo_Set>(); string indexStr = StringEscaper.Preprocess(s, subInfo.Index); string item = StringEscaper.Preprocess(s, subInfo.Item); if (!NumberHelper.ParseInt32(indexStr, out int index)) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (index <= 0) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); list[index - 1] = item; listStr = StringEscaper.PackListStr(list, delimiter); List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.ListVar, listStr); logs.AddRange(varLogs); } break; case ListType.Append: { ListInfo_Append subInfo = info.SubInfo.Cast <ListInfo_Append>(); string item = StringEscaper.Preprocess(s, subInfo.Item); if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); list.Add(item); listStr = StringEscaper.PackListStr(list, delimiter); List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.ListVar, listStr); logs.AddRange(varLogs); } break; case ListType.Insert: { ListInfo_Insert subInfo = info.SubInfo.Cast <ListInfo_Insert>(); string indexStr = StringEscaper.Preprocess(s, subInfo.Index); string item = StringEscaper.Preprocess(s, subInfo.Item); if (!NumberHelper.ParseInt32(indexStr, out int index)) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (index <= 0) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); list.Insert(index - 1, item); listStr = StringEscaper.PackListStr(list, delimiter); List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.ListVar, listStr); logs.AddRange(varLogs); } break; case ListType.Remove: case ListType.RemoveX: { ListInfo_Remove subInfo = info.SubInfo.Cast <ListInfo_Remove>(); string item = StringEscaper.Preprocess(s, subInfo.Item); if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); StringComparison comp; switch (type) { case ListType.Remove: comp = StringComparison.OrdinalIgnoreCase; break; case ListType.RemoveX: comp = StringComparison.Ordinal; break; default: throw new InternalException("Internal Logic Error at CommandList"); } int deletedItemCount = list.RemoveAll(x => x.Equals(item, comp)); if (0 < deletedItemCount) { logs.Add(new LogInfo(LogState.Success, $"[{deletedItemCount}] items were deleted")); listStr = StringEscaper.PackListStr(list, delimiter); List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.ListVar, listStr); logs.AddRange(varLogs); } else { logs.Add(new LogInfo(LogState.Ignore, "No items were deleted")); } } break; case ListType.RemoveAt: { ListInfo_RemoveAt subInfo = info.SubInfo.Cast <ListInfo_RemoveAt>(); string indexStr = StringEscaper.Preprocess(s, subInfo.Index); if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } if (!NumberHelper.ParseInt32(indexStr, out int index)) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } if (index <= 0) { return(LogInfo.LogErrorMessage(logs, $"[{indexStr}] is not a valid positive integer")); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); list.RemoveAt(index - 1); listStr = StringEscaper.PackListStr(list, delimiter); List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.ListVar, listStr); logs.AddRange(varLogs); } break; case ListType.Count: { ListInfo_Count subInfo = info.SubInfo.Cast <ListInfo_Count>(); if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); int destInt = list.Count; List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.DestVar, destInt.ToString()); logs.AddRange(varLogs); } break; case ListType.Pos: case ListType.PosX: case ListType.LastPos: case ListType.LastPosX: { ListInfo_Pos subInfo = info.SubInfo.Cast <ListInfo_Pos>(); string item = StringEscaper.Preprocess(s, subInfo.Item); if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); int destInt; switch (type) { case ListType.Pos: destInt = list.FindIndex(x => x.Equals(item, StringComparison.OrdinalIgnoreCase)); break; case ListType.PosX: destInt = list.FindIndex(x => x.Equals(item, StringComparison.Ordinal)); break; case ListType.LastPos: destInt = list.FindLastIndex(x => x.Equals(item, StringComparison.OrdinalIgnoreCase)); break; case ListType.LastPosX: destInt = list.FindLastIndex(x => x.Equals(item, StringComparison.Ordinal)); break; default: throw new InternalException("Internal Logic Error at CommandList"); } destInt += 1; List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.DestVar, destInt.ToString()); logs.AddRange(varLogs); } break; case ListType.Sort: case ListType.SortX: case ListType.SortN: case ListType.SortNX: { ListInfo_Sort subInfo = info.SubInfo.Cast <ListInfo_Sort>(); string order = StringEscaper.Preprocess(s, subInfo.Order); if (subInfo.Delim != null) { delimiter = StringEscaper.Preprocess(s, subInfo.Delim); } bool reverse; if (order.Equals("ASC", StringComparison.OrdinalIgnoreCase)) { reverse = false; } else if (order.Equals("DESC", StringComparison.OrdinalIgnoreCase)) { reverse = true; } else { return(LogInfo.LogErrorMessage(logs, "Order must be [ASC] or [DESC]")); } List <string> list = StringEscaper.UnpackListStr(listStr, delimiter); switch (type) { case ListType.Sort: list = list .OrderBy(x => x, StringComparer.OrdinalIgnoreCase) .ThenBy(x => x, StringComparer.Ordinal) .ToList(); break; case ListType.SortX: list.Sort(StringComparer.Ordinal); break; case ListType.SortN: list = list .OrderBy(x => x, StringComparer.OrdinalIgnoreCase.WithNaturalSort()) .ThenBy(x => x, StringComparer.Ordinal.WithNaturalSort()) .ToList(); break; case ListType.SortNX: list.Sort(StringComparer.Ordinal.WithNaturalSort()); break; default: throw new InternalException("Internal Logic Error at CommandList"); } if (reverse) { list.Reverse(); } listStr = StringEscaper.PackListStr(list, delimiter); List <LogInfo> varLogs = Variables.SetVariable(s, subInfo.ListVar, listStr); logs.AddRange(varLogs); } break; default: // Error throw new InternalException("Internal Logic Error at CommandList"); } return(logs); }
public EntryTimer( BaseCreature entry, ListType type, TreeOfKnowledge owner ) : base( TimeSpan.FromMinutes( 5.0 ) ) { m_Entry = entry; m_ListType = type; m_Owner = owner; Priority = TimerPriority.TwoFiftyMS; }
public static List <FreeDocument> GetDataFromXPath(this HtmlDocument doc2, IList <CrawlItem> crawlItems, ListType type = ListType.List, string rootXPath = "") { if (crawlItems.Count == 0) { return(new List <FreeDocument>()); } var documents = new List <FreeDocument>(); switch (type) { case ListType.List: var root = ""; var takeoff = ""; if (string.IsNullOrEmpty(rootXPath)) { root = XPath.GetMaxCompareXPath(crawlItems.Select(d => new XPath(d.XPath)).ToList()).ToString(); takeoff = root; } else { root = rootXPath; } var nodes = doc2.DocumentNode.SelectNodes(root); if (nodes == null) { break; } foreach (var node in nodes) { var document = new FreeDocument(); foreach (var r in crawlItems) { string path; if (string.IsNullOrEmpty(takeoff)) { path = node.XPath + r.XPath; } else { path = node.XPath + new XPath(r.XPath).TakeOff(takeoff); } var result = node.GetDataFromXPath(path, r.IsHTML); document.SetValue(r.Name, result); } documents.Add(document); } return(documents); case ListType.One: var freeDocument = new FreeDocument(); foreach (var r in crawlItems) { doc2.GetDataFromXPath(r, freeDocument); } return(new List <FreeDocument> { freeDocument }); } return(new List <FreeDocument>()); }
public UserListEventArgs(string[] users, int teamNumber, ListType type) { Users = users; Id = teamNumber; Type = type; }
public static DataTable Select(ListType ListType, int DepartmentId, int Days) { return(Select(ListType, DepartmentId, Days, -1, -1)); }
public KCT_BuildListVessel(ShipConstruct s, String ls, double effCost, double bP, String flagURL) { ship = s; shipNode = s.SaveShip(); shipName = s.shipName; //Get total ship cost float fuel; cost = s.GetShipCosts(out emptyCost, out fuel); TotalMass = s.GetShipMass(true, out emptyMass, out fuel); HashSet <int> stages = new HashSet <int>(); numStageParts = 0; stagePartCost = 0d; //for (int i = s.Parts.Count - 1; i >= 0; i--) //{ // Part p = s.Parts[i]; foreach (Part p in s.Parts) { if (p.stagingOn) { stages.Add(p.inverseStage); ++numStageParts; stagePartCost += p.GetModuleCosts(p.partInfo.cost, ModifierStagingSituation.CURRENT) + p.partInfo.cost; } } numStages = stages.Count; launchSite = ls; effectiveCost = effCost; buildPoints = bP; progress = 0; flag = flagURL; if (s.shipFacility == EditorFacility.VAB) { type = ListType.VAB; } else if (s.shipFacility == EditorFacility.SPH) { type = ListType.SPH; } else { type = ListType.None; } id = Guid.NewGuid(); cannotEarnScience = false; //get the crew from the editorlogic DesiredManifest = new List <string>(); if (CrewAssignmentDialog.Instance?.GetManifest()?.CrewCount > 0) { //var pcm = CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List<ProtoCrewMember>(); //for (int i = pcm.Count - 1; i >= 0; i--) //{ // ProtoCrewMember crew = pcm[i]; foreach (ProtoCrewMember crew in CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List <ProtoCrewMember>()) { DesiredManifest.Add(crew?.name ?? string.Empty); } } if (effectiveCost == default(double)) { // Can only happen in older saves that didn't have Effective cost persisted as a separate field // This code should be safe to remove after a while. effectiveCost = KCT_Utilities.GetEffectiveCost(shipNode.GetNodes("PART").ToList()); } integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(this); integrationCost = (float)KCT_MathParsing.ParseIntegrationCostFormula(this); }
// Typography public static ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List> ListFor <TComponent, TModel, TValue>( this BootstrapHelper <MvcBootstrapConfig <TModel>, TComponent> helper, Expression <Func <TModel, IEnumerable <TValue> > > expression, Func <TValue, object> item, ListType listType = ListType.Unstyled) where TComponent : Component, ICanCreate <Typography.List> { ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List> builder = new ComponentBuilder <MvcBootstrapConfig <TModel>, Typography.List>(helper.GetConfig(), helper.List(listType).GetComponent()); IEnumerable <TValue> values = ModelMetadata.FromLambdaExpression(expression, builder.GetConfig().HtmlHelper.ViewData).Model as IEnumerable <TValue>; if (values != null) { foreach (TValue value in values) { builder.AddChild(x => x.ListItem(item(value))); } } return(builder); }
/// <summary> /// 日志列表:存档、标签、分类 /// </summary> public static string BlogList(this SiteUrls siteUrls, string spaceKey, ListType listType, string tag = null, int year = 0, int month = 0, long categoryId = 0) { RouteValueDictionary routeValueDictionary = new RouteValueDictionary(); routeValueDictionary.Add("spaceKey", spaceKey); routeValueDictionary.Add("listType", listType); switch (listType) { case ListType.Tag: routeValueDictionary.Add("tag", WebUtility.UrlEncode(tag)); break; case ListType.Archive: routeValueDictionary.Add("year", year); if (month > 0) { routeValueDictionary.Add("month", month); } break; case ListType.Category: routeValueDictionary.Add("categoryId", categoryId); break; default: break; } return CachedUrlHelper.Action("List", "Blog", BlogAreaName, routeValueDictionary); }
public KCT_BuildListVessel(Vessel vessel, KCT_BuildListVessel.ListType listType = ListType.None) //For recovered vessels { id = Guid.NewGuid(); shipName = vessel.vesselName; shipNode = FromInFlightVessel(vessel, listType); if (listType != ListType.None) { this.type = listType; } cost = KCT_Utilities.GetTotalVesselCost(shipNode); emptyCost = KCT_Utilities.GetTotalVesselCost(shipNode, false); TotalMass = 0; emptyMass = 0; HashSet <int> stages = new HashSet <int>(); //for (int i = vessel.protoVessel.protoPartSnapshots.Count - 1; i >= 0; i--) //{ // ProtoPartSnapshot p = vessel.protoVessel.protoPartSnapshots[i]; foreach (ProtoPartSnapshot p in vessel.protoVessel.protoPartSnapshots) { stages.Add(p.inverseStageIndex); if (p.partPrefab != null && p.partPrefab.Modules.Contains <LaunchClamp>()) { continue; } TotalMass += p.mass; emptyMass += p.mass; //for (int i1 = p.resources.Count - 1; i1 >= 0; i1--) //{ // ProtoPartResourceSnapshot rsc = p.resources[i1]; foreach (ProtoPartResourceSnapshot rsc in p.resources) { PartResourceDefinition def = PartResourceLibrary.Instance.GetDefinition(rsc.resourceName); if (def != null) { TotalMass += def.density * (float)rsc.amount; } } } cannotEarnScience = true; numStages = stages.Count; // FIXME ignore stageable part count and cost - it'll be fixed when we put this back in the editor. effectiveCost = KCT_Utilities.GetEffectiveCost(shipNode.GetNodes("PART").ToList()); buildPoints = KCT_Utilities.GetBuildTime(effectiveCost); flag = HighLogic.CurrentGame.flagURL; DistanceFromKSC = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude)); rushBuildClicks = 0; integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(this); integrationCost = (float)KCT_MathParsing.ParseIntegrationCostFormula(this); progress = buildPoints + integrationPoints; }
public static DataTable Select(ListType ListType, int DepartmentId, int Days) { return Select(ListType, DepartmentId, Days, -1, -1); }
public ListItem GetByTitle(ListType listType, string title) { var result = Db.ExecuteList(GetListItemSqlQuery(Exp.Eq("title", title) & Exp.Eq("list_type", (int)listType))).ConvertAll(ToListItem); return(result.Count > 0 ? result[0] : null); }
/// <summary> /// 文章列表 /// </summary> public ActionResult List(string spaceKey, ListType listType, string tag = null, int year = 0, int month = 0, long categoryId = 0, int pageIndex = 1) { PagingDataSet<BlogThread> blogs = null; IUser currentUser = UserContext.CurrentUser; string title = string.Empty; switch (listType) { case ListType.Archive: ArchivePeriod archivePeriod = ArchivePeriod.Year; if (month > 0) { archivePeriod = ArchivePeriod.Month; } ArchiveItem archiveItem = new ArchiveItem(); archiveItem.Year = year; archiveItem.Month = month; if (currentUser != null && currentUser.UserName == spaceKey) { blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, archivePeriod, archiveItem, 20, pageIndex); } else { blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, archivePeriod, archiveItem, 20, pageIndex); } title = "归档:" + year + "年"; if (month > 0) { title += month + "月"; } break; case ListType.Category: if (currentUser != null && currentUser.UserName == spaceKey) { blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, categoryId, null, false, 20, pageIndex); } else { blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, categoryId, null, false, 20, pageIndex); } Category category = categoryService.Get(categoryId); title = "分类:" + category.CategoryName; break; case ListType.Tag: if (currentUser != null && currentUser.UserName == spaceKey) { blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, null, tag, false, 20, pageIndex); } else { blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, null, tag, false, 20, pageIndex); } title = "标签:" + tag; break; default: break; } ViewData["title"] = title; pageResourceManager.InsertTitlePart(title); return View(blogs); }
public override void EditItem(ListType listType, ListItem enumItem) { ResetCache(enumItem.ID); base.EditItem(listType, enumItem); }