Example #1
0
        public static LinkDefinition DeserializeLink(XmlNode node, bool isTextBlock)
        {
            LinkDefinition ret = new LinkDefinition();

            ret.IsTextLink = isTextBlock;
            ret.Block      = node.Attributes["block"].Value;
            if (node.Attributes["separator"] != null)
            {
                ret.Separator = node.Attributes["separator"].Value;
            }
            if (node.HasChildNodes)
            {
                foreach (XmlNode subNode in node.ChildNodes)
                {
                    if (SkipNode(subNode))
                    {
                        continue;
                    }
                    Property prop = new Property();
                    prop.Name  = subNode.Attributes["name"].Value;
                    prop.Value = string.Empty;
                    if (subNode.Attributes["format"] != null)
                    {
                        prop.Format = subNode.Attributes["format"].Value.Contains("{}") ? subNode.Attributes["format"].Value : "{}";
                    }
                    ret.NestedProperties.Add(prop);
                }
            }

            return(ret);
        }
Example #2
0
File: Link.cs Project: wlk0/OCTGN
        public TextLinkModel(TextLinkModel link, IdeCollection <IdeBaseItem> source) : base(source)  //copy
        {
            var _linkDefinition = new LinkDefinition()
            {
                Block            = link._wrapper.Link.Block,
                IsTextLink       = true,
                Separator        = link._wrapper.Link.Separator,
                NestedProperties = new List <Property>()
            };

            _wrapper = new LinkDefinition.LinkWrapper()
            {
                Link = _linkDefinition
            };

            Items = new IdeCollection <IdeBaseItem>(this);
            Items.CollectionChanged += (a, b) =>
            {
                BuildPropertyDefinition(b);
            };
            foreach (TextLinkPropertyModel property in link.Items)
            {
                Items.Add(new TextLinkPropertyModel(property, Items));
            }
            AddPropertyCommand = new RelayCommand(AddProperty);
        }
        public void NoTitle()
        {
            string str = "[id]: url.com";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.id, "id");
            Assert.AreEqual(r.url, "url.com");
            Assert.AreEqual(r.title, null);
        }
        public void SingleQuoteTitle()
        {
            string str = "[id]: url.com \'my title\'";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.id, "id");
            Assert.AreEqual(r.url, "url.com");
            Assert.AreEqual(r.title, "my title");
        }
Example #5
0
        /// <inheritdoc />
        public Task <string> GenerateAsync(ILinkResource resource, LinkDefinition definition)
        {
            Func <ILinkResource, dynamic> valuesFunc = definition.RouteValues ?? DefaultValues;
            object values = valuesFunc(resource) as object;

            ActionContext actionContext = actionContextAccessor.ActionContext;
            IUrlHelper    helper        = urlHelperFactory.GetUrlHelper(actionContext);
            string        path          = helper.RouteUrl(definition.RouteName, values);

            return(Task.FromResult(path));
        }
        public void ParenthesizedTitle()
        {
            string str = "[id]: url.com (my title)";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.id, "id");
            Assert.AreEqual(r.url, "url.com");
            Assert.AreEqual(r.title, "my title");
        }
Example #7
0
        public static string MontarLinkDownload(string pTabela, string pCampo, long pHandle)
        {
            LinkDefinition link = new LinkDefinition();

            link.Url = LinkDownloadPortalCorporativo;
            link.Parameters["$SystemInstanceName$"]   = "BACKOFFICE_XE3";
            link.Parameters["$EntityDefinitionName$"] = pTabela;
            link.Parameters["$FieldName$"]            = pCampo;
            link.Parameters["$EntityHandle$"]         = new Handle(pHandle);
            return(link.GetEncodedUrl());
        }
        public void AngleBracketedUrl()
        {
            string str = "[id]: <url.com> (my title)";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.id, "id");
            Assert.AreEqual(r.url, "url.com");
            Assert.AreEqual(r.title, "my title");
        }
        public void MultiLine()
        {
            string str = "[id]:\n\t     http://www.site.com \n\t      (my title)";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.id, "id");
            Assert.AreEqual(r.url, "http://www.site.com");
            Assert.AreEqual(r.title, "my title");
        }
