Ejemplo n.º 1
0
        public FieldDefinition AddField <TField>(string fieldName, FieldDataEncoding encoding = FieldDataEncoding.None)
        {
            var fdef = new FieldDefinition(fieldName, typeof(TField));

            fdef.DataEncoding = encoding;
            (Fields as HashSet <FieldDefinition>)?.Add(fdef); //fieldName
            return(fdef);
        }
Ejemplo n.º 2
0
 public FieldEncoding(FieldEncodingOptions options, FieldDataEncoding encoding)
 {
     this.Encoding = encoding;
     _options      = options;
     _integration  = _options.Integration;
     //var collection = MongoHelper.GetCollection(_integration.Collection);
     _targetFields = _integration.Fields.Where(x => x.DataEncoding == encoding).ToList();
     _fieldDict    = new Dictionary <string, ConcurrentDictionary <string, FieldExtra> >();
     foreach (var fld in TargetFields)
     {
         if (fld.Extras == null)
         {
             var dict1 = new ConcurrentDictionary <string, FieldExtra>();
             _fieldDict.Add(fld.Name, dict1);
             continue;
         }
         var dict = new ConcurrentDictionary <string, FieldExtra>(fld.Extras.Extra.ToDictionary(x => x.Value));
         _fieldDict[fld.Name] = dict;
     }
 }
Ejemplo n.º 3
0
            public static FieldEncoding Create(IIntegration integration, FieldDataEncoding fldDataEncoding)
            {
                //TODO: Replace this with attributes.
                var ops = new FieldEncodingOptions {
                    Integration = integration
                };

                if (fldDataEncoding == FieldDataEncoding.OneHot)
                {
                    return(new OneHotEncoding(ops));
                }
                else if (fldDataEncoding == FieldDataEncoding.BinaryIntId)
                {
                    return(new BinaryCategoryEncoding(ops));
                }
                else if (fldDataEncoding == FieldDataEncoding.Id)
                {
                    return(new IdEncoding(ops));
                }
                else
                {
                    throw new NotImplementedException($"Field encoding not implemented: {fldDataEncoding}");
                }
            }