예제 #1
0
        public static string ToString <T>(this IBase <T> id, Type type)
        {
            var fieldes = type.GetFields(BindingFlags.GetField | BindingFlags.Public | BindingFlags.Static);

            foreach (var field in fieldes)
            {
                if ((field.FieldType == typeof(T)) && id.Equals(field.GetValue(null)))
                {
                    string lastType  = type.Name;
                    string firstType = type.ToString().Split('.').Last().Split('+').First();
                    return(string.Format("{0}.{1}.{2}", firstType, lastType, field.Name));
                }
            }
            var NestedTypes = type.GetNestedTypes();

            foreach (var nestedType in NestedTypes)
            {
                string asNestedType = ToString(id, nestedType);
                if (asNestedType != null)
                {
                    return(asNestedType);
                }
            }

            return(null);
        }
예제 #2
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public bool Equals(BaseUnit other)
 {
     if (other == null)
     {
         return(false);
     }
     return((_sign != null && _sign.Equals(other._sign)) &&
            ((_power == null && other._power == null) ||
             (_power != null && _power.Equals(other._power))));
 }
예제 #3
0
        protected bool isUnitMatching(IBase unit, string targetOperator, BaseSet other)
        {
            foreach (UnitOperatorPair otherUnitOperator in other._unitOperatorPair)
            {
                if (targetOperator == otherUnitOperator.Operator &&
                    unit.Equals(otherUnitOperator.Unit))
                {
                    return(true);
                }
            }

            return(false);
        }