예제 #1
0
        private void CopyChildAttributes()
        {
            // Copy the attribute values from the ChildControl to the GenericWebPart properties.
            IAttributeAccessor childAttributeAccessor = ChildControl as IAttributeAccessor;

            if (childAttributeAccessor != null)
            {
                base.AuthorizationFilter = childAttributeAccessor.GetAttribute("AuthorizationFilter");
                base.CatalogIconImageUrl = childAttributeAccessor.GetAttribute("CatalogIconImageUrl");
                base.Description         = childAttributeAccessor.GetAttribute("Description");

                string exportMode = childAttributeAccessor.GetAttribute("ExportMode");
                if (exportMode != null)
                {
                    base.ExportMode = (WebPartExportMode)(Util.GetEnumAttribute(
                                                              "ExportMode", exportMode, typeof(WebPartExportMode)));
                }

                // Don't need to check base.Subtitle, since we always want to use the Subtitle on the
                // ChildControl if it is present.  Also, the property is not settable on WebPart, so we
                // know that base.Subtitle will always be String.Empty.
                _subtitle = childAttributeAccessor.GetAttribute("Subtitle");

                base.Title             = childAttributeAccessor.GetAttribute("Title");
                base.TitleIconImageUrl = childAttributeAccessor.GetAttribute("TitleIconImageUrl");
                base.TitleUrl          = childAttributeAccessor.GetAttribute("TitleUrl");
            }

            // Remove all the attributes from the ChildControl, whether or not they were copied
            // to the GenericWebPart property.  We want to remove the attributes so they are not
            // rendered on the ChildControl.  (VSWhidbey 313674)
            WebControl childWebControl = ChildControl as WebControl;

            if (childWebControl != null)
            {
                // If the ChildControl is a WebControl, we want to completely remove the attributes.
                childWebControl.Attributes.Remove("AuthorizationFilter");
                childWebControl.Attributes.Remove("CatalogIconImageUrl");
                childWebControl.Attributes.Remove("Description");
                childWebControl.Attributes.Remove("ExportMode");
                childWebControl.Attributes.Remove("Subtitle");
                childWebControl.Attributes.Remove("Title");
                childWebControl.Attributes.Remove("TitleIconImageUrl");
                childWebControl.Attributes.Remove("TitleUrl");
            }
            else if (childAttributeAccessor != null)
            {
                // If the ChildControl is not a WebControl, we cannot remove the attributes, so we set
                // them to null instead.
                childAttributeAccessor.SetAttribute("AuthorizationFilter", null);
                childAttributeAccessor.SetAttribute("CatalogIconImageUrl", null);
                childAttributeAccessor.SetAttribute("Description", null);
                childAttributeAccessor.SetAttribute("ExportMode", null);
                childAttributeAccessor.SetAttribute("Subtitle", null);
                childAttributeAccessor.SetAttribute("Title", null);
                childAttributeAccessor.SetAttribute("TitleIconImageUrl", null);
                childAttributeAccessor.SetAttribute("TitleUrl", null);
            }
        }
        public ErrorMessage BuildErrorMessage(Exception exception, IAttributeAccessor context)
        {
            var inputMessage = context?.GetAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY);
            var headers      = new Dictionary <string, object>();

            if (context != null)
            {
                headers[AMQP_RAW_MESSAGE] = context.GetAttribute(AMQP_RAW_MESSAGE);
                headers[IntegrationMessageHeaderAccessor.SOURCE_DATA] = context.GetAttribute(AMQP_RAW_MESSAGE);
            }

            return(inputMessage is IMessage message
                ? new ErrorMessage(exception, headers, message)
                : new ErrorMessage(exception, headers));
        }
예제 #3
0
 private void SetCssAttribute(IAttributeAccessor aa, string cssName)
 {
     if (string.IsNullOrEmpty(aa.GetAttribute("class")))
     {
         aa.SetAttribute("class", cssName);
     }
 }
예제 #4
0
        protected virtual Exception PayloadWhenNull(IAttributeAccessor context)
        {
            var message = (IMessage)context.GetAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY);

            return(message == null
                    ? new MessagingException("No root cause exception available")
                    : new MessagingException(message, "No root cause exception available"));
        }
