System.Type.IsAssignableFrom(System.Type)

Here are the examples of the csharp api System.Type.IsAssignableFrom(System.Type) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8165 Examples 7

19 Source : DownloadingAssetsList.cs
with Apache License 2.0
from A7ocin

private T GetTempreplacedet<T>() where T : UnityEngine.Object
		{
			T thisTempreplacedet = null;
			//we only want the last bit after any replacedembly
			var thisTypeName = typeof(T).ToString().Replace(typeof(T).Namespace + ".", "");
			//check RuntimeAnimatorController because these get called different things in the editor and in game
			if (typeof(T) == typeof(RuntimeAnimatorController))
				thisTypeName = "RuntimeAnimatorController";
			T thisPlaceholder = (T)Resources.Load<T>("Placeholderreplacedets/" + thisTypeName + "Placeholder") as T;
			if (thisPlaceholder != null)//can we replacedume if an replacedet was found its a scriptableobject
			{
				thisTempreplacedet = ScriptableObject.Instantiate(thisPlaceholder) as T;
			}
			else
			{
				if (typeof(ScriptableObject).IsreplacedignableFrom(typeof(T)))
				{
					thisTempreplacedet = ScriptableObject.CreateInstance(typeof(T)) as T;
				}
				else
				{
					thisTempreplacedet = (T)Activator.CreateInstance(typeof(T));
				}
			}
			return thisTempreplacedet;
		}

19 Source : BitfinexResultConverter.cs
with MIT License
from aabiryukov

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (objectType == null) throw new ArgumentNullException(nameof(objectType));

            var result = Activator.CreateInstance(objectType);
            var arr = JArray.Load(reader);
            foreach (var property in objectType.GetProperties())
            {
                var attribute =
                    (BitfinexPropertyAttribute) property.GetCustomAttribute(typeof(BitfinexPropertyAttribute));
                if (attribute == null)
                    continue;

                if (attribute.Index >= arr.Count)
                    continue;

                object value;
                var converterAttribute = (JsonConverterAttribute) property.GetCustomAttribute(typeof(JsonConverterAttribute));
                if (converterAttribute != null)
                    value = arr[attribute.Index].ToObject(property.PropertyType, new JsonSerializer() { Converters = { (JsonConverter)Activator.CreateInstance(converterAttribute.ConverterType) } });
                else
                    value = arr[attribute.Index];                

                if (property.PropertyType.IsreplacedignableFrom(value.GetType()))
                    property.SetValue(result, value);
                else
                    property.SetValue(result, value == null ? null : Convert.ChangeType(value, property.PropertyType));
            }
            return result;
        }

19 Source : UnmanagedCache.cs
with MIT License
from Abc-Arbitrage

internal static void Register(Type unmanagedType)
        {
            if (unmanagedType == null)
                throw new ArgumentNullException(nameof(unmanagedType));

            if (!typeof(IStringFormattable).IsreplacedignableFrom(unmanagedType))
                throw new ArgumentException($"Not an {nameof(IStringFormattable)} type: {unmanagedType}");

            if (!TypeUtil.GetIsUnmanagedSlow(unmanagedType))
                throw new ArgumentException($"Not an unmanaged type: {unmanagedType}");

            _registerMethod.MakeGenericMethod(unmanagedType).Invoke(null, null);
        }

19 Source : BitmapAssetValueConverter.cs
with MIT License
from Abdesol

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return null;

            if (value is string rawUri && targetType.IsreplacedignableFrom(typeof(Bitmap)))
            {
                Uri uri;

                // Allow for replacedembly overrides
                if (rawUri.StartsWith("avares://"))
                {
                    uri = new Uri(rawUri);
                }
                else
                {
                    string replacedemblyName = replacedembly.GetEntryreplacedembly().GetName().Name;
                    uri = new Uri($"avares://{replacedemblyName}{rawUri}");
                }

                var replacedets = AvaloniaLocator.Current.GetService<IreplacedetLoader>();
                var replacedet = replacedets.Open(uri);

                return new Bitmap(replacedet);
            }

            throw new NotSupportedException();
        }

19 Source : FdbConverters.cs
with MIT License
from abdullin

[NotNull]
		public static IFdbConverter<T, R> GetConverter<T, R>()
		{

			if (typeof(T) == typeof(R))
			{ // R == T : idenreplacedy function
				return (IFdbConverter<T, R>)Idenreplacedy<T>.Default;
			}

			// Try to get from the known converters
			IFdbConverter converter;
			if (!Converters.TryGetValue(new ComparisonHelper.TypePair(typeof(T), typeof(R)), out converter))
			{
				if (typeof(R).IsreplacedignableFrom(typeof(T)))
				{ // T is a subclreplaced of R, so it should work fine
					return SubClreplaced<T, R>.Default;
				}

				//TODO: ..?
				FailCannotConvert(typeof(T), typeof(R));
			}

			return (IFdbConverter<T, R>)converter;
		}

19 Source : FdbTuplePackers.cs
with MIT License
from abdullin

private static Delegate GetSerializerFor([NotNull] Type type)
		{
			if (type == null) throw new ArgumentNullException("type");

			if (type == typeof(object))
			{ // return a generic serializer that will inspect the runtime type of the object
				return new Encoder<object>(FdbTuplePackers.SerializeObjectTo);
			}

			var typeArgs = new[] { typeof(TupleWriter).MakeByRefType(), type };
			var method = typeof(FdbTuplePackers).GetMethod("SerializeTo", BindingFlags.Static | BindingFlags.Public, null, typeArgs, null);
			if (method != null)
			{ // we have a direct serializer
				return method.CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
			}

			// maybe if it is a tuple ?
			if (typeof(IFdbTuple).IsreplacedignableFrom(type))
			{
				method = typeof(FdbTuplePackers).GetMethod("SerializeTupleTo", BindingFlags.Static | BindingFlags.Public);
				if (method != null)
				{
					return method.MakeGenericMethod(type).CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
				}
			}

			if (typeof(ITupleFormattable).IsreplacedignableFrom(type))
			{
				method = typeof(FdbTuplePackers).GetMethod("SerializeFormattableTo", BindingFlags.Static | BindingFlags.Public);
				if (method != null)
				{
					return method.CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
				}
			}

			if (typeof(IFdbKey).IsreplacedignableFrom(type))
			{
				method = typeof(FdbTuplePackers).GetMethod("SerializeFdbKeyTo", BindingFlags.Static | BindingFlags.Public);
				if (method != null)
				{
					return method.CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
				}
			}

			var nullableType = Nullable.GetUnderlyingType(type);
			if (nullableType != null)
			{ // nullable types can reuse the underlying type serializer
				method = typeof(FdbTuplePackers).GetMethod("SerializeNullableTo", BindingFlags.Static | BindingFlags.Public);
				if (method != null)
				{
					return method.MakeGenericMethod(nullableType).CreateDelegate(typeof(Encoder<>).MakeGenericType(type));
				}
			}

			// TODO: look for a static SerializeTo(BWB, T) method on the type itself ?

			// no luck..
			return null;
		}

