public Resource(JObject json) { Annotations = new Dictionary <string, string>(); RawJson = json; FullId = json.SelectToken("id").ToString(); // Parse FullID into Account, Kind and Id string[] parts = FullId.Split(":", 3); Account = parts[0]; // Convert kind string into enum Kind = (ResourceKind)Enum.Parse(typeof(ResourceKind), parts[1]); Id = parts[2]; // Parse Annotations into Dictionary JArray annotations = RawJson.SelectToken("annotations").ToObject <JArray>(); foreach (JObject a in annotations) { IList <string> keys = a.Properties().Select(p => p.Name).ToList(); foreach (string key in keys) { string value = a.GetValue(key).ToString(); Annotations.Add(key, value); } } }
private void BindValues() { string[] parts = FullId.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); string path = "Navigation/Tabs"; if (parts.Length > 0) { path += String.Format(CultureInfo.InvariantCulture, "/Tab[@id='{0}']", parts[0]); } for (int i = 1; i < parts.Length; i++) { path += String.Format(CultureInfo.InvariantCulture, "/Link[@id='{0}']", parts[i]); } string profileString = ProfileId.HasValue ? ProfileId.Value.ToString() : String.Empty; string principalString = PrincipalId.HasValue ? PrincipalId.Value.ToString() : String.Empty; if (PrincipalId.HasValue) { profileString = ProfileManager.GetProfileIdByUser(PrincipalId.Value).ToString(); } Mediachase.Ibn.XmlTools.Selector selector = new Mediachase.Ibn.XmlTools.Selector(string.Empty, string.Empty, string.Empty, profileString, principalString); IXPathNavigable navigable = Mediachase.Ibn.XmlTools.XmlBuilder.GetCustomizationXml(null, Mediachase.Ibn.XmlTools.StructureType.Navigation, selector); XPathNavigator node = navigable.CreateNavigator().SelectSingleNode(path); if (node != null) { ctrlTitleText.Text = node.GetAttribute("text", string.Empty); ItemOrder.Text = node.GetAttribute("order", string.Empty); SavedText = ctrlTitleText.Text; SavedOrder = int.Parse(ItemOrder.Text); } }