예제 #5
0
        public void Attributes()
        {
            HtmlForm           form = new HtmlForm();
            IAttributeAccessor a    = (IAttributeAccessor)form;

            /* not stored in Attributes */
            form.DefaultButton = "defaultbutton";
            Assert.IsNull(a.GetAttribute("defaultbutton"), "A1");

            /* not stored in Attributes */
            form.DefaultFocus = "defaultfocus";
            Assert.IsNull(a.GetAttribute("defaultfocus"), "A2");
            form.Enctype = "enctype";
            Assert.AreEqual("enctype", a.GetAttribute("enctype"), "A3");

            form.Method = "method";
            Assert.AreEqual("method", a.GetAttribute("method"), "A4");

            /* not stored in Attributes */
            form.Name = "name";
            Assert.AreEqual(form.UniqueID, form.Name, "A5");
            Assert.IsNull(form.Name, "A6");
            Assert.IsNull(form.UniqueID, "A7");
            Assert.IsNull(a.GetAttribute("name"), "A8");
            form.ID = "hithere";
            Assert.AreEqual("hithere", form.Name, "A9");

            form.SubmitDisabledControls = true;
            Assert.IsNull(a.GetAttribute("submitdisabledcontrols"), "A10");

            form.Target = "target";
            Assert.AreEqual("target", a.GetAttribute("target"), "A11");
        }
 /**
  * Copy the attributes from the supplied AttributeAccessor to this accessor.
  * @param source the AttributeAccessor to copy from
  */
 protected void CopyAttributesFrom(IAttributeAccessor source)
 {
     Trace.Assert(source != null, "Source must not be null");
     string[] attributeNames = source.AttributeNames;
     foreach (string attributeName in attributeNames)
     {
         SetAttribute(attributeName, source.GetAttribute(attributeName));
     }
 }
예제 #7
0
        public void GetSetAttributes() {
            // Setup
            DummyMvcControl c = new DummyMvcControl();
            IAttributeAccessor attrAccessor = (IAttributeAccessor)c;
            IDictionary<string, string> attrs = c.Attributes;

            // Execute and Verify
            string value;
            value = attrAccessor.GetAttribute("xyz");
            Assert.IsNull(value);

            attrAccessor.SetAttribute("a1", "v1");
            value = attrAccessor.GetAttribute("a1");
            Assert.AreEqual<string>("v1", value);
            Assert.AreEqual<int>(1, attrs.Count);
            value = c.Attributes["a1"];
            Assert.AreEqual<string>("v1", value);
        }
예제 #8
0
 public bool ApplyAuth(Control control)
 {
     if (control is IAttributeAccessor)
     {
         IAttributeAccessor attributeAccessor = (IAttributeAccessor)control;
         return(string.IsNullOrWhiteSpace(attributeAccessor.GetAttribute("data-auth")));
     }
     return(false);
 }
        public ErrorMessage BuildErrorMessage(Exception exception, IAttributeAccessor attributes)
        {
            var inputMessage = attributes?.GetAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY);

            return(inputMessage switch
            {
                IMessage iMessage => new ErrorMessage(exception, iMessage),
                _ => new ErrorMessage(exception)
            });
예제 #10
0
        internal static void ApplyRolesFilterRecursive(Control c, IPrincipal currentUser, IVersionable versionableObject)
        {
            IAttributeAccessor attributeAccessor = c as IAttributeAccessor;

            if (attributeAccessor != null)
            {
                string             attribute          = attributeAccessor.GetAttribute("SetRoles");
                string             attribute2         = attributeAccessor.GetAttribute("DataBoundProperty");
                PropertyDefinition propertyDefinition = (versionableObject != null && !string.IsNullOrEmpty(attribute2)) ? versionableObject.ObjectSchema[attribute2] : null;
                if (propertyDefinition != null && !versionableObject.IsPropertyAccessible(propertyDefinition))
                {
                    Properties.HideControl(c, Properties.FindAssociatedLabel(c));
                }
                else if ((!string.IsNullOrEmpty(attribute) && !LoginUtil.IsInRoles(currentUser, attribute.Split(new char[]
                {
                    ','
                }))) || (!string.IsNullOrEmpty(attribute2) && versionableObject != null && versionableObject.IsReadOnly))
                {
                    string attribute3      = attributeAccessor.GetAttribute("NoRoleState");
                    Label  associatedLabel = Properties.FindAssociatedLabel(c);
                    if (!string.IsNullOrEmpty(attribute3) && NoRoleState.Hide == (NoRoleState)Enum.Parse(typeof(NoRoleState), attribute3))
                    {
                        Properties.HideControl(c, associatedLabel);
                    }
                    else
                    {
                        Properties.MakeControlRbacDisabled(c, associatedLabel);
                        if (!string.IsNullOrEmpty(attributeAccessor.GetAttribute("helpId")))
                        {
                            attributeAccessor.SetAttribute("helpId", string.Empty);
                        }
                        attributeAccessor.SetAttribute("MandatoryParam", null);
                    }
                }
            }
            if (c.HasControls())
            {
                foreach (object obj in c.Controls)
                {
                    Control c2 = (Control)obj;
                    Properties.ApplyRolesFilterRecursive(c2, currentUser, versionableObject);
                }
            }
        }
