예제 #1
0
        public virtual LinkCollection GetLinkListBySourceId(Int32 sourceId ,LinkColumns orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                Database database = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = database.GetStoredProcCommand("spLinkGetListBySource");

                database.AddInParameter(dbCommand, "@SourceId", DbType.Int32, sourceId);
                database.AddInParameter(dbCommand, "@OrderBy", DbType.AnsiString, orderBy.ToString());
                database.AddInParameter(dbCommand, "@OrderDirection", DbType.AnsiString, orderDirection.ToString());
                database.AddInParameter(dbCommand, "@Page", DbType.Int32, page);
                database.AddInParameter(dbCommand, "@PageSize", DbType.Int32, pageSize);
                database.AddOutParameter(dbCommand, "@TotalRecords", DbType.Int32, 4);

                LinkCollection linkCollection = new LinkCollection();
                using (IDataReader reader = database.ExecuteReader(dbCommand))
                {
                    while (reader.Read())
                    {
                        Link link = CreateLinkFromReader(reader);
                        linkCollection.Add(link);
                    }
                    reader.Close();
                }
                totalRecords = (int)database.GetParameterValue(dbCommand, "@TotalRecords");
                return linkCollection;
            }
            catch (Exception ex)
            {
                // log this exception
                log4net.Util.LogLog.Error(ex.Message, ex);
                // wrap it and rethrow
                throw new ApplicationException(SR.DataAccessGetLinkListException, ex);
            }
        }
예제 #2
0
 public LinkSettings()
 {
     Links = new LinkCollection();
     Links.Add(new Link());
     Links[0].ImageUrlSrc = UrlUtil.JoinUrl(Globals.GetRelativeUrl(SystemDirecotry.Assets_LinkIcon), "bbsmax.gif");
     Links[0].Name = "bbsMax";
     Links[0].Url = "http://www.bbsmax.com";
     Links[0].Index = 0;
     Links[0].ID = 1;
     MaxID = 100;
 }
예제 #3
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     var hrefs = serializer.Deserialize<Dictionary<string, string>>(reader);
     if (hrefs == null) return existingValue;
     var result = new LinkCollection();
     foreach (var href in hrefs)
     {
         result.Add(href.Key, new Link(href.Value));
     }
     return result;
 }
        public void changeLinks(List<Order> orders)
        {
            _links = new LinkCollection();

            foreach (var order in orders)
            {
                _links.Add(new Link() { DisplayName = "Order " + order.Id, Source = new Uri("StorageManager/Views/OrderProductsDetailsControl.xaml#" + order.Id, UriKind.Relative) });
            }

            tabOrders.Links = _links;
        }
예제 #5
0
파일: LinkTests.cs 프로젝트: bubbafat/Hebo
        public void LinkCollectionOperationalTests()
        {
            LinkCollection c = new LinkCollection();
            Link link1 = new Link();

            c.Add(new Link());
            c.Add(link1);
            c.Add(new Link());

            Assert.AreEqual(3, c.Count);

            Assert.IsTrue(c.Contains(link1));
            c.Remove(link1);
            Assert.IsFalse(c.Contains(link1));

            Assert.AreEqual(2, c.Count);

            Link[] linkarray = new Link[2];
            c.CopyTo(linkarray, 0);

            c.Clear();
            Assert.AreEqual(0, c.Count);

            c = new LinkCollection(linkarray);
            Assert.AreEqual(2, c.Count);

            Assert.IsFalse(c.IsReadOnly);

            foreach (Link link in c)
            {
                Assert.IsNotNull(link);
            }

            c[0] = link1;

            Assert.AreSame(link1, c[0]);
        }
        public void LinkCollectionTestInsertRetry()
        {
            var data = new AssetData { };

            var fakeException = new WebException("test", WebExceptionStatus.ConnectionClosed);

            var dataContextMock = TestMediaServicesClassFactory.CreateSaveChangesMock(fakeException, 2, data);
            _mediaContext.MediaServicesClassFactory = new TestMediaServicesClassFactory(dataContextMock.Object);

            data.SetMediaContext(_mediaContext);

            var target = new LinkCollection<IAsset, AssetData>(dataContextMock.Object, data, "", new IAsset[] { });

            target.Add(data);

            dataContextMock.Verify((ctxt) => ctxt.SaveChanges(), Times.Exactly(2));
        }