19 Source : FdbConverters.cs
with MIT License
from abdullin

[CanBeNull]
		public static R ConvertBoxed<R>(object value)
		{
			if (value == null) return default(R);
			var type = value.GetType();

			var targetType = typeof(R);

			// cast !
			if (targetType.IsreplacedignableFrom(type)) return (R)value;

			IFdbConverter converter;
			if (!Converters.TryGetValue(new ComparisonHelper.TypePair(type, targetType), out converter))
			{
				// maybe it is a nullable type ?
				var nullableType = Nullable.GetUnderlyingType(targetType);
				if (nullableType != null)
				{ // we already nullchecked value above, so we just have to convert it to the underlying type...

					// shortcut for converting a R into a Nullable<R> ...
					if (type == nullableType) return (R)value;

					// maybe we have a converter for the underlying type ?
					if (Converters.TryGetValue(new ComparisonHelper.TypePair(type, nullableType), out converter))
					{
						return (R)converter.ConvertBoxed(value);
					}
				}

				FailCannotConvert(type, targetType);
			}

			return (R)converter.ConvertBoxed(value);
		}

19 Source : ExtendsAttribute.cs
with Apache License 2.0
from abist-co-ltd

public override bool IsConstraintSatisfied(Type type)
        {
            return base.IsConstraintSatisfied(type) &&
                   BaseType.IsreplacedignableFrom(type) &&
                   type != BaseType;
        }

19 Source : BaseMixedRealityProfileInspector.cs
with Apache License 2.0
from abist-co-ltd

public static void RenderReadOnlyProfile(SerializedProperty property)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ObjectField(property.objectReferenceValue != null ? "" : property.displayName, property.objectReferenceValue, typeof(BaseMixedRealityProfile), false, GUILayout.ExpandWidth(true));
                EditorGUI.EndDisabledGroup();
            }

            if (property.objectReferenceValue != null)
            {
                bool showReadOnlyProfile = SessionState.GetBool(property.name + ".ReadOnlyProfile", false);

                using (new EditorGUI.IndentLevelScope())
                {
                    RenderFoldout(ref showReadOnlyProfile, property.displayName, () =>
                    {
                        using (new EditorGUI.IndentLevelScope())
                        {
                            UnityEditor.Editor subProfileEditor = CreateEditor(property.objectReferenceValue);
                            // If this is a default MRTK configuration profile, ask it to render as a sub-profile
                            if (typeof(BaseMixedRealityToolkitConfigurationProfileInspector).IsreplacedignableFrom(subProfileEditor.GetType()))
                            {
                                BaseMixedRealityToolkitConfigurationProfileInspector configProfile = (BaseMixedRealityToolkitConfigurationProfileInspector)subProfileEditor;
                                configProfile.RenderreplacedubProfile = true;
                            }
                            subProfileEditor.OnInspectorGUI();
                        }
                    });
                }

                SessionState.SetBool(property.name + ".ReadOnlyProfile", showReadOnlyProfile);
            }
        }

19 Source : ServiceFacadeInspector.cs
with Apache License 2.0
from abist-co-ltd

private bool DrawProfile(Type serviceType)
        {
            bool drawProfileField = true;
            foreach (Type interfaceType in serviceType.GetInterfaces())
            {
                IMixedRealityServiceInspector inspectorInstance;
                if (GetServiceInspectorInstance(interfaceType, out inspectorInstance))
                {
                    drawProfileField &= inspectorInstance.DrawProfileField;
                }
            }

            if (!drawProfileField)
            {   // We've been instructed to skip drawing a profile by the inspector
                return false;
            }

            bool foundAndDrewProfile = false;

            // Draw the base profile stuff
            if (typeof(BaseCoreSystem).IsreplacedignableFrom(serviceType))
            {
                SerializedObject activeProfileObject = new SerializedObject(MixedRealityToolkit.Instance.ActiveProfile);
                // Would be nice to handle this using some other method
                // Would be nice to handle this with a lookup instead
                if (typeof(IMixedRealityInputSystem).IsreplacedignableFrom(serviceType))
                {
                    SerializedProperty serviceProfileProp = activeProfileObject.FindProperty("inputSystemProfile");
                    BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                    EditorGUILayout.Space();
                    foundAndDrewProfile = true;
                }
                else if (typeof(IMixedRealityBoundarySystem).IsreplacedignableFrom(serviceType))
                {
                    SerializedProperty serviceProfileProp = activeProfileObject.FindProperty("boundaryVisualizationProfile");
                    BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                    EditorGUILayout.Space();
                    foundAndDrewProfile = true;
                }
                else if (typeof(IMixedRealityDiagnosticsSystem).IsreplacedignableFrom(serviceType))
                {
                    SerializedProperty serviceProfileProp = activeProfileObject.FindProperty("diagnosticsSystemProfile");
                    BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                    EditorGUILayout.Space();
                    foundAndDrewProfile = true;
                }
                else if (typeof(IMixedRealitySpatialAwarenessSystem).IsreplacedignableFrom(serviceType))
                {
                    SerializedProperty serviceProfileProp = activeProfileObject.FindProperty("spatialAwarenessSystemProfile");
                    BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                    EditorGUILayout.Space();
                    foundAndDrewProfile = true;
                }
                else if (typeof(IMixedRealityCameraSystem).IsreplacedignableFrom(serviceType))
                {
                    SerializedProperty serviceProfileProp = activeProfileObject.FindProperty("cameraProfile");
                    BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                    EditorGUILayout.Space();
                    foundAndDrewProfile = true;
                }
                else if (typeof(IMixedRealitySceneSystem).IsreplacedignableFrom(serviceType))
                {
                    SerializedProperty serviceProfileProp = activeProfileObject.FindProperty("sceneSystemProfile");
                    BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                    EditorGUILayout.Space();
                    foundAndDrewProfile = true;
                }
            }
            else if (typeof(BaseExtensionService).IsreplacedignableFrom(serviceType))
            {
                // Make sure the extension service profile isn't null
                if (MixedRealityToolkit.Instance.ActiveProfile.RegisteredServiceProvidersProfile != null)
                {
                    // If this is an extension service, see if it uses a profile
                    MixedRealityServiceConfiguration[] serviceConfigs = MixedRealityToolkit.Instance.ActiveProfile.RegisteredServiceProvidersProfile.Configurations;
                    for (int serviceIndex = 0; serviceIndex < serviceConfigs.Length; serviceIndex++)
                    {
                        MixedRealityServiceConfiguration serviceConfig = serviceConfigs[serviceIndex];
                        if (serviceConfig.ComponentType.Type.IsreplacedignableFrom(serviceType) && serviceConfig.Profile != null)
                        {
                            // We found the service that this type uses - draw the profile
                            SerializedObject serviceConfigObject = new SerializedObject(MixedRealityToolkit.Instance.ActiveProfile.RegisteredServiceProvidersProfile);
                            SerializedProperty serviceConfigArray = serviceConfigObject.FindProperty("configurations");
                            SerializedProperty serviceConfigProp = serviceConfigArray.GetArrayElementAtIndex(serviceIndex);
                            SerializedProperty serviceProfileProp = serviceConfigProp.FindPropertyRelative("configurationProfile");
                            BaseMixedRealityProfileInspector.RenderReadOnlyProfile(serviceProfileProp);
                            EditorGUILayout.Space();
                            foundAndDrewProfile = true;
                            break;
                        }
                    }
                }
            }

            return foundAndDrewProfile;
        }

