internal bool Valid(Segments.SegmentBase segmentBase)
 {
     if(this.SegmentId!=segmentBase.SegmentID)
         return false;
     System.Reflection.PropertyInfo ret=null;
     if(this.Value==null)
         ret = segmentBase.GetType().GetProperties().Where(a => a.Name == this.Field && a.GetValue(segmentBase)==null).FirstOrDefault();
     else
         ret= segmentBase.GetType().GetProperties().Where(a => a.Name == this.Field && this.Value.Equals(a.GetValue(segmentBase))).FirstOrDefault();
     if (ret == null)
         return false;
     return true;        
     
 }
Example #2
0
 internal void AddSegment(Segments.SegmentBase segment)
 {
     switch (segment.SegmentID)
     {
         case "ST":
             this.Header = segment as ST_Segment;
             break;
         case "SE":
             this.Footer = segment as SE_Segment;
             break;               
         default:
             this.Segments.Add(segment);
             break;
     }
 }
Example #3
0
 /// <summary>
 /// Segment Selector Selected Index Changed Event: Loads the selected segments fields and components to the data grid.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cbSegmentSelector_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cbSegmentSelector.SelectedIndex > -1)
         {
             Segments s = (Segments)cbSegmentSelector.SelectedItem;
             dgvComponents.Rows.Clear();
             LoadDataGrid(s);
         }
     }
     catch (Exception ex)
     {
         Log.LogException(ex).ShowDialog();
     }
 }
Example #4
0
        //---------------------------------------------------------------------------

        public CorridorSegment AddSegment(Point start, Point end, int thickness)
        {
            if (Segments.Count > 0)
            {
                CorridorSegment segment = Segments.Last();
                if (GetDirection(segment.Start, segment.End) == GetDirection(start, end))
                {
                    segment.End = end;
                    return(segment);
                }
            }
            CorridorSegment newSegment = new CorridorSegment(start, end, thickness);

            Segments.Add(newSegment);
            return(newSegment);
        }
Example #5
0
 private void LoadSegments(IEnumerable <string> lines)
 {
     foreach (var line in lines)
     {
         var fields = line.Split(';');
         var m1     = GetPoint(fields[2]);
         var m2     = GetPoint(fields[3]);
         if (m1 == null || m2 == null)
         {
             continue;
         }
         Segments.Add(new Segment {
             Id = fields[1], M1 = m1, M2 = m2, Description = fields[4]
         });
     }
 }
        public Subpath(Point startPoint, [NotNull] IEnumerable <SegmentBase> segments, bool isClosed)
        {
            StartPoint = startPoint;
            Segments   = segments.ToReadOnlyList();
            IsClosed   = isClosed;

            if (Segments.Any(x => x == null))
            {
                throw new ArgumentException();
            }

            if (Segments.Count > 0 && EndPoint != StartPoint)
            {
                _closingSegment = new LineSegment(StartPoint);
            }
        }
Example #7
0
        public Segment(string hl7Sample)
        {
            //--------------------------list of segments
            SegmentStrings = hl7Sample.Split('\r');

            Field segs = new Field(ms);

            foreach (string ms in SegmentStrings)
            {
                //Add content of each field of segment to the Field.description
                Segments.Add(ms);
            }


            Fields = segs.Fields;
        }
Example #8
0
        protected override void RemoveDart()
        {
            if (CurrentPlayerRound.Darts.Count > 0)
            {
                var dart = CurrentPlayerRound.Darts.Last();

                CurrentPlayerRound.Darts.Remove(dart);

                var segment = Segments.FirstOrDefault(s => s.Segment == dart.Segment);

                if (segment != null)
                {
                    segment.RemoveDart((CricketDart)dart);
                }
            }
        }
Example #9
0
        private void setupArgumentsAndSpread()
        {
            _arguments = new Lazy <RouteArgument[]>(() => Segments.OfType <RouteArgument>().ToArray());
            _spread    = Segments.OfType <Spread>().SingleOrDefault();

            if (!HasSpread)
            {
                return;
            }

            if (!Equals(_spread, Segments.Last()))
            {
                throw new ArgumentOutOfRangeException(nameof(Pattern),
                                                      "The spread parameter can only be the last segment in a route");
            }
        }
