IsAssignableFrom() public method

public IsAssignableFrom ( Type type ) : bool
type Type
return bool
Beispiel #1
0
 private object CreateFromString(Type targetType,string name)
 {
     object instance = null;
     if (FrameworkElement != null)
     {
         instance = FrameworkElement.FindResource(name);
         if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
         instance = null;
     }
     if(Contains(name))
     {
         instance = this[name];
         if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
         instance = null;
     }
     if (!RequireExactMatch)
     {
         foreach (string key in Keys)
         {
             if (key.Contains(name))
             {
                 instance = this[key];
                 if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
             }
         }
     }
     return null;
 }
Beispiel #2
0
        /// <summary>
        /// Copies the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="target">The target.</param>
        /// <param name="type">The type the source and target should be interpreded as.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        public static void Copy(ICopy source, ICopy target, Type type, CopyToProgress progressDelegate)
        {
            if (!(type.IsAssignableFrom(source.GetType()) && type.IsAssignableFrom(target.GetType())))
                throw new ArgumentException("Source and Target must implement " + type.ToString());

            foreach (PropertyInfo info in type.GetProperties())
            {
                if (type.GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true) ||
                    source.GetType().GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true) ||
                    target.GetType().GetProperty(info.Name).IsDefined(typeof(IgnoreCopyAttribute), true))
                    continue;

                if (typeof(ICopy).IsAssignableFrom(info.PropertyType))
                {
                    ICopy copyObject = (info.GetValue(source, null) as ICopy);
                    if (copyObject != null)
                        copyObject.CopyTo(info.GetValue(target, null) as ICopy, progressDelegate);
                }

                if (info.IsDefined(typeof(ValueCopyAttribute), true))
                {
                    object value = info.GetValue(source, null);
                    if (value != null)
                        info.SetValue(target, value, null);
                }
            }
        }
        public override IEnumerable<TestCaseParameter> CreateInstances(Type targetType)
        {
            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            foreach (MethodInfo method in ReflectionHelper.GetMethods(this.FactoryType, typeof(FactoryAttribute)))
            {
                if (method.GetParameters().Length > 0)
                    continue;

                FactoryAttribute factoryAttribute = ReflectionHelper.GetAttribute<FactoryAttribute>(method);

                // the method returns the type or a enumerable collection
                if (targetType.IsAssignableFrom(method.ReturnType))
                    yield return CreateSingleInstance(method);
                else if (
                       targetType.IsAssignableFrom(typeof(IEnumerable<>).MakeGenericType(targetType))
                    || (
                            targetType.IsAssignableFrom(typeof(IEnumerable))
                           && targetType.IsAssignableFrom(factoryAttribute.FactoredType)
                        )
                    )
                {
                    foreach (TestCaseParameter parameter in CreateMultipleInstances(method))
                        yield return parameter;
                }
            }
        }
Beispiel #4
0
 public static ValueViewModel GetAppropriateViewModel(Type PropertyType, Object ValueObject)
 {
     if (PropertyType.IsAssignableFrom(typeof (int))) return new IntValueViewModel(ValueObject);
     if (PropertyType.IsAssignableFrom(typeof (bool))) return new BooleanValueViewModel(ValueObject);
     if (PropertyType.IsAssignableFrom(typeof (string))) return new StringValueViewModel(ValueObject);
     throw new ApplicationException("Не поддерживаемый для редактирования тип свойства!");
 }
        public Type GetActualType(Type type, IAdviceRequester adviceRequester)
        {
            Type result = null;

            if (type != null)
            {
                if (type != typeof(string))
                {
                    if (!typeof(IDictionary).IsAssignableFrom(type) &&
                        (!type.IsGenericType || type.GetGenericArguments().Length != 2 || !typeof(IDictionary<,>).MakeGenericType(type.GetGenericArguments()).IsAssignableFrom(type)))
                    {
                        if (type.IsClass && typeof(IEnumerable).IsAssignableFrom(type))
                            result = type;
                        else
                        {
                            if (type.IsInterface && type.IsAssignableFrom(typeof(List<object>)))
                                result = typeof(List<object>);
                            else
                            {
                                if (type.IsGenericType && type.GetGenericArguments().Length == 1 && type.IsAssignableFrom(typeof(List<>).MakeGenericType(type.GetGenericArguments())))
                                    result = typeof(List<>).MakeGenericType(type.GetGenericArguments());
                            }
                        }
                    }
                }
            }

            if (_log.IsDebugEnabled)
                _log.Debug("Converted '" + type + "' to '" + result + "'.");

            return result;
        }
