예제 #1
0
 public static BsonType Create(BsonDataType type)
 {
     BsonType ret = null;
     if(type == BsonDataType.Number){
         ret = new BsonNumber();
     }else if(type == BsonDataType.Number){
         throw new NotImplementedException();
     }else if(type == BsonDataType.String){
         ret = new BsonString();
     }else if(type == BsonDataType.Obj){
         ret = new BsonDocument();
     }else if(type == BsonDataType.Array){
         ret = new BsonArray();
     }else if(type == BsonDataType.Integer){
         ret = new BsonInteger();
     }else if(type == BsonDataType.Long){
         ret = new BsonLong();
     }else if(type == BsonDataType.Boolean){
         ret = new BsonBoolean();
     }else if(type == BsonDataType.Oid){
         ret = new BsonOid();
     }else if(type == BsonDataType.Date){
         ret = new BsonDate();
     }else if(type == BsonDataType.Regex){
         ret = new BsonRegex();
     }else{
         throw new ArgumentOutOfRangeException("Type: " + type + " not recognized");
     }
     return ret;
 }
예제 #2
0
 public static BsonType Create(BsonDataType type)
 {
     BsonType ret = null;
     if(type == BsonDataType.Number){
         ret = new BsonNumber();
     }else if(type == BsonDataType.Number){
         throw new NotImplementedException();
     }else if(type == BsonDataType.String){
         ret = new BsonString();
     }else if(type == BsonDataType.Obj){
         ret = new BsonDocument();
     }else if(type == BsonDataType.Array){
         ret = new BsonArray();
     }else if(type == BsonDataType.Integer){
         ret = new BsonInteger();
     }else if(type == BsonDataType.Long){
         ret = new BsonLong();
     }else if(type == BsonDataType.Boolean){
         ret = new BsonBoolean();
     }else if(type == BsonDataType.Oid){
         ret = new BsonOid();
     }else if(type == BsonDataType.Date){
         ret = new BsonDate();
     }else if(type == BsonDataType.Regex){
         ret = new BsonRegex();
     }else if(type == BsonDataType.Undefined){
         ret = new BsonUndefined();
     }else if(type == BsonDataType.Null){
         ret = new BsonNull();
     }else if(type == BsonDataType.Code){
         ret = new BsonCode();
     }else if(type == BsonDataType.CodeWScope){
         ret = new BsonCodeWScope();
     }else{
         string typename = Enum.GetName(typeof(BsonDataType), type);
         throw new ArgumentOutOfRangeException("type",typename + "is not recognized");
     }
     return ret;
 }