Example #10
0
 public MachOFile(IAddressSpace dataSource, ulong position = 0, bool dataSourceIsVirtualAddressSpace = false)
 {
     _position = position;
     _dataSourceIsVirtualAddressSpace = dataSourceIsVirtualAddressSpace;
     _reader                = new Reader(dataSource);
     _headerMagic           = new Lazy <MachHeaderMagic>(() => _reader.Read <MachHeaderMagic>(_position));
     _dataSourceReader      = new Lazy <Reader>(CreateDataSourceReader);
     _header                = new Lazy <MachHeader>(() => DataSourceReader.Read <MachHeader>(_position));
     _loadCommands          = new Lazy <Tuple <MachLoadCommand, ulong>[]>(ReadLoadCommands);
     _segments              = new Lazy <MachSegment[]>(ReadSegments);
     _sections              = new Lazy <MachSection[]>(() => Segments.SelectMany(seg => seg.Sections).ToArray());
     _virtualAddressReader  = new Lazy <Reader>(CreateVirtualReader);
     _physicalAddressReader = new Lazy <Reader>(CreatePhysicalReader);
     _uuid   = new Lazy <byte[]>(ReadUuid);
     _symtab = new Lazy <MachSymtab>(ReadSymtab);
 }
        public StockTurn(List <Trade> trades)
        {
            OpeningPrice = trades[0].TradePrice;
            LowPrice     = trades.OrderBy((Trade t) => t.TradePrice).ToList()[0].TradePrice;
            HighPrice    = trades.OrderByDescending((Trade t) => t.TradePrice).ToList()[0].TradePrice;
            ClosePrice   = trades[trades.Count - 1].TradePrice;
            double TotalPrice = 0;

            foreach (Trade t in trades)
            {
                TotalPrice += t.TradePrice;
            }
            AveragePrice = TotalPrice / (double)trades.Count;
            Trend        = AssignSegment();
            //Console.WriteLine(Trend);
        }
Example #12
0
        /// ------------------------------------------------------------------------------------
        public SaAudioDocument Clone()
        {
            var clone = new SaAudioDocument();

            clone.m_isForTmpOperation = m_isForTmpOperation;
            clone.DocVersion          = m_docVer;
            clone.Segments            = (SegmentData[])Segments.Clone();
            clone.AudioFile           = m_audioFile;
            clone.MD5HashCode         = m_MD5HashCode;
            clone.SpeakerName         = m_speakerName;
            clone.SpeakerGender       = m_serializedGender[0];
            clone.EthnologueId        = EthnologueId;
            clone.Region                = Region;
            clone.Country               = Country;
            clone.Family                = Family;
            clone.LanguageName          = LanguageName;
            clone.Dialect               = Dialect;
            clone.NoteBookReference     = NoteBookReference;
            clone.FreeFormTranslation   = FreeFormTranslation;
            clone.Transcriber           = Transcriber;
            clone.SADescription         = SADescription;
            clone.DataChunkSize         = DataChunkSize;
            clone.FormatTag             = FormatTag;
            clone.Channels              = Channels;
            clone.SamplesPerSecond      = SamplesPerSecond;
            clone.AverageBytesPerSecond = AverageBytesPerSecond;
            clone.BlockAlignment        = BlockAlignment;
            clone.BitsPerSample         = BitsPerSample;
            clone.SAFlags               = SAFlags;
            clone.RecordFileFormat      = RecordFileFormat;
            clone.RecordTimeStamp       = RecordTimeStamp;
            clone.RecordBandWidth       = RecordBandWidth;
            clone.RecordSampleSize      = RecordSampleSize;
            clone.NumberOfSamples       = NumberOfSamples;
            clone.SignalMax             = SignalMax;
            clone.SignalMin             = SignalMin;
            clone.SignalBandWidth       = SignalBandWidth;
            clone.SignalEffSampSize     = SignalEffSampSize;
            clone.CalcFreqLow           = CalcFreqLow;
            clone.CalcFreqHigh          = CalcFreqHigh;
            clone.CalcVoicingThd        = CalcVoicingThd;
            clone.CalcPercntChng        = CalcPercntChng;
            clone.CalcGrpSize           = CalcGrpSize;
            clone.CalcIntrpGap          = CalcIntrpGap;

            return(clone);
        }
Example #13
0
        private void ApplyChanges(DocumentChangeEventArgs lastChange, ReadOnlyCollection <DocumentSegment> changedSegments)
        {
            if (textDocument.TextLength == 0)
            {
                Segments.Clear();
                return;
            }
            if (lastChange == null)
            {
                return;
            }
            if (textDocument.IsInUpdate)
            {
                return;
            }
            List <DocumentSegment> affectedSegments = changedSegments.Where(v => v is PlaceholderSegment).ToList();

            foreach (var segment in affectedSegments.Where(v => v.Length == 0).ToList())
            {
                Segments.Remove(segment);
                affectedSegments.Remove(segment);
            }

            if (!affectedSegments.Any())
            {
                return;
            }
            if (!textDocument.UndoStack.CanUndo)
            {
                return;
            }
            try
            {
                textDocument.UndoStack.Undo();
            }
            catch (Exception)
            {
                return;
            }

            int    offset = lastChange.Offset;
            int    legnth = lastChange.RemovalLength;
            string text   = lastChange.InsertedText.Text;

            Replace(affectedSegments, ref offset, ref legnth, ref text);
        }