예제 #7
0
        /// <summary>
        /// Gets a collection of mod categories
        /// </summary>
        /// <returns></returns>
        public async Task<LinkCollection> GetCategories()
        {

            var webClient = new HttpClient();
            var result = await webClient.GetStringAsync("http://api.factoriomods.com/categories");
            var categories = JsonConvert.DeserializeObject<Category[]>(result);

            var lCollection = new LinkCollection(from c in categories
                select new Link
                {
                    DisplayName = c.Title,
                    Source = new Uri($"http://api.factoriomods.com/mods?category={c.Name}")
                });
            lCollection.Add(new Link
            {
                DisplayName = "All",
                Source = new Uri("http://api.factoriomods.com/mods")
            });
            var orderedCollection = lCollection.OrderBy(x => x.DisplayName).ToList();
            return new LinkCollection(from n in orderedCollection select n);
        }
예제 #8
0
        public static void ConvertLinks()
        {

            string sql = @"

IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'bbsMax_Links') BEGIN
    SELECT * FROM bbsMax_Links;
END
ELSE
    SELECT -9999 AS LinkID;
";
            LinkSettings linkSetting = new LinkSettings();
            LinkCollection links = new LinkCollection();

            using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(sql, connection);
                command.CommandTimeout = 60;
                try
                {
                    bool hasCreateErrorLog = false;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int linkID = reader.GetInt32(reader.GetOrdinal("LinkID"));

                            if (linkID == -9999)
                                return;

                            Link link = new Link();
                            link.ID = linkID;
                            link.Name = reader.GetString(reader.GetOrdinal("LinkName"));
                            link.Description = reader.GetString(reader.GetOrdinal("LinkDescription"));
                            link.Url = reader.GetString(reader.GetOrdinal("Url"));


                            string imgUrl = reader.GetString(reader.GetOrdinal("LogoUrl")).Replace("\\", "/").Trim();

                            if (imgUrl.StartsWith("http://"))
                                link.ImageUrlSrc = imgUrl;
                            else
                            {
                                int i = imgUrl.LastIndexOf("/") + 1;

                                string iconName = string.Empty;
                                if (imgUrl.Length > i)
                                {
                                    iconName = imgUrl.Substring(i, imgUrl.Length - i);


                                    string targetDir = MaxLabs.bbsMax.UrlUtil.JoinUrl(MaxLabs.bbsMax.Globals.ApplicationPath, "/max-assets/logo-link/");
                                    string targetIconUrl = targetDir + iconName;

                                    imgUrl = MaxLabs.bbsMax.UrlUtil.JoinUrl(MaxLabs.bbsMax.Globals.ApplicationPath, imgUrl);
                                    if (File.Exists(imgUrl))
                                    {
                                        if (File.Exists(targetIconUrl))
                                        {
                                        }
                                        else
                                        {
                                            try
                                            {
                                                if (Directory.Exists(targetDir) == false)
                                                    Directory.CreateDirectory(targetDir);
                                                File.Move(imgUrl, targetIconUrl);
                                            }
                                            catch
                                            {
                                                if (hasCreateErrorLog == false)
                                                {
                                                    hasCreateErrorLog = true;
                                                    ErrorMessages.Add("�ƶ���������ͼ��ʧ��,���ֶ��ѡ�/Images/Logos/��Ŀ¼�µ�����ͼ�긴�Ƶ���/max-assets/logo-link/��Ŀ¼��");
                                                }
                                            }
                                        }
                                    }

                                    link.ImageUrlSrc = "~/max-assets/logo-link/" + iconName;
                                }
                                else
                                    link.ImageUrlSrc = string.Empty;

                            }

                            link.Index = reader.GetInt32(reader.GetOrdinal("SortOrder"));

                            links.Add(link);

                            if (linkSetting.MaxID < link.ID)
                                linkSetting.MaxID = link.LinkID;
                        }
                    }

                    linkSetting.Links = links;

                    sql = @"
