Mono.CSharp.PredefinedType.Define C# (CSharp) Method

Define() public method

public Define ( ) : bool
return bool
		public bool Define ()
		{
			if (type != null)
				return true;

			Namespace type_ns = module.GlobalRootNamespace.GetNamespace (ns, true);
			var te = type_ns.LookupType (module.Compiler, name, arity, true, Location.Null);
			if (te == null)
				return false;

			if (te.Type.Kind != kind)
				return false;

			type = te.Type;
			return true;
		}

Usage Example

Example #1
0
        static bool CheckType(TypeSpec ret, TypeContainer parent, out TypeSpec original_iterator_type, out bool is_enumerable)
        {
            original_iterator_type = null;
            is_enumerable          = false;

            if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerable)
            {
                original_iterator_type = parent.Compiler.BuiltinTypes.Object;
                is_enumerable          = true;
                return(true);
            }
            if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerator)
            {
                original_iterator_type = parent.Compiler.BuiltinTypes.Object;
                is_enumerable          = false;
                return(true);
            }

            InflatedTypeSpec inflated = ret as InflatedTypeSpec;

            if (inflated == null)
            {
                return(false);
            }

            var            member_definition = inflated.MemberDefinition;
            PredefinedType ptype             = parent.Module.PredefinedTypes.IEnumerableGeneric;

            if (ptype.Define() && ptype.TypeSpec.MemberDefinition == member_definition)
            {
                original_iterator_type = inflated.TypeArguments[0];
                is_enumerable          = true;
                return(true);
            }

            ptype = parent.Module.PredefinedTypes.IEnumeratorGeneric;
            if (ptype.Define() && ptype.TypeSpec.MemberDefinition == member_definition)
            {
                original_iterator_type = inflated.TypeArguments[0];
                is_enumerable          = false;
                return(true);
            }

            return(false);
        }
All Usage Examples Of Mono.CSharp.PredefinedType::Define