Example #14
0
        private void EnsureSegmentSize(ImageSegment seg)
        {
            Address addrAbove;

            if (seg.Size == 0)
            {
                if (!Segments.TryGetUpperBoundKey(seg.Address, out addrAbove))
                {
                    // No segment above this one, consume all remaining space.
                    seg.Size = (uint)((seg.MemoryArea.BaseAddress - seg.Address) + seg.MemoryArea.Length);
                }
                else
                {
                    seg.Size = (uint)(addrAbove - seg.Address);
                }
            }
        }
Example #15
0
        protected override void initializeSegments()
        {
            Segments.Add(new SqlSegment("(select)(.+)(from)", "([,])"));
            Segments.Add(new SqlSegment("(from)(.+?)(where |group\\s+by|having|order\\s+by | ENDOFSQL)",
                "(,|s+lefts+joins+|s+rights+joins+|s+inners+joins+)"));
            Segments.Add(new SqlSegment("(where)(.+?)(group\\s+by |having| order\\s+by | ENDOFSQL)", "(and|or)"));
            Segments.Add(new SqlSegment("(group\\s+by)(.+?)(having|order\\s+by| ENDOFSQL)", "([,])"));
            Segments.Add(new SqlSegment("(having)(.+?)(order\\s+by| ENDOFSQL)", "(and|or)"));
            Segments.Add(new SqlSegment("(order\\s+by)(.+)( ENDOFSQL)", "([,])"));

            //Segments.Add(new SqlSegment("(select)(.+)(from)", "([,])"));
            //Segments.Add(new SqlSegment("(from)(.+)( where | on | having | group by | order by | ENDOFSQL)",
            //        "(,| left join | right join | inner join )"));
            //Segments.Add(new SqlSegment("(where|on|having)(.+)( group by | order by | ENDOFSQL)", "(and|or)"));
            //Segments.Add(new SqlSegment("(group by)(.+)( order by| ENDOFSQL)", "([,])"));
            //Segments.Add(new SqlSegment("(order by)(.+)( ENDOFSQL)", "([,])"));
        }