19 Source : BaseDataProviderAccessCoreSystem.cs
with Apache License 2.0
from abist-co-ltd

private bool RegisterDataProviderInternal<T>(
            bool retryWithRegistrar,
            Type concreteType,
            SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1),
            params object[] args) where T : IMixedRealityDataProvider
        {
#if !UNITY_EDITOR
            if (!Application.platform.IsPlatformSupported(supportedPlatforms))
#else
            if (!EditorUserBuildSettings.activeBuildTarget.IsPlatformSupported(supportedPlatforms))
#endif
            {
                return false;
            }

            if (concreteType == null)
            {
                Debug.LogError($"Unable to register {typeof(T).Name} service with a null concrete type.");
                return false;
            }

            if (!typeof(IMixedRealityDataProvider).IsreplacedignableFrom(concreteType))
            {
                Debug.LogError($"Unable to register the {concreteType.Name} data provider. It does not implement {typeof(IMixedRealityDataProvider)}.");
                return false;
            }

            T dataProviderInstance;

            try
            {
                dataProviderInstance = (T)Activator.CreateInstance(concreteType, args);
            }
            catch (Exception e)
            {
                if (retryWithRegistrar && (e is MissingMethodException))
                {
                    Debug.LogWarning($"Failed to find an appropriate constructor for the {concreteType.Name} data provider. Adding the Registrar instance and re-attempting registration.");
#pragma warning disable 0618
                    List<object> updatedArgs = new List<object>();
                    updatedArgs.Add(Registrar);
                    if (args != null)
                    {
                        updatedArgs.AddRange(args);
                    }
                    return RegisterDataProviderInternal<T>(
                        false, // Do NOT retry, we have already added the configured IMIxedRealityServiceRegistrar
                        concreteType,
                        supportedPlatforms,
                        updatedArgs.ToArray());
#pragma warning restore 0618
                }

                Debug.LogError($"Failed to register the {concreteType.Name} data provider: {e.GetType()} - {e.Message}");

                // Failures to create the concrete type generally surface as nested exceptions - just logging
                // the top level exception itself may not be helpful. If there is a nested exception (for example,
                // null reference in the constructor of the object itself), it's helpful to also surface those here.
                if (e.InnerException != null)
                {
                    Debug.LogError("Underlying exception information: " + e.InnerException);
                }
                return false;
            }

            return RegisterDataProvider(dataProviderInstance);
        }

19 Source : MixedRealityServiceRegistry.cs
with Apache License 2.0
from abist-co-ltd

public static bool TryGetService(Type interfaceType,
            out IMixedRealityService serviceInstance,
            out IMixedRealityServiceRegistrar registrar,
            string name = null)
        {
            if (!typeof(IMixedRealityService).IsreplacedignableFrom(interfaceType))
            {
                Debug.LogWarning($"Cannot find type {interfaceType.Name} since it does not extend IMixedRealityService");
                serviceInstance = null;
                registrar = null;
                return false;
            }

            return TryGetServiceInternal(interfaceType, out serviceInstance, out registrar, name);
        }

19 Source : MixedRealityServiceRegistry.cs
with Apache License 2.0
from abist-co-ltd

private static bool FindEntry(List<KeyValuePair<IMixedRealityService, IMixedRealityServiceRegistrar>> serviceList,
            Type interfaceType,
            string name,
            out IMixedRealityService serviceInstance, 
            out IMixedRealityServiceRegistrar registrar)
        {
            using (FindEntryPerfMarker.Auto())
            {
                // replacedume failed and return null unless proven otherwise
                serviceInstance = null;
                registrar = null;

                for (int i = 0; i < serviceList.Count; ++i)
                {
                    var svc = serviceList[i].Key;
                    if ((string.IsNullOrEmpty(name) || svc.Name == name) && interfaceType.IsreplacedignableFrom(svc.GetType()))
                    {
                        serviceInstance = svc;
                        registrar = serviceList[i].Value;

                        return true;
                    }
                }

                return false;
            }
        }

19 Source : BaseEventSystem.cs
with Apache License 2.0
from abist-co-ltd

public virtual void RegisterHandler<T>(IEventSystemHandler handler) where T : IEventSystemHandler
        {
            if (handler == null)
            {
                return;
            }

            // #if due to Microsoft.MixedReality.Toolkit.ReflectionExtensions overload of Type.IsInterface
#if WINDOWS_UWP && !ENABLE_IL2CPP
            Debug.replacedert(typeof(T).IsInterface(), "RegisterHandler must be called with an interface as a generic parameter.");
#else
            Debug.replacedert(typeof(T).IsInterface, "RegisterHandler must be called with an interface as a generic parameter.");
#endif
            Debug.replacedert(typeof(T).IsreplacedignableFrom(handler.GetType()), "Handler preplaceded to RegisterHandler doesn't implement a type given as generic parameter.");

            TraverseEventSystemHandlerHierarchy<T>(handler, RegisterHandler);
        }

19 Source : BaseEventSystem.cs
with Apache License 2.0
from abist-co-ltd