UPDATE bx_Settings SET [Value] = @LinkString WHERE TypeName = 'MaxLabs.bbsMax.Settings.LinkSettings' AND [Key] = '*';
IF @@ROWCOUNT = 0
    INSERT INTO bx_Settings ([Key], [Value], [TypeName]) VALUES ('*', @LinkString, 'MaxLabs.bbsMax.Settings.LinkSettings');


DROP TABLE bbsMax_Links;
";
                    command.CommandText = sql;

                    SqlParameter param = new SqlParameter("@LinkString", SqlDbType.NText);
                    param.Value = linkSetting.ToString();
                    command.Parameters.Add(param);

                    command.ExecuteNonQuery();


                }
                catch (Exception ex)
                {
                    CreateLog(ex);
                    throw new Exception("����������������ʧ��" + ex.Message + sql);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
예제 #9
0
            /// <summary>
            /// Visits a navigation link item.
            /// </summary>
            /// <param name="navigationLink">The navigation link to visit.</param>
            protected override ODataPayloadElement VisitNavigationLink(ODataNestedResourceInfo navigationLink)
            {
                ExceptionUtilities.CheckArgumentNotNull(navigationLink, "navigationLink");

                ODataPayloadElement navigationPropertyContent = null;

                // check whether there is an entry or feed associated with the link
                var expandedItemAnnotation = navigationLink.GetAnnotation <ODataNavigationLinkExpandedItemObjectModelAnnotation>();

                if (expandedItemAnnotation != null)
                {
                    string navigationLinkUrlString = !this.payloadContainsIdentityMetadata || navigationLink.Url == null ? null : navigationLink.Url.OriginalString;

                    if (expandedItemAnnotation.ExpandedItem is ODataResource)
                    {
                        navigationPropertyContent = new ExpandedLink(this.Visit((ODataResource)expandedItemAnnotation.ExpandedItem))
                        {
                            UriString = navigationLinkUrlString
                        };
                    }
                    else if (expandedItemAnnotation.ExpandedItem is ODataResourceSet)
                    {
                        navigationPropertyContent = new ExpandedLink(this.Visit((ODataResourceSet)expandedItemAnnotation.ExpandedItem))
                        {
                            UriString = navigationLinkUrlString
                        };
                    }
                    else if (expandedItemAnnotation.ExpandedItem is ODataEntityReferenceLink)
                    {
                        ExceptionUtilities.Assert(!this.response, "Entity reference links in navigation links can only appear in requests.");
                        navigationPropertyContent = this.VisitEntityReferenceLink((ODataEntityReferenceLink)expandedItemAnnotation.ExpandedItem);
                    }
                    else if (expandedItemAnnotation.ExpandedItem is List <ODataItem> )
                    {
                        ExceptionUtilities.Assert(!this.response, "Navigation links with multiple items in content can only appear in requests.");
                        LinkCollection linkCollection = new LinkCollection();
                        foreach (ODataItem item in (List <ODataItem>)expandedItemAnnotation.ExpandedItem)
                        {
                            if (item is ODataResourceSet)
                            {
                                linkCollection.Add(new ExpandedLink(this.Visit((ODataResourceSet)item)));
                            }
                            else
                            {
                                ExceptionUtilities.Assert(item is ODataEntityReferenceLink, "Only feed and entity reference links can appear in navigation link content with multiple items.");
                                linkCollection.Add(this.VisitEntityReferenceLink((ODataEntityReferenceLink)item));
                            }
                        }

                        navigationPropertyContent = linkCollection;
                    }
                    else
                    {
                        ExceptionUtilities.Assert(expandedItemAnnotation.ExpandedItem == null, "Only expanded entry, feed or null is allowed.");
                        navigationPropertyContent = new ExpandedLink(new EntityInstance(null, true))
                        {
                            UriString = navigationLinkUrlString
                        };
                    }
                }
                else
                {
                    ExceptionUtilities.Assert(this.response, "Deferred links are only valid in responses.");

                    // this is a deferred link
                    DeferredLink deferredLink = new DeferredLink()
                    {
                        UriString = !this.payloadContainsIdentityMetadata || navigationLink.Url == null ? null : navigationLink.Url.OriginalString,
                    };
                    navigationPropertyContent = deferredLink;
                }

                DeferredLink associationLink = null;

                if (this.payloadContainsIdentityMetadata && navigationLink.AssociationLinkUrl != null)
                {
                    associationLink = new DeferredLink()
                    {
                        UriString = navigationLink.AssociationLinkUrl.OriginalString
                    };
                }

                return(new NavigationPropertyInstance(navigationLink.Name, navigationPropertyContent, associationLink));
            }
예제 #10
0
        public bool SaveSettings()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("url", "name");
            int rowindex = 0;
            int[] linkids = StringUtil.Split<int>(_Request.Get("linkids", Method.Post));

            LinkSettings settings = SettingManager.CloneSetttings<LinkSettings>(AllSettings.Current.LinkSettings);

            LinkCollection links = new LinkCollection();
            
            Link temp;
            foreach (int id in linkids)
            {
                temp = new Link();
                temp.LinkID = id;
                temp.Url = _Request.Get("url." + id, Method.Post);
                temp.Name = _Request.Get("name." + id, Method.Post);
                temp.ImageUrlSrc = _Request.Get("imageurl." + id, Method.Post);
                temp.Description = _Request.Get("description." + id, Method.Post);
                temp.Index = _Request.Get<int>("index." + id, Method.Post, 0);
                temp.IsNew = _Request.Get<bool>("isnew." + id, Method.Post, false);
                ValidateLink(temp, msgDisplay, rowindex);
                rowindex++;
                links.Add(temp);
            }

            ///客户端无脚本
            if (_Request.Get("newlinkid", Method.Post) != null
                && _Request.Get("newlinkid").Contains("{0}"))
            {
                temp = settings.CreateLink();
                temp.Url = _Request.Get("url.new.{0}", Method.Post);
                temp.Name = _Request.Get("name.new.{0}", Method.Post);
                temp.ImageUrlSrc = _Request.Get("imageurl.new.{0}", Method.Post);
                temp.Description = _Request.Get("description.new.{0}", Method.Post);
                temp.Index = _Request.Get<int>("index.new.{0}", Method.Post, 0);
                rowindex++;
                if (!string.IsNullOrEmpty(temp.Name) && !string.IsNullOrEmpty(temp.Url)) links.Add(temp);
            }
            else
            {
                int[] newLinkArray = StringUtil.Split<int>(_Request.Get("newlinkid", Method.Post));
                foreach (int id in newLinkArray)
                {
                    temp = settings.CreateLink();
                    temp.IsNew = true;
                    temp.Url = _Request.Get("url.new." + id, Method.Post);
                    temp.Name = _Request.Get("name.new." + id, Method.Post);
                    temp.ImageUrlSrc = _Request.Get("imageurl.new." + id, Method.Post);
                    temp.Description = _Request.Get("description.new." + id, Method.Post);
                    temp.Index = _Request.Get<int>("index.new." + id, Method.Post, 0);
                    ValidateLink(temp, msgDisplay, rowindex);
                    rowindex++;
                    links.Add(temp);
                }
            }

            if (msgDisplay.HasAnyError())
            {
                msgDisplay.AddError(new DataNoSaveError());
                m_LinkList = links;
            }
            else
            {
                foreach (Link l in links) { l.IsNew = false; }

                settings.Links = links;

                SettingManager.SaveSettings(settings);
                m_LinkList = null;
            }
            return true;
        }
