private Entry ParseEntry(Dictionary<string, object> entry) { var ret = new Entry(); foreach (var property in entry) { if (property.Key == "__metadata") { var metadata = (Dictionary<string, object>)property.Value; if (metadata.ContainsKey("id")) { ret.Id = metadata["id"].ToString(); } } else { var dic = property.Value as Dictionary<string, object>; if (dic != null && dic.ContainsKey("__deferred")) { ret.Links.Add(this.ParseLink(property)); } else { ret.Add(this.ParseProperty(property)); } } } return ret; }
public int AddEntry(string name, byte[] bytes, bool overWrite, int expectedSize = -1) { if (expectedSize != -1 && Entry.Count != expectedSize) { throw new Exception(String.Format("The EEPK container and EMB are out of sync. Cannot add the entry.")); } //Check if entry exists for (int i = 0; i < Entry.Count; i++) { if (Entry[i].Name == name) { if (overWrite) { Entry[i].Data = bytes.ToList(); } return(i); } } //Add it int newIdx = Entry.Count; Entry.Add(new EmbEntry() { Index = newIdx.ToString(), Name = name, Data = bytes.ToList() }); return(newIdx); }
/// <summary> /// Add embEntry if new. If a similar one already exists then that will be returned. /// </summary> /// <returns></returns> public EmbEntry Add(EmbEntry embEntry, List <IUndoRedo> undos = null) { foreach (var entry in Entry) { if (entry == embEntry) { return(entry); } if (entry.Compare(embEntry)) { return(entry); } } //Check entry size if (Entry.Count >= MAX_EFFECT_TEXTURES) { throw new Exception(String.Format("EMB_File.Add: Texture limit has been reached. Cannot add any more.")); } if (undos != null) { undos.Add(new UndoableListAdd <EmbEntry>(Entry, embEntry)); } Entry.Add(embEntry); return(embEntry); }
public MainViewModel() { FileHandler readFile = new FileHandler(); BtnAddClick = new RelayCommand(AddPerson, () => { if (Lastname.Length > 2) { return(true); } else { return(false); } }); BtnLoadClick = new RelayCommand(LoadData, CanExecuteLoadData); BtnSaveClick = new RelayCommand(SaveData, () => { if (Entry.Count > 0) { return(true); } else { return(false); } }); FetchData = new RelayCommand(AddPerson); Entry.Add(new PersonViewModel(1234, "Böck", "Sascha", new DateTime(1990, 04, 29))); Entry.Add(new PersonViewModel(5678, "Maier", "Hermann", new DateTime(1997, 12, 12))); Entry.Add(new PersonViewModel(1897, "Stark", "Ned", new DateTime(1980, 02, 01))); }
/// <summary> /// Add embEntry if new. If a similar one already exists then that will be returned. /// </summary> /// <returns></returns> public EmbEntry Add(EmbEntry embEntry) { foreach (var entry in Entry) { if (entry == embEntry) { return(entry); } if (entry.Compare(embEntry)) { return(entry); } } //Check entry size if (Entry.Count >= MAX_EFFECT_TEXTURES) { throw new Exception(String.Format("EMB_File.Add: Texture limit has been reached. Cannot add any more.")); } Entry.Add(embEntry); return(embEntry); }
private void Composite_Click(object sender, RoutedEventArgs e) { // preparing composite code //vm.CompositeTextProperty = "test composite!"; Entry item; var button = sender as Button; if (button.Name == "composite1") { item = new Directory("bin" + count++); } else if (button.Name == "composite2") { item = new Directory("tmp" + count++); } else { item = new File("vi" + count, 1000); } rootdir.Add(item); rootdir.PrintList(); }
public void RemoveEntry(string _idx, EmbEntry original = null) { int idx = int.Parse(_idx); if (idx == Entry.Count - 1) { //Last entry, so just remove it Entry.RemoveAt(idx); if (original != null) { Entry.Add(original); } } else if (idx < Entry.Count - 1 && idx >= 0) { //Replace entry with an empty entry if (original != null) { Entry[idx] = original; } else { Entry[idx] = EmbEntry.Empty(idx); } } }
public static void ElitePacks() { if (AlreadyExists(ApplicationType.ElitePacks)) { return; } List <IDesignHelper.IMenu> Entries = new List <IDesignHelper.IMenu>(); DropdownEntries.Add(ApplicationType.ElitePacks, Config.Get <FKAffixes>().Affixes.OrderBy(x => x.Name)); Entries.Add(new IDesignHelper.IMenu { Name = "Settings", Image = "pack://application:,,,./Images/FK/Icons/SettingActive.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/SettingActive.png".ToImage(), isActive = true, Data = { }, Target = (() => { LoadPage <Application.ElitePacks.GeneralSettings>(); }) }); Entries.Add(new IDesignHelper.IMenu { Name = "Minimap Options", Image = "pack://application:,,,./Images/FK/Icons/minimap.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/minimap.png".ToImage(), isActive = false, isLast = true, Data = { }, Target = (() => LoadPage <Application.ElitePacks.SetAffixes>(ApplicationType.None, true)) }); Entry.Add(ApplicationType.ElitePacks, Entries); }
private void AddPerson() { Entry.Add(new PersonViewModel(SocialSecurityNumber, Lastname, Firstname, Birthdate)); Firstname = ""; Lastname = ""; SocialSecurityNumber = 0; Birthdate = DateTime.Today; }
public void Save() { foreach (var field in _addedFields .Where(x => !string.IsNullOrEmpty(x.Name))) { _entry.Add(field); } }
public override void GET() { //Get required fields List <User> Users = new List <User>(); if (Params.ContainsKey("email")) { //Get all user objects foreach (string Email in Params["email"]) { if (Email == "CurrentUser") { Users.Add(RequestUser); continue; } if (RequestUserLevel < PermLevel.Manager) { Response.Send(HttpStatusCode.Forbidden); return; } User Acc = User.GetUserByEmail(Connection, Email); if (Acc != null) { Users.Add(Acc); } } //If email is missing, assume all users } else { if (RequestUserLevel < PermLevel.Manager) { Response.Send(HttpStatusCode.Forbidden); return; } Users = User.GetAllUsers(Connection); } //Convert to JSON and add permissionlevels List <Department> Departments = Department.GetAllDepartments(Connection); JArray JSON = JArray.FromObject(Users); foreach (JObject Entry in JSON) { Entry.Remove("PasswordHash"); //Security JObject PermissionInfo = new JObject(); foreach (Department Dept in Departments) { PermissionInfo.Add(Dept.Name, User.GetPermissionLevel(Connection, (int)Entry["ID"], Dept.ID).ToString()); } Entry.Add("Permissions", PermissionInfo); } //Send response Response.Send(JSON); }
public Neuron(Layer entryNeurons) : this() { for (int i = 0; i < entryNeurons.Neurons.Count; i++) { var synapse = new Synapse(entryNeurons.Neurons[i], this); entryNeurons.Neurons[i].Exit.Add(synapse); Entry.Add(synapse); } }
public Neuron(IEnumerable <Neuron> entryNeuron) : this() { foreach (var x in entryNeuron) { var synapse = new Synapse(x, this); x.Exit.Add(synapse); Entry.Add(synapse); } }
public Bundle AddResourceEntry(Resource r) { Entry.Add(new BundleEntryComponent() { Resource = r }); return(this); }
public void Add(Entry newEntry) { Next ??= newEntry; if (Next != newEntry) { Next.Add(newEntry); } }
private void LoadData() { String[] rawInput = File.ReadAllLines(readPath); Entry.Clear(); foreach (var item in rawInput) { var fields = item.Split(';'); Entry.Add(new PersonViewModel(Convert.ToInt32(fields[0]), fields[1], fields[2], Convert.ToDateTime(fields[3]))); } }
public Entry CreateEntry(Manifest.BundleInfo bundle) { Entry entry = new Entry(bundle); foreach (var assetPath in bundle.assets) { entry.Add(assetPath); } _entries.Add(bundle.name, entry); return(entry); }
public static void Overlay() { if (AlreadyExists(ApplicationType.Overlay)) { return; } List <IDesignHelper.IMenu> Entries = new List <IDesignHelper.IMenu>(); Entries.Add(new IDesignHelper.IMenu { Name = "Minimap Settings", Image = "pack://application:,,,./Images/FK/Icons/intersect.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/intersect.png".ToImage(), isFirst = true, isActive = true, Data = Config.Get <FKConfig>().General.MiniMapSettings, Target = (() => LoadPage <Application.Overlay.OverlaySettings>(ApplicationType.Overlay)) }); Entries.Add(new IDesignHelper.IMenu { Name = "Skillbar Settings", Image = "pack://application:,,,./Images/FK/Icons/flags.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/flags.png".ToImage(), Data = Config.Get <FKConfig>().General.Skills, Target = (() => LoadPage <Application.Overlay.Skillbar>(ApplicationType.Overlay)) }); Entries.Add(new IDesignHelper.IMenu { Name = "Experiencebar Settings", Image = "pack://application:,,,./Images/FK/Icons/pins.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/pins.png".ToImage(), Data = Config.Get <FKConfig>().General.Experience, Target = (() => LoadPage <Application.Overlay.ExperienceBar>(ApplicationType.Overlay)) }); Entries.Add(new IDesignHelper.IMenu { Name = "Misc Settings", Image = "pack://application:,,,./Images/FK/Icons/droplets.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/droplets.png".ToImage(), isLast = true, Data = Config.Get <FKConfig>().General.Misc, Target = (() => LoadPage <Application.Overlay.MiscBar>(ApplicationType.Overlay)) }); Entry.Add(ApplicationType.Overlay, Entries); }
public int AddEntry(EmbEntry embEntry, string _idx, InstallMode _installMode) { int idx = int.Parse(_idx); if (_installMode == InstallMode.MatchIndex) { if (idx <= (Entry.Count - 1)) { Entry[idx] = embEntry; return(idx); } else { //Add empty entries until idx is reached while ((Entry.Count - 1) < (idx - 1)) { Entry.Add(new EmbEntry() { Name = "dummy_" + (Entry.Count - 1).ToString(), Data = new List <byte>() }); } Entry.Add(embEntry); return(Entry.Count - 1); } } else if (_installMode == InstallMode.MatchName) { for (int i = 0; i < Entry.Count; i++) { if (Entry[i].Name == embEntry.Name) { Entry[i] = embEntry; return(i); } } Entry.Add(embEntry); return(Entry.Count - 1); } return(-1); }
public override void Deactivation() { base.Deactivation(); foreach (RouteEntry Entry in EntryAdded.Values) { Entry.Remove(); } foreach (RouteEntry Entry in EntryRemoved.Values) { Entry.Add(); Engine.Instance.Logs.Log(LogType.Verbose, MessagesFormatter.Format(Messages.NetworkLockRouteRestored, Entry.ToString())); } DefaultGateway = ""; DefaultInterface = ""; EntryAdded.Clear(); EntryRemoved.Clear(); }
private Entry ParseEntry(Dictionary<string, object> entry) { var ret = new Entry(); foreach (var property in entry) { if (property.Key == "odata.metadata") { continue; } if (property.Value != null && property.Value.GetType() == typeof(Dictionary<string, object>)) { ret.Links.Add(this.ParseLink(property)); } else { ret.Add(this.ParseProperty(property)); } } return ret; }
//public public static void MinimapNPC() { if (AlreadyExists(ApplicationType.MinimapNPC)) { return; } List <IDesignHelper.IMenu> Entries = new List <IDesignHelper.IMenu>(); DropdownEntries.Add(ApplicationType.MinimapNPC, Config.Get <FKMinimap>().DefaultMapItem.CustomActors.Select(x => x.Value) .Concat(Config.Get <FKMinimap>().DefaultMapItem.DefaultActors.Select(x => x.Value).OrderBy(x => x.Name)) ); Entries.Add(new IDesignHelper.IMenu { Name = "Settings", Image = "pack://application:,,,./Images/FK/Icons/SettingActive.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/SettingActive.png".ToImage(), isActive = true, Data = { }, Target = (() => { LoadPage <Application.NPC.Settings>(); }) }); Entries.Add(new IDesignHelper.IMenu { Name = "Minimap Options", Image = "pack://application:,,,./Images/FK/Icons/minimap.png".ToImage(), ImageHover = "pack://application:,,,./Images/FK/Icons/minimap.png".ToImage(), isActive = false, isLast = true, Data = { }, Target = (() => LoadPage <Application.NPC.MinimapItem>(ApplicationType.None, true)) }); Entry.Add(ApplicationType.MinimapNPC, Entries); }
private void Save() { progBusy.IsBusy = true; string errorMessage = string.Empty; string groupId; if (!NavigationContext.QueryString .TryGetValue("group", out groupId)) { groupId = null; } if (IsReservedName()) { errorMessage = Strings.EntryDetails_NameReserved; } var duplicate = GetAnyDuplicateField(); if (duplicate != null) { errorMessage = string.Format(Strings.EntryDetails_NameDuplicate, duplicate.Name); } if (!string.IsNullOrEmpty(errorMessage)) { MessageBox.Show(errorMessage, "Warning", MessageBoxButton.OK); progBusy.IsBusy = false; return; } ThreadPool.QueueUserWorkItem(_ => { var info = Cache.DbInfo; var database = Cache.Database; var writer = new DatabaseWriter(); info.OpenDatabaseFile(x => writer .LoadExisting(x, info.Data.MasterKey)); foreach (var fild in _fields) { _entry.Add(new Field() { Name = fild.Name, Value = fild.Value, Protected = fild.Protected }); } if (_entry.ID != null) { _binding.Save(); writer.Details(_entry); } else { database.AddNew( _entry, groupId); writer.New(_entry); } info.SetDatabase(x => writer.CreateRecycleBin( x, database.RecycleBin)); Dispatcher.BeginInvoke(() => { UpdateNotes(); progBusy.IsBusy = false; _binding.HasChanges = false; if (!info.NotifyIfNotSyncable()) { new ToastPrompt { Title = Properties.Resources.SavedTitle, Message = Properties.Resources.SavedCaption, TextOrientation = System.Windows.Controls .Orientation.Vertical, }.Show(); } }); ThreadPool.QueueUserWorkItem( __ => Cache.AddRecent(_entry.ID)); }); }
public bool Add(ScopedNavigator candidate) { return(Entry.Add(candidate)); }
public bool Add(IElementNavigator candidate) { return(Entry.Add(candidate)); }
public bool Add(ITypedElement candidate) { return(Entry.Add(candidate)); }
public void Add(TKey key, TValue value) { Entry entry = this[key]; entry.Add(value); }
/// <summary> /// Returns an <see cref="IRaiseChanged"/> created for the specified target observable type. /// </summary> /// <param name="target">The type of the target observable.</param> /// <returns>The <see cref="IRaiseChanged"/> for the <paramref name="target"/>.</returns> private static IRaiseChanged Create(Type target) { string indexerName = null; Dictionary <string, Entry> dictionary = new Dictionary <string, Entry>(); PropertyInfo[] array = target.GetProperties(BindingFlags.Public | BindingFlags.Instance); for (int i = 0; i < array.Length; i++) { Entry current = null; PropertyInfo property = array[i]; string propertyName = property.Name; object[] attributes = property.GetCustomAttributes(false); for (int j = 0; j < attributes.Length; j++) { if (attributes[j] is DependsOnAttribute attribute) { IEnumerable <string> properties = attribute.Properties; if (properties != null) { foreach (string otherName in properties) { if (string.IsNullOrEmpty(otherName) || otherName == propertyName) { continue; } if (current == null) { current = Entry.Get(propertyName, dictionary); } Entry entry = Entry.Get(otherName, dictionary); if (entry.Contains(current)) { continue; } entry.Add(current); } } } } if (indexerName == null && property.GetIndexParameters().Length > 0) { indexerName = propertyName; } } if (dictionary.Count > 0) { MappedNotifyChanged mapped = CreateMapped(indexerName); foreach (Entry entry in dictionary.Values) { string[] properties = entry.Resolve(); if (properties != null) { mapped.Add(entry.Name, properties); } } return(mapped); } if (indexerName == null) { return(NotifyChanged.Instance); } if (indexerName == IndexerName) { return(IndexerNotifyChanged.Default); } return(new IndexerNotifyChanged(indexerName)); }
void GridEntriesRowValidated(object sender, DataGridViewCellEventArgs e) { if (rowEdited == -1 || e.RowIndex >= entries.Count) { return; } Entry entry = entries[e.RowIndex]; bool isNewEntry = entry.Id == 0; List <WordType> wordTypeSettings = new List <WordType>(); List <Grade> resetGrades = new List <Grade>(); foreach (DataGridViewColumn column in gridEntries.Columns) { if (!temp.ContainsKey(column.Name)) { continue; } IColumn c = column.Tag as IColumn; Language language = c?.Language ?? (Language)column.Tag; Word word = words[entry, language]; if (word == null) { word = entry.Add(language); words.Add(word); } if (c == null) { if (word.Writing != temp[column.Name]) { Grade grade = words.Grade(word); if (grade != null) { resetGrades.Add(grade); } SetSpellCheck(word, SpellCheck.None); } word.Writing = temp[column.Name]; } else { switch (c.Prefix) { case "WT": WordType wordType = types.SingleOrDefault(x => x.Name == temp[column.Name].Trim()); wordTypeSettings.AddRange(new WordType[] { word.WordType, wordType }); word.WordType = wordType; break; case "PW": word.Pronunciation = temp[column.Name]; break; case "SP": word.Sample = temp[column.Name]; break; case "CW": word.Note = temp[column.Name]; break; case "MW": word.Meaning = temp[column.Name]; break; } } } using (ISession session = DataHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { bool needRefresh = false; if (entry.IsNew) { session.SaveOrUpdate(entry); } wordTypeSettings.Add(filter.WordType); foreach (Word word in words.From(entry).Where(x => !string.IsNullOrWhiteSpace(x.Writing))) { if (filter.WordType != null && word.WordType == null && word.Id == 0) { wordTypeSettings.Add(word.WordType); word.WordType = filter.WordType; needRefresh = true; } session.SaveOrUpdate(word); } foreach (Grade grade in resetGrades) { grade.Current = 0; session.SaveOrUpdate(grade); } transaction.Commit(); if (isNewEntry) { DoLessonContentModified(new Lesson[] { entry.Lesson }); } DoWordTypeContentModified(wordTypeSettings); DoGradeContentModified(resetGrades); foreach (Word word in words[entry]) { CheckSpellWord(word); } if (needRefresh) { gridEntries.Refresh(); } } catch (ADOException ex) { transaction.Rollback(); Trace.TraceError(ErrorHelper.Message(ex)); ErrorHelper.ShowDbError(this, ex); gridEntries.Refresh(); } } } temp.Clear(); rowEdited = -1; }
private static Entry ParseEntry(XElement entry) { var ret = new Entry(); IEnumerable<XElement> columns; ret.Links.AddRange(entry.Elements(AtomNS + "link").Select(ParseLink)); if (entry.Element(AtomNS + "content").HasElements) { columns = entry.Element(AtomNS + "content") .Element(MetadataNS + "properties") .Elements(); } else { // sometimes, the OData service may not put the properties element into the content element columns = entry.Element(MetadataNS + "properties") .Elements(); } ret.Id = entry.Elements(AtomNS + "id").FirstOrDefault().Value; foreach (XElement property in columns) { ret.Add(ParseProperty(property)); } return ret; }