Beispiel #6
0
		static object InternalConvert(object arg, Type source, Type target, bool isAddress)
		{

            if (target == source)
                return arg;
            if (target.IsValueType)
            {
                if (source.IsValueType)
                {
                    if (!CanConvert (Type.GetTypeCode (target)))
                        throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.NoConversionPossibleTo, DataContract.GetClrTypeFullName(target))));
                    else
						return target;
                }
                else if (source.IsAssignableFrom(target))
					return arg;
                else
                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.IsNotAssignableFrom, DataContract.GetClrTypeFullName(target), DataContract.GetClrTypeFullName(source))));
            }
            else if (target.IsAssignableFrom(source))
				return arg;
            else if (source.IsAssignableFrom(target))
				return arg;
            else if (target.IsInterface || source.IsInterface)
				return arg;
            else
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.IsNotAssignableFrom, DataContract.GetClrTypeFullName(target), DataContract.GetClrTypeFullName(source))));
		}
        public ViewModelConfig CreateViewModelConfig(Type type)
        {
            if (!type.IsBaseObject() && !type.IsDefined(typeof(ComplexTypeAttribute))) return null;

            string serviceName = "";

            if (type.IsBaseObject())
            {
                if (type.IsAssignableFrom(typeof(HCategory)))
                    serviceName = typeof(IBaseCategoryService<>).GetTypeName();
                else if (type.IsAssignableFrom(typeof(ICategorizedItem)))
                    serviceName = typeof(IBaseCategorizedItemService<>).GetTypeName();
                else
                    serviceName = typeof(IBaseObjectService<>).GetTypeName();
            }

            return new ViewModelConfig(
                mnemonic: type.GetTypeName(),
                entity: type.GetTypeName(),
                listView: new ListView(),
                detailView: new DetailView(),
                lookupProperty:
                    type.IsBaseObject()
                        ? (type.GetProperty("Title") ?? type.GetProperty("Name") ?? type.GetProperty("ID")).Name
                        : "",
                service: serviceName);
        }
        public void Handle_error(string id_, string jwtResponse, Type expectedExceptionType, int expectedCode, int expectedStatus, string expectedMessage, string expectedDeveloperMessage)
        {
            var testApiKey = ClientApiKeys.Builder()
                .SetId("2EV70AHRTYF0JOA7OEFO3SM29")
                .SetSecret("goPUHQMkS4dlKwl5wtbNd91I+UrRehCsEDJrIrMruK8")
                .Build();
            var fakeRequestExecutor = Substitute.For<IRequestExecutor>();
            fakeRequestExecutor.ApiKey.Returns(testApiKey);

            this.dataStore = TestDataStore.Create(fakeRequestExecutor, Caches.NewInMemoryCacheProvider().Build());

            var request = new DefaultHttpRequest(HttpMethod.Get, new CanonicalUri($"https://foo.bar?{IdSiteClaims.JwtResponse}={jwtResponse}"));

            IIdSiteSyncCallbackHandler callbackHandler = new DefaultIdSiteSyncCallbackHandler(this.dataStore, request);

            try
            {
                var accountResult = callbackHandler.GetAccountResult();

                throw new Exception("Should not reach here. Proper exception was not thrown.");
            }
            catch (IdSiteRuntimeException e) when (expectedExceptionType.IsAssignableFrom(e.GetType()))
            {
                e.Code.ShouldBe(expectedCode);
                e.HttpStatus.ShouldBe(expectedStatus);
                e.Message.ShouldBe(expectedMessage);
                e.DeveloperMessage.ShouldBe(expectedDeveloperMessage);
            }
            catch (Exception e) when (expectedExceptionType.IsAssignableFrom(e.GetType()))
            {
                e.Message.ShouldStartWith(expectedMessage);
            }
        }
		public bool CanReadFile (FilePath file, Type expectedObjectType)
		{
			if (expectedObjectType.IsAssignableFrom (typeof(Solution)) && String.Compare (file.Extension, ".sln", true) == 0) {
				string ver = GetSlnFileVersion (file);
				if (ver == "7.00" || ver == "8.00")
					return true;
			}
			
			if (!expectedObjectType.IsAssignableFrom (typeof(DotNetProject)))
				return false;
			
			if (String.Compare (file.Extension, ".csproj", true) != 0 &&
				String.Compare (file.Extension, ".vbproj", true) != 0)
				return false;

			try {
				using (XmlReader xr = XmlReader.Create (file)) {
					xr.MoveToContent ();
					if (xr.NodeType == XmlNodeType.Element && String.Compare (xr.LocalName, "VisualStudioProject") == 0)
						return true;
				}
			} catch {
				return false;
			}

			return false;
		}
 /// <summary>
 /// Get a function that coerces a sequence of one type into another type.
 /// This is primarily used for aggregators stored in ProjectionExpression's, 
 /// which are used to represent the final transformation of the entire result set of a query.
 /// </summary>
 public static LambdaExpression Aggregate(Type expectedType, Type actualType)
 {
     Type actualElementType = actualType.GetSequenceElementType();
     
     if (!expectedType.IsAssignableFrom(actualType))
     {
         Type expectedElementType = expectedType.GetSequenceElementType();
         ParameterExpression p = Expression.Parameter(actualType, "p");
         Expression body = null;
         
         if (expectedType.IsAssignableFrom(actualElementType))
             body = Expression.Call(typeof(Enumerable), "SingleOrDefault", new Type[] { actualElementType }, p);                
         else if (expectedType.IsGenericType && expectedType.GetGenericTypeDefinition() == typeof(IQueryable<>))
             body = Expression.Call(typeof(Queryable), "AsQueryable", new Type[] { expectedElementType }, 
                 CoerceElement(expectedElementType, p));
         else if (expectedType.IsArray && expectedType.GetArrayRank() == 1)
             body = Expression.Call(typeof(Enumerable), "ToArray", new Type[] { expectedElementType }, 
                 CoerceElement(expectedElementType, p));
         else if (expectedType.IsAssignableFrom(typeof(List<>).MakeGenericType(actualElementType)))
             body = Expression.Call(typeof(Enumerable), "ToList", new Type[] { expectedElementType }, 
                 CoerceElement(expectedElementType, p));
         else
         {
             ConstructorInfo ci = expectedType.GetConstructor(new Type[] { actualType });
             if (ci != null)
                 body = Expression.New(ci, p);
         }
         
         if (body != null)
             return Expression.Lambda(body, p);
     }
     return null;
 }
		/// <summary>
		/// Get a function that coerces a sequence of one type into another type.
		/// This is primarily used for aggregators stored in ProjectionExpression's, which are used to represent the 
		/// final transformation of the entire result set of a query.
		/// </summary>
		public static LambdaExpression GetAggregator(Type expectedType, Type actualType)
		{
			Type actualElementType = TypeHelper.GetElementType(actualType);
			if (!expectedType.IsAssignableFrom(actualType))
			{
				Type expectedElementType = TypeHelper.GetElementType(expectedType);
				ParameterExpression p = Expression.Parameter(actualType, "p");
				Expression body = null;
				if (expectedType.IsAssignableFrom(actualElementType))
				{
					body = Expression.Call(typeof(Enumerable), "SingleOrDefault", new Type[] { actualElementType }, p);
				}
				else if (expectedType.IsGenericType
				         &&
				         (expectedType == typeof(IQueryable) || expectedType == typeof(IOrderedQueryable)
				          || expectedType.GetGenericTypeDefinition() == typeof(IQueryable<>)
				          || expectedType.GetGenericTypeDefinition() == typeof(IOrderedQueryable<>)))
				{
					body = Expression.Call(
						typeof(Queryable), "AsQueryable", new Type[] { expectedElementType }, CoerceElement(expectedElementType, p));
					if (body.Type != expectedType)
					{
						body = Expression.Convert(body, expectedType);
					}
				}
				else if (expectedType.IsArray && expectedType.GetArrayRank() == 1)
				{
					body = Expression.Call(
						typeof(Enumerable), "ToArray", new Type[] { expectedElementType }, CoerceElement(expectedElementType, p));
				}
				else if (expectedType.IsGenericType && expectedType.GetGenericTypeDefinition().IsAssignableFrom(typeof(IList<>)))
				{
					var gt = typeof(DeferredList<>).MakeGenericType(expectedType.GetGenericArguments());
					var cn =
						gt.GetConstructor(new Type[] { typeof(IEnumerable<>).MakeGenericType(expectedType.GetGenericArguments()) });
					body = Expression.New(cn, CoerceElement(expectedElementType, p));
				}
				else if (expectedType.IsAssignableFrom(typeof(List<>).MakeGenericType(actualElementType)))
				{
					// List<T> can be assigned to expectedType
					body = Expression.Call(
						typeof(Enumerable), "ToList", new Type[] { expectedElementType }, CoerceElement(expectedElementType, p));
				}
				else
				{
					// some other collection type that has a constructor that takes IEnumerable<T>
					ConstructorInfo ci = expectedType.GetConstructor(new Type[] { actualType });
					if (ci != null)
					{
						body = Expression.New(ci, p);
					}
				}
				if (body != null)
				{
					return Expression.Lambda(body, p);
				}
			}
			return null;
		}
