public virtual void Add(CUnionType union) { foreach (CTypeRef type in union.types) { Add(type); } }
public virtual void Add(CUnionType union) { foreach (CTypeRef type in union.types) Add(type); }
public virtual bool canConvertTo(CClass klass) { // check the easy cases if (ReferenceEquals(klass, this)) { return(true); } else if (ReferenceEquals(klass, null)) { return(false); } // convert union types else if (this is CUnionType) { return(canUnionConvert(klass)); } else if (klass is CUnionType) { CUnionType union = ((CUnionType)klass); foreach (CClass type in union.Types) { if (canConvertTo(type)) { return(true); } } return(false); } // check for nothing conversions else if (klass.className.Value == ("Nothing")) { return(isObject || (this is CArrayType) || this == BuiltIns.String); } else if (className.Value == ("Nothing")) { return(klass.isObject || (klass is CArrayType) || klass == BuiltIns.String); } // Variants can convert to anything but Null else if ((klass.className.Value == ("__Variant") || className.Value == ("__Variant")) && !(klass.className.Value == ("DbNull") || className.Value == ("DbNull"))) { return(true); } // check for strings else if (klass.className.Value == ("String")) { return(canConvertToString); } // Object is like variant but only for objects else if ((klass.className.Value == ("__Object") || className.Value == ("__Object")) && (klass.isObject && isObject)) { return(true); } // Check for Array casts else if (this is CArrayType && klass is CArrayType) { return(canArrayConvert((CArrayType)klass)); } // Casts are always possible to base classes. else if (CClass.IsSubClass(this, klass)) { return(true); } // Casts are always possible to interfaces. else if (CClass.Implements(this, klass)) { return(true); } // Otherwise use the convertsTo hash else { if (klass.className.Value == className.Value) { throw new ApplicationException(className.RawValue + ": Multiple class objects with the same name"); } return(convertsTo.ContainsKey(klass)); } }