Example #10
0
        public void DoubleQuoteTitle()
        {
            string str = "[id]: url.com \"my title\"";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.Id, "id");
            Assert.AreEqual(r.Url, "url.com");
            Assert.AreEqual(r.Title, "my title");
        }
Example #11
0
        public void NoTitle()
        {
            string str = "[id]: url.com";

            r = LinkDefinition.ParseLinkDefinition(str, false);

            Assert.IsNotNull(r);
            Assert.AreEqual(r.Id, "id");
            Assert.AreEqual(r.Url, "url.com");
            Assert.AreEqual(r.Title, string.Empty);
        }
 public void Invalid()
 {
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]:", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]: <url", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]: <url> \"title", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]: <url> \'title", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]: <url> (title", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]: <url> \"title\" crap", false));
     Assert.IsNull(LinkDefinition.ParseLinkDefinition("[id]: <url> crap", false));
 }
Example #13
0
File: Link.cs Project: wlk0/OCTGN
        public OverlayLinkModel(IdeCollection <IdeBaseItem> source) : base(source) //new
        {
            var _linkDefinition = new LinkDefinition()
            {
                NestedProperties = new List <Property>()
            };

            _wrapper = new LinkDefinition.LinkWrapper()
            {
                Link = _linkDefinition
            };
        }
Example #14
0
File: Link.cs Project: wlk0/OCTGN
        public OverlayLinkModel(OverlayLinkModel link, IdeCollection <IdeBaseItem> source) : base(source)  //copy
        {
            var _linkDefinition = new LinkDefinition()
            {
                Block            = link._wrapper.Link.Block,
                NestedProperties = new List <Property>()
            };

            _wrapper = new LinkDefinition.LinkWrapper()
            {
                Link = _linkDefinition
            };
        }
Example #15
0
File: Link.cs Project: wlk0/OCTGN
        public TextLinkModel(IdeCollection <IdeBaseItem> source) : base(source) //new
        {
            var _linkDefinition = new LinkDefinition()
            {
                IsTextLink       = true,
                NestedProperties = new List <Property>()
            };

            _wrapper = new LinkDefinition.LinkWrapper()
            {
                Link = _linkDefinition
            };
            Items = new IdeCollection <IdeBaseItem>(this);
            Items.CollectionChanged += (a, b) =>
            {
                BuildPropertyDefinition(b);
            };
            AddPropertyCommand = new RelayCommand(AddProperty);
        }
Example #16
0
        public static LinkDefinition.LinkWrapper DeserializeLinkWrapper(XmlNode node, bool isTextBlock)
        {
            var ret = new LinkDefinition.LinkWrapper();

            if (node.Name == "link")
            {
                LinkDefinition link = DeserializeLink(node, isTextBlock);
                ret.Link = link;
            }
            if (node.Name == "conditional")
            {
                ConditionalDefinition conditional = DeserializeConditional(node, isTextBlock);
                ret.Conditional = conditional;
            }
            if (node.Name == "artoverlay")
            {
                BlockDefinition b = DeserializeArtOverlayBlock(node);
                ret.CardArtCrop = b;
            }
            return(ret);
        }
