コード例 #1
0
        public virtual CodeTypeReference GetFieldType(ITypedItem itemData)
        {
            var tRef = new CodeTypeReference(this.Name);

            //tRef.TypeArguments.Add(this.Name);
            return(tRef);
        }
コード例 #2
0
        protected string ResolveTypeName(ITypedItem item)
        {
            var typeName = TypeMapper.Map(item);

            return(Aliases.TryGetValue(typeName, out var aliasedType)
                ? aliasedType
                : typeName);
        }
コード例 #3
0
 public CreateBindingSignatureParams(CodeTypeDeclaration context, Func <Type, CodeTypeReference> convertGenericParameter, ViewNode elementView, ITypedItem sourceItem, string subscribablePropertyNameFormat = "{0}Property")
 {
     this._context = context;
     this._convertGenericParameter = convertGenericParameter;
     this._elementView             = elementView;
     this._sourceItem = sourceItem;
     this._subscribablePropertyNameFormat = subscribablePropertyNameFormat;
 }
コード例 #4
0
        private static string GetTypeDisplayName(ITypedItem item)
        {
            if (item.IsTypeDynamic)
            {
                return(Utilities.DynamicTypeName);
            }

            return(item.Type.DisplayName);
        }
コード例 #5
0
        public Enum(ITypedItem owner, ITypedItem source, string[] values)
        {
            Owner       = owner;
            Source      = source;
            Values      = values;
            Source.Type = Type.Enum;

            MakeEnumTypeName(source.Name.ToPascalCase());
        }
コード例 #6
0
        //public static IEnumerable<IDiagramNode> FilterItems(this IGraphData designerData, INodeRepository repository)
        //{
        //    return designerData.CurrentFilter.FilterItems(repository);
        //}



        public static IDiagramNode RelatedNode(this ITypedItem item)
        {
            var gt = item as GenericTypedChildItem;

            if (gt != null)
            {
                return(gt.RelatedTypeNode as IDiagramNode);
            }

            return(item.Repository.GetById <IDiagramNode>(item.RelatedType));
        }
コード例 #7
0
        private static void ParseRef(ITypedItem item, JsonObject json)
        {
            if (item == null || json == null)
            {
                return;
            }

            var reference = json["$ref"];

            if (reference == null)
            {
                return;
            }

            var match = DefinitionsReferenceRegex.Match(reference);

            if (!match.Success)
            {
                return;
            }

            item.Type = Type.Ref;
            item.Ref  = match.Groups["name"].Value;
        }
コード例 #8
0
        private static bool IsParameterMapped(Operation operation, List <OperationParameter> parameters, ITypedItem item)
        {
            var parameter = parameters.SingleOrDefault(p => p.Name == item.Name);

            if (parameter != null)
            {
                var mappedTypeName = TypeMapper.Map(parameter);
                var itemTypeName   = TypeMapper.Map(item);

                if (mappedTypeName != itemTypeName)
                {
                    throw new ExpectedException($"{operation.Route} has conflicting parameter types for Name='{parameter.Name}' Type1={mappedTypeName} Type2={itemTypeName}");
                }
            }

            return(parameter != null);
        }
コード例 #9
0
 private static void ParseRef(ITypedItem item, string jsonText)
 {
     ParseRef(item, JsonObject.Parse(jsonText));
 }
コード例 #10
0
 /// <summary>
 /// Creates a <see cref="FormatItem"/> to represent the type name of a typed item with the specified formatting.
 /// </summary>
 public static FormatItem TypedItemTypeName(ITypedItem item, StyleFlags style = StyleFlags.Normal)
 {
     return(new FormatItem(GetTypeDisplayName(item), style));
 }
コード例 #11
0
 /// <summary>
 /// Creates a <see cref="FormatItem"/> to represent the full name of a typed item with the specified formatting.
 /// </summary>
 public static FormatItem TypedItemName(ITypedItem item, StyleFlags style = StyleFlags.Normal)
 {
     return(new FormatItem(GetFullMemberName((MemberDataBase)item), style));
 }
コード例 #12
0
 /// <summary>
 /// Creates a <see cref="FormatItem"/> to represent the C# name of a typed item with the specified formatting.
 /// </summary>
 public static FormatItem TypedItemKind(ITypedItem item, StyleFlags style = StyleFlags.Normal)
 {
     return(new FormatItem(GetItemDescription((MetadataItemBase)item), style));
 }
コード例 #13
0
        protected string ResolveName(ITypedItem item)
        {
            var name = item.Name;

            return(name.Replace('-', '_').ToPascalCase());
        }
コード例 #14
0
 internal ChangedMemberType(ITypedItem oldTypedItem, ITypedItem newTypedItem)
     : base((MetadataItemBase)oldTypedItem, (MetadataItemBase)newTypedItem, null, BreakingChangeKind.ChangedMemberType)
 {
     OldTypedItem = oldTypedItem;
     NewTypedItem = newTypedItem;
 }
コード例 #15
0
 private static bool IsEnumRequiringNormalization(ITypedItem item)
 {
     return(item.Type == Type.String && item.Enum != null && item.Enum.Any());
 }
コード例 #16
0
 private static string GetTypeDisplayName(ITypedItem item) =>
 item.IsTypeDynamic ? Utilities.DynamicTypeName : item.Type.DisplayName;
コード例 #17
0
        public static string Map(ITypedItem item)
        {
            switch (item.Type)
            {
            case Type.Enum:
                if (string.IsNullOrEmpty(item.EnumTypeName))
                {
                    throw new ArgumentException($"Cannot resolve enumeration typename for {item.ToJson()}");
                }

                if (item.EnumTypeName == "Unknown")
                {
                    throw new ArgumentException($"Unknown enum type for {item.ToJson()}");
                }

                return(item.EnumTypeName);

            case Type.Ref:
                if (string.IsNullOrEmpty(item.Ref))
                {
                    throw new ArgumentException($"Cannot resolve reference for {item.ToJson()}");
                }

                if (item.Ref == "Unknown")
                {
                    throw new ArgumentException($"Unknown refernce type for {item.ToJson()}");
                }

                return(item.Ref);

            case Type.Array:
                var arrayTypeName = item.ArrayTypeName();
                if (string.IsNullOrEmpty(arrayTypeName))
                {
                    throw new ArgumentException($"Cannot resolve array type for {item.ToJson()}");
                }

                if (arrayTypeName == "Unknown")
                {
                    throw new ArgumentException($"Unknown array type for {item.ToJson()}");
                }

                return($"List<{arrayTypeName}>");
            }

            Dictionary <string, string> formatsForType;

            if (!TypeMaps[Language].TryGetValue(item.Type, out formatsForType))
            {
                var typeName = item.Type.ToString();

                if (typeName == "Unknown")
                {
                    throw new ArgumentException($"Unknown type for {item.ToJson()}");
                }

                return(typeName);
            }

            string specificFormat;

            if (formatsForType.TryGetValue(item.Format ?? DefaultFormat, out specificFormat))
            {
                return(specificFormat);
            }

            return(formatsForType[DefaultFormat]);
        }
コード例 #18
0
 public virtual CodeTypeReference GetPropertyType(ITypedItem itemData)
 {
     return(new CodeTypeReference(this.Name));
 }
コード例 #19
0
 protected TypedItemViewModel(ITypedItem viewModelItem, DiagramNodeViewModel nodeViewModel)
     : base(viewModelItem, nodeViewModel)
 {
 }