Example #16
0
        /// <summary>
        /// Class constructor - ADT
        /// </summary>
        /// <param name="messageSubType">ADT Message Sub Type.</param>
        public AdtMessage(System.String messageSubType) : base("ADT", messageSubType)
        {
            Hl7Segment segment = new Hl7Segment(1, Hl7SegmentEnum.EVN);

            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(2, Hl7SegmentEnum.PID);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(3, Hl7SegmentEnum.PD1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(4, Hl7SegmentEnum.NK1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(5, Hl7SegmentEnum.PV1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(6, Hl7SegmentEnum.PV2);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(7, Hl7SegmentEnum.DB1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(8, Hl7SegmentEnum.OBX);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(9, Hl7SegmentEnum.AL1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(10, Hl7SegmentEnum.DG1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(11, Hl7SegmentEnum.DRG);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(12, Hl7SegmentEnum.PR1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(13, Hl7SegmentEnum.ROL);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(14, Hl7SegmentEnum.GT1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(15, Hl7SegmentEnum.IN1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(16, Hl7SegmentEnum.IN2);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(17, Hl7SegmentEnum.IN3);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(18, Hl7SegmentEnum.ACC);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(19, Hl7SegmentEnum.UB1);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(20, Hl7SegmentEnum.UB2);
            Segments.Add(segment.SegmentId.Id, segment);
            segment = new Hl7Segment(21, Hl7SegmentEnum.MRG);
            Segments.Add(segment.SegmentId.Id, segment);
        }
Example #17
0
        public RelativeValueStoragePath(params string[] segments)
        {
            if (segments is null)
            {
                throw new ArgumentNullException(nameof(segments));
            }

            foreach (var segment in segments)
            {
                if (segment.Contains('/', StringComparison.Ordinal))
                {
                    throw new ArgumentException("The segment contains invalid chars (/).");
                }

                Segments.Add(segment);
            }
        }
        public cache_file_resource_layout_table(CacheBase Cache, int Offset)
        {
            EndianReader Reader = Cache.Reader;

            Reader.SeekTo(Offset);

            #region Shared Cache Block
            Reader.SeekTo(Offset + 12);
            int iCount  = Reader.ReadInt32();
            int iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                SharedCaches.Add(new SharedCache(Cache, iOffset + 264 * i));
            }
            #endregion

            #region Page Block
            Reader.SeekTo(Offset + 24);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Pages.Add(new Page(Cache, iOffset + 88 * i));
            }
            #endregion

            #region SoundRawChunk Block
            Reader.SeekTo(Offset + 36);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                SoundRawChunks.Add(new SoundRawChunk(Cache, iOffset + 16 * i));
            }
            #endregion

            #region RawLocation Block
            Reader.SeekTo(Offset + 48);
            iCount  = Reader.ReadInt32();
            iOffset = Reader.ReadInt32() - Cache.Magic;
            for (int i = 0; i < iCount; i++)
            {
                Segments.Add(new Segment(Cache, iOffset + 16 * i));
            }
            #endregion
        }
Example #19
0
        private IEnumerable<IQrDataObject> extractSegment(string specificTagId)
        {
            var merchant = Segments.LastOrDefault(it => it.IdByConvention == QrIdentifier.MerchantAccountInformation);
            var shouldSkip = merchant == null || merchant.Id != specificTagId;
            if (shouldSkip)
            {
                yield break;
            }

            var nextValue = merchant.Value;
            while (!string.IsNullOrWhiteSpace(nextValue))
            {
                var (segment, next) = ExtractSegments(new QrDataObject(nextValue));
                nextValue = next;
                yield return segment;
            }
        }
Example #20
0
        public Expression(IEnumerable <IExpressionSegment> segments)
        {
            if (segments == null)
            {
                throw new ArgumentNullException("segments");
            }

            Segments = segments.ToList().AsReadOnly();
            if (!Segments.Any())
            {
                throw new ArgumentException("The segments set may not be empty");
            }
            if (Segments.Any(t => t == null))
            {
                throw new ArgumentException("Null reference encountered in segments set");
            }
        }
Example #21
0
        private Segments CreateSegmentsMultipleMatches(string source)
        {
            Segments segments = new Segments();

            foreach (Regex pattern in _patterns)
            {
                MatchCollection matches = pattern.Matches(source);
                if (matches != null)
                {
                    foreach (Match match in matches)
                    {
                        segments.Add(new Segment(match.Value));
                    }
                }
            }
            return(segments);
        }
Example #22
0
		internal override void ParseXml(XmlElement xml)
		{
			base.ParseXml(xml);
			foreach (XmlNode child in xml.ChildNodes)
			{
				string name = child.Name;
				if (string.Compare(name, "Segments") == 0)
				{
					foreach (XmlNode cn in child.ChildNodes)
					{
						IfcAlignmentVerticalSegment s = mDatabase.ParseXml<IfcAlignmentVerticalSegment>(cn as XmlElement);
						if (s != null)
							Segments.Add(s);
					}
				}
			}
		}
Example #23
0
        /// <summary>
        ///     Merges duplicate segments of a surface
        /// </summary>
        private void MergeDuplicates()
        {
            int i = 0;

            while (i < Segments.Count - 1)
            {
                if (Segments[i].Graph.Equals(Segments[i + 1].Graph))
                {
                    Segments[i].End = Segments[i + 1].End;
                    Segments.Remove(Segments[i + 1]);
                }
                else
                {
                    i++;
                }
            }
        }
Example #24
0
        /// <inheritdoc/>
        public ISegmentMatches Match(string stringToMatch)
        {
            var matches = new List <ISegmentMatch>();
            var strings = stringToMatch.Split(Separators);

            var segments            = Segments.ToArray();
            var currentStringIndex  = 0;
            var currentSegmentIndex = 0;

            while (currentSegmentIndex < segments.Length)
            {
                var segment = segments[currentSegmentIndex];
                var length  = strings.Length - currentStringIndex;
                if (length <= 0)
                {
                    break;
                }

                if (!segment.Fixed && currentSegmentIndex < segments.Length - 1)
                {
                    length = FindNextStop(strings, segments, currentStringIndex, currentSegmentIndex, segment, length);
                }

                if (length <= 0)
                {
                    break;
                }

                var match = MatchStrings(strings, currentStringIndex, segment, length);
                if (!match.HasMatch && !segment.Optional)
                {
                    return(new SegmentMatches(new ISegmentMatch[0]));
                }
                if (match.HasMatch)
                {
                    matches.Add(match);
                    matches.AddRange(match.Children);
                    currentStringIndex += match.Values.Count();
                }
                currentSegmentIndex++;
            }

            var segmentMatches = new SegmentMatches(matches);

            return(segmentMatches);
        }
Example #25
0
        /// <summary>
        /// Gets the URL part for this segment. Used in URLs construction.
        /// If any of the child parts is <c>null</c>, returns an empty string.
        /// </summary>
        /// <param name="valueGetter">The route value getter delegate.</param>
        /// <returns>
        /// Returns the corresponding part of the URL or <c>null</c> when the value is missing.
        /// </returns>
        public override SegmentValue GetUrlPart(Func <string, SegmentValue> valueGetter)
        {
            var parts = Segments.Select(s => s.GetUrlPart(valueGetter)).ToList();

            if (parts.Any(p => p == null) || parts.Count == 0)
            {
                return(SegmentValue.Empty);
            }

            if (ShouldBeEmpty(parts))
            {
                return(SegmentValue.Empty);
            }
            var result = string.Concat(parts.Select(s => s.ToString()));

            return(SegmentValue.Create(result));
        }
Example #26
0
        /// <summary>
        /// Loads the dynamic segment of the executable.
        /// </summary>
        /// <remarks>
        /// The ELF standard specifies that there will be at most 1 dynamic segment
        /// in an executable binary.
        /// </remarks>
        public void LoadDynamicSegment()
        {
            var dynSeg = Segments.FirstOrDefault(p => p.p_type == ProgramHeaderType.PT_DYNAMIC);

            if (dynSeg == null)
            {
                return;
            }
            var rdr = this.endianness.CreateImageReader(rawImage, (long)dynSeg.p_offset);

            var(deps, entries) = LoadDynamicSegment(rdr);
            this.Dependencies.AddRange(deps);
            foreach (var de in entries)
            {
                this.DynamicEntries[de.Tag] = de;
            }
        }
Example #27
0
        private Client(string apiKey, string username, string password, string baseUri, string apiVersion, HttpClient httpClient)
        {
            _mustDisposeHttpClient = httpClient == null;
            _httpClient            = httpClient;

            Version = typeof(Client).GetTypeInfo().Assembly.GetName().Version.ToString();

            _fluentClient = new FluentClient(new Uri($"{baseUri.TrimEnd('/')}/{apiVersion.TrimStart('/')}"), httpClient)
                            .SetUserAgent($"StrongGrid/{Version} (+https://github.com/Jericho/StrongGrid)")
                            .SetRequestCoordinator(new SendGridRetryStrategy());

            _fluentClient.Filters.Remove <DefaultErrorFilter>();
            _fluentClient.Filters.Add(new SendGridErrorHandler());

            if (!string.IsNullOrEmpty(apiKey))
            {
                _fluentClient.SetBearerAuthentication(apiKey);
            }
            if (!string.IsNullOrEmpty(username))
            {
                _fluentClient.SetBasicAuthentication(username, password);
            }

            Alerts             = new Alerts(_fluentClient);
            ApiKeys            = new ApiKeys(_fluentClient);
            Batches            = new Batches(_fluentClient);
            Blocks             = new Blocks(_fluentClient);
            Campaigns          = new Campaigns(_fluentClient);
            Categories         = new Categories(_fluentClient);
            Contacts           = new Contacts(_fluentClient);
            CustomFields       = new CustomFields(_fluentClient);
            GlobalSuppressions = new GlobalSuppressions(_fluentClient);
            InvalidEmails      = new InvalidEmails(_fluentClient);
            Lists             = new Lists(_fluentClient);
            Mail              = new Mail(_fluentClient);
            Segments          = new Segments(_fluentClient);
            SenderIdentities  = new SenderIdentities(_fluentClient);
            Settings          = new Settings(_fluentClient);
            SpamReports       = new SpamReports(_fluentClient);
            Statistics        = new Statistics(_fluentClient);
            Suppressions      = new Suppressions(_fluentClient);
            Templates         = new Templates(_fluentClient);
            UnsubscribeGroups = new UnsubscribeGroups(_fluentClient);
            User              = new User(_fluentClient);
            Whitelabel        = new Whitelabel(_fluentClient);
        }
Example #28
0
        public void InsertTemplate(int offset, Template template, out int insertionEndIndex)
        {
            var placeholder =
                Segments.FindSegmentsContaining(offset).Where(v => v is PlaceholderSegment).FirstOrDefault() as PlaceholderSegment;

            SegmentedDocument document = template.TemplateDocument;

            if (placeholder != null)
            {
                document = placeholder.TransformTemplate(template);
            }

            int replacmentLength = 0;

            Replace(ref offset, ref replacmentLength, document);
            insertionEndIndex = offset + document.TextLength;
        }
Example #29
0
        public IHttpActionResult PostSegmentsViewModel(SegmentsViewModel segmentsViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Segments Segments = new Segments();

            Mapper.CreateMap <SegmentsViewModel, Segments>();
            Segments = Mapper.Map <SegmentsViewModel, Segments>(segmentsViewModel);

            db.Segments.Add(Segments);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = segmentsViewModel.Id }, segmentsViewModel));
        }
Example #30
0
        /// <summary>
        /// Adds the specified point to the point collection.
        /// </summary>
        /// <param name="position">Position of the new point</param>
        public override void AddPoint(Point position)
        {
            // Create the new model point
            PolygonPoint modelPoint = new PolygonPoint();

            // Add the model point to the model's point collection
            Polygon.Points.Add(modelPoint);

            // Create the new view model point
            PolygonPointViewModel viewModelPoint = new PolygonPointViewModel(modelPoint, this);

            // Initialize the position of the point
            viewModelPoint.X = position.X;
            viewModelPoint.Y = position.Y;

            // Add the point to the view model point collection
            PointCollection.Add(viewModelPoint);

            // If there are at least two points on the polygon then...
            if (PointCollection.Count > 1)
            {
                // Create a segment between the points
                LineSegmentViewModel segment =
                    new LineSegmentViewModel(
                        viewModelPoint,
                        PointCollection[PointCollection.Count - 2]);

                // Add the segment
                Segments.Add(segment);
            }

            // If there are two or more points then...
            if (PointCollection.Count >= 2)
            {
                // If the mouse is over the first polygon point then...
                if (IsMouseOverFirstPolygonPoint(position))
                {
                    // Remove the last point since we are going to connect up to the first point
                    PointCollection.Remove(PointCollection[PointCollection.Count - 1]);
                    Polygon.Points.Remove(Polygon.Points[Polygon.Points.Count - 1]);

                    // Make the WPF polygon visible
                    ClosePolygon();
                }
            }
        }
Example #31
0
        private ODataPathKind CalcPathType()
        {
            if (Segments.Any(c => c.Kind == ODataSegmentKind.StreamProperty || c.Kind == ODataSegmentKind.StreamContent))
            {
                return(ODataPathKind.MediaEntity);
            }
            else if (Segments.Any(c => c.Kind == ODataSegmentKind.Ref))
            {
                return(ODataPathKind.Ref);
            }
            else if (Segments.Any(c => c.Kind == ODataSegmentKind.OperationImport))
            {
                return(ODataPathKind.OperationImport);
            }
            else if (Segments.Any(c => c.Kind == ODataSegmentKind.Operation))
            {
                return(ODataPathKind.Operation);
            }
            else if (Segments.Any(c => c.Kind == ODataSegmentKind.NavigationProperty))
            {
                return(ODataPathKind.NavigationProperty);
            }

            if (Segments.Count == 1)
            {
                ODataNavigationSourceSegment segment = Segments[0] as ODataNavigationSourceSegment;
                if (segment != null)
                {
                    if (segment.NavigationSource is IEdmSingleton)
                    {
                        return(ODataPathKind.Singleton);
                    }
                    else
                    {
                        return(ODataPathKind.EntitySet);
                    }
                }
            }
            else if (Segments.Count == 2 && Segments.Last().Kind == ODataSegmentKind.Key)
            {
                return(ODataPathKind.Entity);
            }

            return(ODataPathKind.Unknown);
        }
Example #32
0
        public async Task CreateAsync()
        {
            // Arrange
            var name       = "Last Name Miller";
            var listId     = 4;
            var conditions = new[]
            {
                new SearchCondition
                {
                    Field           = "last_name",
                    Value           = "Miller",
                    Operator        = ConditionOperator.Equal,
                    LogicalOperator = LogicalOperator.None
                },
                new SearchCondition
                {
                    Field           = "last_clicked",
                    Value           = "01/02/2015",
                    Operator        = ConditionOperator.GreatherThan,
                    LogicalOperator = LogicalOperator.And
                },
                new SearchCondition
                {
                    Field           = "clicks.campaign_identifier",
                    Value           = "513",
                    Operator        = ConditionOperator.Equal,
                    LogicalOperator = LogicalOperator.Or
                }
            };

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT)).Respond("application/json", SINGLE_SEGMENT_JSON);

            var client   = Utils.GetFluentClient(mockHttp);
            var segments = new Segments(client);

            // Act
            var result = await segments.CreateAsync(name, conditions, listId, null, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
        }
 /// <summary>
 /// Returns the segments from the source string. Where a segment returns nothing
 /// a single empty segment will be added.
 /// </summary>
 /// <param name="source"></param>
 /// <returns></returns>
 internal override Segments CreateAllSegments(string source)
 {
     Segments results = new Segments();
     foreach (RegexSegment segment in _segments)
     {
         results.Add(CreateSegments(source, segment));
     }
     return results;
 }
Example #34
0
            public void Traslate(Segments reference)
            {
                switch (reference)
                {
                    case Segments.AB:

                        break;
                }
            }
 private Segments CreateSegmentsFirstMatch(string source)
 {
     Segments segments = new Segments();
     foreach (Regex pattern in _patterns)
     {
         Match match = pattern.Match(source);
         if (match != null && match.Success)
             segments.Add(new Segment(match.Value));
         else
             segments.Add(new Segment(string.Empty));
     }
     return segments;
 }
Example #36
0
 internal Request(string userAgent, SegmentHandler handler, AutoResetEvent completeEvent)
     : base(userAgent, handler, completeEvent)
 {
     _target = Handler.CreateAllSegments(userAgent);
     _results = new Results();
 }
Example #37
0
 public InsertSegments(Segments segments)
     : base(null)
 {
     _segments = segments;
 }
 private Segments CreateSegmentsMultipleMatches(string source)
 {
     Segments segments = new Segments();
     foreach (Regex pattern in _patterns)
     {
         MatchCollection matches = pattern.Matches(source);
         if (matches != null)
         {
             foreach (Match match in matches)
             {
                 segments.Add(new Segment(match.Value));
             }
         }
     }
     return segments;
 }
Example #39
0
 internal Request(string userAgent, SegmentHandler handler)
     : base(userAgent, handler)
 {
     _target = Handler.CreateAllSegments(userAgent);
     _results = new Results();
 }
Example #40
0
        /// <summary>各部位の血流量[L/h]を取得する</summary>
        /// <param name="segment">血管の種類</param>
        /// <returns>各部位の血流量[L/h]</returns>
        public double GetBloodFlow(Segments segment)
        {
            //血流を更新
            updateBloodFlow();

            switch (segment)
            {
                case Segments.Artery:
                    return bloodFlow_Artery;
                case Segments.AVA:
                    return bloodFlow_AVA;
                case Segments.Core:
                    if (isJOSModel) return bloodFlow_Core + bloodFlow_Muscle + bloodFlow_Fat;
                    else return bloodFlow_Core;
                case Segments.DeepVein:
                    return bloodFlow_DeepVein;
                case Segments.Skin:
                    return bloodFlow_Skin;
                case Segments.SuperficialVein:
                    return bloodFlow_SuperficialVein;
                case Segments.Muscle:
                    if (isJOSModel) return 0;
                    else return bloodFlow_Muscle;
                case Segments.Fat:
                    if (isJOSModel) return 0;
                    else return bloodFlow_Fat;
                default:
                    return 0;
            }
        }
Example #41
0
 public Segments GetSegments()
 {
     OAuthResponse response = null;
     List<Segment> segments = new List<Segment>();
     Segments segmentsResponse = new Segments();
     try
     {
         response = _manager.GetOAuthResponse("GET", "audience/segments");
         if (response.ErrorFlag) throw response.Error;
         else
         {
             var repeatFlag = true;
             while (repeatFlag)
             {
                 Segments s = JsonConvert.DeserializeObject<Segments>(response.ResponseString);
                 repeatFlag = (s.next != null);
                 segments.AddRange(s.segments);
             }
         }
         segmentsResponse.segments = segments.ToArray();
     }
     catch (Exception ex)
     {
         segmentsResponse.ErrorFlag = true;
         segmentsResponse.Error = ex;
         if (response != null) segmentsResponse.ErrorMessage = response.ResponseString;
     }
     return segmentsResponse;
 }
Example #42
0
 /// <summary>各部位の熱容量[Wh/K]を取得する</summary>
 /// <param name="segment">部位</param>
 /// <returns>各部位の熱容量[Wh/K]</returns>
 public double GetHeatCapacity(Segments segment)
 {
     switch (segment)
     {
         case Segments.Artery:
             return heatCapacity_Artery;
         case Segments.Core:
             if (isJOSModel) return heatCapacity_Core + heatCapacity_Muscle + heatCapacity_Fat;
             else return heatCapacity_Core;
         case Segments.DeepVein:
             return heatCapacity_DeepVein;
         case Segments.Fat:
             if (isJOSModel) return 0;
             else return heatCapacity_Fat;
         case Segments.Muscle:
             if (isJOSModel) return 0;
             else return heatCapacity_Muscle;
         case Segments.Skin:
             return heatCapacity_Skin;
         case Segments.SuperficialVein:
             return heatCapacity_SuperficialVein;
         default:
             return 0;
     }
 }
Example #43
0
 /// <summary>各部位の温度[C]を取得する</summary>
 /// <param name="segment">部位</param>
 /// <returns>各部位の温度[C]</returns>
 public double GetTemperature(Segments segment)
 {
     switch (segment)
     {
         case Segments.Artery:
             return arteryTemperature;
         case Segments.Core:
             return coreTemperature;
         case Segments.DeepVein:
             return deepVeinTemperature;
         case Segments.Fat:
             return fatTemperature;
         case Segments.Muscle:
             return muscleTemperature;
         case Segments.Skin:
             return SkinTemperature_Contact * ContactPortionRate + SkinTemperature_NonContact * NonContactPortionRate;
         case Segments.SuperficialVein:
             return superficialVeinTemperature;
         default:
             return 0;
     }
 }
Example #44
0
 /// <summary>各部位の代謝量[W]を取得する</summary>
 /// <param name="component">部位</param>
 /// <returns>各部位の代謝量[W]</returns>
 public double GetMetabolicRate(Segments component)
 {
     switch (component)
     {
         case Segments.Core:
             if (isJOSModel) return metabolicRate_Core + metabolicRate_Fat + metabolicRate_Muscle;
             else return metabolicRate_Core;
         case Segments.Fat:
             if (isJOSModel) return 0;
             else return metabolicRate_Fat;
         case Segments.Muscle:
             if (isJOSModel) return 0;
             else return metabolicRate_Muscle;
         case Segments.Skin:
             return metabolicRate_Skin;
         default:
             return 0;
     }
 }
Example #45
0
        /// <summary>部位1から部位2への熱移動量[W]を計算する</summary>
        /// <param name="segment1">部位1</param>
        /// <param name="segment2">部位2</param>
        /// <returns>部位1から部位2への熱移動量[W]</returns>
        public double GetHeatTransfer(Segments segment1, Segments segment2)
        {
            double hTransfer = 0;
            const double RCS = HumanBody.RHO_C / 3.6d;  //流量単位がL/hなので、ここで単位を調整

            //温度差を計算
            double deltaT = GetTemperature(segment1) - GetTemperature(segment2);

            //伝導による熱移動を計算
            hTransfer = deltaT * GetHeatConductance(segment1, segment2);

            //熱交換を行わない部位の場合
            if (((segment1 | segment2) & (Segments.AVA | Segments.None)) != Segments.None)
            {
                return 0;
            }
            //動脈と表在静脈の場合
            else if ((segment1 | segment2) == (Segments.Artery | Segments.SuperficialVein))
            {
                //AVA血流による熱移動を追加
                if (segment1 == Segments.Artery) hTransfer += GetTemperature(segment1) * bloodFlow_AVA * RCS;
            }
            //component1が動脈の場合
            else if (segment1 == Segments.Artery && segment2 != Segments.DeepVein)
            {
                //動脈流による熱移動を追加
                hTransfer += GetBloodFlow(segment2) * GetTemperature(segment1) * RCS;
            }
            //component2が静脈の場合
            else if (segment2 == Segments.DeepVein && segment1 != Segments.Artery)
            {
                //静脈流による熱移動を追加
                hTransfer += GetBloodFlow(segment1) * GetTemperature(segment1) * RCS;
            }

            return hTransfer;
        }
Example #46
0
 /// <summary>部位間の熱コンダクタンス[W/K]を取得する</summary>
 /// <param name="segment1">部位1</param>
 /// <param name="segment2">部位2</param>
 /// <returns>部位間の熱コンダクタンス[W/K]</returns>
 public double GetHeatConductance(Segments segment1, Segments segment2)
 {
     switch (segment1 | segment2)
     {
         case (Segments.Core | Segments.Muscle):
             return heatConductance_Core_Muscle;
         case (Segments.Muscle | Segments.Fat):
             return heatConductance_Muscle_Fat;
         case (Segments.Fat | Segments.Skin):
             return heatConductance_Fat_Skin;
         case (Segments.Core | Segments.Skin):
             return heatConductance_Core_Skin;
         case (Segments.Artery | Segments.DeepVein):
             return heatConductance_Artery_DeepVein;
         case (Segments.DeepVein | Segments.Core):
         case (Segments.Artery | Segments.Core):
             return heatConductance_Vein_Core;
         case (Segments.SuperficialVein | Segments.Skin):
             return heatConductance_SuperficialVein_Skin;
         default:
             return 0;
     }
 }