public virtual void UnregisterHandler<T>(IEventSystemHandler handler) where T : IEventSystemHandler
        {
            if (handler == null)
            {
                return;
            }

            // #if due to Microsoft.MixedReality.Toolkit.ReflectionExtensions overload of Type.IsInterface
#if WINDOWS_UWP && !ENABLE_IL2CPP
            Debug.replacedert(typeof(T).IsInterface(), "UnregisterHandler must be called with an interface as a generic parameter.");
#else
            Debug.replacedert(typeof(T).IsInterface, "UnregisterHandler must be called with an interface as a generic parameter.");
#endif
            Debug.replacedert(typeof(T).IsreplacedignableFrom(handler.GetType()), "Handler preplaceded to UnregisterHandler doesn't implement a type given as generic parameter.");

            TraverseEventSystemHandlerHierarchy<T>(handler, UnregisterHandler);
        }

19 Source : MixedRealitySearchUtility.cs
with Apache License 2.0
from abist-co-ltd

private static bool CheckFieldForProfile(SerializedProperty property)
        {
            bool isProfileField = false;
            if (property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue != null)
            {
                Type referenceType = property.objectReferenceValue.GetType();
                isProfileField = (typeof(BaseMixedRealityProfile).IsreplacedignableFrom(referenceType));
            }
            return isProfileField;
        }

19 Source : MixedRealityProfileCloneWindow.cs
with Apache License 2.0
from abist-co-ltd

private void Initialize(BaseMixedRealityProfile parentProfile, BaseMixedRealityProfile childProfile, SerializedProperty childProperty, Object selectionTarget)
        {
            this.childProperty = childProperty;
            this.parentProfile = parentProfile;
            this.childProfile = childProfile;
            this.selectionTarget = selectionTarget;

            childSerializedObject = new SerializedObject(childProfile);
            childProfileTypeName = childProfile.GetType().Name;
            childProfilereplacedetName = "New " + childProfileTypeName;

            // Find all the serialized properties for sub-profiles
            SerializedProperty iterator = childSerializedObject.Gereplacederator();
            System.Type basePropertyType = typeof(BaseMixedRealityProfile);

            while (iterator.Next(true))
            {
                SerializedProperty subProfileProperty = childSerializedObject.FindProperty(iterator.name);

                if (subProfileProperty == null)
                {
                    continue;
                }

                if (!subProfileProperty.type.Contains("PPtr<$")) // Not an object reference type
                {
                    continue;
                }

                string subProfileTypeName = subProfileProperty.type.Replace("PPtr<$", string.Empty).Replace(">", string.Empty).Trim();
                System.Type subProfileType = FindProfileType(subProfileTypeName);
                if (subProfileType == null)
                {
                    continue;
                }

                if (!basePropertyType.IsreplacedignableFrom(subProfileType))
                {
                    continue;
                }

                subProfileActions.Add(new SubProfileAction(
                    ProfileCloneBehavior.UseExisting,
                    subProfileProperty,
                    subProfileProperty.objectReferenceValue,
                    subProfileType));
            }

            cloneWindow.maxSize = MinWindowSizeBasic;

            targetFolder = EnsureTargetFolder(targetFolder);
        }

19 Source : BaseServiceManager.cs
with Apache License 2.0
from abist-co-ltd

public IReadOnlyList<T> GetServices<T>(string name = null) where T : IMixedRealityService
        {
            Type interfaceType = typeof(T);
            List<T> matchingServices = new List<T>();

            foreach(IMixedRealityService service in registeredServices.Values)
            {
                if (!interfaceType.IsreplacedignableFrom(service.GetType())) { continue; }

                // If a name has been provided and if it matches the services's name, add the service.
                if (!string.IsNullOrWhiteSpace(name) && string.Equals(service.Name, name))
                {
                    matchingServices.Add((T)service);
                }
                // If no name has been specified, always add the service.
                else
                {
                    matchingServices.Add((T)service);
                }
            }

            return matchingServices;
        }

19 Source : BaseServiceManager.cs
with Apache License 2.0
from abist-co-ltd

private T ActivateInstance<T>(Type concreteType, SupportedPlatforms supportedPlatforms = (SupportedPlatforms)(-1), params object[] args) where T : IMixedRealityService
        {
            if (concreteType == null) { return default(T); }

#if UNITY_EDITOR
            if (!UnityEditor.EditorUserBuildSettings.activeBuildTarget.IsPlatformSupported(supportedPlatforms))
#else
            if (!Application.platform.IsPlatformSupported(supportedPlatforms))
#endif
            {
                return default(T);
            }

            if (!typeof(T).IsreplacedignableFrom(concreteType))
            {
                Debug.LogError($"Error: {concreteType.Name} service must implement {typeof(T)}.");
                return default(T);
            }

            try
            {
                T serviceInstance = (T)Activator.CreateInstance(concreteType, args);
                return serviceInstance;
            }
            catch (Exception e)
            {
                Debug.LogError($"Error: Failed to instantiate {concreteType.Name}: {e.GetType()} - {e.Message}");
                return default(T);
            }
        }

19 Source : MixedRealityInspectorUtility.cs
with Apache License 2.0
from abist-co-ltd

public static void DrawSubProfileEditor(Object profileObject, bool renderProfileInBox)
        {
            if (profileObject == null)
            {
                return;
            }

            UnityEditor.Editor subProfileEditor = null;
            if (!profileEditorCache.TryGetValue(profileObject, out subProfileEditor))
            {
                subProfileEditor = UnityEditor.Editor.CreateEditor(profileObject);
                profileEditorCache.Add(profileObject, subProfileEditor);
            }

            // If this is a default MRTK configuration profile, ask it to render as a sub-profile
            if (typeof(BaseMixedRealityToolkitConfigurationProfileInspector).IsreplacedignableFrom(subProfileEditor.GetType()))
            {
                BaseMixedRealityToolkitConfigurationProfileInspector configProfile = (BaseMixedRealityToolkitConfigurationProfileInspector)subProfileEditor;
                configProfile.RenderreplacedubProfile = true;
            }

            var subProfile = profileObject as BaseMixedRealityProfile;
            if (subProfile != null && !subProfile.IsCustomProfile)
            {
                string msg = MixedRealityProjectPreferences.LockProfiles ? CloneProfileHelpLockedLabel : CloneProfileHelpLabel;
                EditorGUILayout.HelpBox(msg, MessageType.Warning);
            }

            if (renderProfileInBox)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            }
            else
            {
                EditorGUILayout.BeginVertical();
            }

            EditorGUILayout.Space();
            subProfileEditor.OnInspectorGUI();
            EditorGUILayout.Space();

            EditorGUILayout.EndVertical();
        }

19 Source : MixedRealityProfileUtility.cs
with Apache License 2.0
from abist-co-ltd