예제 #11
0
 public MainViewModel(IstarLogic context)
 {
     _context = context;
     if (_context.GetJobs().Count == 0)
     {
         _context.AddNewJob(new Job { Jobdate = DateTime.Today, Jobtitle = "ВНИМАНИЕ! Необходимо обновить базу данных.", Jobtext = "Перед началом работы с программой требуется выполнить скрипт для обновления базы данных.", Ismonthly = true, Iscomplete = false });
     }
     TitleLinks = new LinkCollection();
     SettingsLink = new Link { DisplayName = "Настройки", Source = new Uri("/Shared/Settings.xaml", UriKind.Relative) };
     AboutLink = new Link { DisplayName = "О программе", Source = new Uri("cmd://AboutThis", UriKind.Absolute) };
     SchemaLink = new Link { DisplayName = "Подготовить базу", Source = new Uri("cmd://GoSchema", UriKind.Absolute) };
     ScriptLink = new Link { DisplayName = "Заполнить базу", Source = new Uri("cmd://GoScript", UriKind.Absolute) };
     SoundLink = new Link { DisplayName = "Выключить звук", Source = new Uri("cmd://GoSound", UriKind.Absolute) };
     ExitLink = new Link { DisplayName = "Выход", Source = new Uri("cmd://GoExit", UriKind.Absolute) };
     TitleLinks.Add(SettingsLink);
     TitleLinks.Add(AboutLink);
     if (CanExecuteSchema)
     {
         TitleLinks.Add(SchemaLink);
     }
     else
     {
         if (CanExecuteScript)
         {
             TitleLinks.Add(ScriptLink);
         }
     }
     TitleLinks.Add(SoundLink);
     TitleLinks.Add(ExitLink);
     MainWin = Application.Current.MainWindow;
     MainWin.Closing += (sender, cancelEventArgs) => GoExit();
 }