Example #17
0
        public static void RefreshRelationShipPosition(
            LinkDefinition linkDefinition,
            Dictionary <TableDefinition, TableDefinitionControl> tableDefinitionControls,
            Canvas modelViewerContainer,
            Line line)
        {
            var sourceTableDefinition        = linkDefinition.Source.TableDefinition;
            var targetTableDefinition        = linkDefinition.Target.TableDefinition;
            var sourceTableDefinitionControl = tableDefinitionControls[sourceTableDefinition];
            var targetTableDefinitionControl = tableDefinitionControls[targetTableDefinition];
            var sourceCenterPoint            = CalculateTableDefinitionControlCenterPoint(sourceTableDefinitionControl);
            var targetCenterPoint            = CalculateTableDefinitionControlCenterPoint(targetTableDefinitionControl);
            var sourceTableCoordinateX       = Canvas.GetLeft(sourceTableDefinitionControl);
            var targetTableCoordinateX       = Canvas.GetLeft(targetTableDefinitionControl);
            var sourceTableCoordinateY       = Canvas.GetTop(sourceTableDefinitionControl);
            var targetTableCoordinateY       = Canvas.GetTop(targetTableDefinitionControl);

            line.X1 = sourceTableCoordinateX + sourceCenterPoint.X;
            line.X2 = targetTableCoordinateX + targetCenterPoint.X;
            line.Y1 = sourceTableCoordinateY + sourceCenterPoint.Y;
            line.Y2 = targetTableCoordinateY + targetCenterPoint.Y;
        }
Example #18
0
        private void AddLinkCommandExecute()
        {
            if (TableDefinitions.Count < 2)
            {
                return;
            }

            var link = new LinkDefinition
            {
                Source = new EndPointDefinition()
                {
                    ColumnDefinition = TableDefinitions.Last().ColumnDefinitions.First(),
                    TableDefinition  = TableDefinitions.Last()
                },
                Target = new EndPointDefinition()
                {
                    ColumnDefinition = TableDefinitions[TableDefinitions.Count - 2].ColumnDefinitions.First(),
                    TableDefinition  = TableDefinitions[TableDefinitions.Count - 2]
                }
            };

            _linkDefinitions.Add(link);
        }
Example #19
0
        /// <summary>
        /// Convert URLs in the markdown file into their HTML equivelents.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        protected virtual string QualifyUrl(string url)
        {
            if (url.StartsWith("#"))
            {
                return(url);
            }
            if (LinkDefinition.IsUrlFullyQualified(url))
            {
                return(url);
            }

            string filePath, bookmark;

            SplitUrlPathAndBookmark(url, out filePath, out bookmark);
            foreach (var extension in this.ScannableExtensions)
            {
                if (filePath.EndsWith(extension))
                {
                    return(filePath.Substring(0, filePath.Length - extension.Length) + HtmlOutputExtension + bookmark);
                }
            }
            return(url);
        }
Example #20
0
 public LinkInfo(LinkDefinition def, string link_text)
 {
     this.def = def;
     this.link_text = link_text;
 }
Example #21
0
 public LinkInfo(LinkDefinition definition, string linkText)
 {
     Definition = definition;
     LinkText = linkText;
 }
Example #22
0
 public ProxyTextBlockItemModel(LinkDefinition ld)
 {
     _linkDefinition = ld;
     LinkedTextBlock = (TextBlockDefinitionItemModel)ViewModelLocator.ProxyTabViewModel.TextBlocks.First(x => ((TextBlockDefinitionItemModel)x).Name == ld.Block);
 }
