public static SegmentType Switch(SegmentType segmentType)
        {
            switch (segmentType)
            {
                case SegmentType.TenantCompleteNoGuarantor:
                    return SegmentType.ApplicationContainsGuarantor;

                case SegmentType.ApplicationContainsGuarantor:
                    return SegmentType.TenantCompleteNoGuarantor;

                case SegmentType.ApplicationLikedPropertyNoViewing:
                    return SegmentType.ApplicationLikedPropertyViewingBooked;

                case SegmentType.ApplicationLikedPropertyViewingBooked:
                    return SegmentType.ApplicationLikedPropertyNoViewing;

                case SegmentType.ApplicationDeclinedGuarantor:
                    return SegmentType.ApplicationApprovedGuarantor;

                case SegmentType.ApplicationApprovedGuarantor:
                    return SegmentType.ApplicationApprovedGuarantor; //legacy issue, should not occur on new apps

                default:
                    throw new ArgumentOutOfRangeException(nameof(segmentType), segmentType, null);
            }
        }
예제 #2
0
        private static List <SegmentType> getSingleSegmentType(SegmentType segmentType)
        {
            List <SegmentType>      segmentTypes = new List <SegmentType>();
            SysDataAccessCredential dac          = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();
                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = das.GET_SINGLE_SEGMENT_TYPE;
                command.Parameters.AddWithValue(SegmentTypeDAO.AT_ID, segmentType.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            segmentTypes.Add(new SegmentType(reader));
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "getSingleSegmentType(SegmentType SegmentType)", segmentType.id.ToString());
                }
            }

            return(segmentTypes);
        }
예제 #3
0
파일: Segment.cs 프로젝트: Eamnon/Emergence
 public SegmentShape(int arm, int segment, SegmentType type, PrimitiveShape shape)
 {
     this.arm = arm;
     this.segment = segment;
     this.type = type;
     this.shape = shape;
 }
예제 #4
0
 /// <summary>
 /// Creates a new instance that implements the <see cref="IBridge" /> interface.
 /// </summary>
 /// <param name="segmentType">The current run segment type.</param>
 /// <param name="entityType">The current entity-representing type.</param>
 /// <param name="bootstrapper">
 /// The <see cref="IBootstrapper" /> instance to use.
 /// </param>
 /// <returns>
 /// A new instance that implements the <see cref="IBridge" /> interface.
 /// </returns>
 public IBridge CreateBridge(
     SegmentType segmentType,
     Type entityType,
     IBootstrapper bootstrapper)
 {
     return(new Bridge(segmentType, entityType, bootstrapper));
 }