예제 #12
0
        public bool SaveSettings()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("url", "name");
            int            rowindex   = 0;

            int[] linkids = StringUtil.Split <int>(_Request.Get("linkids", Method.Post));

            LinkSettings settings = SettingManager.CloneSetttings <LinkSettings>(AllSettings.Current.LinkSettings);

            LinkCollection links = new LinkCollection();

            Link temp;

            foreach (int id in linkids)
            {
                temp             = new Link();
                temp.LinkID      = id;
                temp.Url         = _Request.Get("url." + id, Method.Post);
                temp.Name        = _Request.Get("name." + id, Method.Post);
                temp.ImageUrlSrc = _Request.Get("imageurl." + id, Method.Post);
                temp.Description = _Request.Get("description." + id, Method.Post);
                temp.Index       = _Request.Get <int>("index." + id, Method.Post, 0);
                temp.IsNew       = _Request.Get <bool>("isnew." + id, Method.Post, false);
                ValidateLink(temp, msgDisplay, rowindex);
                rowindex++;
                links.Add(temp);
            }

            ///客户端无脚本
            if (_Request.Get("newlinkid", Method.Post) != null &&
                _Request.Get("newlinkid").Contains("{0}"))
            {
                temp             = settings.CreateLink();
                temp.Url         = _Request.Get("url.new.{0}", Method.Post);
                temp.Name        = _Request.Get("name.new.{0}", Method.Post);
                temp.ImageUrlSrc = _Request.Get("imageurl.new.{0}", Method.Post);
                temp.Description = _Request.Get("description.new.{0}", Method.Post);
                temp.Index       = _Request.Get <int>("index.new.{0}", Method.Post, 0);
                rowindex++;
                if (!string.IsNullOrEmpty(temp.Name) && !string.IsNullOrEmpty(temp.Url))
                {
                    links.Add(temp);
                }
            }
            else
            {
                int[] newLinkArray = StringUtil.Split <int>(_Request.Get("newlinkid", Method.Post));
                foreach (int id in newLinkArray)
                {
                    temp             = settings.CreateLink();
                    temp.IsNew       = true;
                    temp.Url         = _Request.Get("url.new." + id, Method.Post);
                    temp.Name        = _Request.Get("name.new." + id, Method.Post);
                    temp.ImageUrlSrc = _Request.Get("imageurl.new." + id, Method.Post);
                    temp.Description = _Request.Get("description.new." + id, Method.Post);
                    temp.Index       = _Request.Get <int>("index.new." + id, Method.Post, 0);
                    ValidateLink(temp, msgDisplay, rowindex);
                    rowindex++;
                    links.Add(temp);
                }
            }

            if (msgDisplay.HasAnyError())
            {
                msgDisplay.AddError(new DataNoSaveError());
                m_LinkList = links;
            }
            else
            {
                foreach (Link l in links)
                {
                    l.IsNew = false;
                }

                settings.Links = links;

                SettingManager.SaveSettings(settings);
                m_LinkList = null;
            }
            return(true);
        }