예제 #11
0
 /// <summary>
 /// 如果此控件不存在此属性,将属性添加到控件中
 /// </summary>
 /// <param name="accessor"></param>
 /// <param name="attributeName"></param>
 /// <param name="attributeValue"></param>
 public static void AddAttributeIfNotExists(IAttributeAccessor accessor, string attributeName, string attributeValue)
 {
     if (accessor != null && attributeName != null)
     {
         if (accessor.GetAttribute(attributeName) == null)
         {
             accessor.SetAttribute(attributeName, attributeValue);
         }
     }
 }
예제 #12
0
        public void GetSetAttributes()
        {
            // Setup
            DummyMvcControl              c            = new DummyMvcControl();
            IAttributeAccessor           attrAccessor = c;
            IDictionary <string, string> attrs        = c.Attributes;

            // Execute and Verify
            string value;

            value = attrAccessor.GetAttribute("xyz");
            Assert.Null(value);

            attrAccessor.SetAttribute("a1", "v1");
            value = attrAccessor.GetAttribute("a1");
            Assert.Equal("v1", value);
            Assert.Single(attrs);
            value = c.Attributes["a1"];
            Assert.Equal("v1", value);
        }
예제 #13
0
        // This has become pure decoration. I still think it's nice to have for developmental purposes/reference.
        public void SetWidgetNameOnTarget(IAttributeAccessor targetControl)
        {
            String attr = targetControl.GetAttribute("data-ui-widget") ?? String.Empty;

            if (!attr.Contains(Widget.WidgetName))
            {
                attr = String.IsNullOrEmpty(attr) ? Widget.WidgetName : String.Join(",", attr, Widget.WidgetName);

                targetControl.SetAttribute("data-ui-widget", attr);
            }
        }
예제 #14
0
        protected override Exception PayloadWhenNull(IAttributeAccessor context)
        {
            var message     = (IMessage)context.GetAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY);
            var description = "No retry exception available; " +
                              "this can occur, for example, if the RetryPolicy allowed zero attempts " +
                              "to execute the handler; " +
                              "RetryContext: " + context.ToString();

            return(message == null
                    ? new RetryExceptionNotAvailableException(description)
                    : new RetryExceptionNotAvailableException(message, description));
        }
예제 #15
0
        protected List <SDK.Operation> GetSDKOperationListFromControl(Control control)
        {
            List <SDK.Operation> sdkOpearationList = new List <SDK.Operation>();

            if (control is IAttributeAccessor)
            {
                IAttributeAccessor attributeAccessor = (IAttributeAccessor)control;
                var list = this.Serializer.Deserialize <List <SDK.Operation> >(attributeAccessor.GetAttribute("data-auth") ?? "[]");
                sdkOpearationList.AddRange(list);
            }
            return(CalculateSDKOperationList(sdkOpearationList));
        }
예제 #16
0
        /// <summary>
        /// 如果此控件不存在此属性,将属性添加到控件中
        /// </summary>
        /// <param name="accessor"></param>
        /// <param name="attributeName"></param>
        /// <param name="attributeValue"></param>
        public static void AddAttributeIfNotExists(IAttributeAccessor accessor, string attributeName, string attributeValue)
        {
            if (accessor == null || attributeName == null)
            {
                return;
            }

            if (accessor.GetAttribute(attributeName) == null)
            {
                accessor.SetAttribute(attributeName, attributeValue);
            }
        }
예제 #17
0
 /// <summary>
 /// 如果此控件不存在此属性,将属性添加到控件中
 /// </summary>
 /// <param name="accessor">控件</param>
 /// <param name="attributes">属性集合</param>
 public static void AddAttributesIfNotExists(IAttributeAccessor accessor, StringDictionary attributes)
 {
     if (accessor != null && attributes != null)
     {
         foreach (string key in attributes.Keys)
         {
             if (accessor.GetAttribute(key) == null)
             {
                 accessor.SetAttribute(key, attributes[key]);
             }
         }
     }
 }