Beispiel #12
0
		public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor)
		{
			if (expectedType.IsAssignableFrom(typeof(WorkspaceItem)))
				return DubFileManager.Instance.LoadAsSolution(file, monitor);
			if (expectedType.IsAssignableFrom(typeof(SolutionEntityItem)))
				return DubFileManager.Instance.LoadProject(file, Ide.IdeApp.Workspace.GetAllSolutions().First(), monitor);
			return null;
		}
        /// <summary>
        /// Gets an array of <see cref="Type"/>s that are assignable from the given type with the 
        /// specified <see cref="IDefinitionManager"/>.
        /// </summary>
        /// <param name="type">The <see cref="System.Type"/> to find other types that are 
        /// assignable from this type.</param>
        /// <returns>An array of <see cref="Type"/>s which the given type is assignable from.</returns>
        public static Type[] GetTypesAssignableFrom(this IDefinitionManager definitions, Type type)
        {
            Type[] result = definitions.GetDefinitions()
                .Where(definition => type.IsAssignableFrom(definition.ItemType)
                    && type.IsAssignableFrom(definition.ItemType))
                .Select(definition => definition.ItemType)
                .ToArray();

            return result;
        }
 public static IEnumerable<Type> GetAllTypesImplementingOpenGenericType(this Assembly assembly, Type openGenericType)
 {
     return from type in assembly.GetExportedTypes()
         from z in type.GetInterfaces()
         let y = type.BaseType
         where
             (y != null && y.IsGenericType && openGenericType.IsAssignableFrom(y.GetGenericTypeDefinition())) ||
             (z.IsGenericType && openGenericType.IsAssignableFrom(z.GetGenericTypeDefinition()))
         select type;
 }
		public bool CanReadFile (FilePath file, Type expectedType)
		{
			string ext = Path.GetExtension (file).ToLower ();
			
			if (ext == ".mds" && expectedType.IsAssignableFrom (typeof(Solution)))
				return true;
			else if (ext == ".mdp" && expectedType.IsAssignableFrom (typeof(Project)))
				return true;
			else if (ext == ".mdw" && expectedType.IsAssignableFrom (typeof(WorkspaceItem)))
				return true;
			return ext == ".mdse" && expectedType.IsAssignableFrom (typeof(SolutionEntityItem));
		}
Beispiel #16
0
		public static bool IsAssignable (Type to, Type from) {
			if (to == null)
				throw new ArgumentNullException("to");

			if (to.IsAssignableFrom (from))
				return true;

			if (to.IsGenericType && from.IsGenericTypeDefinition)
				return to.IsAssignableFrom (from.MakeGenericType (to.GetGenericArguments ()));

			return false;
		}
Beispiel #17
0
        /// <summary>
        /// Initialize an instance of ObjectMapper
        /// </summary>
        /// <param name="inputType"></param>
        /// <param name="outputType"></param>
        public ObjectMapper(Type inputType, Type outputType)
        {
            Check.Require(inputType, "inputType");
            Check.Require(outputType, "outputType");
            Check.Require(!inputType.IsAssignableFrom(typeof(DataTable)), "intput type could not be DataTable,pls use datarow instead.");
            Check.Require(!outputType.IsAssignableFrom(typeof(DataTable)), "output type could not be DataTable,pls use datarow instead.");
            Check.Require(!outputType.IsAssignableFrom(typeof(IDataReader)), "output type could not be IDataReader.");

            this.inputType = inputType;
            this.outputType = outputType;
            this.initType = outputType;
        }
Beispiel #18
0
 public static IEnumerable<Type> GetAllTypesImplementingOpenGenericType(Type openGenericType, Assembly assembly)
 {
     return from x in Assembly.GetAssembly(typeof(Program)).GetTypes()
            from z in x.GetInterfaces()
            let y = x.BaseType
            where
            (y != null && y.IsGenericType &&
            openGenericType.IsAssignableFrom(y.GetGenericTypeDefinition())) ||
            (z.IsGenericType &&
            openGenericType.IsAssignableFrom(z.GetGenericTypeDefinition()))
            select x;
 }
 public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
 {
     if (absoluteUri != null && absoluteUri.IsFile && ofObjectToReturn.IsAssignableFrom(typeof(FileStream)))
     {
         // local file: return a stream on it. This might be the main file we are checking.
         var path = absoluteUri.LocalPath;
         return new FileStream(path, FileMode.Open);
     }
     if (ofObjectToReturn.IsAssignableFrom(typeof(MemoryStream)))
         return new MemoryStream();
     return null;
 }