예제 #13
0
        private LinkCollection GetInLinks(IFactory factory)
        {
            LinkCollection links = new LinkCollection();

            ChartObjectCollection nodes = new ChartObjectCollection();

            nodes.Add(_node);

            // Collect all objects within that group
            if (_keepGroups)
            {
                int i = 0;
                while (i < nodes.Count)
                {
                    Node node = nodes[i] as Node;
                    i++;

                    if (node.SubordinateGroup != null)
                    {
                        foreach (ChartObject sub in node.SubordinateGroup.AttachedObjects)
                        {
                            // Check if attached object is a node
                            if (!(sub is Node))
                            {
                                continue;
                            }

                            // Add the node to the nodes of the group
                            if (!nodes.Contains(sub))
                            {
                                nodes.Add(sub);
                            }
                        }
                    }
                }
            }

            foreach (Node node in nodes)
            {
                foreach (Arrow a in node.IncomingArrows)
                {
                    // Ignore non-layoutable objects
                    if (a.IgnoreLayout)
                    {
                        continue;
                    }
                    if (a.Origin.Frozen)
                    {
                        continue;
                    }
                    if (!a.IsConnected)
                    {
                        continue;
                    }

                    // Add only if it comes from outside the group
                    if (!nodes.Contains(a.Origin))
                    {
                        // Use the factory to create the adapter link.
                        // That way, if the adapter for the arrow already
                        // exists, it will be returned instead of creating a
                        // new adapter.
                        links.Add(factory.CreateLink(a,
                                                     _keepGroups, _ignoreArrowDirection));
                    }
                }

                if (node is Table)
                {
                    Table t = node as Table;

                    foreach (Table.Row r in t.Rows)
                    {
                        foreach (Arrow a in r.IncomingArrows)
                        {
                            // Ignore non-layoutable objects
                            if (a.IgnoreLayout)
                            {
                                continue;
                            }
                            if (a.Origin.Frozen)
                            {
                                continue;
                            }
                            if (!a.IsConnected)
                            {
                                continue;
                            }

                            // Add only if it comes from outside the group
                            if (!nodes.Contains(a.Origin))
                            {
                                // Use the factory to create the adapter link.
                                // That way, if the adapter for the arrow already
                                // exists, it will be returned instead of creating a
                                // new adapter.
                                links.Add(factory.CreateLink(a,
                                                             _keepGroups, _ignoreArrowDirection));
                            }
                        }
                    }
                }
            }

            return(links);
        }
