예제 #1
0
 public FactoryParameter(FactoryParameter other)
 {
     Name = other.Name;
     OriginalType = other.OriginalType;
     Type = other.Type;
     IsList = other.IsList;
     IsParams = other.IsParams;
     IsOptional = other.IsOptional;
     ParseNameType = other.ParseNameType;
 }
예제 #2
0
 public FactoryParameter(FactoryParameter other)
 {
     Name          = other.Name;
     OriginalType  = other.OriginalType;
     Type          = other.Type;
     IsList        = other.IsList;
     IsParams      = other.IsParams;
     IsOptional    = other.IsOptional;
     ParseNameType = other.ParseNameType;
 }
예제 #3
0
        private void SeedParseNameFactories(Dictionary<SyntaxType, List<Factory>> factories)
        {
            foreach (var item in factories)
            {
                var newFactories = new List<Factory>();

                foreach (var factory in item.Value)
                {
                    if (factory.Parameters.All(p => !typeof(TypeSyntax).IsAssignableFrom(p.OriginalType)))
                        continue;

                    var newFactory = new Factory(factory.Name);

                    foreach (var parameter in factory.Parameters)
                    {
                        FactoryParameter newParameter;

                        if (typeof(TypeSyntax).IsAssignableFrom(parameter.OriginalType))
                        {
                            newParameter = new FactoryParameter(
                                parameter.Name,
                                parameter.OriginalType,
                                "String",
                                parameter.IsList,
                                parameter.IsParams,
                                parameter.IsOptional
                            )
                            {
                                ParseNameType = parameter.OriginalType.Name
                            };
                        }
                        else
                        {
                            newParameter = new FactoryParameter(parameter);
                        }

                        newFactory.Parameters.Add(newParameter);
                    }

                    newFactories.Add(newFactory);
                }

                newFactories.RemoveAll(p => item.Value.Any(p1 => p1.Equals(p)));

                item.Value.AddRange(newFactories);
            }
        }
예제 #4
0
        private string EscapeParameterName(FactoryParameter parameter)
        {
            switch (parameter.Name)
            {
                case "else":
                case "finally":
                case "operator":
                case "default":
                    return "@" + parameter.Name;

                default:
                    return parameter.Name;
            }
        }