Beispiel #20
0
		public bool CanReadFile (FilePath file, Type expectedType)
		{
			if (expectedType.IsAssignableFrom (typeof(Solution)) && slnFileFormat.CanReadFile (file, this))
				return true;
			else if (expectedType.IsAssignableFrom (typeof(SolutionEntityItem))) {
				if (!MSBuildProjectService.CanReadFile (file))
					return false;
				//TODO: check ProductVersion first
				return SupportsToolsVersion (ReadToolsVersion (file));
			}
			return false;
		}
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            IPAddress addr = value as IPAddress;

            if (addr == null)
                return base.ConvertTo(context, culture, value, destinationType);
            else if (destinationType.IsAssignableFrom(typeof(String)))
                return addr.ToString();
            else if (destinationType.IsAssignableFrom(typeof(byte[])))
                return addr.GetAddressBytes();
            else
                return base.ConvertTo(context, culture, value, destinationType);
        }
        /// <summary>
        /// During serialization, deserialization, and schema import and export, returns a data contract type that substitutes the specified type.
        /// </summary>
        /// <returns>
        /// The <see cref="T:System.Type"/> to substitute for the <paramref name="type"/> value. This type must be serializable by the <see cref="T:System.Runtime.Serialization.DataContractSerializer"/> . For example, it must be marked with the <see cref="T:System.Runtime.Serialization.DataContractAttribute"/> attribute or other mechanisms that the serializer recognizes. 
        /// </returns>
        /// <param name="type">
        /// The CLR type <see cref="T:System.Type"/> to substitute. 
        /// </param>
        public Type GetDataContractType(Type type)
        {
            if (type.IsAssignableFrom(typeof(StateTracker)))
            {
                return typeof(StateTrackerSurrogated);
            }

            if (type.IsAssignableFrom(typeof(StateMachineInfo)))
            {
                return typeof(StateMachineInfoSurrogated);
            }

            return type;
        }
Beispiel #23
0
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (targetType.IsAssignableFrom(typeof(bool)) && targetType.IsAssignableFrom(typeof(string)))
			{
				throw new ArgumentException("EnumBoolConverter can only convert to boolean or string.");
			}

			if (targetType == typeof(string))
			{
				return value.ToString();
			}

			return string.Compare(value.ToString(), (string)parameter, StringComparison.InvariantCultureIgnoreCase) == 0;
		}
		public bool CanReadFile (FilePath file, Type expectedType)
		{
			if (file.FileName != "Makefile") return false;
			MonoMakefile mkfile = new MonoMakefile (file);
			if (mkfile.Content.IndexOf ("build/rules.make") == -1) return false;
			
			if (mkfile.GetVariable ("LIBRARY") != null) return expectedType.IsAssignableFrom (typeof(DotNetProject));
			if (mkfile.GetVariable ("PROGRAM") != null) return expectedType.IsAssignableFrom (typeof(DotNetProject));
			string subdirs = mkfile.GetVariable ("SUBDIRS");
			if (subdirs != null && subdirs.Trim (' ','\t') != "")
				return expectedType.IsAssignableFrom (typeof(Solution)) || expectedType.IsAssignableFrom (typeof(SolutionFolder));
			
			return false;
		}
 public static bool CheckIsVBugClass(Type type)
 {
     if (vBugClassTable.ContainsKey(type)) {
         return vBugClassTable[type];
     } else {
         if (type.FullName.ToLower().Contains("vbug") || type.IsAssignableFrom(typeof(vBugHiddenUniqueComponent<>)) || type.IsAssignableFrom(typeof(BaseActivityGrabber<>))){
             vBugClassTable.Add(type, true);
             return true;
         } else {
             vBugClassTable.Add(type, false);
             return false;
         }
     }
 }
 private object Create(Type targetType,string name)
 {
     if(Cache.ContainsKey(name))
     {
         var instance = Cache[name];
         if (instance != null && targetType.IsAssignableFrom(instance.GetType())) return instance;
     }
     if (Assemblies != null)
     {
         foreach (var assembly in Assemblies)
         {
             foreach (var manifestResourceName in assembly.GetManifestResourceNames())
             {
                 bool ignore = false;
                 if(ManifestResourceNameIgnorePatterns != null)
                 {
                     foreach(var ignore_pattern in ManifestResourceNameIgnorePatterns)
                     {
                         if (manifestResourceName.Contains(ignore_pattern)) ignore = true;
                     }
                 }
                 if (!ignore)
                 {
                     if (manifestResourceName == name || (manifestResourceName.Contains(name) && !RequireExactMatch))
                     {
                         object instance = null;
                         try
                         {
                             instance = ReadFunction(assembly.GetManifestResourceStream(manifestResourceName));
                         }
                         catch (Exception e)
                         {
                             throw new Exception($"ReadFunction failed on ManifestResourceName '{manifestResourceName}'", e);
                         }
                         if (instance != null)
                         {
                             if (targetType.IsAssignableFrom(instance.GetType()))
                             {
                                 Cache[name] = instance;
                                 return instance;
                             }
                         }
                     }
                 }
             }
         }
     }
     return null;
 }
        public static object GetService(Type t, IServiceContext localContext)
        {
            var loadedAssemblies = new Assembly[] { localContext.GetType().Assembly };

            object service = null;

            if (!_loadedServices.ContainsKey(localContext))
            {
                _loadedServices.Add(localContext, new List<object>());
            }

            var loadedServicesTemp = _loadedServices[localContext];

            foreach (var serviceTemp in loadedServicesTemp)
            {
                if (t.IsAssignableFrom(serviceTemp.GetType()))
                {
                    service = serviceTemp;
                }
            }

            if (service == null)
            {
                foreach (var assembly in loadedAssemblies)
                {
                    foreach (var module in assembly.GetModules())
                    {
                        foreach (var type in module.GetTypes())
                        {
                            if (t.IsAssignableFrom(type))
                            {
                                var constructor = type.GetConstructor(new Type[] { typeof(LocalContext) });
                                if (constructor != null)
                                {
                                    service = (constructor.Invoke(new object[] { localContext }));
                                    loadedServicesTemp.Add(service);
                                }
                            }
                        }
                    }
                }
            }

            if (service != null)
            {
                return service;
            }
            throw new InvalidPluginExecutionException(string.Format("Service '{0}' not found", t.Name));
        }