예제 #14
0
        /// <summary>
        /// Cria um valor compatível para o tipo indicado com base no conteúdo
        /// do modelo deserializado.
        /// </summary>
        /// <param name="type">O tipo do dado esperado.</param>
        /// <param name="node">O modelo deserializado.</param>
        /// <returns>O valor obtido da compatibilização.</returns>
        private object CreateCompatibleValue(Type type, NodeModel node)
        {
            if (node == null)
            {
                return(null);
            }

            if (type == typeof(PropertyCollection))
            {
                return((PropertyCollection)CreateCompatibleValue(typeof(object), node));
            }

            if (type == typeof(NameCollection))
            {
                var target = new NameCollection();
                foreach (var item in node.ChildValues())
                {
                    target.Add(item.Value.ToString());
                }
                return(target);
            }

            if (type == typeof(FieldCollection))
            {
                var target = new FieldCollection();
                foreach (var @object in node.ChildObjects())
                {
                    var field = new Field();
                    CopyNodeProperties(@object, field);
                    target.Add(field);
                }
                return(target);
            }

            if (type == typeof(LinkCollection))
            {
                var target = new LinkCollection();
                foreach (var item in node.Children())
                {
                    var link = new Link();
                    CopyNodeProperties(item, link);
                    target.Add(link);
                }
                return(target);
            }

            if (type == typeof(EntityActionCollection))
            {
                var target = new EntityActionCollection();
                foreach (var item in node.Children())
                {
                    var action = new EntityAction();
                    CopyNodeProperties(item, action);
                    target.Add(action);
                }
                return(target);
            }

            if (type == typeof(EntityCollection))
            {
                var target = new EntityCollection();
                foreach (var item in node.Children())
                {
                    var entity = new Entity();
                    CopyNodeProperties(item, entity);
                    target.Add(entity);
                }
                return(target);
            }

            if (type == typeof(CaseVariantString))
            {
                var text = (node as ValueModel)?.Value.ToString();
                return(text.ChangeCase(TextCase.PascalCase));
            }

            return(CreateCompatibleValue(node));
        }
        /// <summary>
        /// Deserializes a collection of links
        /// </summary>
        /// <param name="links">Xml element representing the links collection</param>
        /// <returns>Deserialized link collection</returns>
        private LinkCollection DeserializeLinks(XElement links)
        {
            LinkCollection collection = new LinkCollection();

            AddXmlBaseAnnotation(collection, links);

            // read the count, if present
            XElement count = links.Element(MetadataCount);
            if (count != null)
            {
                collection.InlineCount = long.Parse(count.Value, CultureInfo.InvariantCulture);
            }

            // read the next-link if present
            XElement nextLink = links.Element(DataServicesNext);
            if (nextLink != null)
            {
                collection.NextLink = nextLink.Value;
            }

            // deserialize each element as a link and add it to the collection
            foreach (var link in links.Elements(MetadataUri))
            {
                collection.Add(this.DeserializeLink(link));
            }

            return collection;
        }
        private IEnumerable<NavigationPropertyInstance> DeserializeNavigationProperties(IEnumerable<XElement> links)
        {
            // get the links and convert them into navigation properties
            ILookup<string, XElement> linksByName = links
                .Select(link => link.Attribute(Rel))
                .Where(rel => rel != null)
                .Where(rel => rel.Value.StartsWith(ODataConstants.DataServicesRelatedNamespaceName, StringComparison.OrdinalIgnoreCase))
                .ToLookup(
                    rel => rel.Value.Substring(ODataConstants.DataServicesRelatedNamespaceName.Length),
                    rel => rel.Parent);

            List<NavigationPropertyInstance> results = new List<NavigationPropertyInstance>(linksByName.Count);
            foreach (var group in linksByName)
            {
                NavigationPropertyInstance navProp = new NavigationPropertyInstance();
                navProp.Name = group.Key;
                List<XElement> elements = group.ToList();

                if (elements.Count > 1)
                {
                    LinkCollection collection = new LinkCollection();
                    foreach (XElement link in elements)
                    {
                        ODataPayloadElement linkValue = this.DeserializeLink(link);
                        ExceptionUtilities.Assert(
                            linkValue.ElementType == ODataPayloadElementType.DeferredLink,
                            "Navigation property '" + group.Key + "' had multiple <link> elements which were not all deferred");

                        collection.Add(linkValue);
                    }

                    navProp.Value = collection;
                }
                else
                {
                    // Note: it is possible in cases where we are parsing an update payload, that this was really a collection of size one
                    // however, we cannot possibly detect this case here, so we will have to deal with it elsewhere should it arise
                    navProp.Value = this.DeserializeLink(elements[0]);
                }

                results.Add(navProp);
            }

            return results;
        }
