当前位置: 首页>>代码示例>>C#>>正文


C# Component.GetProperty方法代码示例

本文整理汇总了C#中Component.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Component.GetProperty方法的具体用法?C# Component.GetProperty怎么用?C# Component.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Component的用法示例。


在下文中一共展示了Component.GetProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Format

        public string Format(Component component)
        {
            Regex variable = new Regex("\\$[a-zA-z]+ ");
            string plainVars = variable.Replace(Value, new MatchEvaluator(delegate(Match match)
            {
                string propertyName = match.Value.Replace("$", "").Trim().ToLowerInvariant();
                ComponentProperty propertyInfo = component.FindProperty(propertyName);
                if (propertyInfo != null)
                    return component.GetProperty(propertyInfo).ToString();
                return "";
            }));

            variable = new Regex("\\$[a-zA-Z]+[\\(\\)a-z_0-9]+ ");
            string formattedVars = variable.Replace(plainVars, new MatchEvaluator(delegate(Match match)
            {
                Regex propertyNameRegex = new Regex("\\$[a-zA-z]+");
                string propertyName = propertyNameRegex.Match(match.Value).Value.Replace("$", "").Trim().ToLowerInvariant();
                ComponentProperty propertyInfo = component.FindProperty(propertyName);
                if (propertyInfo != null)
                {
                    return ApplySpecialFormatting(component.GetProperty(propertyInfo), match.Value.Replace(propertyNameRegex.Match(match.Value).Value, "").Trim());
                }
                return "";
            }));

            Regex regex = new Regex(@"\\[uU]([0-9A-F]{4})");
            return regex.Replace(formattedVars, match => ((char)Int32.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString());
        }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:28,代码来源:ComponentPropertyFormat.cs

示例2: Matches

 public bool Matches(Component component)
 {
     foreach (var setter in Setters)
     {
         if (!setter.Value.Equals(component.GetProperty(component.FindPropertyBySerializedName(setter.Key))))
             return false;
     }
     return true;
 }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:9,代码来源:ComponentConfiguration.cs

示例3: IsMet

        public bool IsMet(Component component)
        {
            if (Type == ConditionType.Empty)
            {
                return true;
            }
            else if (Type == ConditionType.State)
            {
                if (VariableName.ToLower() == "horizontal")
                {
                    if (Comparison == ConditionComparison.Equal)
                        return (component.Orientation == Orientation.Horizontal) == (bool)CompareTo.Value;
                    else
                        return (component.Orientation == Orientation.Horizontal) != (bool)CompareTo.Value;
                }
            }
            else
            {
                var propertyValue = component.GetProperty(component.FindProperty(VariableName));

                if (Comparison == ConditionComparison.Empty)
                    return propertyValue.IsEmpty();
                else if (Comparison == ConditionComparison.NotEmpty)
                    return !propertyValue.IsEmpty();

                int cv = propertyValue.CompareTo(CompareTo);
                switch (Comparison)
                {
                    case ConditionComparison.Equal:
                        return cv == 0;
                    case ConditionComparison.Greater:
                        return cv == 1;
                    case ConditionComparison.GreaterOrEqual:
                        return cv >= 0;
                    case ConditionComparison.Less:
                        return cv == -1;
                    case ConditionComparison.LessOrEqual:
                        return cv <= 0;
                    case ConditionComparison.NotEqual:
                        return cv != 0;
                }
            }

            return false;
        }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:45,代码来源:ConditionTreeLeaf.cs


注:本文中的Component.GetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。