예제 #18
0
        private static bool CategoryDefined(Control control)
        {
            bool result = false;

            if (control is IAttributeAccessor)
            {
                IAttributeAccessor accessor = (IAttributeAccessor)control;

                result = string.IsNullOrEmpty(accessor.GetAttribute("Category")) == false;
            }

            return(result);
        }
예제 #19
0
        public ErrorMessage BuildErrorMessage(Exception exception, IAttributeAccessor attributes)
        {
            var inputMessage = attributes == null ? null
                  : attributes.GetAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY);

            if (inputMessage is IMessage)
            {
                return(new ErrorMessage(exception, (IMessage)inputMessage));
            }
            else
            {
                return(new ErrorMessage(exception));
            }
        }
예제 #20
0
        protected virtual void CopyAttributesFrom(IAttributeAccessor source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var attributeNames = source.AttributeNames;

            foreach (var attributeName in attributeNames)
            {
                SetAttribute(attributeName, source.GetAttribute(attributeName));
            }
        }
예제 #21
0
        /// <summary>
        /// 如果此控件不存在此属性,将属性添加到控件中
        /// </summary>
        /// <param name="accessor">控件</param>
        /// <param name="attributes">属性集合</param>
        public static void AddAttributesIfNotExists(IAttributeAccessor accessor, Dictionary <string, string> attributes)
        {
            if (accessor == null || attributes == null)
            {
                return;
            }

            foreach (var key in attributes.Keys)
            {
                if (accessor.GetAttribute(key) == null)
                {
                    accessor.SetAttribute(key, attributes[key]);
                }
            }
        }
예제 #22
0
        public static T Attribute <T>([NotNull] this IAttributeAccessor thisValue, string name, T defaultValue)
        {
            string value;

            try
            {
                value = thisValue.GetAttribute(name);
            }
            catch
            {
                value = null;
            }

            return(value.To(defaultValue));
        }
예제 #23
0
        /// <summary>
        /// 如果此控件不存在此属性,将属性添加到控件中
        /// </summary>
        /// <param name="accessor">控件</param>
        /// <param name="attributes">属性集合</param>
        public static void AddAttributesIfNotExists(IAttributeAccessor accessor, NameValueCollection attributes)
        {
            if (accessor == null || attributes == null)
            {
                return;
            }

            foreach (var key in attributes.AllKeys)
            {
                if (accessor.GetAttribute(key) == null)
                {
                    accessor.SetAttribute(key, attributes[key]);
                }
            }
        }
예제 #24
0
        private void CopyChildAttributes()
        {
            IAttributeAccessor childControl = this.ChildControl as IAttributeAccessor;

            if (childControl != null)
            {
                base.AuthorizationFilter = childControl.GetAttribute("AuthorizationFilter");
                base.CatalogIconImageUrl = childControl.GetAttribute("CatalogIconImageUrl");
                base.Description         = childControl.GetAttribute("Description");
                string attribute = childControl.GetAttribute("ExportMode");
                if (attribute != null)
                {
                    base.ExportMode = (WebPartExportMode)Util.GetEnumAttribute("ExportMode", attribute, typeof(WebPartExportMode));
                }
                this._subtitle         = childControl.GetAttribute("Subtitle");
                base.Title             = childControl.GetAttribute("Title");
                base.TitleIconImageUrl = childControl.GetAttribute("TitleIconImageUrl");
                base.TitleUrl          = childControl.GetAttribute("TitleUrl");
            }
            WebControl control = this.ChildControl as WebControl;

            if (control != null)
            {
                control.Attributes.Remove("AuthorizationFilter");
                control.Attributes.Remove("CatalogIconImageUrl");
                control.Attributes.Remove("Description");
                control.Attributes.Remove("ExportMode");
                control.Attributes.Remove("Subtitle");
                control.Attributes.Remove("Title");
                control.Attributes.Remove("TitleIconImageUrl");
                control.Attributes.Remove("TitleUrl");
            }
            else if (childControl != null)
            {
                childControl.SetAttribute("AuthorizationFilter", null);
                childControl.SetAttribute("CatalogIconImageUrl", null);
                childControl.SetAttribute("Description", null);
                childControl.SetAttribute("ExportMode", null);
                childControl.SetAttribute("Subtitle", null);
                childControl.SetAttribute("Title", null);
                childControl.SetAttribute("TitleIconImageUrl", null);
                childControl.SetAttribute("TitleUrl", null);
            }
        }