Example #23
0
        public void Load(BinaryReader reader)
        {
            this.Id                 = reader.ReadInt32();
            this.IsDungeon          = reader.ReadBoolean();
            this.DungeonId          = reader.ReadInt32();
            this.Area               = reader.ReadString();
            this.IsRoomTransition   = reader.ReadBoolean();
            this.RoomFlags          = (RoomFlags)reader.ReadInt32();
            this.DifficultyModifier = reader.ReadSingle();
            this.X = reader.ReadInt32();
            this.Y = reader.ReadInt32();
            this.VariationIndex   = reader.ReadInt32();
            this.SpawnIndex       = reader.ReadInt32();
            this.TemplateId       = reader.ReadInt32();
            this.PlayerEntersLeft = reader.ReadBoolean();
            int count = reader.ReadInt32();

            LeftDoors = new Dictionary <int, LinkDefinition>(count);
            for (int i = 0; i < count; i++)
            {
                int            key   = reader.ReadInt32();
                LinkDefinition value = default(LinkDefinition);
                value.Load(reader);
                this.LeftDoors.Add(key, value);
            }
            count      = reader.ReadInt32();
            RightDoors = new Dictionary <int, LinkDefinition>(count);
            for (int j = 0; j < count; j++)
            {
                int            key   = reader.ReadInt32();
                LinkDefinition value = default(LinkDefinition);
                value.Load(reader);
                this.RightDoors.Add(key, value);
            }
            count       = reader.ReadInt32();
            CustomDoors = new Dictionary <int, LinkDefinition>(count);
            for (int k = 0; k < count; k++)
            {
                int            key   = reader.ReadInt32();
                LinkDefinition value = default(LinkDefinition);
                value.Load(reader);
                this.CustomDoors.Add(key, value);
            }
            count     = reader.ReadInt32();
            EnemyInfo = new List <EnemyInfo>(count);
            for (int l = 0; l < count; l++)
            {
                EnemyInfo item = default(EnemyInfo);
                item.Load(reader);
                this.EnemyInfo.Add(item);
            }
            count       = reader.ReadInt32();
            RandomProps = new List <PropData>(count);
            for (int m = 0; m < count; m++)
            {
                string fullName  = reader.ReadString();
                string localName = fullName.IndexOf("ComboLock", StringComparison.OrdinalIgnoreCase) > -1
                    ? "ComboLockHint"
                    : fullName.Substring(fullName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase) + 1);
                Type        type        = Type.GetType("ChasmDeserializer.Model.SaveGameData.WorldState.Saveable." + localName);
                GenericProp genericProp = Activator.CreateInstance(type) as GenericProp;
                this.RandomProps.Add(new PropData(fullName, genericProp));
                ISaveGame saveGame = genericProp as ISaveGame;
                saveGame.LoadGame(reader);
            }
            count           = reader.ReadInt32();
            AreaConnections = new List <AreaConnectionDef>(count);
            for (int n = 0; n < count; n++)
            {
                this.AreaConnections.Add(AreaConnectionDef.Load(reader));
            }
            this.IsDark      = reader.ReadBoolean();
            this.IsBacktrack = reader.ReadBoolean();
            count            = reader.ReadInt32();
            LocalVaribles    = new Dictionary <string, string>(count);
            for (int num4 = 0; num4 < count; num4++)
            {
                string key   = reader.ReadString();
                string value = reader.ReadString();
                this.LocalVaribles.Add(key, value);
            }
            this.IsHub     = reader.ReadBoolean();
            count          = reader.ReadInt32();
            IdTranslations = new List <KeyValuePair <int, int> >(count);
            for (int num6 = 0; num6 < count; num6++)
            {
                int key   = reader.ReadInt32();
                int value = reader.ReadInt32();
                this.IdTranslations.Add(new KeyValuePair <int, int>(key, value));
            }
        }
Example #24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ld">Link definition<see cref="LinkDefinition"/></param>
 public LinkRuntime(LinkDefinition ld)
 {
     _ld = ld;
 }
Example #25
0
 public ProxyTextLinkItemModel(LinkDefinition link)
 {
     _linkDefinition = link;
 }
 static public void LinkCreated(LinkDefinition createdLink)
 {
     Console.WriteLine("Link created: {0} {1} {2}", createdLink.Source.GetPointer(), createdLink.Linker.GetPointer(), createdLink.Target.GetPointer());
 }
Example #27
0
 public LinkInfo(LinkDefinition def, string linkText)
 {
     Def      = def;
     LinkText = linkText;
 }
Example #28
0
 public ProxyTextBlockItemModel(LinkDefinition ld)
 {
     _linkDefinition = ld;
     TextBlock       = ViewModelLocator.ProxyTabViewModel.TextBlocks.First(x => x.Name == ld.Block);
 }
 public static void LinkCreated(LinkDefinition createdLink)
 {
     Console.WriteLine("Link created: {0} {1} {2}", createdLink.Source.ToIndex(), createdLink.Linker.ToIndex(), createdLink.Target.ToIndex());
 }
Example #30
0
 public LinkInfo(LinkDefinition def, string link_text)
 {
     this.def       = def;
     this.link_text = link_text;
 }