public static OwaStoreObjectId CreateFromStoreObject(StoreObject storeObject) { if (storeObject == null) { throw new ArgumentNullException("storeObject"); } if (storeObject.Id == null) { throw new ArgumentException("storeObject.Id must not be null"); } OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject; string legacyDN = null; if (Utilities.IsOtherMailbox(storeObject)) { owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject; legacyDN = Utilities.GetMailboxSessionLegacyDN(storeObject); } else if (Utilities.IsInArchiveMailbox(storeObject)) { owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject; legacyDN = Utilities.GetMailboxSessionLegacyDN(storeObject); } if (storeObject is Item) { if (Utilities.IsPublic(storeObject)) { owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem; } return(OwaStoreObjectId.CreateFromItemId(storeObject.Id.ObjectId, (owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject) ? null : storeObject.ParentId, owaStoreObjectIdType, legacyDN)); } if (storeObject is Folder) { if (Utilities.IsPublic(storeObject)) { owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder; } return(OwaStoreObjectId.CreateFromFolderId(storeObject.Id.ObjectId, owaStoreObjectIdType, legacyDN)); } string message = string.Format(CultureInfo.InvariantCulture, "OwaStoreObjectId.CreateOwaStoreObjectId(StoreObject) only support item or folder as input, but the input is an {0}", new object[] { storeObject.GetType().ToString() }); throw new ArgumentOutOfRangeException("storeObject", message); }
// Generates the input fields, depending to the selected category private void GenerateInputFields(StoreObject obj) { PropertyContents.Clear(); this.window.AddTabChildStack.Children.RemoveRange(1, this.window.AddTabChildStack.Children.Count - 1); var list = obj.GetType().GetProperties(); this.window.AddButton.IsEnabled = true; foreach (var item in list) { this.window.AddTabChildStack.Children.Add(new Label { Content = item.Name + ":" }); if (item.PropertyType.Name == "Branch") { TextBox box = new TextBox { Text = this.window.productCategories.SelectedItem.ToString(), Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(box); PropertyContents.Add(box); } else if (item.PropertyType.Name == "Color") { var colors = new List <string>(); foreach (var color in Enum.GetValues(typeof(WarehouseSystem.Enumerations.Color))) { colors.Add(color.ToString()); } ComboBox comboBox = new ComboBox { ItemsSource = colors, Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(comboBox); PropertyContents.Add(comboBox); } else if (item.PropertyType.Name == "Material") { var materials = new List <string>(); foreach (var material in Enum.GetValues(typeof(Material))) { materials.Add(material.ToString()); } ComboBox comboBox = new ComboBox { ItemsSource = materials, Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(comboBox); PropertyContents.Add(comboBox); } else { TextBox box = new TextBox { MaxLength = 20, Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(box); PropertyContents.Add(box); } } }