예제 #25
0
        protected virtual Exception DeterminePayload(Exception exception, IAttributeAccessor context)
        {
            var lastThrowable = exception;

            if (lastThrowable == null)
            {
                lastThrowable = PayloadWhenNull(context);
            }
            else if (!(lastThrowable is MessagingException))
            {
                var message = (IMessage)context.GetAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY);
                lastThrowable = message == null
                    ? new MessagingException(lastThrowable.Message, lastThrowable)
                    : new MessagingException(message, lastThrowable.Message, lastThrowable);
            }

            return(lastThrowable);
        }
예제 #26
0
        public static void SetAttribute(IAttributeAccessor iaa, string key, string value, AttributeValuePosition csp, char separator)
        {
            string attribute = iaa.GetAttribute(key);

            if (string.IsNullOrEmpty(attribute))
            {
                iaa.SetAttribute(key, value);
            }
            else if (csp == AttributeValuePosition.First)
            {
                attribute = attribute.TrimStart(new char[] { separator });
                iaa.SetAttribute(key, value + separator + attribute);
            }
            else if (csp == AttributeValuePosition.Last)
            {
                iaa.SetAttribute(key, attribute.TrimEnd(new char[] { separator }) + separator + value);
            }
        }
예제 #27
0
파일: Attribute.cs 프로젝트: pcstx/OA
        /// <summary>
        /// 设置实现了IAttributeAccessor接口的控件的Attribute(保留原来同Key的Attribute)
        /// </summary>
        /// <param name="iaa">实现了IAttributeAccessor接口的控件</param>
        /// <param name="key">属性的名称</param>
        /// <param name="value">属性的值</param>
        /// <param name="csp">属性的值的位置</param>
        /// <param name="separator">属性分隔符</param>
        public static void SetAttribute(IAttributeAccessor iaa, string key, string value, AttributeValuePosition csp, char separator)
        {
            string tmp = iaa.GetAttribute(key);

            if (String.IsNullOrEmpty(tmp))
            {
                iaa.SetAttribute(key, value);
            }
            else if (csp == AttributeValuePosition.First)
            {
                tmp = tmp.TrimStart(separator);
                iaa.SetAttribute(key, value + separator + tmp);
            }
            else if (csp == AttributeValuePosition.Last)
            {
                tmp = tmp.TrimEnd(separator);
                iaa.SetAttribute(key, tmp + separator + value);
            }
        }
예제 #28
0
        public static List <WebUI.Control> GetByLink(WebUI.Control holder, string linkId)
        {
            List <WebUI.Control> controlList = new List <Control>();

            foreach (Control control in holder.Controls)
            {
                if (control is IAttributeAccessor)
                {
                    IAttributeAccessor attributeAccessor = (IAttributeAccessor)control;
                    var _linkId = attributeAccessor.GetAttribute("data-link");
                    if (!string.IsNullOrWhiteSpace(_linkId) &&
                        _linkId.Split(',').Contains(linkId))
                    {
                        controlList.Add(control);
                    }
                }
            }
            return(controlList);
        }
예제 #29
0
        /// <summary>
        /// 验证控件是否绑定了验证规则 如果绑定了, 加入到控件属性中
        /// </summary>
        /// <param name="c">继承了WebControl或是IAttributeAccessor接口的控件 </param>
        protected void Validator(IAttributeAccessor c)
        {
            string validator = Control.Params["validator"] ?? "";

            if (validator.Length > 0)
            {
                List <Dictionary <string, string> > list = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(validator);
                foreach (Dictionary <string, string> t in list)
                {
                    if (t.ContainsKey("rule") && t.ContainsKey("val"))
                    {
                        c.SetAttribute(t["rule"], t["val"]);
                    }
                }
            }
            //匹配以前的验证方式
            if (Control.Required && c.GetAttribute("required") == null)
            {
                c.SetAttribute("required", "required");
            }
        }
예제 #30
0
        public static void ApplyScript(IAttributeAccessor control, string attr, string script)
        {
            var sCurValue = control.GetAttribute(attr);
            var sNewValue = string.Empty;

            if (!string.IsNullOrEmpty(sCurValue))
            {
                if (!sCurValue.EndsWith(";"))
                {
                    sNewValue = string.Format("{0}; {1}", sCurValue, script);
                }
                else
                {
                    sNewValue = string.Concat(sCurValue, script);
                }
            }
            else
            {
                sNewValue = script;
            }
            control.SetAttribute(attr, sNewValue);
        }
	    /**
	     * Copy the attributes from the supplied AttributeAccessor to this accessor.
	     * @param source the AttributeAccessor to copy from
	     */
	    protected void CopyAttributesFrom(IAttributeAccessor source) {
		    Trace.Assert(source != null, "Source must not be null");
		    string[] attributeNames = source.AttributeNames;
		    foreach(string attributeName in attributeNames)
            {
			    SetAttribute(attributeName, source.GetAttribute(attributeName));
		    }
	    }
		private void SetCssAttribute(IAttributeAccessor aa, string cssName)
		{
			if (string.IsNullOrEmpty(aa.GetAttribute("class")))
				aa.SetAttribute("class", cssName);
		}
