private static SerdeProvision DetermineSerdeFromProviders( Type type, ICollection <SerdeProvider> serdeProviders, SerdeProviderAdditionalInfo additionalInfo) { if (serdeProviders.IsEmpty()) { return(null); } SerdeProviderContextClass context = new SerdeProviderContextClass(type, additionalInfo); foreach (SerdeProvider provider in serdeProviders) { try { SerdeProvision serde = provider.ResolveSerdeForClass(context); if (serde != null) { return(serde); } } catch (DataInputOutputSerdeException) { throw; } catch (EPException) { throw; } catch (Exception ex) { throw HandleProviderRuntimeException(provider, type, ex); } } return(null); }
private DataInputOutputSerdeForge[] SerdeForClasses( Type[] sortCriteriaExpressions, SerdeProviderAdditionalInfo additionalInfo) { DataInputOutputSerdeForge[] forges = new DataInputOutputSerdeForge[sortCriteriaExpressions.Length]; for (int i = 0; i < sortCriteriaExpressions.Length; i++) { forges[i] = SerdeForClass(sortCriteriaExpressions[i], additionalInfo); } return(forges); }
private DataInputOutputSerdeForge SerdeMayArray( Type type, SerdeProviderAdditionalInfo info) { if (type.IsArray) { DataInputOutputSerde mkSerde = GetMKSerdeClassForComponentType(type.GetElementType()); return(new DataInputOutputSerdeForgeSingleton(mkSerde.GetType())); } return(SerdeForClass(type, info)); }
private static DataInputOutputSerdeException MakeFailedToFindException( Type clazz, bool allowSerializable, int numSerdeProviders, SerdeProviderAdditionalInfo additionalInfo) { return(new DataInputOutputSerdeException( "Failed to find serde for class '" + TypeExtensions.CleanName(clazz) + "' for use with " + additionalInfo + " (" + "allowSerializable=" + allowSerializable + "," + "serdeProvider-count=" + numSerdeProviders + ")")); }
private DataInputOutputSerdeForge SerdeForClass( Type type, SerdeProviderAdditionalInfo additionalInfo) { if (IsBasicBuiltin(type)) { DataInputOutputSerde serde = VMBasicBuiltinSerdeFactory.GetSerde(type); if (serde == null) { throw new DataInputOutputSerdeException("Failed to find built-in serde for class " + type.Name); } return(new DataInputOutputSerdeForgeSingleton(serde.GetType())); } if (_allowExtended) { DataInputOutputSerde serde = VMExtendedBuiltinSerdeFactory.GetSerde(type); if (serde != null) { return(new DataInputOutputSerdeForgeSingleton(serde.GetType())); } } if (type == typeof(EPLMethodInvocationContext)) { return(new DataInputOutputSerdeForgeSingleton(typeof(DIOSkipSerde))); } SerdeProvision provision = SerdeCompileTimeResolverUtil.DetermineSerde( type, serdeProviders, allowSerializable, allowSerializationFallback, additionalInfo); return(provision.ToForge()); }
// Order of resolution: // (1) any serde providers are asked first, first one taking it counts // (2) class implements Serializable (when allowed) internal static SerdeProvision DetermineSerde( Type type, ICollection <SerdeProvider> serdeProviders, bool allowSerializable, bool allowSerializationFallback, SerdeProviderAdditionalInfo additionalInfo) { SerdeProvision serde; if (!serdeProviders.IsEmpty()) { serde = DetermineSerdeFromProviders(type, serdeProviders, additionalInfo); if (serde != null) { return(serde); } if (type.IsArray) { SerdeProvision componentSerde = DetermineSerdeFromProviders(type.GetElementType(), serdeProviders, additionalInfo); if (componentSerde != null) { return(new SerdeProvisionParameterized( typeof(DIONullableObjectArraySerde), vars => Constant(type.GetElementType()), vars => componentSerde.ToForge().Codegen(vars.Method, vars.Scope, vars.OptionalEventTypeResolver))); } } } serde = DetermineSerializable(type, allowSerializable, allowSerializationFallback); if (serde != null) { return(serde); } throw MakeFailedToFindException(type, allowSerializable, serdeProviders.Count, additionalInfo); }