Ejemplo n.º 1
0
        public static void RegisterWindowType(Type windowType)
        {
            if (!windowType.GetInterfaces().Contains(typeof(IPersistableWindow)))
            {
                throw new Exception();
            }

            object[] foundAttributes = windowType.GetCustomAttributes(typeof(WindowTypeNameAttribute), true);
            if (foundAttributes.Length == 0)
            {
                throw new Exception();
            }
            WindowTypeNameAttribute typeNameAttribute = foundAttributes[0] as WindowTypeNameAttribute;

            if (typeNameAttribute == null)
            {
                throw new Exception();
            }

            string typeName = typeNameAttribute.TypeName;

            if (!registeredTypes.ContainsKey(typeName))
            {
                registeredTypes.Add(typeName, windowType);
            }
        }
Ejemplo n.º 2
0
        public static void RegisterWindowType <TWindow>()
            where TWindow : IPersistableWindow
        {
            Type windowType = typeof(TWindow);
            WindowTypeNameAttribute typeNameAttribute = windowType.GetAttribute <WindowTypeNameAttribute>();

            if (typeNameAttribute == null)
            {
                throw new Exception();
            }
            string typeName = typeNameAttribute.TypeName;

            if (!registeredTypes.ContainsKey(typeName))
            {
                registeredTypes.Add(typeName, windowType);
            }
        }