예제 #33
0
        // This has become pure decoration. I still think it's nice to have for developmental purposes/reference.
        public void SetWidgetNameOnTarget(IAttributeAccessor targetControl)
        {
            String attr = targetControl.GetAttribute("data-ui-widget") ?? String.Empty;

            if(!attr.Contains(Widget.WidgetName)) {
                attr = String.IsNullOrEmpty(attr) ? Widget.WidgetName : String.Join(",", attr, Widget.WidgetName);

                targetControl.SetAttribute("data-ui-widget", attr);
            }
        }
예제 #34
0
        /// <summary>
        /// Create a new <see cref="IGraphType" /> or get an existing <see cref="IGraphType" /> based on the given CLR type.
        /// </summary>
        /// <param name="type">The <see cref="IGraphType" /> specific CLR type.</param>
        /// <param name="isRequired">Indicate whether to create a required based <see cref="IGraphType" />.</param>
        /// <param name="isEnumerable">Indicate whether to create an array based <see cref="IGraphType" />.</param>
        /// <param name="otherTypes">The other CLR types for union GraphQL type.</param>
        /// <returns>
        /// The <see cref="IGraphType" /> to be created to provided.
        /// </returns>
        public IGraphType GetGraphType(Type type, bool?isRequired, bool?isEnumerable, params Type[] otherTypes)
        {
            Guard.ArgumentNotNull(type, nameof(type));
            type = GetValidType(type);
            EnsureValidUnionTypes(otherTypes);

            if (GraphValueResolver.IsRequired(type) == true && isRequired == false)
            {
                throw new GraphException($"Cannot create optional GraphType based on the type '{type}'");
            }
            if (GraphValueResolver.IsRequired(type) == false && isRequired == true)
            {
                throw new GraphException($"Cannot create required GraphType based on the type '{type}'");
            }

            var required = isRequired ?? GraphValueResolver.IsRequired(type) ?? false;

            var isEnumerableType = type.IsEnumerable(out var elementType);

            if (isEnumerableType && isEnumerable == false)
            {
                throw new GraphException($"Cannot create non-enumerable GraphType based on the type '{type}'");
            }
            var clrType       = isEnumerableType ? elementType : type;
            var enumerable    = isEnumerable ?? isEnumerableType;
            var isEnum        = clrType.IsEnum;
            var name          = GraphValueResolver.GetGraphTypeName(clrType, otherTypes);
            var requiredFlag  = required == true ? "!" : "";
            var valueResolver = GraphValueResolver.GetResolver(clrType, _serviceProvider);

            name = enumerable
                ? $"[{name.TrimEnd('!')}]{requiredFlag}"
                : $"{name.TrimEnd('!')}{requiredFlag}";

            if (_graphTypes.TryGetValue(name, out var value))
            {
                return(value);
            }
            var graphType = new GraphType(valueResolver, type, otherTypes, name, required, enumerable, isEnum);

            _graphTypes[name] = graphType;
            if (!GraphValueResolver.IsScalar(type))
            {
                foreach (var(fieldName, property) in GetProperties(type, otherTypes))
                {
                    var memberAttribute     = _attributeAccessor.GetAttribute <GraphFieldAttribute>(property, false);
                    var resolver            = GetPropertyResolver(type, property, memberAttribute);
                    var propertyGraphType   = GetPropertyGraphType(type, property, memberAttribute);
                    var normalizedFieldName = _fieldNameConverter.Normalize(fieldName);
                    var field = new GraphField(normalizedFieldName, propertyGraphType, property.DeclaringType, resolver);
                    foreach (var argument in GetPropertyArguments(property))
                    {
                        field.AddArgument(argument);
                    }
                    graphType.AddField(property.DeclaringType, field);
                }
            }

            var knownTypeAttribute = _attributeAccessor.GetAttribute <KnownTypesAttribute>(type, false);

            if (knownTypeAttribute != null)
            {
                Array.ForEach(knownTypeAttribute.Types, it => GetGraphType(it, false, false));
            }
            return(graphType);
        }