Beispiel #28
0
    public static T ChkOtherObject <T>(this ILuaState self, int index, System.Type type) where T : class
    {
        if (self.IsNil(index))
        {
            return(null);
        }

        object obj = self.ToUserData(index);

        if (obj == null)
        {
            self.L_ArgError(index, string.Format("{0} expected, got nil", type.Name));
            return(null);
        }

        var tObj = obj as T;

        if (tObj == null)
        {
            self.L_ArgError(index, string.Format("{0} expected, got nil", type.Name));
            return(null);
        }

        System.Type objType = tObj.GetType();

        if (type == objType || type.IsAssignableFrom(objType))
        {
            return(tObj);
        }

        self.L_ArgError(index, string.Format("{0} expected, got {1}", type.Name, objType.Name));
        return(null);
    }
Beispiel #29
0
    public static object ChkUserData(this ILuaState self, int index, System.Type type)
    {
        if (self.IsNil(index))
        {
            return(null);
        }

        var luaT = self.Type(index);

        if (luaT != LuaTypes.LUA_TUSERDATA && luaT != LuaTypes.LUA_TLIGHTUSERDATA)
        {
            self.L_ArgError(index, string.Format("{0} expected, got {1}", type.FullName, luaT));
            return(null);
        }

        object obj = self.ToUserData(index);

        if (obj == null)
        {
            self.L_ArgError(index, string.Format("{0} expected, got nil", type.FullName));
            return(null);
        }

        System.Type objType = obj.GetType();

        if (type == objType || type.IsAssignableFrom(objType))
        {
            return(obj);
        }

        self.L_ArgError(index, string.Format("{0} expected, got {1}", type.FullName, objType.Name));
        return(null);
    }
Beispiel #30
0
    private static int __newindex_Array(ILuaState L)
    {
        System.Array obj = L.ChkUserDataSelf(1, CLASS) as System.Array;

        if (obj == null)
        {
            L.L_Error("trying to newindex an invalid Array reference");
            return(0);
        }

        int    index   = L.ChkInteger(2);
        object val     = L.ToAnyObject(3);
        var    valType = val.GetType();

        System.Type type = obj.GetType().GetElementType();

        if (!type.IsAssignableFrom(valType))
        {
            L.L_Error(string.Format("trying to set object type is not correct: {0} expected, got {1}", type, valType));
            return(0);
        }

        val = System.Convert.ChangeType(val, type);
        obj.SetValue(val, index);

        return(0);
    }
Beispiel #31
0
    /// <summary>
    /// Get objects with specific type (include derived objects) with enumerable method
    /// </summary>
    /// <returns></returns>
    public static IEnumerable <object> GetObjectsEnumerable(System.Type theType)
    {
        foreach (System.Type aType in itsListSorted.Keys)
        {
            if (theType.IsAssignableFrom(aType))
            {
                List <KGFObject> aListObjectScripts = itsListSorted[aType];

                for (int i = aListObjectScripts.Count - 1; i >= 0; i--)
                {
                    object        anObject       = aListObjectScripts[i];
                    MonoBehaviour aMonobehaviour = (MonoBehaviour)aListObjectScripts[i];
                    if (aMonobehaviour == null)
                    {
                        aListObjectScripts.RemoveAt(i);
                        continue;
                    }
                    if (aMonobehaviour.gameObject == null)
                    {
                        aListObjectScripts.RemoveAt(i);
                        continue;
                    }
                    yield return(anObject);
                }
            }
        }
        yield break;
    }
Beispiel #32
0
 private object GetValue(DateTime dateTime, Type type, TypeConverter converter)
 {
     if (type.IsAssignableFrom(typeof(DateTime)))
         return dateTime;
     else
         return converter.ConvertFrom(dateTime);
 }
        /// <summary>
        ///   Gets the given <paramref name="implementationType" />'s constructor that can be used by the
        ///   container to create that instance.
        /// </summary>
        /// <param name="serviceType">Type of the abstraction that is requested.</param>
        /// <param name="implementationType">Type of the implementation to find a suitable constructor for.</param>
        /// <returns>
        ///   The <see cref="T:System.Reflection.ConstructorInfo" />.
        /// </returns>
        /// <exception cref="T:SimpleInjector.ActivationException">Thrown when no suitable constructor could be found.</exception>
        public ConstructorInfo GetConstructor(Type serviceType, Type implementationType)
        {
            // note: this I want in the future to be pushed out to a rule overrides folder
            if (typeof(EntitiesContext).IsAssignableFrom(implementationType))
            {
                var defaultconstructor =
                    (from constructor in implementationType.GetConstructors()
                     where constructor.GetParameters().Count() == 0
                     select constructor).Take(1);

                if (defaultconstructor.Any()) return defaultconstructor.First();
            }

            if (serviceType.IsAssignableFrom(implementationType))
            {
                var longestConstructor =
                    (from constructor in implementationType.GetConstructors()
                     orderby constructor.GetParameters().Count() descending
                     select constructor).Take(1);

                if (longestConstructor.Any()) return longestConstructor.First();
            }

            // fall back to the container's default behavior.
            return _originalBehavior.GetConstructor(serviceType, implementationType);
        }
Beispiel #34
0
    /// <summary>
    /// 把指定索引的值转成指定类型的UnityEngine.Component
    /// 如果类型不匹配,尝试获取其相关的GameObject,
    /// 再从GameoObject上获取其挂载的Component
    /// </summary>
    public static Component ToComponent(this ILuaState self, int index, System.Type type)
    {
        var obj = self.ToAnyObject(index);

        if (obj == null)
        {
            return(null);
        }

        if (type.IsAssignableFrom(obj.GetType()))
        {
            return(obj as Component);
        }

        var com = obj as Component;

        if (com)
        {
            return(com.gameObject.GetComponent(type));
        }

        var go = obj as GameObject;

        if (go == null)
        {
            go = self.ToGameObject(index);
        }
        if (go)
        {
            return(go.GetComponent(type));
        }

        return(null);
    }
