public override IEncoder Build() { //Must be instantiated so that super class can initialize //boilerplate variables. encoder = new LogEncoder(); //Call super class here base.Build(); //////////////////////////////////////////////////////// // Implementing classes would do setting of specific // // vars here together with any sanity checking // //////////////////////////////////////////////////////// try { ((LogEncoder)encoder).Init(); } catch (Exception e) { string msg = e.Message; int idx = -1; if ((idx = (msg = e.Message).IndexOf("ScalarEncoder")) != -1) { msg = msg.Substring(0, idx) + "LogEncoder"; } throw new InvalidOperationException(msg); } return((LogEncoder)encoder); }
/** * Open up for internal Network API use. * Returns an {@link Encoder.Builder} which corresponds to the specified name. * @param encoderName * @return */ public IBuilder GetBuilder(string encoderName) { switch (encoderName) { case "CategoryEncoder": return(CategoryEncoder.GetBuilder()); case "CoordinateEncoder": return(CoordinateEncoder.GetBuilder()); case "GeospatialCoordinateEncoder": return(GeospatialCoordinateEncoder.GetGeobuilder()); case "LogEncoder": return(LogEncoder.GetBuilder()); case "PassThroughEncoder": return(PassThroughEncoder <int[]> .GetBuilder()); case "ScalarEncoder": return(ScalarEncoder.GetBuilder()); case "AdaptiveScalarEncoder": return(AdaptiveScalarEncoder.GetAdaptiveBuilder()); case "SparsePassThroughEncoder": return(SparsePassThroughEncoder.GetSparseBuilder()); case "SDRCategoryEncoder": return(SDRCategoryEncoder.GetBuilder()); case "RandomDistributedScalarEncoder": return(RandomDistributedScalarEncoder.GetBuilder()); case "DateEncoder": return(DateEncoder.GetBuilder()); case "DeltaEncoder": return(DeltaEncoder.GetDeltaBuilder()); case "SDRPassThroughEncoder": return(SDRPassThroughEncoder.GetSptBuilder()); default: throw new ArgumentException("Invalid encoder: " + encoderName); } }