예제 #17
0
        private void UpdateSelection()
        {
            LinkGroup selectedGroup = null;
            Link selectedLink = null;
			LinkCollection toolLinks = new LinkCollection();

            if (this.LinkGroups != null) {
                // find the current select group and link based on the selected source
                var linkInfo = (from g in this.LinkGroups
                                from l in g.Links
                                where l.Source == this.SelectedSource
                                select new {
                                    Group = g,
                                    Link = l
                                }).FirstOrDefault();

                if (linkInfo != null) {
                    selectedGroup = linkInfo.Group;
                    selectedLink = linkInfo.Link;
                }
                else {
                    // could not find link and group based on selected source, fall back to selected link group
                    selectedGroup = this.SelectedLinkGroup;

                    // if selected group doesn't exist in available groups, select first group
                    if (!this.LinkGroups.Any(g => g == selectedGroup)) {
                        selectedGroup = this.LinkGroups.FirstOrDefault();
                    }
                }
				//获取需要添加的工具栏的link
				var toolLink = from g in this.LinkGroups
							from l in g.Links
							where l.ShowInTool == true
							select l;
				if (toolLink != null)
				{
					foreach (Link l in toolLink)
					{
						toolLinks.Add(l);
                    }
                }
			}
            
            ReadOnlyLinkGroupCollection groups = null;
            if (selectedGroup != null) {
                // ensure group itself maintains the selected link
                selectedGroup.SelectedLink = selectedLink;

                // find the collection this group belongs to
                var groupKey = GetGroupKey(selectedGroup);
                this.groupMap.TryGetValue(groupKey, out groups);
            }

            this.isSelecting = true;
            // update selection
            SetValue(VisibleLinkGroupsPropertyKey, groups);
            SetCurrentValue(SelectedLinkGroupProperty, selectedGroup);
            SetCurrentValue(SelectedLinkProperty, selectedLink);
			SetCurrentValue(ToolLinksProperty, toolLinks);
			this.isSelecting = false;
        }
예제 #18
0
        private void ModernTab_SelectedSourceChanged(object sender, SourceEventArgs e)
        {
            if (e.Source.OriginalString.EndsWith("Vasco da Gama"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 6; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;

                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "102";
            }

            if (e.Source.OriginalString.EndsWith("Alvaláxia"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 5; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;

                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "98";
            }

            if (e.Source.OriginalString.EndsWith("Colombo"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 6; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;

                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "140";
            }

            if (e.Source.OriginalString.EndsWith("Dolce Vita Porto"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 7; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;

                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "102";
            }

            if (e.Source.OriginalString.EndsWith("Algarve Shopping"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 3; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;
                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "130";
            }

            if (e.Source.OriginalString.EndsWith("Viana Shopping"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 4; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;
                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "140";
            }

            if (e.Source.OriginalString.EndsWith("Glicínias Plaza"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 5; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;
                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "170";
            }

            if (e.Source.OriginalString.EndsWith("Leiria Shopping"))
            {
                var            salas_list = (ModernTab)this.FindName("salas_list");
                LinkCollection links      = new LinkCollection();

                for (int i = 0; i < 5; i++)
                {
                    Link link = new Link();

                    link.DisplayName = (i + 1) + "";
                    link.Source      = new Uri((i + 1) + "", UriKind.Relative);

                    links.Add(link);
                }

                salas_list.Links = links;
                var capacidade = (TextBox)this.FindName("capacidade_textbox");
                capacidade.Text = "165";
            }
        }
예제 #19
0
 private void LoadUserList(IEnumerable<string> userlist)
 {
     CurrentUsers = new LinkCollection();
     foreach (var user in userlist)
     {
         if (Users.Contains(user))
         {
             return;
         }
         else
         {
             Users.Add(user);
             CurrentUsers.Add(new Link() { DisplayName = user, Source = new Uri("/Pages/Chat/MainRoom.xaml", UriKind.Relative) });
         }
     }
 }