public static bool IsProfileForService(Type profileType, Type serviceType)
        {
            foreach (MixedRealityServiceProfileAttribute serviceProfileAttribute in profileType.GetCustomAttributes(typeof(MixedRealityServiceProfileAttribute), true))
            {
                bool requirementsMet = true;
                foreach (Type requiredType in serviceProfileAttribute.RequiredTypes)
                {
                    if (!requiredType.IsreplacedignableFrom(serviceType))
                    {
                        requirementsMet = false;
                        break;
                    }
                }

                if (requirementsMet)
                {
                    foreach (Type excludedType in serviceProfileAttribute.ExcludedTypes)
                    {
                        if (excludedType.IsreplacedignableFrom(serviceType))
                        {
                            requirementsMet = false;
                            break;
                        }

                    }
                }

                return requirementsMet;
            }
            return false;
        }

19 Source : ObjectManipulatorInspector.cs
with Apache License 2.0
from abist-co-ltd

public override void OnInspectorGUI()
        {
            EditorGUILayout.PropertyField(hostTransform);
            EditorGUILayout.PropertyField(manipulationType);
            EditorGUILayout.PropertyField(allowFarManipulation);

            var handedness = (ManipulationHandFlags)manipulationType.intValue;

            EditorGUILayout.Space();
            GUIStyle style = EditorStyles.foldout;
            FontStyle previousStyle = style.fontStyle;
            style.fontStyle = FontStyle.Bold;
            oneHandedFoldout = EditorGUILayout.Foldout(oneHandedFoldout, "One Handed Manipulation", true);

            if (oneHandedFoldout)
            {
                if (handedness.HasFlag(ManipulationHandFlags.OneHanded))
                {
                    EditorGUILayout.PropertyField(oneHandRotationModeNear);
                    EditorGUILayout.PropertyField(oneHandRotationModeFar);
                }
                else
                {
                    EditorGUILayout.HelpBox("One handed manipulation disabled. If you wish to enable one handed manipulation select it as a Manipulation Type above.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            twoHandedFoldout = EditorGUILayout.Foldout(twoHandedFoldout, "Two Handed Manipulation", true);

            if (twoHandedFoldout)
            {
                if (handedness.HasFlag(ManipulationHandFlags.TwoHanded))
                {
                    EditorGUILayout.PropertyField(twoHandedManipulationType);
                }
                else
                {
                    EditorGUILayout.HelpBox("Two handed manipulation disabled. If you wish to enable two handed manipulation select it as a Manipulation Type above.", MessageType.Info);
                }
            }

            var mh = (ObjectManipulator)target;
            var rb = mh.HostTransform.GetComponent<Rigidbody>();

            EditorGUILayout.Space();
            constraintsFoldout = EditorGUILayout.Foldout(constraintsFoldout, "Constraints", true);

            if (constraintsFoldout)
            {
                if (EditorGUILayout.DropdownButton(new GUIContent("Add Constraint"), FocusType.Keyboard))
                {
                    // create the menu and add items to it
                    GenericMenu menu = new GenericMenu();

                    var type = typeof(TransformConstraint);
                    var types = AppDomain.CurrentDomain.Getreplacedemblies()
                        .SelectMany(s => s.GetLoadableTypes())
                        .Where(p => type.IsreplacedignableFrom(p));

                    foreach (var derivedType in types)
                    {
                        menu.AddItem(new GUIContent(derivedType.Name), false, t => mh.gameObject.AddComponent((Type)t), derivedType);
                    }

                    menu.ShowAsContext();
                }

                var constraints = mh.GetComponents<TransformConstraint>();

                foreach (var constraint in constraints)
                {
                    EditorGUILayout.BeginHorizontal();
                    string constraintName = constraint.GetType().Name;
                    EditorGUILayout.LabelField(constraintName);
                    if (GUILayout.Button("Go to component"))
                    {
                        Highlighter.Highlight("Inspector", $"{ObjectNames.NicifyVariableName(constraintName)} (Script)");
                        EditorGUIUtility.ExitGUI();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();
            physicsFoldout = EditorGUILayout.Foldout(physicsFoldout, "Physics", true);

            if (physicsFoldout)
            {
                if (rb != null)
                {
                    EditorGUILayout.PropertyField(releaseBehavior);
                }
                else
                {
                    EditorGUILayout.HelpBox("Physics options disabled. If you wish to enable physics options, add a Rigidbody component to this object.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            smoothingFoldout = EditorGUILayout.Foldout(smoothingFoldout, "Smoothing", true);

            if (smoothingFoldout)
            {
                EditorGUILayout.PropertyField(smoothingActive);
                EditorGUILayout.PropertyField(moveLerpTime);
                EditorGUILayout.PropertyField(rotateLerpTime);
                EditorGUILayout.PropertyField(scaleLerpTime);
            }

            EditorGUILayout.Space();
            eventsFoldout = EditorGUILayout.Foldout(eventsFoldout, "Manipulation Events", true);

            if (eventsFoldout)
            {
                EditorGUILayout.PropertyField(onManipulationStarted);
                EditorGUILayout.PropertyField(onManipulationEnded);
                EditorGUILayout.PropertyField(onHoverEntered);
                EditorGUILayout.PropertyField(onHoverExited);
            }

            // reset foldouts style
            style.fontStyle = previousStyle;

            serializedObject.ApplyModifiedProperties();
        }

19 Source : CoreServices.cs
with Apache License 2.0
from abist-co-ltd

public static bool ResetCacheReference(Type serviceType)
        {
            if (typeof(IMixedRealityService).IsreplacedignableFrom(serviceType))
            {
                if (serviceCache.ContainsKey(serviceType))
                {
                    serviceCache.Remove(serviceType);
                    return true;
                }
            }
            else
            {
                Debug.Log("Cache only contains types that implement IMixedRealityService");
            }

            return false;
        }

19 Source : MixedRealitySpatialAwarenessSystem.cs
with Apache License 2.0
from abist-co-ltd

public override IReadOnlyList<T> GetDataProviders<T>()
        {
            using (GetDataProvidersPerfMarker.Auto())
            {
                if (!typeof(IMixedRealitySpatialAwarenessObserver).IsreplacedignableFrom(typeof(T)))
                {
                    return null;
                }

                return base.GetDataProviders<T>();
            }
        }

19 Source : MixedRealitySpatialAwarenessSystem.cs
with Apache License 2.0
from abist-co-ltd

public override T GetDataProvider<T>(string name = null)
        {
            using (GetDataProviderPerfMarker.Auto())
            {
                if (!typeof(IMixedRealitySpatialAwarenessObserver).IsreplacedignableFrom(typeof(T)))
                {
                    return default(T);
                }

                return base.GetDataProvider<T>(name);
            }
        }

19 Source : AbpElsaModule.cs
with Apache License 2.0
from AbpApp

private static void AutoAddWorkFlowDefinitions(IServiceCollection services)
        {
            var activityDefinitionList= new ActivityDefinitionList();
            var definitionProviders = new List<Type>();
            services.OnRegistred(context =>
            {
                if (typeof(IActivity).IsreplacedignableFrom(context.ImplementationType))
                {
                    activityDefinitionList.Add(ActivityDescriber.Describe(context.ImplementationType));
                }

                if (typeof(IWorkflowProvider).IsreplacedignableFrom(context.ImplementationType)) {
                    definitionProviders.Add(context.ImplementationType);
                }
            });
            services.Configure<AbpElsaOptions>(options =>
            {
                options.ActivityDefinitions = activityDefinitionList;
                options.DefinitionProviders.AddIfNotContains(definitionProviders);
            });
        }

19 Source : MergedStyles.cs
with MIT License
from Accelerider

private static Type GetMergedStyleType(Type left, Type right)
        {
            if (left == right) return left;
            if (left.IsreplacedignableFrom(right)) return right;
            if (right.IsreplacedignableFrom(left)) return left;

            throw new InvalidOperationException();
        }

19 Source : ResourceProperties.cs
with MIT License
from actions

public override Boolean CanConvert(Type objectType)
        {
            return typeof(IDictionary<String, JToken>).GetTypeInfo().IsreplacedignableFrom(objectType);
        }

19 Source : ParentTokenTaggerProvider.g.cs
with MIT License
from Actipro

public ITagger<T> GetTagger<T>(ICodeDoreplacedent doreplacedent)
            where T : ITag {
            if (typeof(ITagger<T>).IsreplacedignableFrom(typeof(ParentTokenTagger))) {
                TaggerFactory factory = new TaggerFactory(this, doreplacedent);
                return ((ITagger<T>)(doreplacedent.Properties.GetOrCreateSingleton(typeof(ITagger<ITokenTag>), new ActiproSoftware.Text.Utility.PropertyDictionary.Creator<ParentTokenTagger>(factory.CreateTagger))));
            }
            else {
                return null;
            }
        }

19 Source : SimpleTokenTaggerProvider.g.cs
with MIT License
from Actipro

public ITagger<T> GetTagger<T>(ICodeDoreplacedent doreplacedent)
            where T : ITag {
            if (typeof(ITagger<T>).IsreplacedignableFrom(typeof(SimpleTokenTagger))) {
                TaggerFactory factory = new TaggerFactory(this, doreplacedent);
                return ((ITagger<T>)(doreplacedent.Properties.GetOrCreateSingleton(typeof(ITagger<ITokenTag>), new ActiproSoftware.Text.Utility.PropertyDictionary.Creator<SimpleTokenTagger>(factory.CreateTagger))));
            }
            else {
                return null;
            }
        }

19 Source : NodeFactory.cs
with GNU General Public License v3.0
from Adam-Wilkinson

private NodeContainer<T> PrivateGet<T>(T node) where T : INode, new()
        {
            if (typeof(IFlowNode).IsreplacedignableFrom(typeof(T)))
            {
                return Make<FlowNode<T>, T>(node);
            }

            if (typeof(IActionNode).IsreplacedignableFrom(typeof(T)))
            {
                return Make<ActionNode<T>, T>(node);
            }

            if (typeof(IFunctionNode).IsreplacedignableFrom(typeof(T)))
            {
                return Make<FunctionNode<T>, T>(node);
            }

            if (typeof(ITriggerNode).IsreplacedignableFrom(typeof(T)))
            {
                return Make<TriggerNode<T>, T>(node);
            }

            if (typeof(T) == typeof(InputNode))
            {
                return Make<InputNodeContainer<T>, T>(node);
            }

            return Make<NodeContainer<T>, T>(node);
        }

19 Source : TypeDefinitionProvider.cs
with GNU General Public License v3.0
from Adam-Wilkinson

public bool CanAcceptValue(object value) => ValueType.IsreplacedignableFrom(value.GetType());

19 Source : UserInterfaceRegister.cs
with GNU General Public License v3.0
from Adam-Wilkinson

private static object PrepareForReturning(object internalUserInterface)
            {
                if (typeof(Type).IsreplacedignableFrom(internalUserInterface.GetType()))
                {
                    return Activator.CreateInstance((Type)internalUserInterface);
                }

                return internalUserInterface;
            }

19 Source : Arbitrary.cs
with MIT License
from adamant

private static bool SeparateTokens(PsuedoToken t1, PsuedoToken t2)
        {
            switch (t1.Text)
            {
                case ".":
                case "^":
                    return t2.Text == "." || t2.Text == ".." || t2.Text == "..<";
                case "+":
                case ">":
                    return t2.Text == "=" || t2.Text == "==" || t2.Text == "=/=" || t2.Text == "=>";
                case "*":
                    return t2.Text == "=" || t2.Text == "==" || t2.Text == "=/=" || t2.Text == "=>"
                        || t2.Text == "*=";
                case "<":
                    return t2.Text == "=" || t2.Text == "==" || t2.Text == "=/=" || t2.Text == "=>"
                        || t2.Text == ":" || t2.Text == "::."
                        || t2.Text == ".." || t2.Text == "..<"
                        || t2.Text == "~>";
                case "-":
                    return t2.Text == "=" || t2.Text == "==" || t2.Text == "=/=" || t2.Text == "=>"
                        || t2.Text == ">" || t2.Text == ">=";
                case "/":
                    return t2.Text == "=" || t2.Text == "==" || t2.Text == "=/=" || t2.Text == "=>"
                        || t2.Text == "*" || t2.Text == "*="
                        || t2.Text == "/" || t2.Text == "/="
                        || t2.TokenType == typeof(ICommentToken);
                case "=":
                    return t2.Text == "=" || t2.Text == "==" || t2.Text == "=/=" || t2.Text == "=>" || t2.Text == "/="
                        || t2.Text == ">" || t2.Text == ">=";
                case "?":
                    return t2.Text == "." || t2.Text == ".." || t2.Text == "..<"
                        || t2.Text == "?" || t2.Text == "?." || t2.Text == "??";
                case "..":
                case "<..":
                    return t2.Text == "<" || t2.Text == "<=" || t2.Text == "<:" || t2.Text == "<.." || t2.Text == "<..<" || t2.Text == "<~";
                case "#":
                    return t2.Text == "#" || t2.Text == "##";
                case ":":
                    // TODO actually ':',':' is fine. It is really the three token sequence ':',':','.' that is the problem
                    return t2.Text == ":";
                default:
                    if (typeof(IKeywordToken).IsreplacedignableFrom(t1.TokenType)
                        || typeof(IIdentifierToken).IsreplacedignableFrom(t1.TokenType))
                        return typeof(IIdentifierToken).IsreplacedignableFrom(t2.TokenType)
                            || typeof(IKeywordToken).IsreplacedignableFrom(t2.TokenType)
                            || t2.TokenType == typeof(IIntegerLiteralToken);
                    else if (t1.TokenType == typeof(IIntegerLiteralToken))
                        return t2.TokenType == typeof(IIntegerLiteralToken);
                    else if (t1.TokenType == typeof(IWhitespaceToken))
                        return t2.TokenType == typeof(IWhitespaceToken);
                    else
                        return false;
            }
        }

19 Source : PsuedoToken.cs
with MIT License
from adamant

public override bool Equals(object? obj)
        {
            if (obj is PsuedoToken token &&
                (TokenType == token.TokenType
                    || TokenType.IsreplacedignableFrom(token.TokenType)
                    || token.TokenType.IsreplacedignableFrom(TokenType)) &&
                Text == token.Text)
            {
                if (Value is IReadOnlyList<Diagnostic> diagnostics
                    && token.Value is IReadOnlyList<Diagnostic> otherDiagnostics)
                {
                    // TODO this zip looks wrong, shouldn't it be comparing something rather than always returning false?
                    return diagnostics.Zip(otherDiagnostics, (d1, d2) => false).All(i => i);
                }
                return EqualityComparer<object>.Default.Equals(Value, token.Value);
            }
            return false;
        }

19 Source : TypeExtensions.cs
with MIT License
from adamant

public static IEnumerable<Type> GetAllSubtypes(this Type type)
        {
            return AppDomain.CurrentDomain.Getreplacedemblies()
                    .SelectMany(a => a.GetTypes())
                    .Where(t => type.IsreplacedignableFrom(t) && t != type)
                    .ToArray();
        }

19 Source : MessageHandlerContainer.cs
with MIT License
from AdemCatamak

public void Register(Type messageHandlerType, Action<MessageHandlerMetadata>? configureMessageHandlerMetadata = null)
        {
            if (!typeof(IMessageHandler).IsreplacedignableFrom(messageHandlerType))
            {
                throw new ArgumentNotCompatibleException(messageHandlerType.FullName ?? string.Empty, nameof(IMessageHandler));
            }

            List<Type> payloadTypes = GetPayloadTypes(messageHandlerType);

            MessageHandlerMetadata messageHandlerMetadata = new MessageHandlerMetadata(messageHandlerType, payloadTypes);
            configureMessageHandlerMetadata?.Invoke(messageHandlerMetadata);

            bool added = _messageHandlerAndMessageHandlerDescriptions.TryAdd(messageHandlerType.FullName, messageHandlerMetadata);
            if (!added)
            {
                throw new DuplicateDependencyInjectionException(messageHandlerType);
            }
        }

19 Source : AnonymousTypeWrapper.cs
with MIT License
from adoconnection

public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            PropertyInfo propertyInfo = this.model.GetType().GetProperty(binder.Name);

            if (propertyInfo == null)
            {
                result = null;
                return false;
            }

            result = propertyInfo.GetValue(this.model, null);

            if (result == null)
            {
                return true;
            }

            var type = result.GetType();

            if (result.IsAnonymous())
            {
                result = new AnonymousTypeWrapper(result);
            }

            bool isEnumerable = typeof(IEnumerable).IsreplacedignableFrom(type);

            if (isEnumerable && !(result is string))
            {
                result = ((IEnumerable<object>) result)
                        .Select(e =>
                        {
                            if (e.IsAnonymous())
                            {
                                return new AnonymousTypeWrapper(e);
                            }

                            return e;
                        })
                        .ToList();
            }
        

            return true;
        }

19 Source : Program.cs
with MIT License
from adospace

public static void Main()
        {
            //force XF replacedembly load
            var _ = new Xamarin.Forms.Shapes.Rectangle();

            var types = (from domainreplacedembly in AppDomain.CurrentDomain.Getreplacedemblies()
                             // alternative: from domainreplacedembly in domainreplacedembly.GetExportedTypes()
                         from replacedemblyType in domainreplacedembly.GetTypes()
                         where typeof(BindableObject).IsreplacedignableFrom(replacedemblyType)
                         // alternative: where replacedemblyType.IsSubclreplacedOf(typeof(B))
                         // alternative: && ! replacedemblyType.IsAbstract
                         select replacedemblyType)
                .ToDictionary(_ => _.FullName, _ => _);

            foreach (var clreplacedNameToGenerate in File.ReadAllLines("WidgetList.txt").Where(_ => !string.IsNullOrWhiteSpace(_)))
            {
                var typeToScaffold = types[clreplacedNameToGenerate];
                var outputPath = Path.Combine(Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location), "gen");
                Directory.CreateDirectory(outputPath);

                Scaffold(typeToScaffold, outputPath);
            }
        }

19 Source : DependencyInjectionMessageHandlerContainer.cs
with MIT License
from AdemCatamak

public void Register(Type messageHandlerType, Action<MessageHandlerMetadata>? configureMessageHandlerMetadata)
        {
            if (!typeof(IMessageHandler).IsreplacedignableFrom(messageHandlerType))
            {
                throw new ArgumentNotCompatibleException(messageHandlerType.FullName ?? string.Empty, typeof(IMessageHandler).FullName);
            }

            var payloadTypes = GetPayloadTypes(messageHandlerType);
            MessageHandlerMetadata messageHandlerMetadata = new MessageHandlerMetadata(messageHandlerType, payloadTypes);
            configureMessageHandlerMetadata?.Invoke(messageHandlerMetadata);

            _serviceCollection.AddSingleton(messageHandlerMetadata);

            _serviceCollection.AddTransient(typeof(IMessageHandler), messageHandlerType);
            _serviceCollection.AddTransient(messageHandlerType);
        }

19 Source : CrmJsonConverter.cs
with MIT License
from Adoxio

public override bool CanConvert(Type objectType)
		{
			if (CanConvertTypes.Any(type => type == objectType))
			{
				 return true;
			}

			if (CanConvertBaseTypes.Any(type => type.IsreplacedignableFrom(objectType)))
			{
				 return true;
			}

			return false;
		}

19 Source : SearchManager.cs
with MIT License
from Adoxio

private static TProvider InstantiateProvider<TProvider>(ProviderSettings settings) where TProvider : ProviderBase
		{
			try
			{
				var typeSetting = settings.Type == null ? null : settings.Type.Trim();

				if (string.IsNullOrEmpty(typeSetting))
				{
					throw new ArgumentException("Type_Name_Required_For_Provider_Exception (Key present in resx file with same string)");
				}

				var providerType = Type.GetType(settings.Type, true, true);

				if (!typeof(TProvider).IsreplacedignableFrom(providerType))
				{
					throw new ArgumentException("Provider must implement the clreplaced {0}.".FormatWith(typeof(TProvider)));
				}

				var provider = (TProvider)Activator.CreateInstance(providerType);

				var parameters = settings.Parameters;
				var config = new NameValueCollection(parameters.Count, StringComparer.Ordinal);

				foreach (string key in parameters)
				{
					config[key] = parameters[key];
				}

				provider.Initialize(settings.Name, config);

				return provider;
			}
			catch (Exception e)
			{
				if (e is ConfigurationException)
				{
					throw;
				}

				var typePropertyInformation = settings.ElementInformation.Properties["type"];

				if (typePropertyInformation == null)
				{
					throw;
				}

				throw new ConfigurationErrorsException(e.Message, typePropertyInformation.Source, typePropertyInformation.LineNumber);
			}
		}

19 Source : ReflectionEntityAttributeUpdate.cs
with MIT License
from Adoxio

protected object GetValue(JToken token, Type propertyType)
		{
			var value = token.ToObject<object>();

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

			if (propertyType == typeof(bool?))
			{
				return Convert.ToBoolean(value);
			}

			if (propertyType == typeof(CrmEnreplacedyReference))
			{
				EnreplacedyReference enreplacedyReference;

				if (TryGetEnreplacedyReference(value, out enreplacedyReference))
				{
					return new CrmEnreplacedyReference(enreplacedyReference.LogicalName, enreplacedyReference.Id);
				}

				throw new FormatException("Unable to convert value {0} for attribute {1} to {2}.".FormatWith(value, Attribute.CrmPropertyAttribute.LogicalName, typeof(EnreplacedyReference)));
			}

			if (propertyType == typeof(DateTime?))
			{
				var dateTimeValue = value is DateTime ? (DateTime)value : Convert.ToDateTime(value);

				return dateTimeValue.Kind == DateTimeKind.Utc ? dateTimeValue : dateTimeValue.ToUniversalTime();
			}

			if (propertyType == typeof(double?))
			{
				return Convert.ToDouble(value);
			}

			if (propertyType == typeof(decimal))
			{
				return Convert.ToDecimal(value);
			}

			if (propertyType == typeof(EnreplacedyReference))
			{
				EnreplacedyReference enreplacedyReference;

				if (TryGetEnreplacedyReference(value, out enreplacedyReference))
				{
					return enreplacedyReference;
				}

				throw new FormatException("Unable to convert value {0} for attribute {1} to {2}.".FormatWith(value, Attribute.CrmPropertyAttribute.LogicalName, typeof(EnreplacedyReference)));
			}

			if (propertyType == typeof(Guid?))
			{
				return value is Guid ? value : new Guid(value.ToString());
			}

			if (propertyType == typeof(int?))
			{
				return Convert.ToInt32(value);
			}

			if (propertyType == typeof(long?))
			{
				return Convert.ToInt64(value);
			}

			if (propertyType == typeof(string))
			{
				return value is string ? value : value.ToString();
			}

			if (propertyType.IsreplacedignableFrom(value.GetType()))
			{
				return value;
			}

			throw new InvalidOperationException("Unable to convert value of type".FormatWith(value.GetType(), propertyType, Attribute.CrmPropertyAttribute.LogicalName));
		}

19 Source : OrganizationServiceCachePluginMessageHandler.cs
with MIT License
from Adoxio

private static bool IsExtendedOrganizationServiceCache(Type type)
		{
			return typeof(IExtendedOrganizationServiceCache).IsreplacedignableFrom(type);
		}

19 Source : TypeExtensions.cs
with MIT License
from Adoxio

public static bool IsA(this Type type, Type referenceType)
		{
			return referenceType != null ? referenceType.IsreplacedignableFrom(type) : false;
		}

19 Source : VerifyLogExpressionArgs.cs
with Apache License 2.0
from adrianiftode

private static Exception GetException(Expression expression)
            => ExpressionInspector.GetArgExpression(expression, c => typeof(Exception).IsreplacedignableFrom(c.Type)) 

19 Source : Agent.cs
with MIT License
from adrenak

private void LoadActorFromComponent() {
            foreach (Component comp in gameObject.GetComponents(typeof(Component))) {
                if (typeof(IActor).IsreplacedignableFrom(comp.GetType())) {
                    mActor = (IActor)comp;
                    return;
                }
            }
        }

19 Source : VerifyLogExpression.cs
with Apache License 2.0
from adrianiftode

public static VerifyLogExpression From(Expression expression) =>
            new VerifyLogExpression
            {
                ExceptionExpression = ExpressionInspector.GetArgExpression(expression, c => typeof(Exception).IsreplacedignableFrom(c.Type)),
                EventIdExpression = ExpressionInspector.GetArgExpressionOf<EventId>(expression),
                MessageExpression = ExpressionInspector.GetArgExpressionOf<string>(expression),
                MessageArgsExpression = ExpressionInspector.GetArgExpressionOf<object[]>(expression),
                Args = VerifyLogExpressionArgs.From(expression)
            };

19 Source : EventTriggerBase.cs
with GNU General Public License v3.0
from aduskin

private static bool IsValidEvent(EventInfo eventInfo)
        {
            var eventHandlerType = eventInfo.EventHandlerType;
            if (!typeof(Delegate).IsreplacedignableFrom(eventInfo.EventHandlerType))
                return false;
            var parameters = eventHandlerType.GetMethod("Invoke")?.GetParameters();
            return parameters != null && parameters.Length == 2 && typeof(object).IsreplacedignableFrom(parameters[0].ParameterType) && typeof(EventArgs).IsreplacedignableFrom(parameters[1].ParameterType);
        }

19 Source : InvokeCommandAction.cs
with GNU General Public License v3.0
from aduskin

private ICommand ResolveCommand()
        {
            var command = (ICommand)null;
            if (Command != null)
                command = Command;
            else if (replacedociatedObject != null)
                foreach (var property in replacedociatedObject.GetType()
                    .GetProperties(BindingFlags.Instance | BindingFlags.Public))
                    if (typeof(ICommand).IsreplacedignableFrom(property.PropertyType) &&
                        string.Equals(property.Name, CommandName, StringComparison.Ordinal))
                        command = (ICommand)property.GetValue(replacedociatedObject, null);
            return command;
        }

See More Examples