public MagicCircleLinks AddLink(LinkTypes lt) { MagicCircleLinks mcl; switch (lt) { case LinkTypes.Transition: { mcl = gameObject.AddComponent <MagicCircleTransitionLinks>(); break; } case LinkTypes.Data: { mcl = gameObject.AddComponent <MagicCircleDataLinks>(); break; } default: { Debug.LogWarning("Yo, there isn't this type of LinkType"); return(null); } } mcl.spellParent = this; links.Add(mcl); return(mcl); }
public void Applies_cascading_settings_for_relationship_links(LinkTypes linksInRelationshipAttribute, LinkTypes linksInResourceContext, LinkTypes linksInOptions, LinkTypes expected) { // Arrange var exampleResourceContext = new ResourceContext { PublicName = nameof(ExampleResource), ResourceType = typeof(ExampleResource), RelationshipLinks = linksInResourceContext }; var options = new JsonApiOptions { RelationshipLinks = linksInOptions }; var request = new JsonApiRequest(); var paginationContext = new PaginationContext(); var resourceGraph = new ResourceGraph(exampleResourceContext.AsArray()); var httpContextAccessor = new FakeHttpContextAccessor(); var linkGenerator = new FakeLinkGenerator(); var controllerResourceMapping = new FakeControllerResourceMapping(); var linkBuilder = new LinkBuilder(options, request, paginationContext, resourceGraph, httpContextAccessor, linkGenerator, controllerResourceMapping); var relationship = new HasOneAttribute { Links = linksInRelationshipAttribute }; // Act RelationshipLinks relationshipLinks = linkBuilder.GetRelationshipLinks(relationship, new ExampleResource()); // Assert if (expected == LinkTypes.None) { relationshipLinks.Should().BeNull(); } else { if (expected.HasFlag(LinkTypes.Self)) { relationshipLinks.Self.Should().NotBeNull(); } else { relationshipLinks.Self.Should().BeNull(); } if (expected.HasFlag(LinkTypes.Related)) { relationshipLinks.Related.Should().NotBeNull(); } else { relationshipLinks.Related.Should().BeNull(); } } }
public void BuildRelationshipLinks_GlobalResourceAndAttrConfiguration_ExpectedLinks( LinkTypes global, LinkTypes resource, LinkTypes relationship, object expectedSelfLink, object expectedRelatedLink) { // Arrange var config = GetConfiguration(relationshipLinks: global); var primaryResource = GetArticleResourceContext(relationshipLinks: resource); _provider.Setup(m => m.GetResourceContext(typeof(Article))).Returns(primaryResource); var builder = new LinkBuilder(config, GetRequestManager(), new PaginationContext(), _provider.Object, _queryStringAccessor); var attr = new HasOneAttribute { Links = relationship, RightType = typeof(Author), PublicName = "author" }; // Act var links = builder.GetRelationshipLinks(attr, new Article { Id = _primaryId }); // Assert if (expectedSelfLink == null && expectedRelatedLink == null) { Assert.Null(links); } else { Assert.Equal(expectedSelfLink, links.Self); Assert.Equal(expectedRelatedLink, links.Related); } }
public static InterfaceDescriptionBlock Parse(BaseBlock baseBlock, Action <Exception> ActionOnException) { Contract.Requires <ArgumentNullException>(baseBlock != null, "BaseBlock cannot be null"); Contract.Requires <ArgumentNullException>(baseBlock.Body != null, "BaseBlock.Body cannot be null"); Contract.Requires <ArgumentException>(baseBlock.BlockType == BaseBlock.Types.InterfaceDescription, "Invalid packet type"); long positionInStream = baseBlock.PositionInStream; using (Stream stream = new MemoryStream(baseBlock.Body)) { using (BinaryReader binaryReader = new BinaryReader(stream)) { UInt16 linktype = binaryReader.ReadUInt16().ReverseByteOrder(baseBlock.ReverseByteOrder); if (!Enum.IsDefined(typeof(LinkTypes), linktype)) { throw new ArgumentException(string.Format("[InterfaceDescriptionBlock.ctor] invalid LinkTypes: {0}, block begin on position {1} ", linktype, positionInStream)); } LinkTypes linkType = (LinkTypes)linktype; binaryReader.ReadUInt16(); // Reserved field. int snapLength = binaryReader.ReadInt32().ReverseByteOrder(baseBlock.ReverseByteOrder); InterfaceDescriptionOption Options = InterfaceDescriptionOption.Parse(binaryReader, baseBlock.ReverseByteOrder, ActionOnException); InterfaceDescriptionBlock interfaceBlock = new InterfaceDescriptionBlock(linkType, snapLength, Options, positionInStream); return(interfaceBlock); } } }
/// <summary> /// Checks if the resource object level <paramref name="link"/> should be added by first checking /// configuration on the <see cref="ResourceContext"/>, and if not configured, by checking with the /// global configuration in <see cref="IJsonApiOptions"/>. /// </summary> private bool ShouldAddResourceLink(ResourceContext resourceContext, LinkTypes link) { if (resourceContext.ResourceLinks != LinkTypes.NotConfigured) { return(resourceContext.ResourceLinks.HasFlag(link)); } return(_options.ResourceLinks.HasFlag(link)); }
public void AddTerm <T>(string termText, LinkTypes linkType) where T : SearchTerm { var instance = (T)Activator.CreateInstance(typeof(T), termText); instance.LinkType = new SearchTermLinkType(linkType); instance.Term = termText; Terms.Add(instance); }
/// <summary> /// The Interface Description Block is mandatory. This block is needed to specify the characteristics of the network interface /// on which the capture has been made. In order to properly associate the captured data to the corresponding interface, the Interface /// Description Block must be defined before any other block that uses it; therefore, this block is usually placed immediately after /// the Section Header Block. /// </summary> public InterfaceDescriptionBlock(LinkTypes LinkType, int SnapLength, InterfaceDescriptionOption Options, long PositionInStream = 0) { Contract.Requires <ArgumentNullException>(Options != null, "Options cannot be null"); this.LinkType = LinkType; this.SnapLength = SnapLength; this.options = Options; this.PositionInStream = PositionInStream; }
private void CollectResourceTypesNames(IResourceList validResTypes) { MajorTypes = FormattedTypes = LinkTypes = Core.ResourceStore.EmptyResourceList; ArrayList validNames = new ArrayList(); if (validResTypes != null) { foreach (IResource res in validResTypes) { validNames.Add(res.GetStringProp(Core.Props.Name)); } } //----------------------------------------------------------------- foreach (IResourceType rt in Store.ResourceTypes) { IResource resForType = Core.ResourceStore.FindUniqueResource("ResourceType", Core.Props.Name, rt.Name); // possible when resource types are deleted via DebugPlugin. if (resForType != null) { if (rt.HasFlag(ResourceTypeFlags.FileFormat)) { if (IsFeasibleRT(rt, validNames, ResourceTypeFlags.Internal)) { FormattedTypes = FormattedTypes.Union(resForType.ToResourceList()); } } else { if (IsFeasibleRT(rt, validNames, ResourceTypeFlags.NoIndex)) { MajorTypes = MajorTypes.Union(resForType.ToResourceList()); } } } } // Resource "Clipping" is a special resource since it is semantically // subsumed to be the part of other resource (and thus indirectly // inherits its type) // temp1.Remove( "Clipping" ); // end hack //----------------------------------------------------------------- foreach (IPropType pt in Store.PropTypes) { if (pt.HasFlag(PropTypeFlags.SourceLink) && (pt.DisplayName != null) && pt.OwnerPluginLoaded) { if (validResTypes == null || validNames.IndexOf(pt.Name) != -1) { IResource resForProp = Core.ResourceStore.FindUniqueResource("PropType", "Name", pt.Name); LinkTypes = LinkTypes.Union(resForProp.ToResourceList()); } } } }
public virtual BOLinkTypes MapEFToBO( LinkTypes ef) { var bo = new BOLinkTypes(); bo.SetProperties( ef.Id, ef.Type); return(bo); }
public virtual LinkTypes MapBOToEF( BOLinkTypes bo) { LinkTypes efLinkTypes = new LinkTypes(); efLinkTypes.SetProperties( bo.Id, bo.Type); return(efLinkTypes); }
public TileSettings(string name, Uri uri,BitmapSource image, Color backgroundColor, bool showLabel, bool useDarkLabel, LinkTypes linkType) { Name = name; Uri = uri; Image = image; BackgroundColor = backgroundColor; ShowLabel = showLabel; UseDarkLabel = useDarkLabel; LinkType = linkType; }
public TileSettings(TileData tileData) { Name = tileData.Name; Uri = tileData.Uri; Image = tileData.SquareFinal; BackgroundColor = tileData.Color; ShowLabel = tileData.LabelType != LabelTypes.NoLabel; UseDarkLabel = tileData.LabelType == LabelTypes.DarkLabel; LinkType = tileData.LinkType; }
public TileSettings(string name, Uri uri, BitmapSource image, Color backgroundColor, bool showLabel, bool useDarkLabel, LinkTypes linkType) { Name = name; Uri = uri; Image = image; BackgroundColor = backgroundColor; ShowLabel = showLabel; UseDarkLabel = useDarkLabel; LinkType = linkType; }
private IJsonApiOptions GetConfiguration(LinkTypes resourceLinks = LinkTypes.All, LinkTypes topLevelLinks = LinkTypes.All, LinkTypes relationshipLinks = LinkTypes.All) { var config = new Mock <IJsonApiOptions>(); config.Setup(m => m.TopLevelLinks).Returns(topLevelLinks); config.Setup(m => m.ResourceLinks).Returns(resourceLinks); config.Setup(m => m.RelationshipLinks).Returns(relationshipLinks); config.Setup(m => m.DefaultPageSize).Returns(new PageSize(25)); return(config.Object); }
public void MapBOToEF() { var mapper = new DALLinkTypesMapper(); var bo = new BOLinkTypes(); bo.SetProperties(1, "A"); LinkTypes response = mapper.MapBOToEF(bo); response.Id.Should().Be(1); response.Type.Should().Be("A"); }
private ResourceContext GetArticleResourceContext(LinkTypes resourceLinks = LinkTypes.NotConfigured, LinkTypes topLevelLinks = LinkTypes.NotConfigured, LinkTypes relationshipLinks = LinkTypes.NotConfigured) { return(new ResourceContext { ResourceLinks = resourceLinks, TopLevelLinks = topLevelLinks, RelationshipLinks = relationshipLinks, PublicName = "articles" }); }
public static string LinkName(LinkTypes linkType) { switch (linkType) { case LinkTypes.artifactFire: return("ArtifactFire"); case LinkTypes.drawTwo: return("DrawTwo"); } return(""); }
internal static string ToSerializedValue(this LinkTypes value) { switch (value) { case LinkTypes.UpdateAlways: return("UpdateAlways"); case LinkTypes.CopyIfNull: return("CopyIfNull"); } return(null); }
public void MapEFToBO() { var mapper = new DALLinkTypesMapper(); LinkTypes entity = new LinkTypes(); entity.SetProperties(1, "A"); BOLinkTypes response = mapper.MapEFToBO(entity); response.Id.Should().Be(1); response.Type.Should().Be("A"); }
/// <summary> /// Checks if the resource object level <paramref name="link"/> should be added by first checking /// configuration on the <see cref="ResourceContext"/>, and if not configured, by checking with the /// global configuration in <see cref="IJsonApiOptions"/>. /// </summary> private bool ShouldAddResourceLink(ResourceContext resourceContext, LinkTypes link) { if (_request.Kind == EndpointKind.Relationship) { return(false); } if (resourceContext.ResourceLinks != LinkTypes.NotConfigured) { return(resourceContext.ResourceLinks.HasFlag(link)); } return(_options.ResourceLinks.HasFlag(link)); }
private Task <DataArgs <ViaElement> > Response(string data) { var lastVia = _via?.GetLast(); if (lastVia == null) { throw new CoreException("Responce message error: via element is null"); } var properties = Dispatcher.Connection.CreateChannelProperties(); properties.CorrelationId = ReceivedMessage?.Properties?.CorrelationId; properties.ContentType = lastVia.queryHandlerName; properties.MessageId = lastVia.messageId; properties.Priority = lastVia.priority == 0 ? (byte)1 : lastVia.priority; properties.Type = lastVia.mqWorkKind; properties.Headers = new Dictionary <string, object>(); properties.Headers.TryAdd(MessageBasicPropertiesHeaders.VIA, this._via.ToJson()); properties.Headers.TryAdd(MessageBasicPropertiesHeaders.DIRECTION, MessageBasicPropertiesHeaders.DIRECTION_VALUE_RESPONSE); properties.Headers.TryAdd(MessageBasicPropertiesHeaders.WORKKIND, null); properties.Headers.TryAdd(MessageBasicPropertiesHeaders.VIA_TYPE, MessageBasicPropertiesHeaders.VIA_TYPE_VALUE); var link = LinkTypes.GetLinkByExchangeType(lastVia.mqWorkKind); var routeKey = string.Empty; switch (lastVia.mqWorkKind) { case ExchangeType.Fanout: routeKey = lastVia.replyTo; break; case ExchangeType.Direct: routeKey = lastVia.appId; break; case ExchangeType.Topic: routeKey = lastVia.routeKey; break; } var exchange = lastVia.mqWorkKind == ExchangeType.Fanout ? string.Empty : lastVia.replyTo; var doResolve = lastVia.doResolve; return(Push(lastVia, doResolve, link, lastVia.replyTo, exchange, routeKey, lastVia.mqWorkKind, data, properties) .ContinueWith((res) => { if (res.Exception != null) { ReceivedMessage?.Nack(false); throw res.Exception; } ReceivedMessage?.Ack(); return res.Result; })); }
public void MapEFToBOList() { var mapper = new DALLinkTypesMapper(); LinkTypes entity = new LinkTypes(); entity.SetProperties(1, "A"); List <BOLinkTypes> response = mapper.MapEFToBO(new List <LinkTypes>() { entity }); response.Count.Should().Be(1); }
private static string GenerateLink(Models.Card card, LinkTypes linkType) { var str = new Regex("[^a-zA-Z0-9 -]").Replace(card.card_name.english, ""); switch (linkType) { case LinkTypes.artifactFire: return($"https://www.artifactfire.com/artifact/cards/{str.Replace(' ', '-')}"); case LinkTypes.drawTwo: return($"https://drawtwo.gg/cards/view/{str.Replace(" ", "")}"); } return("https://playartifact.com/"); }
public LinkStroke(Point pointFrom, string formId, int anchor, LinkTypes linkType, StylusPointCollection stylusPointCollection) : base(stylusPointCollection) { guid = Guid.NewGuid(); name = "Link"; this.linkType = (int)linkType; from = new AnchorPoint(formId, anchor, ""); to = new AnchorPoint(); to.SetDefaults(); strokeType = (int)StrokeTypes.LINK; style = new LinkStyle(); style.SetDefaults(); path = new List <Coordinates>(); path.Add(new Coordinates(pointFrom)); }
public DiagnosticEventBuilder AppendLink(LinkTypes linkType, Func<string> getLink) { var link = string.Empty; try { link = getLink(); } catch(Exception ex) { link = ex.DumpToString(); } EventToBuild.Properties.AddOrUpdateProperty("Link." + linkType.ToString(), link); return this; }
public async void Get() { var mock = new ServiceMockFacade <ILinkTypesRepository>(); var record = new LinkTypes(); mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record)); var service = new LinkTypesService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.LinkTypesModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLLinkTypesMapperMock, mock.DALMapperMockFactory.DALLinkTypesMapperMock); ApiLinkTypesResponseModel response = await service.Get(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>())); }
public void BuildTopLevelLinks_GlobalAndResourceConfiguration_ExpectedLinks( LinkTypes global, LinkTypes resource, string expectedSelfLink, bool pages) { // Arrange var config = GetConfiguration(topLevelLinks: global); var primaryResource = GetArticleResourceContext(topLevelLinks: resource); _provider.Setup(m => m.GetResourceContext <Article>()).Returns(primaryResource); bool usePrimaryId = expectedSelfLink != null && expectedSelfLink.Contains("123"); string relationshipName = expectedSelfLink == _topRelatedSelf ? _relationshipName : null; IJsonApiRequest request = GetRequestManager(primaryResource, usePrimaryId, relationshipName); var builder = new LinkBuilder(config, request, _paginationContext, _provider.Object, _queryStringAccessor); // Act var links = builder.GetTopLevelLinks(); // Assert if (!pages && expectedSelfLink == null) { Assert.Null(links); } else { Assert.Equal(links.Self, expectedSelfLink); if (pages) { Assert.Equal($"{_host}/articles?foo=bar&page[size]=10", links.First); Assert.Equal($"{_host}/articles?foo=bar&page[size]=10", links.Prev); Assert.Equal($"{_host}/articles?foo=bar&page[size]=10&page[number]=3", links.Next); Assert.Equal($"{_host}/articles?foo=bar&page[size]=10&page[number]=3", links.Last); } else { Assert.Null(links.First); Assert.Null(links.Prev); Assert.Null(links.Next); Assert.Null(links.Last); } } }
public void Applies_cascading_settings_for_resource_links(LinkTypes linksInResourceContext, LinkTypes linksInOptions, LinkTypes expected) { // Arrange var exampleResourceContext = new ResourceContext { PublicName = nameof(ExampleResource), ResourceType = typeof(ExampleResource), ResourceLinks = linksInResourceContext }; var resourceGraph = new ResourceGraph(new[] { exampleResourceContext }); var request = new JsonApiRequest(); var paginationContext = new PaginationContext(); var queryStringAccessor = new EmptyRequestQueryStringAccessor(); var options = new JsonApiOptions { ResourceLinks = linksInOptions }; var linkBuilder = new LinkBuilder(options, request, paginationContext, resourceGraph, queryStringAccessor); // Act var resourceLinks = linkBuilder.GetResourceLinks(nameof(ExampleResource), "id"); // Assert if (expected == LinkTypes.Self) { resourceLinks.Self.Should().NotBeNull(); } else { resourceLinks.Should().BeNull(); } }
//开始检测 private void StartStudy() { DeviceID = int.Parse(this.txbDeviceID.Text); PatientName = this.txbPatientName.Text.Trim(); LinkType = (LinkTypes)(cboLinkType.SelectedIndex); MyConfig.Config.WebServerUrl = this.txbWebServerUrl.Text.Trim(); MyConfig.Config.TcpServerIP = this.txbTcpServerIP.Text.Trim(); MyConfig.Config.TcpServerPort = int.Parse(this.txbTcpServerPort.Text); MyConfig.SaveConfig(); //采集心电图 byte[] sampleBuf = MySampleECG.SampleECGData(); //创建检查记录 Study study = CreateStudy(sampleBuf); //发送检查记录到服务器 SendStudyToServerAsync(study); }
public static SectionHeader Parse(BinaryReader binaryReader) { ////Contract.Requires<ArgumentNullException>(binaryReader != null, "binaryReader cannot be null"); bool reverseByteOrder = false; long positionInStream = binaryReader.BaseStream.Position; uint tempMagicNumber = binaryReader.ReadUInt32(); if (!Enum.IsDefined(typeof(MagicNumbers), tempMagicNumber)) { throw new ArgumentException(string.Format("[SectionHeader.Parse] Unrecognized pcap magic number: {0}", tempMagicNumber.ToString("x"))); } MagicNumbers magicNumber = (MagicNumbers)tempMagicNumber; if (magicNumber == MagicNumbers.nanosecondIdentical || magicNumber == MagicNumbers.microsecondIdentical) { reverseByteOrder = false; } else { reverseByteOrder = true; } ushort major = binaryReader.ReadUInt16().ReverseByteOrder(reverseByteOrder); ushort minor = binaryReader.ReadUInt16().ReverseByteOrder(reverseByteOrder); int thiszone = binaryReader.ReadInt32().ReverseByteOrder(reverseByteOrder); uint sigfigs = binaryReader.ReadUInt32().ReverseByteOrder(reverseByteOrder); uint snaplen = binaryReader.ReadUInt32().ReverseByteOrder(reverseByteOrder); uint linktype = binaryReader.ReadUInt32().ReverseByteOrder(reverseByteOrder); if (!Enum.IsDefined(typeof(LinkTypes), (ushort)linktype)) { throw new ArgumentException(string.Format("[SectionHeader.Parse] Invalid LinkTypes: {0}, block begin on position {1} ", linktype, positionInStream)); } LinkTypes LinkType = (LinkTypes)linktype; SectionHeader header = new SectionHeader(magicNumber, major, minor, thiszone, sigfigs, snaplen, LinkType); return(header); }
public void BuildResourceLinks_GlobalAndResourceConfiguration_ExpectedResult(LinkTypes global, LinkTypes resource, object expectedResult) { // Arrange var config = GetConfiguration(resourceLinks: global); var primaryResource = GetArticleResourceContext(resourceLinks: resource); _provider.Setup(m => m.GetResourceContext("articles")).Returns(primaryResource); var builder = new LinkBuilder(config, GetRequestManager(), new PaginationContext(), _provider.Object, _queryStringAccessor); // Act var links = builder.GetResourceLinks("articles", _primaryId.ToString()); // Assert if (expectedResult == null) { Assert.Null(links); } else { Assert.Equal(_resourceSelf, links.Self); } }
//Links which depend on only 2 nodes public LinkData(NodeData node1, NodeData node2, LinkTypes typeValue) { linkedNodeId = new int[2] { node1.id, node2.id }; switch (typeValue) { case LinkTypes.Generalization: //Since you cannot link from generalizations, only to them, the indicator node will always be the second one //also, the second one will be named name = node1.nodeName; break; case LinkTypes.Specialization: name = node1.nodeName; break; default: name = node1.id + "-" + node2.id; break; } type = typeValue; }
public void AddLink(ulong from, ulong to, LinkTypes type) { _links.Add(new Link() { From = from, To = to, Type = type }); }
public DiagnosticEventBuilder AppendLink(LinkTypes linkType, string link) { EventToBuild.Properties.AddOrUpdateProperty("Link." + linkType.ToString(), link); return this; }
/// <summary> /// The Interface Description Block is mandatory. This block is needed to specify the characteristics of the network interface /// on which the capture has been made. In order to properly associate the captured data to the corresponding interface, the Interface /// Description Block must be defined before any other block that uses it; therefore, this block is usually placed immediately after /// the Section Header Block. /// </summary> public InterfaceDescriptionBlock(LinkTypes LinkType, int SnapLength, InterfaceDescriptionOption Options, long PositionInStream = 0) { Contract.Requires<ArgumentNullException>(Options != null, "Options cannot be null"); this.LinkType = LinkType; this.SnapLength = SnapLength; this.options = Options; this.PositionInStream = PositionInStream; }
public SectionHeader(MagicNumbers magicNumber = MagicNumbers.microsecondIdentical, UInt16 majorVersion = 2, UInt16 minorVersion = 4, int thiszone =0 , uint sigfigs = 0, uint snaplen = 65535, LinkTypes linkType = LinkTypes.Ethernet) { this.MagicNumber = magicNumber; this.MajorVersion = majorVersion; this.MinorVersion = minorVersion; this.TimezoneOffset = thiszone; this.SignificantFigures = sigfigs; this.MaximumCaptureLength = snaplen; this.LinkType = linkType; }