예제 #5
0
        private static char GetLineChar(LineDirection direction, SegmentType segmentType)
        {
            switch (segmentType)
            {
            case SegmentType.Line:
                switch (direction)
                {
                case LineDirection.East:
                case LineDirection.West:
                    return('-');

                case LineDirection.North:
                case LineDirection.South:
                    return('|');

                default:
                    throw new ArgumentOutOfRangeException();
                }

            case SegmentType.Slope:
                return('+');

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #6
0
        public SegmentType Current(Point2D[] points, int offset)
        {
            SegmentType segmentType = this.isegment2DIterator_0.Current(points, offset);

            switch (segmentType)
            {
            case SegmentType.MoveTo:
            case SegmentType.LineTo:
                points[offset] = this.matrix4D_0.TransformTo2D(points[offset]);
                break;

            case SegmentType.QuadTo:
                points[offset] = this.matrix4D_0.TransformTo2D(points[offset]);
                ++offset;
                points[offset] = this.matrix4D_0.TransformTo2D(points[offset]);
                break;

            case SegmentType.CubicTo:
                points[offset] = this.matrix4D_0.TransformTo2D(points[offset]);
                ++offset;
                points[offset] = this.matrix4D_0.TransformTo2D(points[offset]);
                ++offset;
                points[offset] = this.matrix4D_0.TransformTo2D(points[offset]);
                break;
            }
            return(segmentType);
        }
예제 #7
0
        public static byte[] GetSegmentData(SegmentType segmentType, ArrayList dataSegments)
        {
            int foundCount = 0;

            byte[] result = null;
            foreach (SonyPspTagDataSegment ds in dataSegments)
            {
                if ((uint)segmentType == ds.type)
                {
                    foundCount++;
                    result = ds.segmentData;
                }
            }
            if (1 == foundCount)
            {
                return(result);
            }
            // TODO:  Implement a real exception handler for these
            else if (0 == foundCount)
            {
                throw new ApplicationException("No " + Enum.GetName(typeof(SegmentType), segmentType) +
                                               " segment found in current MpegSonyPspAtom");
            }
            else
            {
                throw new ApplicationException("Multiple (" + foundCount.ToString() +
                                               ") " + Enum.GetName(typeof(SegmentType), segmentType) +
                                               " segments found in current MpegSonyPspAtom");
            }
        }
예제 #8
0
        public static SegmentType getSegmentType(string segmentType)
        {
            Dictionary <string, SegmentType> segmentTypeDictionary = new Dictionary <string, SegmentType>()
            {
                { "MSH", SegmentType.MSH },
                { "PID", SegmentType.PID },
                { "PV1", SegmentType.PV1 },
                { "PV2", SegmentType.PV2 },
                { "ORC", SegmentType.ORC },
                { "OBR", SegmentType.OBR },
                { "OBX", SegmentType.OBX },
                { "IN1", SegmentType.IN1 },
                { "IN2", SegmentType.IN2 },
                { "IN3", SegmentType.IN3 },
                { "ZD1", SegmentType.ZD1 },
                { "ZD2", SegmentType.ZD2 },
                { "UNK", SegmentType.UNKNOWN }
            };

            SegmentType result = SegmentType.UNKNOWN;

            segmentTypeDictionary.TryGetValue(segmentType, out result);

            // return the segment type
            return(result);
        }
 internal static bool ComponentsAreEquivalent(SegmentType component, PipelineHints.PipelineSegment pipelineHints)
 {
     if (component.Equals(SegmentType.ASA) && pipelineHints.Equals(PipelineHints.PipelineSegment.AddInSideAdapter))
     {
         return true;
     }
     if (component.Equals(SegmentType.HSA) && pipelineHints.Equals(PipelineHints.PipelineSegment.HostSideAdapter))
     {
         return true;
     }
     if (component.Equals(SegmentType.HAV) && pipelineHints.Equals(PipelineHints.PipelineSegment.HostView))
     {
         return true;
     }
     if (component.Equals(SegmentType.AIB) && pipelineHints.Equals(PipelineHints.PipelineSegment.AddInView))
     {
         return true;
     }
     if ((pipelineHints.Equals(PipelineHints.PipelineSegment.Views) &&
             (component.Equals(SegmentType.HAV) || component.Equals(SegmentType.AIB) || component.Equals(SegmentType.VIEW))))
     {
         return true;
     }
     return false;
 }
예제 #10
0
        public GeneralShape2D[] GetUnbrokenShapes()
        {
            List <GeneralShape2D> generalShape2DList = new List <GeneralShape2D>();
            int pStart = 0;
            int sStart = 0;
            int pEnd   = 0;

            for (int sEnd = 0; sEnd < this.int_3; ++sEnd)
            {
                SegmentType segmentType = this.segmentType_0[sEnd];
                if (segmentType == SegmentType.MoveTo)
                {
                    if (sEnd > sStart)
                    {
                        generalShape2DList.Add(new GeneralShape2D(this, sStart, sEnd, pStart, pEnd));
                    }
                    pStart = pEnd;
                    sStart = sEnd;
                }
                pEnd += GeneralShape2D.int_1[(int)segmentType];
            }
            if (this.int_3 > sStart)
            {
                generalShape2DList.Add(new GeneralShape2D(this, sStart, this.int_3, pStart, pEnd));
            }
            return(generalShape2DList.ToArray());
        }
예제 #11
0
            private bool ParseMode()
            {
                _mode = SegmentType.Default;
                if (!SkipWhiteSpace())
                {
                    return(false);
                }
                char ch = _message[_index];

                switch (ch)
                {
                case '@':
                    _mode = SegmentType.Struct;
                    _index++;
                    break;

                case '$':
                    _mode = SegmentType.String;
                    _index++;
                    break;

                default:
                    return(true);
                }
                return(SkipWhiteSpace());
            }
        private UIVertex[] CreateLineSegment(Vector2 start, Vector2 end, SegmentType type)
        {
            Vector2[] uvs = middleUvs;
            switch (type)
            {
            case SegmentType.Start:
                uvs = startUvs;
                break;

            case SegmentType.End:
                uvs = endUvs;
                break;
            }
            Vector2 b       = new Vector2(start.y - end.y, end.x - start.x).normalized *LineThickness / 2f;
            Vector2 vector  = start - b;
            Vector2 vector2 = start + b;
            Vector2 vector3 = end + b;
            Vector2 vector4 = end - b;

            return(SetVbo(new Vector2[4]
            {
                vector,
                vector2,
                vector3,
                vector4
            }, uvs));
        }
예제 #13
0
 void OnSegmentChange(SegmentType segmenttype)
 {
     foreach (Connector connector in diagram.Connectors)
     {
         connector.SegmentType = segmenttype;
     }
 }
예제 #14
0
 public int Position; //Position in raw text of the token for error reporting
 public TemplateSegment(string text, AstNode node, int position)
 {
     Type           = node == null? SegmentType.Text : SegmentType.Expression;
     Text           = text;
     ExpressionNode = node;
     Position       = position;
 }
예제 #15
0
        public readonly bool        Oneway;                  // TODO: more general treatment of attributes?

        public Segment(int id, SegmentType type, Vector3 start, Vector3 end, bool oneway)
        {
            Id            = id;
            Type          = type;
            ControlPoints = new[] { start, end };
            Oneway        = oneway;
        }
예제 #16
0
 public FixedWidthDataSegment(string inVarName, int inStart, int inEnd, SegmentType inType)
 {
     VariableName = inVarName;
     StartIndex   = inStart;
     EndIndex     = inEnd;
     DataType     = inType;
 }
예제 #17
0
        public static SegmentType getSegmentType(string segmentType)
        {
            Dictionary <string, SegmentType> segmentTypeDictionary = new Dictionary <string, SegmentType>()
            {
                { SEGMENT_TYPE_MSH, SegmentType.MSH },
                { SEGMENT_TYPE_PID, SegmentType.PID },
                { SEGMENT_TYPE_PD1, SegmentType.PD1 },
                { SEGMENT_TYPE_PV1, SegmentType.PV1 },
                { SEGMENT_TYPE_PV2, SegmentType.PV2 },
                { SEGMENT_TYPE_ORC, SegmentType.ORC },
                { SEGMENT_TYPE_OBR, SegmentType.OBR },
                { SEGMENT_TYPE_OBX, SegmentType.OBX },
                { SEGMENT_TYPE_GT1, SegmentType.GT1 },
                { SEGMENT_TYPE_IN1, SegmentType.IN1 },
                { SEGMENT_TYPE_IN2, SegmentType.IN2 },
                { SEGMENT_TYPE_IN3, SegmentType.IN3 },
                { SEGMENT_TYPE_ZD1, SegmentType.ZD1 },
                { SEGMENT_TYPE_ZD2, SegmentType.ZD2 },
                { SEGMENT_TYPE_UNK, SegmentType.UNKNOWN }
            };

            SegmentType result = SegmentType.UNKNOWN;

            segmentTypeDictionary.TryGetValue(segmentType, out result);

            // return the segment type
            return(result);
        }
예제 #18
0
    private GameObject CreateSegment(int segmentLocation, SegmentType type)
    {
        GameObject selectedPrefab;
        Color      color;

        switch (type)
        {
        case (SegmentType.BAD):
            selectedPrefab = badSegmentPrefab;
            color          = badSegmentColor;
            break;

        case (SegmentType.ENDLEVEL):
            selectedPrefab = endLevelSegmentPrefab;
            color          = endLevelSegmentColor;
            break;

        case (SegmentType.NORMAL):
        default:
            selectedPrefab = normalSegmentPrefab;
            color          = normalSegmentColor;
            break;
        }

        GameObject seg = Instantiate(selectedPrefab, this.transform);

        seg.transform.Rotate(Vector3.up, 15 * segmentLocation);
        //  Debug.Log(seg.ToString());
        return(seg);
    }
예제 #19
0
        public List <Line> GetLines(Curve curve)
        {
            List <Line> lines = new List <Line>();

            if (curve is Polyline)
            {
                Polyline pl = (Polyline)curve;
                for (int i = 0; i < pl.NumberOfVertices; i++)
                {
                    SegmentType segmentType = pl.GetSegmentType(i);
                    if (segmentType == SegmentType.Line)
                    {
                        var lineSegment = pl.GetLineSegmentAt(i);
                        var line        = getLine(lineSegment, curve);
                        lines.Add(line);
                    }
                }
            }
            else if (curve is Line)
            {
                Line          lineCurve = (Line)curve;
                LineSegment3d segment   = new LineSegment3d(lineCurve.StartPoint, lineCurve.EndPoint);
                var           line      = getLine(segment, curve);
                lines.Add(line);
            }
            return(lines);
        }
예제 #20
0
        private static bool deleteSegmentType(SegmentType segmentType)
        {
            SysDataAccessCredential dac = DAOUtility.GetSysCredentials();
            DataAccess das = new DataAccess();

            using (SqlConnection conn = new SqlConnection(DAOUtility.GetConnectionString(dac)))
            {
                conn.Open();

                SqlCommand command = new SqlCommand();
                command.Connection  = conn;
                command.CommandType = System.Data.CommandType.Text;
                command.CommandText = das.DELETE_SEGMENT_TYPE;
                command.Parameters.AddWithValue(SegmentTypeDAO.AT_ID, segmentType.id);

                try
                {
                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            segmentType.id = DAOUtility.GetData <int>(reader, SegmentTypeDAO.ID);
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLogger.LogError(e, "DeleteSegmentType()", segmentType.id.ToString());
                }
            }
            return(true);
        }
예제 #21
0
 public SnakeNode(SnakeNode a_Follow, SegmentType a_SegmentType, GraphicType a_GraphicType, Vector2 a_Translation)
 {
     m_Follow      = a_Follow;
     SegmentType   = a_SegmentType;
     m_GraphicType = a_GraphicType;
     Position      = Vector2.Zero + a_Translation;
 }
예제 #22
0
 public Segment(
     IEnumerable <SegmentEnum> connections,
     SegmentType segmentType)
 {
     Connections = connections;
     SegmentType = segmentType;
 }
예제 #23
0
        private static TakerResult TakeSegment(string input, int offset, SegmentType type = SegmentType.Unknown)
        {
            while (true)
            {
                if (offset >= input.Length)
                {
                    return(null);
                }
                if (input[offset] != ' ')
                {
                    break;
                }
                offset++;
            }

            var         start       = offset;
            TakerResult takerResult = null;

            foreach (var taker in segmentTakers)
            {
                takerResult = taker(input, offset);
                if (takerResult?.Segment != null)
                {
                    break;
                }
            }
            return(takerResult ?? new TakerResult(new CommandSegment(SegmentType.Unknown, input.Substring(start))));
        }
예제 #24
0
        public Polycurve PolycurveToSpeckle(AcadDB.Polyline polyline) // AC polylines are polycurves with linear or arc segments
        {
            var polycurve = new Polycurve(units: ModelUnits)
            {
                closed = polyline.Closed
            };

            // extract segments
            var segments = new List <ICurve>();

            for (int i = 0; i < polyline.NumberOfVertices; i++)
            {
                SegmentType type = polyline.GetSegmentType(i);
                switch (type)
                {
                case SegmentType.Line:
                    segments.Add(LineToSpeckle(polyline.GetLineSegmentAt(i)));
                    break;

                case SegmentType.Arc:
                    segments.Add(ArcToSpeckle(polyline.GetArcSegmentAt(i)));
                    break;
                }
            }
            polycurve.segments = segments;

            polycurve.length = polyline.Length;
            polycurve.bbox   = BoxToSpeckle(polyline.GeometricExtents, true);

            return(polycurve);
        }
예제 #25
0
 public Segment(int id, SegmentType type, Vector3[] controlPoints, bool oneway)
 {
     Id            = id;
     Type          = type;
     ControlPoints = controlPoints;
     Oneway        = oneway;
 }
예제 #26
0
        private UIVertex[] CreateLineSegment(Vector2 start, Vector2 end, SegmentType type)
        {
            Vector2 offset = new Vector2((start.y - end.y), end.x - start.x).normalized *lineThickness / 2;

            var v1 = start - offset;
            var v2 = start + offset;
            var v3 = end + offset;
            var v4 = end - offset;

            //Return the VDO with the correct uvs
            switch (type)
            {
            case SegmentType.Start:
                return(SetVbo(new[] { v1, v2, v3, v4 }, startUvs));

            case SegmentType.End:
                return(SetVbo(new[] { v1, v2, v3, v4 }, endUvs));

            case SegmentType.Full:
                return(SetVbo(new[] { v1, v2, v3, v4 }, fullUvs));

            default:
                return(SetVbo(new[] { v1, v2, v3, v4 }, middleUvs));
            }
        }
예제 #27
0
        CoordinateList ReadCoordination(Polyline polyline)
        {
            var coordinateList = new CoordinateList();
            int num            = polyline.NumberOfVertices - 1;

            for (int i = 0; i <= num; i++)
            {
                SegmentType segmentType = polyline.GetSegmentType(i);
                if (segmentType == SegmentType.Arc)
                {
                    try
                    {
                        coordinateList.Add(this.GetTessellatedCurveCoordinates(polyline.GetArcSegmentAt(i)), this.AllowRepeatedCoordinates);
                    }
                    catch (Exception ex)
                    {
                        coordinateList.Add(this.ReadCoordinate(polyline.GetPoint3dAt(i)), this.AllowRepeatedCoordinates);
                    }
                }
                else
                {
                    coordinateList.Add(this.ReadCoordinate(polyline.GetPoint3dAt(i)), this.AllowRepeatedCoordinates);
                }
            }
            if (polyline.Closed)
            {
                coordinateList.Add(coordinateList[0]);
            }

            return(coordinateList);
        }
예제 #28
0
        public static IEnumerable <Curve3d> GetSegments(this Polyline pline)
        {
            List <Curve3d> res   = new List <Curve3d>();
            int            count = pline.NumberOfVertices /*-1*/;

            for (int i = 0; i < count; i++)
            {
                SegmentType type = pline.GetSegmentType(i);
                switch (type)
                {
                case SegmentType.Arc:
                {
                    res.Add(pline.GetArcSegmentAt(i));
                    break;
                }

                case SegmentType.Line:
                {
                    res.Add(pline.GetLineSegmentAt(i));
                    break;
                }
                }
            }

            return(res);
        }
예제 #29
0
            public Segment(uint aid, string url, SegmentType segmentType, long contentLength, int threads)
            {
                Aid = aid;
                FinishedThreadCount = 0;
                IsFinished          = false;
                Url    = url;
                Type   = segmentType;
                Length = contentLength;
                string directory = Bili_dl.SettingPanel.settings.TempPath + "\\";

                Directory.CreateDirectory(directory);
                Filepath        = string.Format("{0}{1}", directory, Url.Substring(Url.LastIndexOf('/') + 1, Url.IndexOf('?') - Url.LastIndexOf('/') - 1));
                Threads         = threads;
                DownloadThreads = new List <DownloadThread>();
                for (int i = 0; i < threads; i++)
                {
                    DownloadThread downloadThread;
                    if (i != threads - 1)
                    {
                        downloadThread = new DownloadThread(Aid, Filepath + "_" + (i + 1), Url, i * (Length / threads), (i + 1) * (Length / threads) - 1, Threads);
                    }
                    else
                    {
                        downloadThread = new DownloadThread(Aid, Filepath + "_" + threads, Url, (threads - 1) * (Length / threads), Length - 1, Threads);
                    }
                    downloadThread.Finished += DownloadThread_Finished;
                    DownloadThreads.Add(downloadThread);
                }
            }
예제 #30
0
파일: Segment.cs 프로젝트: Eamnon/Emergence
        public Segment(List<Vector2> vertices, int id, int parentID, int parentFace, SegmentType type)
        {
            this.vertices = new List<Vector2>(vertices);
            this.id = id;
            this.parentID = parentID;
            this.parentFace = parentFace;
            this.faces = new Dictionary<int, int>();
            this.type = type;

            collidable = false;

            // Set up the faces
            for (int i = 1; i < this.vertices.Count; i++)
            {
                faces.Add(i, -1);
            }

            this.alive = true;

            this.volume = Symet.CalculateArea(vertices);

            shape = new PrimitiveShape(this.vertices.ToArray(), Color.White, DrawType.LineStrip);

            maxHitPoints = Convert.ToInt32(volume * 5);
            hitPoints = maxHitPoints;
        }
예제 #31
0
 internal static bool ComponentsAreEquivalent(SegmentType component, PipelineHints.PipelineSegment pipelineHints)
 {
     if (component.Equals(SegmentType.AddInSideAdapter) && pipelineHints.Equals(PipelineHints.PipelineSegment.AddInSideAdapter))
     {
         return(true);
     }
     if (component.Equals(SegmentType.HostSideAdapter) && pipelineHints.Equals(PipelineHints.PipelineSegment.HostSideAdapter))
     {
         return(true);
     }
     if (component.Equals(SegmentType.HostAddInView) && pipelineHints.Equals(PipelineHints.PipelineSegment.HostView))
     {
         return(true);
     }
     if (component.Equals(SegmentType.AddInView) && pipelineHints.Equals(PipelineHints.PipelineSegment.AddInView))
     {
         return(true);
     }
     if ((pipelineHints.Equals(PipelineHints.PipelineSegment.Views) &&
          (component.Equals(SegmentType.HostAddInView) || component.Equals(SegmentType.AddInView) || component.Equals(SegmentType.View))))
     {
         return(true);
     }
     return(false);
 }
예제 #32
0
        internal static byte[] GetSegmentData(SegmentType segmentType, ArrayList dataSegments)
        {
            int foundCount = 0;

            byte[] result = null;
            foreach (MsvTagDataSegment ds in dataSegments)
            {
                if ((uint)segmentType == ds.type)
                {
                    foundCount++;
                    result = ds.segmentData;
                }
            }
            if (1 == foundCount)
            {
                return(result);
            }
            // TODO:  Implement a real exception handler for these
            else if (0 == foundCount)
            {
                throw new MsvTagNotFoundException("No " + Enum.GetName(typeof(SegmentType), segmentType) +
                                                  " segment found in current MsvBox");
            }
            else
            {
                throw new MsvDecoderException("Multiple (" + foundCount.ToString() +
                                              ") " + Enum.GetName(typeof(SegmentType), segmentType) +
                                              " segments found in current MsvBox");
            }
        }
예제 #33
0
 public Segment(SegmentType type, DateTime startTime, DateTime endTime)
 {
     this.type      = type;
     this.startTime = HelpMethods.ConvertToIso1601(startTime);
     this.endTime   = HelpMethods.ConvertToIso1601(endTime);
     lastUpdate     = HelpMethods.ConvertToIso1601(DateTime.Now);
 }
예제 #34
0
 protected ResxValueSegment(SegmentType type, int start, int end, string rawValue)
 {
     Type     = type;
     Start    = start;
     End      = end;
     RawValue = rawValue;
 }
예제 #35
0
파일: DNA.cs 프로젝트: Eamnon/Emergence
        public DNA(Shape bodyShape, float bodySize, SegmentType bodyType, float movementFrequency)
        {
            this.bodyShape = bodyShape;
            this.bodySize = bodySize;
            this.bodyType = bodyType;
            this.movementFrequency = movementFrequency;

            chromosomes = new Dictionary<int, Chromosome>();
        }
예제 #36
0
 public Frame(byte flags, SegmentType type, byte track, int channel, int bodySize,
              MemoryStream body)
 {
     this.flags = flags;
     this.type = type;
     this.track = track;
     this.channel = channel;
     this.body = body;
     _bodySize = bodySize;
 }
 internal string GetNameFromType(Type type, SegmentType component, SegmentDirection direction, Type referenceType)
 {
     if (direction.Equals(SegmentDirection.None))
     {
         return GetNameFromType(type, component, direction,
             !GetNameSpace(component, type).Equals(GetNameSpace(component, referenceType)));
     }
     else
     {
         return GetNameFromType(type, component, direction, true);
     }
 }
 internal string GetNameSpace(SegmentType component, Type contractType)
 {
     if (contractType.IsArray)
     {
         contractType = contractType.GetElementType();
     }
     object[] namespaceAttributes = contractType.GetCustomAttributes(typeof(PipelineHints.NamespaceAttribute), false);
     foreach (PipelineHints.NamespaceAttribute attr in namespaceAttributes)
     {
         if (ComponentsAreEquivalent(component, attr.Segment))
         {
             return attr.Name;
         }
     }
     String contractNamespace = contractType.FullName.Remove(contractType.FullName.LastIndexOf("."));
     if (contractNamespace.EndsWith(".Contracts") || contractNamespace.EndsWith(".Contract"))
     {
         string viewNamespace = contractNamespace.Remove(contractNamespace.LastIndexOf("."));
         if (!(component.Equals(SegmentType.ASA) || component.Equals(SegmentType.HSA)))
         {
             return viewNamespace;
         }
         else if (component.Equals(SegmentType.ASA))
         {
             return viewNamespace + ".AddInSideAdapters";
         }
         else if (component.Equals(SegmentType.HSA))
         {
             return viewNamespace + ".HostSideAdapters";
         }
     }
     else
     {
         switch (component)
         {
             case SegmentType.AIB:
                 return contractNamespace + ".AddInViews";
             case SegmentType.ASA:
                 return contractNamespace + ".AddInSideAdapters";
             case SegmentType.HAV:
                 return contractNamespace + ".HostViews";
             case SegmentType.HSA:
                 return contractNamespace + ".HostSideAdapters";
             case SegmentType.VIEW:
                 return contractNamespace + ".Views";
             default:
                 throw new InvalidOperationException("Component is not a valid type: " + component + "/" + contractType.FullName);
         }
     }
     throw new InvalidOperationException("Component is not a valid type: " + component + "/" + contractType.FullName);
 }
 public ISubscriberState GetSubscriberStateBySegmentType(SegmentType segmentType)
 {
     return _subscriberStates.FirstOrDefault(x => x.SegmentType == segmentType.ToString());
 }
예제 #40
0
파일: DNA.cs 프로젝트: Eamnon/Emergence
        // Create and attach a new chromosome to an existing one
        public int CreateChromosome(List<VectorP> instructions, int parentID, int faceID, SegmentType type, Vector2 movementVector)
        {
            int id;

            if (parentID != 0)
            {
                // See if this parent and its face exists
                if (!chromosomes.ContainsKey(parentID))
                    return -1;
                if (!chromosomes[parentID].IsFaceFree(faceID))
                    return -1;
            }
            else
                chromosomes.Clear();

            // Find an available id
            for (id = 1; true; id++)
            {
                if (!chromosomes.ContainsKey(id))
                    break;
            }

            // Attach the chromosome
            chromosomes.Add(id, new Chromosome(instructions, id, parentID, faceID, type, movementVector));

            return id;
        }
예제 #41
0
 public PathInfo(SegmentType segmentType)
 {
     this.segmentType = segmentType;
 }
        internal string GetNameFromType(Type type, SegmentType segmentType,SegmentDirection direction, bool prefix)
        {
            Type underlyingType;
            if (type.IsArray)
            {
                underlyingType = type.GetElementType();
            }
            else
            {
                underlyingType = type;
            }
            if (type.Equals(typeof(System.AddIn.Contract.INativeHandleContract)))
            {
                if (segmentType.Equals(SegmentType.VIEW) || segmentType.Equals(SegmentType.AIB) || segmentType.Equals(SegmentType.HAV))
                {
                    return typeof(System.Windows.FrameworkElement).FullName;
                }
                else
                {
                    return typeof(System.AddIn.Pipeline.FrameworkElementAdapters).FullName;
                }
            }
            if (!type.Assembly.Equals(this._rootAssembly))
            {
                return type.FullName;
            }

            String refPrefix = "";
            String refSuffix = "";
            if (direction == SegmentDirection.ContractToView)
            {
                refSuffix = "ContractToView";
            }
            else if (direction == SegmentDirection.ViewToContract)
            {
                refSuffix = "ViewToContract";
            }
            String typeName = NormalizeContractName(type);
            if (PipelineBuilder.IsViewInterface(type))
            {
                typeName = "I" + typeName;
            }
            if (prefix)
            {
                if (_sharedView && (segmentType.Equals(SegmentType.HAV) || segmentType.Equals(SegmentType.AIB) || segmentType.Equals(SegmentType.VIEW)))
                {
                    refPrefix = GetNameSpace(SegmentType.VIEW,underlyingType) + ".";
                }
                else
                {
                    refPrefix = GetNameSpace(segmentType, underlyingType) + ".";
                }
            }
            if (type.IsArray)
            {
                if (segmentType.Equals(SegmentType.ASA) || segmentType.Equals(SegmentType.HSA))
                {
                    typeName += "Array";
                }
                else
                {
                    typeName += "[]";
                }
            }
            switch (segmentType)
            {
                case SegmentType.HAV:
                    return refPrefix + typeName;
                case SegmentType.HSA:
                    return refPrefix + typeName + refSuffix + "HostAdapter";
                case SegmentType.ASA:
                    return refPrefix + typeName + refSuffix + "AddInAdapter";
                case SegmentType.AIB:
                    return refPrefix + typeName;
                case SegmentType.VIEW:
                    return refPrefix + typeName;
                default:
                    throw new InvalidOperationException("No segment type specified: " + segmentType);
            }
        }
 internal string GetNameFromType(Type type, SegmentType component,SegmentDirection direction)
 {
     return GetNameFromType(type,component,direction,true);
 }
 internal String GetAssemblyName(SegmentType component)
 {
     return _assemblyNameMapping[component];
 }
예제 #45
0
        public void Initialize(string fn)
        {
            segmentGroupMap.Add((int)SegmentGroupType.MarketSegType, new SegmentGroup(SegmentGroupType.MarketSegType));
            segmentGroupMap.Add((int)SegmentGroupType.QueryIntentType, new SegmentGroup(SegmentGroupType.QueryIntentType));
            segmentGroupMap.Add((int)SegmentGroupType.FileFormatType, new SegmentGroup(SegmentGroupType.FileFormatType));
            segmentGroupMap.Add((int)SegmentGroupType.PageLayoutType, new SegmentGroup(SegmentGroupType.PageLayoutType));
            segmentGroupMap.Add((int)SegmentGroupType.VisitType, new SegmentGroup(SegmentGroupType.VisitType));

            using (TextReader reader = new HierarchicConfigStreamReader(fn))
            {
                string line;
                string currentSegmentGroup = "";
                string currentSegment = "";

                while ((line = reader.ReadLine()) != null)
                {
                    ConfigEntry entry = new ConfigEntry();

                    if (line.StartsWith("[") && line.EndsWith("]"))
                    {
                        // Global parameters
                        if (line.Equals("[Main]"))
                        {
                            continue;
                        }

                        // Segment Group section, e.g. [Market]
                        else if (!line.Contains(SEGMENT_TYPE_SEPARATOR))
                        {
                            currentSegmentGroup = line.Substring(1, (line.Length - 2));
                            currentSegment = "";
                        }

                        // Segment subsection, e.g. [Market*en_us]
                        else
                        {
                            int SegmentSeparatorCharIndex = line.IndexOf(SEGMENT_TYPE_SEPARATOR);

                            currentSegmentGroup = line.Substring(1, (SegmentSeparatorCharIndex - 1));
                            currentSegment = line.Substring((SegmentSeparatorCharIndex + 2), (line.Length - SegmentSeparatorCharIndex - 3));
                        }
                    }

                    // Line format is: paramName=value
                    else
                    {
                        int pos = line.IndexOf('=');
                        Common.Assert(pos > 0, "Invalid configuration line: \"" + line + "\"");

                        string paramName = line.Substring(0, pos);
                        string paramValue = line.Substring(pos + 1);

                        if (!(currentSegmentGroup == ""))
                        {
                            entry.segmentGroup = (int)Enum.Parse(typeof(SegmentGroupType), currentSegmentGroup, true);
                        }

                        if (!(currentSegment == ""))
                        {
                            entry.segment = getIndexForSegment((SegmentGroupType)entry.segmentGroup, currentSegment);
                        }

                        entry.paramName = paramName;
                        entry.paramValue = paramValue;

                        if (entry.segmentGroup == -1 && entry.segment == -1)
                        {
                            if (globalParametersMap.Contains(entry))
                            {
                                globalParametersMap.Remove(entry);
                            }

                            globalParametersMap.Add(entry);
                        }

                        else if (entry.segmentGroup != -1 && entry.segment == -1)
                        {
                            if (segmentGroupParametersMap.Contains(entry))
                            {
                                segmentGroupParametersMap.Remove(entry);
                            }

                            segmentGroupParametersMap.Add(entry);
                        }

                        else if (entry.segmentGroup != -1 && entry.segment != -1)
                        {
                            if (segmentParametersMap.Contains(entry))
                            {
                                segmentParametersMap.Remove(entry);
                            }

                            segmentParametersMap.Add(entry);
                        }
                    }
                }
            }

            /*
             *  At this point, all Parameters are read.
             *  Now, SegmentParameter objects will inherit the parameters from those lists obeying the rule:
             *
             *  if segmentParameter exists --> use segment parameter
             *  else if segmentGroupParameter exists --> use segmentGroupParameter
             *  else if globalParameter exists --> use globalParameter
             *  else --> use defaultValue
             */

            propogateParameters();
            parseParameters();
            SegEnabledMask = createEnabledMask();
            SegEnabled.Reset();
            SegEnabled.Aggregate(SegEnabledMask);
            initMinCutoffFilters();
        }
예제 #46
0
 public void SetState(SegmentType type)
 {
     for (int i = 0; i < obstacles.Count; i++) {
         obstacles[i].SetActive(i == (int)type);
     }
 }
예제 #47
0
 /// <summary>
 /// Initializes a new instance of <see cref="SegmentRegister"/>.
 /// </summary>
 /// <param name="segment">The segment.</param>
 private SegmentRegister(SegmentType segment)
     : base((int)segment)
 {
     _segment = segment;
 }
예제 #48
0
 public ButtonSegment(SegmentType segmentType, Image icon, bool toggleButton = false)
 {
     SegmentType = segmentType;
     this.icon = icon.WithBoxSize(bg[0].Size);
     this.toggleButton = toggleButton;
 }
예제 #49
0
        private void InitialiseSegment(string directive)
        {
            switch (directive)
            {
                case ".text":
                    context = SegmentType.Code;
                    break;

                case ".data":
                    context = SegmentType.Data;
                    break;

                default:
                    throw new FormatException("Unknown segment type " + directive);
            }
        }
예제 #50
0
        public void BuildSegments(ParseTreeNode node)
        {
            switch (node.Term.Name)
            {
                //a program is divided into segments separated by directives
                case "program":
                    context = SegmentType.Basic;
                    BuildSegments(node.ChildNodes[0]);
                    FinaliseSegment();
                    break;

                case "directive":
                    FinaliseSegment();
                    InitialiseSegment(node.Token.Text);
                    break;

                //many rules just structure the syntax and have no semantic meaning
                case "statement_list":
                case "statement_list_cont":
                case "statement":
                case "labelled_instruction":
                case "instruction":
                case "label_opt":
                case "DAT":
                case "data_list":
                case "datum":
                    foreach (var child in node.ChildNodes)
                        BuildSegments(child);
                    break;

                //add labels to a stack which is applied whenever we reach an instruction
                case "label":
                    string labelName = node.Token.Text.TrimStart(':');
                    symbolicLabels.Push(labelName);
                    break;

                //whenever an instruction is parsed, we first pop the label stack to the current relative address
                case "basic_instruction":
                    ApplyLabels();
                    var bop = node.ChildNodes[0].ChildNodes[0].Token.Text;
                    var dest = valueBuilder.BuildValue(node.ChildNodes[1]);
                    var src = valueBuilder.BuildValue(node.ChildNodes[3]); //node 2 is a comma!
                    instructions.Enqueue(new BasicInstruction(bop, dest, src));
                    break;

                case "nonbasic_instruction":
                    ApplyLabels();
                    var nbop = node.ChildNodes[0].ChildNodes[0].Token.Text;
                    var arg = valueBuilder.BuildValue(node.ChildNodes[1]);
                    instructions.Enqueue(new NonBasicInstruction(nbop, arg));
                    break;

                case "data":
                    ApplyLabels();
                    foreach (var child in node.ChildNodes)
                        BuildSegments(child);
                    break;

                //create pseudo-instructions for constant data
                case "literal":
                    var literal = (ushort)(int)node.Token.Value;
                    instructions.Enqueue(new LiteralData(literal));
                    break;

                case "character_string":
                    var characters = (string)node.Token.Value;
                    instructions.Enqueue(new CharacterData(characters));
                    break;

                //A parse element we don't know about - this should not happen!
                default:
                    string nodeInfo = string.Format(
                        "Unknown node <{0}{1}>",
                        node.Term.Name,
                        node.Token != null ?
                            string.Format(" token=\"{0}\"", node.Token.Text) :
                            "");
                    //throw new FormatException(nodeInfo);
                    Console.WriteLine(nodeInfo);

                    foreach (var child in node.ChildNodes)
                        BuildSegments(child);
                    break;
            }
        }
예제 #51
0
        private UIVertex[] CreateLineCap(Vector2 start, Vector2 end, SegmentType type)
        {
            if (type == SegmentType.Start)
            {
                var capStart = start - ((end - start).normalized * LineThickness / 2);
                return CreateLineSegment(capStart, start, SegmentType.Start);
            }
            else if (type == SegmentType.End)
            {
                var capEnd = end + ((end - start).normalized * LineThickness / 2);
                return CreateLineSegment(end, capEnd, SegmentType.End);
            }

            Debug.LogError("Bad SegmentType passed in to CreateLineCap. Must be SegmentType.Start or SegmentType.End");
            return null;
        }
 internal string GetStaticAdapterMethodNameName(Type type, SegmentType component, SegmentDirection direction)
 {
     switch (direction)
     {
         case SegmentDirection.ContractToView:
             return "ContractToViewAdapter";
         case SegmentDirection.ViewToContract:
             return "ViewToContractAdapter";
         default:
             throw new InvalidOperationException("Must be either incoming our outgoing");
     }
 }
예제 #53
0
        private UIVertex[] CreateLineSegment(Vector2 start, Vector2 end, SegmentType type)
        {
            var uvs = middleUvs;
            if (type == SegmentType.Start)
                uvs = startUvs;
            else if (type == SegmentType.End)
                uvs = endUvs;

            Vector2 offset = new Vector2(start.y - end.y, end.x - start.x).normalized * LineThickness / 2;
            var v1 = start - offset;
            var v2 = start + offset;
            var v3 = end + offset;
            var v4 = end - offset;
            return SetVbo(new[] { v1, v2, v3, v4 }, uvs);
        }
예제 #54
0
 public SnakeNode(SnakeNode a_Follow, SegmentType a_SegmentType, GraphicType a_GraphicType, Vector2 a_Translation)
 {
     m_Follow = a_Follow;
     SegmentType = a_SegmentType;
     m_GraphicType = a_GraphicType;
     Position = Vector2.Zero + a_Translation;
 }
 internal string GetNameFromType(Type type, SegmentType component)
 {
     return GetNameFromType(type, component, SegmentDirection.None);
 }
예제 #56
0
        /// <summary>
        /// Create mask  as SegmentType object so it can by applied by Segments UDT 
        /// </summary>
        public SegmentType createEnabledMask( )
        {
            SegmentType segEnabledMask = new SegmentType();

            if (getSegmentGroupEnabled((int)SegmentGroupType.MarketSegType))
            {

                for (int i = 0; i < (int) MarketSegType.NumTypes; ++i)
                {
                    segEnabledMask.markets[i] = (getSegmentEnabled((int) SegmentGroupType.MarketSegType, i));
                }
            }

            if (getSegmentGroupEnabled((int)SegmentGroupType.QueryIntentType))
            {
                for (int i = 0; i < (int)QueryIntentType.NumTypes; ++i)
                {
                    segEnabledMask.querySegs[i] = (getSegmentEnabled((int)SegmentGroupType.QueryIntentType, i));
                }
            }

            if (getSegmentGroupEnabled((int)SegmentGroupType.FileFormatType))
            {
                for (int i = 0; i < (int)FileFormatType.NumTypes; ++i)
                {
                    segEnabledMask.fileFormats[i] = (getSegmentEnabled((int)SegmentGroupType.FileFormatType, i));
                }
            }

            if (getSegmentGroupEnabled((int)SegmentGroupType.PageLayoutType))
            {
                for (int i = 0; i < (int)PageLayoutType.NumTypes; ++i)
                {
                    segEnabledMask.pageLayouts[i] = (getSegmentEnabled((int)SegmentGroupType.PageLayoutType, i));
                }
            }

            if (getSegmentGroupEnabled((int)SegmentGroupType.VisitType))
            {
                for (int i = 0; i < (int)VisitType.NumTypes; ++i)
                {
                    if (getSegmentEnabled((int)SegmentGroupType.VisitType, i))
                    {
                        segEnabledMask.SetSourceType(((VisitType)i).ToString());
                    }
                }
            }

            return segEnabledMask;
        }
예제 #57
0
        // Functions
        public Chromosome(List<VectorP> instructions, int id, int parentID, int parentFace, SegmentType type, Vector2 movementVector)
        {
            this.instructions = new List<VectorP>(instructions);
            this.id = id;
            this.parentID = parentID;
            this.parentFace = parentFace;
            this.faces = new Dictionary<int, int>();
            this.type = type;
            this.movementVector = movementVector;

            // Set up the faces
            faces.Add(0, parentID);
            for (int i = 1; i < this.instructions.Count + 1; i++)
            {
                faces.Add(i, -1);
            }

            this.active = true;
        }
        /// <summary>
        /// draw split line
        /// </summary>
        /// <param name="split"></param>
        /// <param name="stroke"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public LineGraph AddSplitLine(int split, double stroke, double min, double max, SegmentType segType, Color color)
        {
            var tempPoints = new TwoDimensionViewPointCollection();
            var v_right = new EnumerableDataSource<TwoDimensionViewPoint>(tempPoints);
            v_right.SetXMapping(x => x.TimeStamp);
            v_right.SetYMapping(y => y.Value);
            tempPoints.Add(new TwoDimensionViewPoint(max, split));
            tempPoints.Add(new TwoDimensionViewPoint(min, split));

            LineGraph newSplit;
            if (segType == SegmentType.NotSegment)
            {
                newSplit = chart.AddLineGraph(v_right, color, stroke, "seg line");
            }
            else
            {
                newSplit = new LineGraph(v_right);
                newSplit.LinePen = new Pen(new SolidColorBrush(color), stroke);
            }
            if (segType == SegmentType.AccSegment)
            {
                _accSegLineList.Add(newSplit);
            }
            if (segType == SegmentType.VelSegment)
            {
                _velSegLineList.Add(newSplit);
            }
            if (segType == SegmentType.AngSegment)
            {
                _angSegLineList.Add(newSplit);
            }

            return newSplit;
        }
예제 #59
0
 /// <summary>
 /// Initializes a new instance of <see cref="SegmentRegister"/>.
 /// </summary>
 /// <param name="segment">The segment.</param>
 private SegmentRegister(SegmentType segment, int index)
     : base(index)
 {
     this.segment = segment;
 }
예제 #60
0
 public Segment(SegmentType type, PointF[] points)
 {
     this.type = type;
     this.points = points;
 }