Beispiel #35
0
        public override Expression/*!*/ ConvertExpression(Expression/*!*/ expr, Type/*!*/ toType, ConversionResultKind kind, Expression context) {
            ContractUtils.RequiresNotNull(expr, "expr");
            ContractUtils.RequiresNotNull(toType, "toType");

            Type exprType = expr.Type;

            if (toType == typeof(object)) {
                if (exprType.IsValueType) {
                    return AstUtils.Convert(expr, toType);
                } else {
                    return expr;
                }
            }

            if (toType.IsAssignableFrom(exprType)) {
                return expr;
            }

            Type visType = CompilerHelpers.GetVisibleType(toType);

            if (exprType == typeof(PythonType) && visType == typeof(Type)) {
                return AstUtils.Convert(expr, visType); // use the implicit conversion
            }

            return Binders.Convert(
                context,
                _context.DefaultBinderState,
                visType,
                visType == typeof(char) ? ConversionResultKind.ImplicitCast : kind,
                expr
            );
        }
Beispiel #36
0
 public static bool Same(System.Type a, System.Type b)
 {
     return((
                a.FullName == b.FullName) ||
            b.IsAssignableFrom(a) ||
            (a.IsAssignableFrom(b)
            ));
 }
Beispiel #37
0
 public override bool SupportsRemappedAssetType(System.Type type)
 {
     if (type.IsAssignableFrom(typeof(TextAsset)))
     {
         return(true);
     }
     return(false);
 }
Beispiel #38
0
 void Init(Type requiredType, Type defaultType, bool executesAfterDependency)
 {
     Assert.IsTrue(requiredType != null && defaultType != null, "ComponentDependency: types cannot be NULL");
     Assert.IsTrue(!defaultType.IsAbstract, "ComponentDependency: default type " + defaultType.Name + " cannot be abstract");
     Assert.IsTrue(typeof(Component).IsAssignableFrom(defaultType), "ComponentDependency: default type " + defaultType.Name + " is not a Component");
     Assert.IsTrue(requiredType.IsAssignableFrom(defaultType), "ComponentDependency default type must be same as or assignable to required type");
     defaultComponentType        = defaultType;
     m_executesAfterDependencies = executesAfterDependency;
 }
Beispiel #39
0
    public static Component GetComponent(int cacheId, System.Type type, bool needDecode = false)
    {
        var component = GetComponent(cacheId, needDecode);

        if (component != null && type.IsAssignableFrom(component.GetType()))
        {
            return((Component)System.Convert.ChangeType(component, type));
        }
        return(null);
    }
Beispiel #40
0
    public static Component GetComponent(int cacheId, int index, System.Type type)
    {
        var component = GetComponent(cacheId, index);

        if (component != null && type.IsAssignableFrom(component.GetType()))
        {
            return((Component)System.Convert.ChangeType(component, type));
        }
        return(null);
    }
Beispiel #41
0
 /// <summary>
 /// Calculates the weapon damage based on the target
 /// </summary>
 /// <returns>damage</returns>
 protected float GetDamage()
 {
     if (GetTarget() != null && bonusDamageType != null && GetTarget().GetComponent <Entity>())
     {
         if (bonusDamageType.IsAssignableFrom(GetTarget().GetComponent <Entity>().GetType()))
         {
             return((damage + Core.damageAddition) * bonusDamageMultiplier);
         }
     }
     return(damage + Core.damageAddition);
 }
Beispiel #42
0
 protected static bool IsSameOrSubClassOrImplementInterface(System.Type p_potentialDescendant, System.Type p_potentialBase)
 {
     if (p_potentialBase != null && p_potentialDescendant != null)
     {
         bool v_sucess = p_potentialBase.IsAssignableFrom(p_potentialDescendant) || (new List <System.Type>(p_potentialDescendant.GetInterfaces())).Contains(p_potentialBase);
         if (!v_sucess)
         {
             v_sucess = IsSameOrSubclass(p_potentialDescendant, p_potentialBase);
         }
         return(v_sucess);
     }
     return(false);
 }
Beispiel #43
0
    public static List <System.Type> GetTypes(System.Type aBaseType)
    {
        var res = new List <System.Type>();

        foreach (var t in m_Types)
        {
            if (aBaseType.IsAssignableFrom(t))
            {
                res.Add(t);
            }
        }
        return(res);
    }
Beispiel #44
0
    /**
     * Find all activities which have data of a given class. Useful for finding custom activity types.
     */
    virtual public List <Activity> GetActivitiesOfDataClassType(System.Type type)
    {
        List <Activity> result = new List <Activity>();

        foreach (Activity activity in currentActivities)
        {
            ActivityData data = GetActivityData(activity.Type);
            if (type.IsAssignableFrom(data.GetType()))
            {
                result.Add(activity);
            }
        }
        foreach (Activity activity in completedActivities)
        {
            ActivityData data = GetActivityData(activity.Type);
            if (type.IsAssignableFrom(data.GetType()))
            {
                result.Add(activity);
            }
        }
        return(result);
    }
Beispiel #45
0
    private static bool OkToAdd(List <ScriptableObject> items, ScriptableObject item)
    {
        if (!item)
        {
            Debug.LogError("Can't set item to none.");
            return(false);
        }

        if (!(item is IInputBuildProcessor))
        {
            Debug.LogError(string.Format("{0} does not implement {1}."
                                         , item.name, typeof(IInputBuildProcessor).Name));
            return(false);
        }

        if (items.Contains(item))
        {
            Debug.LogError(item.name + " already in the processor list.");
            return(false);
        }

        IInputBuildProcessor pa = (IInputBuildProcessor)item;

        if (pa.DuplicatesAllowed)
        {
            return(true);
        }

        foreach (ScriptableObject itemB in items)
        {
            IInputBuildProcessor pb = (IInputBuildProcessor)itemB;

            if (pb.DuplicatesAllowed)
            {
                continue;
            }

            System.Type ta = pb.GetType();
            System.Type tb = pa.GetType();

            if (ta.IsAssignableFrom(tb) || tb.IsAssignableFrom(ta))
            {
                Debug.LogError(string.Format(
                                   "Disallowed dulicate detected. {0} and {1} are same type."
                                   , pa.Name, pb.Name));
                return(false);
            }
        }

        return(true);
    }
