Example #1
0
        private string MakeParametersList(ParameterListSyntax syntax)
        {
            var args = syntax.Parameters;
            StringBuilder str = new StringBuilder();
            if (args.Count > 0)
            {
                var fstArg = args[0];
                if (fstArg.IsExtensionParameter())
                    this.AppendCompileIssue(syntax, IssueType.Error, IssueId.ExtensionMethodNotSupport);

                foreach (var arg in args)
                {
                    var info = _semanticModel.GetDeclaredSymbol(arg);
                    if (!info.Type.IsScriptSymbol())
                    {
                        this.AppendCompileIssue(syntax, IssueType.Error, IssueId.UseNonScript, info.Type);
                    }

                    if (arg.Default != null)
                    {
                        this.AppendCompileIssue(syntax, IssueType.Error, IssueId.DefaultParamNotSupport);
                    }

                    str.Append(_semanticModel.GetParameterSymbolName(arg)).Append(", ");
                }
                str.RemoveEnd(", ");
            }
            return str.ToString();
        }
 public virtual StringBuilder BuildSelectColumns(IObjectMapInfo map)
 {
     StringBuilder b = new StringBuilder();
     foreach (var pmi in map.PropertyMaps)
     {
         b.Append(_tr.GetEscapedColumnName(pmi.ColumnName)).Append(_tr.ColumnDelimiter);
     }
     b.RemoveEnd(_tr.ColumnDelimiter);
     return b;
 }
Example #3
0
 public override StringBuilder BuildInsertColumns(MappingInfo.IObjectMapInfo map, object entity)
 {
     StringBuilder b = new StringBuilder();
     foreach (var pmi in map.PropertyMaps)
     {
         b.Append(_tr.GetEscapedColumnName(pmi.ColumnName)).Append(_tr.ColumnDelimiter);
     }
     b.RemoveEnd(_tr.ColumnDelimiter);
     return b;
 }
 public virtual StringBuilder BuildOrderSelectColumns(OrderCollection order, IEnumerable<SingleEntityView> svList)
 {
     _str = new StringBuilder();
     foreach (var o in order)
     {
         _str.Append(_oev.GetOrderByClause(o.OrderExpression, svList));
         _str.Append(_tr.ColumnDelimiter);
     }
     _str.RemoveEnd(_tr.ColumnDelimiter);
     return _str;
 }
Example #5
0
        public string ToJsonString(object instance)
        {
            var dict = instance as IEnumerable;
            StringBuilder str = new StringBuilder();
            foreach (dynamic kvp in dict)
            {
                str.AppendFormat("\"{0}\":{1},", kvp.Key, JsonExtension.ToJsonString(kvp.Value));
            }
            if (str.Length > 0)
                str.RemoveEnd(',');

            return str.Bracketing(StringPair.CurlyBracket).ToString();
        }
 public virtual StringBuilder BuildUpdateSets(IObjectMapInfo map, object entity)
 {
     StringBuilder b = new StringBuilder();
     IReflector r = Reflector.Bind(entity);
     foreach (var pmi in map.NonPKPropertyMaps)
     {
         b.Append(_tr.GetEscapedColumnName(pmi.ColumnName));
         b.Append(_tr.Equal).Append(_tr.GetValueString(r.GetPropertyValue(pmi.PropertyName)));
         b.Append(_tr.ColumnDelimiter);
     }
     b.RemoveEnd(_tr.ColumnDelimiter);
     return b;
 }
        public virtual StringBuilder BuildInsertColumns(IObjectMapInfo map, object entity)
        {
            StringBuilder b = new StringBuilder();
            foreach (var pmi in map.PropertyMaps)
            {
                if (map.PrimaryKeyGenerate == PrimaryKeyGenerate.Auto && map.PrimaryKeyMaps.Contains(pmi))
                    continue;

                b.Append(_tr.GetEscapedColumnName(pmi.ColumnName)).Append(_tr.ColumnDelimiter);
            }
            b.RemoveEnd(_tr.ColumnDelimiter);
            return b;
        }
Example #8
0
        public string ToJsonString(object instance)
        {
            var list = instance as IEnumerable;
            StringBuilder str = new StringBuilder();
            foreach (var item in list)
            {
                str.Append(item.ToJsonString()).Append(",");
            }
            if (str.Length > 0)
                str.RemoveEnd(',');

            return str.Bracketing(StringPair.SquareBracket).ToString();
        }
Example #9
0
        public override StringBuilder BuildInsertValues(MappingInfo.IObjectMapInfo map, object entity)
        {
            StringBuilder b = new StringBuilder();
            IReflector r = Reflector.Bind(entity);
            foreach (var pmi in map.PropertyMaps)
            {
                if (map.PrimaryKeyGenerate == PrimaryKeyGenerate.Customized && map.PrimaryKeyMaps.Contains(pmi))
                {
                    string sequenceName = map.PKGenerateString.RemoveBegin(ConstantString.SEQ_Prefix);
                    b.Append(sequenceName).Append(_tr.MemberAccess).Append(ConstantString.SEQ_NextVal).Append(_tr.ColumnDelimiter);
                    continue;
                }

                b.Append(_tr.GetValueString(r.GetPropertyValue(pmi.PropertyName))).Append(_tr.ColumnDelimiter);
            }
            b.RemoveEnd(_tr.ColumnDelimiter);
            return b;
        }
Example #10
0
        private string MakeInterfacesList(ClassDeclarationSyntax syntax)
        {
            var interfaces = _semanticModel.GetDeclaredSymbol(syntax).Interfaces;

            StringBuilder str = new StringBuilder();
            foreach (var info in interfaces)
            {
                if (!info.IsScriptSymbol())
                {
                    this.AppendCompileIssue(syntax, IssueType.Error, IssueId.UseNonScript, info);
                }
                str.AppendFormat("{0}, ", info.GetTypeSymbolName());
            }
            if (interfaces.Count() > 0)
                str.RemoveEnd(", ");

            return str.ToString();
        }
        public virtual StringBuilder BuildInsertValues(IObjectMapInfo map, object entity)
        {
            StringBuilder b = new StringBuilder();
            IReflector r = Reflector.Bind(entity);
            foreach (var pmi in map.PropertyMaps)
            {
                if (map.PrimaryKeyGenerate == PrimaryKeyGenerate.Auto && map.PrimaryKeyMaps.Contains(pmi))
                    continue;

                //Note:special handling Guid when insert, must use '*', not same as WHERE {Guid{*}}
                object val = r.GetPropertyValue(pmi.PropertyName);
                if (val is Guid)
                    b.Append(_tr.GetValueString(val.ToString())).Append(_tr.ColumnDelimiter);
                else
                    b.Append(_tr.GetValueString(val)).Append(_tr.ColumnDelimiter);
            }
            b.RemoveEnd(_tr.ColumnDelimiter);
            return b;
        }
 public virtual StringBuilder BuildWherePrimaryKey(IObjectMapInfo map, object entity)
 {
     StringBuilder b = new StringBuilder();
     IReflector r = Reflector.Bind(entity);
     foreach (var pki in map.PrimaryKeyMaps)
     {
         b.Append(_tr.GetEscapedColumnName(pki.ColumnName));
         object right = r.GetPropertyValue(pki.PropertyName);
         if (right == null)
             b.Append(_tr.Is);
         else
             b.Append(_tr.Equal);
         b.Append(_tr.GetValueString(right));
         b.Append(_tr.And);
     }
     b.RemoveEnd(_tr.And);
     return b;
 }