Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj != null && obj is Runtime)
            {
                var other = obj as Runtime;
                return(_runtimeType.Equals(other._runtimeType));
            }

            return(false);
        }
Exemplo n.º 2
0
        //
        // This is a port of the desktop CLR's RuntimeType.FormatTypeName() routine. This routine is used by various Reflection ToString() methods
        // to display the name of a type. Do not use for any other purpose as it inherits some pretty quirky desktop behavior.
        //
        // The Project N version takes a raw metadata handle rather than a completed type so that it remains robust in the face of missing metadata.
        //
        public static String FormatTypeName(this RuntimeType runtimeType)
        {
            try
            {
                // Though we wrap this in a try-catch as a failsafe, this code must still strive to avoid triggering MissingMetadata exceptions
                // (non-error exceptions are very annoying when debugging.)

                ReflectionDomain reflectionDomain = runtimeType.GetReflectionDomain();

                // Legacy: this doesn't make sense, why use only Name for nested types but otherwise
                // ToString() which contains namespace.
                RuntimeType rootElementType = runtimeType;
                while (rootElementType.HasElementType)
                {
                    rootElementType = rootElementType.InternalRuntimeElementType;
                }
                if (rootElementType.IsNested)
                {
                    String name = runtimeType.InternalNameIfAvailable;
                    return(name == null ? UnavailableType : name);
                }

                // Legacy: why removing "System"? Is it just because C# has keywords for these types?
                // If so why don't we change it to lower case to match the C# keyword casing?
                FoundationTypes foundationTypes = reflectionDomain.FoundationTypes;
                String          typeName        = runtimeType.ToString();
                if (typeName.StartsWith("System."))
                {
                    foreach (Type pt in reflectionDomain.PrimitiveTypes)
                    {
                        if (pt.Equals(rootElementType) || rootElementType.Equals(foundationTypes.SystemVoid))
                        {
                            typeName = typeName.Substring("System.".Length);
                            break;
                        }
                    }
                }
                return(typeName);
            }
            catch (Exception)
            {
                return(UnavailableType);
            }
        }
Exemplo n.º 3
0
        public async Task <Dictionary <string, bool> > GetRuntimeFeatures(ZumoTest test)
        {
            if (runtimeFeatures == null)
            {
                RuntimeType     = "unknown";
                RuntimeVersion  = "unknown";
                IsNetRuntime    = false;
                IsNHPushEnabled = false;

                try
                {
                    JToken apiResult = await Client.InvokeApiAsync("runtimeInfo", HttpMethod.Get, null);

                    runtimeFeatures = apiResult["features"].ToObject <Dictionary <string, bool> >();
                    var runtimeInfo = apiResult["runtime"].ToObject <Dictionary <string, string> >();
                    RuntimeType    = runtimeInfo["type"];
                    RuntimeVersion = runtimeInfo["version"];

                    IsNetRuntime    = RuntimeType.Equals(".NET");
                    IsNHPushEnabled = runtimeFeatures[ZumoTestGlobals.RuntimeFeatureNames.NH_PUSH_ENABLED];
                }
                catch (Exception ex)
                {
                    test.AddLog(ex.Message);
                }

                if (runtimeFeatures.Count > 0)
                {
                    test.AddLog("Runtime: {0}", ZumoTestGlobals.Instance.RuntimeType);
                    test.AddLog("Version: {0}", ZumoTestGlobals.Instance.RuntimeVersion);
                    foreach (var entry in runtimeFeatures)
                    {
                        test.AddLog("Runtime feature: {0} : {1}", entry.Key, entry.Value);
                    }
                }
                else
                {
                    test.AddLog("Could not load the runtime information");
                }
            }

            return(runtimeFeatures);
        }