Beispiel #46
0
        public bool ParamsMatch(object param)
        {
            if (Param == null)
            {
                return(param == null);
            }

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

            return(Param.IsAssignableFrom(param.GetType()));
        }
Beispiel #47
0
 public static void Setup()
 {
     netMessageTypes = new List <System.Type>();
     System.Type baseType = typeof(NetMessage);
     System.Reflection.Assembly assembly = baseType.Assembly;
     System.Type[] types = assembly.GetTypes();
     foreach (System.Type type in types)
     {
         if (baseType.IsAssignableFrom(type))
         {
             netMessageTypes.Add(type);
         }
     }
 }
Beispiel #48
0
    public ItemStack(System.Type type)
    {
        itemType = type;

        if (itemType == null)
        {
            if (!itemType.IsAssignableFrom(typeof(IInventoryItem)))
            {
                throw new UnityException("Type is not an item");
            }
            else
            {
                itemType = type;
            }
        }
    }
Beispiel #49
0
    private static bool IsAssignableFrom(System.Type to, System.Type from)
    {
        if (to.IsAssignableFrom(from))
        {
            return(true);
        }
        else if (to.IsArray && to.GetElementType().IsAssignableFrom(from))
        {
            return(true);
        }
        else if (from == typeof(Texture2D) && to == typeof(Sprite) || to.HasElementType && to.GetElementType() == typeof(Sprite))
        {
            return(true);
        }

        return(false);
    }
Beispiel #50
0
 private static void InitializeValidator(Attribute attribute, System.Type validatorClass, IValidator entityValidator)
 {
     /* This method was added to supply major difference between JAVA and NET generics.
      * So far in JAVA the generic type is something optional, in NET mean "strongly typed".
      * In this case we don't know exactly wich is the generic version of "IInitializableValidator<>"
      * so we create the type on the fly and invoke the Initialize method by reflection.
      * All this work is only to give to the user the ability of implement IInitializableValidator<>
      * without need to inherit from a base class or implement a generic and a no generic version of
      * the method Initialize.
      */
     System.Type[] args        = { attribute.GetType() };
     System.Type   concreteIvc = BaseInitializableType.MakeGenericType(args);
     if (concreteIvc.IsAssignableFrom(validatorClass))
     {
         MethodInfo initMethod = concreteIvc.GetMethod("Initialize");
         initMethod.Invoke(entityValidator, new object[] { attribute });
     }
 }
Beispiel #51
0
        private static bool IsMatchingImplementor(string entityOrClassName, System.Type entityClass, IQueryable implementor)
        {
            var implementorClass = implementor.MappedClass;

            if (implementorClass == null)
            {
                return(false);
            }
            if (entityClass == implementorClass)
            {
                // It is possible to have multiple mappings for the same entity class, but with different entity names.
                // When querying for a specific entity name, we should only return entities for the requested entity name
                // and not return entities for any other entity names that may map to the same entity class.
                bool isEntityName = !entityOrClassName.Equals(entityClass.FullName);
                return(!isEntityName || entityOrClassName.Equals(implementor.EntityName));
            }
            return(entityClass.IsAssignableFrom(implementorClass));
        }
