コード例 #1
0
        /// <summary>The get pattern info.</summary>
        /// <param name="name">The name value.</param>
        /// <returns>The Tekla.Structures.Concrete.PatternInfo.</returns>
        public static PatternInfo GetPatternInfo(string name)
        {
            PatternInfo result = null;

            if (patternData == null)
            {
                LoadPatternData();
            }

            if (patternData != null)
            {
                foreach (PatternInfo pi in patternData)
                {
                    if (pi.Name == name)
                    {
                        result = pi;
                        break;
                    }
                }

                if (result == null)
                {
                    result = (PatternInfo)patternData[0];
                }
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// The load pattern data.
        /// </summary>
        /// <returns>
        /// The System.Boolean.
        /// </returns>
        /// <exception cref="Exception">
        /// Throws an exception.
        /// </exception>
        private static bool LoadPatternData()
        {
            patternData = new ArrayList();

            try
            {
                var path = GetPatternFileName();
                if (!path.Equals(string.Empty))
                {
                    var sr = new StreamReader(path);
                    using (sr)
                    {
                        string      line;
                        var         currentBeam = string.Empty;
                        PatternInfo pi;
                        while ((line = sr.ReadLine()) != null)
                        {
                            var items = line.Split(new[] { ';' }, 3);
                            if (items.GetLength(0) > 1)
                            {
                                if (items[0] == BeamTag)
                                {
                                    currentBeam = items[1];
                                }
                                else if (items[0] == BottomNameTag)
                                {
                                    bottomName = items[1];
                                }
                                else if (items[0] == BottomClassTag)
                                {
                                    try
                                    {
                                        bottomClass = Convert.ToInt32(items[1]);
                                    }
                                    catch
                                    {
                                    }
                                }
                                else if (items[0] == TopNameTag)
                                {
                                    topName = items[1];
                                }
                                else if (items[0] == TopClassTag)
                                {
                                    try
                                    {
                                        topClass = Convert.ToInt32(items[1]);
                                    }
                                    catch
                                    {
                                    }
                                }
                                else if (items[0] == PatternBeginTag)
                                {
                                    pi = new PatternInfo {
                                        Name = items[1], BeamType = currentBeam
                                    };
                                    pi.ReadPatternBlock(sr);
                                    patternData.Add(pi);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                throw new Exception("Exception in LoadPatternData of PatternInfo.");
            }

            return(patternData.Count < 0);
        }