Beispiel #52
0
        //TODO YAGNI add an ContainsAssignable function similar to containstype


        /// <summary>
        /// Checks the containedTypes list for duplicate types
        /// </summary>
        /// <param name="t">type to compare to conaintedtypes list</param>
        /// <returns> true if there is a duplicate type</returns>
        public bool ContainsAssignable(System.Type t)
        {
            System.Type st = null;
            for (int i = 0; i < containedTypes.Count; i++)
            {
                st = containedTypes[i].SystemType;
                if (st == null)
                {
                    continue;
                }
                //Debug.Log("Comparing: " + st + " and " + t);
                if (t.IsAssignableFrom(st))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #53
0
    public static System.Type[] GetTypesWithInterface(this System.AppDomain aAppDomain, System.Type aInterfaceType)
    {
        List <System.Type> result = new List <System.Type>();

        System.Reflection.Assembly[] assemblies = aAppDomain.GetAssemblies();

        foreach (var assembly in assemblies)
        {
            var types = assembly.GetTypes();
            foreach (var type in types)
            {
                if (aInterfaceType.IsAssignableFrom(type))
                {
                    result.Add(type);
                }
            }
        }
        return(result.ToArray());
    }
Beispiel #54
0
    public static Dictionary <uint, string> GetAllDerivedTypes()
    {
        System.Type               c          = typeof(AkTriggerBase);
        System.Type[]             types      = c.Assembly.GetTypes();
        Dictionary <uint, string> dictionary = new Dictionary <uint, string>();

        for (int i = 0; i < types.Length; i++)
        {
            if (types[i].IsClass && (types[i].IsSubclassOf(c) || (c.IsAssignableFrom(types[i]) && (c != types[i]))))
            {
                string name = types[i].Name;
                dictionary.Add(AkUtilities.ShortIDGenerator.Compute(name), name);
            }
        }
        dictionary.Add(AkUtilities.ShortIDGenerator.Compute("Awake"), "Awake");
        dictionary.Add(AkUtilities.ShortIDGenerator.Compute("Start"), "Start");
        dictionary.Add(AkUtilities.ShortIDGenerator.Compute("Destroy"), "Destroy");
        return(dictionary);
    }
Beispiel #55
0
 /// <summary>Convert an object to another type</summary>
 /// <param name="pNewType"></param>
 /// <returns></returns>
 public Instance CastAs(string pNewType)
 {
     System.Type lNewType = this.lBridge.GetLoadedTypeFromString(pNewType);
     if (lNewType != null)
     {
         if (lNewType.IsAssignableFrom(this.lType))
         {
             return(new Instance(this.lBridge, lNewType, this.CurrentInstance));
         }
         else
         {
             throw new ApplicationException("Cast fail from Type <" + this.lType.FullName + "> to type <" + pNewType + ">! ");
         }
     }
     else
     {
         throw new ApplicationException("Type <" + pNewType + "> not found! ");
     }
 }
Beispiel #56
0
        /// <summary>
        /// 字符串与枚举型、TimeSpan与整型之间转换的方法。
        /// </summary>
        /// <param name="srcType">源数据类型</param>
        /// <param name="srcValue">源数据的值</param>
        /// <param name="targetType">目标数据类型</param>
        /// <returns>类型转换后的结果</returns>
        /// <remarks>字符串与枚举型、TimeSpan与整型之间转换的方法。
        /// <seealso cref="MCS.Library.Core.XmlHelper"/>
        /// </remarks>
        public static object ChangeType(System.Type srcType, object srcValue, System.Type targetType)
        {
            targetType.NullCheck(nameof(targetType));

            bool   dealed = false;
            object result = null;

            if (srcType == typeof(object))
            {
                if (srcValue != null)
                {
                    srcType = srcValue.GetType();
                }
            }

            foreach (ChangeTypeAction action in _changeTypeActions)
            {
                action(srcType, srcValue, targetType, ref result, ref dealed);

                if (dealed)
                {
                    break;
                }
            }

            if (dealed == false)
            {
                if (targetType != typeof(object) && targetType.IsAssignableFrom(srcType))
                {
                    result = srcValue;
                }
                else if (targetType == typeof(DateTime))
                {
                    result = Convert.ToDateTime(srcValue);
                }
                else
                {
                    result = Convert.ChangeType(srcValue, targetType);
                }
            }

            return(result);
        }
Beispiel #57
0
    internal static object[] SmlToArray(this string data)
    {
        if (data.StartsWith(SMLSIG))
        {
            string[]      l_vals = data.Split('|');
            List <object> l_res  = new List <object>();

            for (int i = 1; i < l_vals.Length; i++)
            {
                string[] l_contents = l_vals[i].Split('~');
                string   l_typename = l_contents[0];
                string   l_val      = l_contents[1].Remove(0, 1);
                int      l_rNumber  = l_val[l_val.Length - 1] == '}' ? 1 : 2;
                l_val = l_val.Remove(l_val.Length - l_rNumber, l_rNumber);
                //Debug.Log(l_typename);
                System.Type   l_type   = System.Type.GetType(l_typename);
                System.Object l_resval = null;

                if (l_val.Length > 0 && l_type != null && (l_type.IsAssignableFrom(typeof(IConvertible)) || l_type.IsPrimitive || l_type == typeof(string) || l_type.IsEnum))
                {
                    if (l_type.IsEnum)
                    {
                        l_resval = Enum.Parse(l_type, l_val, true);
                    }
                    else
                    {
                        l_resval = Convert.ChangeType(l_val, l_type);
                    }
                }

                l_res.Add(l_resval);
                //Debug.Log(l_resval);
            }

            return(l_res.ToArray());
        }
        else
        {
            Debug.LogError("sml sig not detected");
            return(null);
        }
    }
Beispiel #58
0
        public void MetaValue(object value, System.Type entityType)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }
            if (value is System.Type)
            {
                throw new ArgumentOutOfRangeException("value", "System.Type is invalid meta-type (you don't need to set meta-values).");
            }
            if (!elementType.IsAssignableFrom(entityType))
            {
                throw new ArgumentOutOfRangeException("entityType", string.Format("A {0} is not assignable to the collection's elements which type is {1}", entityType, elementType));
            }
            System.Type metavalueType = value.GetType();
            if (manyToAny.metavalue == null)
            {
                manyToAny.metavalue = new HbmMetaValue[0];
            }
            Dictionary <string, string> values = manyToAny.metavalue.ToDictionary(mv => mv.value, mv => mv.@class);

            MetaType(metavalueType);
            string newClassMetavalue = entityType.GetShortClassName(mapDoc);
            string metavalueKey      = value.ToString();
            string existingClassMetavalue;

            if (values.TryGetValue(metavalueKey, out existingClassMetavalue) && existingClassMetavalue != newClassMetavalue)
            {
                throw new ArgumentException(
                          string.Format(
                              "Can't set two different classes for same meta-value (meta-value='{0}' old-class:'{1}' new-class='{2}')",
                              metavalueKey, existingClassMetavalue, newClassMetavalue));
            }
            values[metavalueKey] = newClassMetavalue;
            manyToAny.metavalue  = values.Select(vd => new HbmMetaValue {
                value = vd.Key, @class = vd.Value
            }).ToArray();
        }
Beispiel #59
0
        /// <summary>

        /// Checks whether the proxy representing the specified object type can be cast to the type represented by the IRemotingTypeInfo interface

        /// </summary>

        /// <param name="toType">The Type we wish to cast to</param>

        /// <param name="obj">The object we wish to cast</param>

        /// <returns>True if the strict property is false, otherwise the list of supportedTypes is checked.<br>

        /// The proxy targets type(s) are automatically supported</br></returns>

        public bool CanCastTo(System.Type toType, object obj)
        {
            // Assume we can (which is the default unless strict is true)

            bool canCast = true;



            if (strict)
            {
                // First check if the proxyTarget supports the cast

                if (toType.IsAssignableFrom(proxyTarget.GetType()))
                {
                    canCast = true;
                }
                else if (supportedTypes != null)
                {
                    canCast = false;

                    // Check if the list of supported interfaces supports the cast

                    foreach (Type type in supportedTypes)
                    {
                        if (toType == type)
                        {
                            canCast = true;

                            break;
                        }
                    }
                }
                else
                {
                    canCast = false;
                }
            }



            return(canCast);
        }
Beispiel #60
0
        static StackObject *IsAssignableFrom_12(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Type @c = (System.Type) typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Type instance_of_this_method = (System.Type) typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.IsAssignableFrom(@c);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }